moved the jobs to use quartz

pull/2922/head
tidusjar 6 years ago
parent e9ead2eddb
commit 52d9a7a586

@ -16,7 +16,6 @@
// You should have received a copy of the GNU Lesser General Public
// License along with Hangfire. If not, see <http://www.gnu.org/licenses/>.
using System;
/// <summary>
/// Helper class that provides common values for the cron expressions.
/// </summary>
@ -44,7 +43,7 @@
/// <param name="minute">The minute in which the schedule will be activated (0-59).</param>
public static string Hourly(int minute)
{
return $"{minute} * * * *";
return $"0 {minute} 0/1 1/1 * ? *";
}
/// <summary>
@ -73,7 +72,7 @@
/// <param name="minute">The minute in which the schedule will be activated (0-59).</param>
public static string Daily(int hour, int minute)
{
return $"{minute} {hour} * * *";
return $"0 {minute} {hour} 1/1 * ? *";
}
/// <summary>
@ -114,7 +113,7 @@
/// <param name="minute">The minute in which the schedule will be activated (0-59).</param>
public static string Weekly(DayOfWeek dayOfWeek, int hour, int minute)
{
return $"{minute} {hour} * * {(int)dayOfWeek}";
return $"0 {minute} {hour} ? * {(int)dayOfWeek} *";
}
/// <summary>
@ -219,7 +218,7 @@
/// <param name="interval">The number of minutes to wait between every activation.</param>
public static string MinuteInterval(int interval)
{
return $"*/{interval} * * * *";
return $" 0 0/{interval} * 1/1 * ? *";
}
/// <summary>
@ -228,7 +227,7 @@
/// <param name="interval">The number of hours to wait between every activation.</param>
public static string HourInterval(int interval)
{
return $"0 */{interval} * * *";
return $"0 0 0/{interval} 1/1 * ? *";
}
/// <summary>
@ -237,7 +236,7 @@
/// <param name="interval">The number of days to wait between every activation.</param>
public static string DayInterval(int interval)
{
return $"0 0 */{interval} * *";
return $"0 0 12 1/{interval} * ? *";
}
/// <summary>
@ -249,4 +248,39 @@
return $"0 0 1 */{interval} *";
}
}
//
// Summary:
// Specifies the day of the week.
public enum DayOfWeek
{
//
// Summary:
// Indicates Sunday.
Sunday = 1,
//
// Summary:
// Indicates Monday.
Monday = 2,
//
// Summary:
// Indicates Tuesday.
Tuesday = 3,
//
// Summary:
// Indicates Wednesday.
Wednesday = 4,
//
// Summary:
// Indicates Thursday.
Thursday = 5,
//
// Summary:
// Indicates Friday.
Friday = 6,
//
// Summary:
// Indicates Saturday.
Saturday = 7
}
}

@ -65,24 +65,24 @@ namespace Ombi.Schedule
{
var s = _jobSettings.GetSettings();
RecurringJob.AddOrUpdate(() => _embyContentSync.Start(), JobSettingsHelper.EmbyContent(s));
RecurringJob.AddOrUpdate(() => _sonarrSync.Start(), JobSettingsHelper.Sonarr(s));
RecurringJob.AddOrUpdate(() => _radarrSync.CacheContent(), JobSettingsHelper.Radarr(s));
//RecurringJob.AddOrUpdate(() => _plexContentSync.Execute(null), JobSettingsHelper.PlexContent(s));
//RecurringJob.AddOrUpdate(() => _plexRecentlyAddedSync.Start(), JobSettingsHelper.PlexRecentlyAdded(s));
RecurringJob.AddOrUpdate(() => _cpCache.Start(), JobSettingsHelper.CouchPotato(s));
RecurringJob.AddOrUpdate(() => _srSync.Start(), JobSettingsHelper.SickRageSync(s));
RecurringJob.AddOrUpdate(() => _refreshMetadata.Start(), JobSettingsHelper.RefreshMetadata(s));
RecurringJob.AddOrUpdate(() => _lidarrArtistSync.CacheContent(), JobSettingsHelper.LidarrArtistSync(s));
RecurringJob.AddOrUpdate(() => _issuesPurge.Start(), JobSettingsHelper.IssuePurge(s));
// RecurringJob.AddOrUpdate(() => _embyContentSync.Start(), JobSettingsHelper.EmbyContent(s));
// RecurringJob.AddOrUpdate(() => _sonarrSync.Start(), JobSettingsHelper.Sonarr(s));
// RecurringJob.AddOrUpdate(() => _radarrSync.CacheContent(), JobSettingsHelper.Radarr(s));
// //RecurringJob.AddOrUpdate(() => _plexContentSync.Execute(null), JobSettingsHelper.PlexContent(s));
// //RecurringJob.AddOrUpdate(() => _plexRecentlyAddedSync.Start(), JobSettingsHelper.PlexRecentlyAdded(s));
// RecurringJob.AddOrUpdate(() => _cpCache.Start(), JobSettingsHelper.CouchPotato(s));
// RecurringJob.AddOrUpdate(() => _srSync.Start(), JobSettingsHelper.SickRageSync(s));
// RecurringJob.AddOrUpdate(() => _refreshMetadata.Start(), JobSettingsHelper.RefreshMetadata(s));
// RecurringJob.AddOrUpdate(() => _lidarrArtistSync.CacheContent(), JobSettingsHelper.LidarrArtistSync(s));
// RecurringJob.AddOrUpdate(() => _issuesPurge.Start(), JobSettingsHelper.IssuePurge(s));
RecurringJob.AddOrUpdate(() => _updater.Update(null), JobSettingsHelper.Updater(s));
// RecurringJob.AddOrUpdate(() => _updater.Update(null), JobSettingsHelper.Updater(s));
RecurringJob.AddOrUpdate(() => _embyUserImporter.Start(), JobSettingsHelper.UserImporter(s));
RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(s));
RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
// RecurringJob.AddOrUpdate(() => _resender.Start(), JobSettingsHelper.ResendFailedRequests(s));
RecurringJob.AddOrUpdate(() => _mediaDatabaseRefresh.Start(), JobSettingsHelper.MediaDatabaseRefresh(s));
// RecurringJob.AddOrUpdate(() => _embyUserImporter.Start(), JobSettingsHelper.UserImporter(s));
// RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(s));
// RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
//// RecurringJob.AddOrUpdate(() => _resender.Start(), JobSettingsHelper.ResendFailedRequests(s));
// RecurringJob.AddOrUpdate(() => _mediaDatabaseRefresh.Start(), JobSettingsHelper.MediaDatabaseRefresh(s));
}
private bool _disposed;

@ -36,6 +36,7 @@ using Ombi.Helpers;
using Ombi.Settings.Settings.Models.External;
using Ombi.Store.Context;
using Ombi.Store.Entities;
using Quartz;
namespace Ombi.Schedule.Jobs.Couchpotato
{
@ -56,7 +57,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
private readonly ILogger<CouchPotatoSync> _log;
private readonly IExternalContext _ctx;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
var settings = await _settings.GetSettingsAsync();
if (!settings.Enabled)

@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Couchpotato
{
public interface ICouchPotatoSync : IBaseJob
{
Task Start();
}
}

@ -37,6 +37,7 @@ using Ombi.Notifications.Models;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests;
using Quartz;
namespace Ombi.Schedule.Jobs.Emby
{
@ -58,7 +59,7 @@ namespace Ombi.Schedule.Jobs.Emby
private readonly INotificationService _notificationService;
private readonly ILogger<EmbyAvaliabilityChecker> _log;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
await ProcessMovies();
await ProcessTv();

@ -12,6 +12,7 @@ using Ombi.Helpers;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
using Serilog;
using EmbyMediaType = Ombi.Store.Entities.EmbyMediaType;
@ -38,7 +39,7 @@ namespace Ombi.Schedule.Jobs.Emby
private readonly IRefreshMetadata _metadata;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
var embySettings = await _settings.GetSettingsAsync();
if (!embySettings.Enable)
@ -57,8 +58,8 @@ namespace Ombi.Schedule.Jobs.Emby
}
// Episodes
BackgroundJob.Enqueue(() => _episodeSync.Start());
BackgroundJob.Enqueue(() => _metadata.Start());
//BackgroundJob.Enqueue(() => _episodeSync.Start());
//BackgroundJob.Enqueue(() => _metadata.Start());
}

@ -36,6 +36,7 @@ using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
namespace Ombi.Schedule.Jobs.Emby
{
@ -58,7 +59,7 @@ namespace Ombi.Schedule.Jobs.Emby
private readonly IEmbyAvaliabilityChecker _avaliabilityChecker;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
var settings = await _settings.GetSettingsAsync();
@ -67,7 +68,7 @@ namespace Ombi.Schedule.Jobs.Emby
await CacheEpisodes(server);
}
BackgroundJob.Enqueue(() => _avaliabilityChecker.Start());
//BackgroundJob.Enqueue(() => _avaliabilityChecker.Start());
}
private async Task CacheEpisodes(EmbyServers server)

@ -37,6 +37,7 @@ using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities;
using Quartz;
namespace Ombi.Schedule.Jobs.Emby
{
@ -58,7 +59,7 @@ namespace Ombi.Schedule.Jobs.Emby
private readonly ISettingsService<EmbySettings> _embySettings;
private readonly ISettingsService<UserManagementSettings> _userManagementSettings;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
var userManagementSettings = await _userManagementSettings.GetSettingsAsync();
if (!userManagementSettings.ImportEmbyUsers)

@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Emby
{
public interface IEmbyAvaliabilityChecker : IBaseJob
{
Task Start();
}
}

@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Emby
{
public interface IEmbyContentSync : IBaseJob
{
Task Start();
}
}

@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Emby
{
public interface IEmbyEpisodeSync : IBaseJob
{
Task Start();
}
}

@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Emby
{
public interface IEmbyUserImporter : IBaseJob
{
Task Start();
}
}

@ -25,11 +25,12 @@
// ************************************************************************/
#endregion
using Quartz;
using System;
namespace Ombi.Schedule
{
public interface IBaseJob : IDisposable
public interface IBaseJob : IJob, IDisposable
{
}

@ -1,12 +1,12 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Store.Entities;
using Quartz;
namespace Ombi.Schedule.Jobs.Lidarr
{
public interface ILidarrArtistSync
public interface ILidarrArtistSync : IJob
{
Task CacheContent();
void Dispose();
Task<IEnumerable<LidarrArtistCache>> GetCachedContent();
}

@ -11,6 +11,7 @@ using Ombi.Helpers;
using Ombi.Settings.Settings.Models.External;
using Ombi.Store.Context;
using Ombi.Store.Entities;
using Quartz;
using ILogger = Microsoft.Extensions.Logging.ILogger;
namespace Ombi.Schedule.Jobs.Lidarr
@ -35,7 +36,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
private readonly IBackgroundJobClient _job;
private readonly ILidarrAlbumSync _albumSync;
public async Task CacheContent()
public async Task Execute(IJobExecutionContext job)
{
try
{

@ -3,7 +3,6 @@
namespace Ombi.Schedule.Jobs.Ombi
{
public interface IIssuesPurge : IBaseJob
{
Task Start();
{
}
}

@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Plex.Interfaces
{
public interface IMediaDatabaseRefresh : IBaseJob
{
Task Start();
}
}

@ -5,7 +5,6 @@ namespace Ombi.Schedule.Jobs.Ombi
{
public interface INewsletterJob : IBaseJob
{
Task Start();
Task Start(NewsletterSettings settings, bool test);
}
}

@ -5,7 +5,6 @@ namespace Ombi.Schedule.Jobs.Ombi
{
public interface IOmbiAutomaticUpdater : IBaseJob
{
Task Update(PerformContext context);
string[] GetVersion();
Task<bool> UpdateAvailable(string branch, string currentVersion);
}

@ -5,7 +5,6 @@ namespace Ombi.Schedule.Jobs.Ombi
{
public interface IRefreshMetadata : IBaseJob
{
Task Start();
Task ProcessPlexServerContent(IEnumerable<int> contentIds);
}
}

@ -1,9 +1,9 @@
using System.Threading.Tasks;
using Quartz;
using System.Threading.Tasks;
namespace Ombi.Schedule.Jobs.Ombi
{
public interface IResendFailedRequests
public interface IResendFailedRequests : IJob
{
Task Start();
}
}

@ -3,7 +3,7 @@ using Ombi.Store.Entities;
namespace Ombi.Schedule.Jobs.Ombi
{
public interface IWelcomeEmail : IBaseJob
public interface IWelcomeEmail
{
Task SendEmail(OmbiUser user);
}

@ -5,6 +5,7 @@ using Ombi.Core.Settings;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities.Requests;
using Ombi.Store.Repository;
using Quartz;
namespace Ombi.Schedule.Jobs.Ombi
{
@ -20,7 +21,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private readonly IRepository<Issues> _issuesRepository;
private readonly ISettingsService<IssueSettings> _settings;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
var settings = await _settings.GetSettingsAsync();
if (!settings.DeleteIssues)

@ -9,6 +9,7 @@ using Ombi.Helpers;
using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Plex.Interfaces;
using Ombi.Store.Repository;
using Quartz;
namespace Ombi.Schedule.Jobs.Ombi
{
@ -31,7 +32,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private readonly IEmbyContentRepository _embyRepo;
private readonly IEmbyContentSync _embyContentSync;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
try
{
@ -60,7 +61,7 @@ namespace Ombi.Schedule.Jobs.Ombi
await _embyRepo.ExecuteSql(episodeSQL);
await _embyRepo.ExecuteSql(mainSql);
BackgroundJob.Enqueue(() => _embyContentSync.Start());
//BackgroundJob.Enqueue(() => _embyContentSync.Start()); // TODO
}
catch (Exception e)
{

@ -26,6 +26,7 @@ using Ombi.Settings.Settings.Models.External;
using Ombi.Settings.Settings.Models.Notifications;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
using ContentType = Ombi.Store.Entities.ContentType;
namespace Ombi.Schedule.Jobs.Ombi
@ -288,7 +289,7 @@ namespace Ombi.Schedule.Jobs.Ombi
}
}
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
var newsletterSettings = await _newsletterSettings.GetSettingsAsync();
await Start(newsletterSettings, false);

@ -20,6 +20,7 @@ using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Ombi.Updater;
using Quartz;
using SharpCompress.Readers;
using SharpCompress.Readers.Tar;
@ -41,7 +42,6 @@ namespace Ombi.Schedule.Jobs.Ombi
private IChangeLogProcessor Processor { get; }
private ISettingsService<UpdateSettings> Settings { get; }
private readonly IProcessProvider _processProvider;
private static PerformContext Ctx { get; set; }
private readonly IApplicationConfigRepository _appConfig;
public string[] GetVersion()
@ -59,10 +59,8 @@ namespace Ombi.Schedule.Jobs.Ombi
}
[AutomaticRetry(Attempts = 1)]
public async Task Update(PerformContext c)
public async Task Execute(IJobExecutionContext job)
{
Ctx = c;
Logger.LogDebug(LoggingEvents.Updater, "Starting Update job");
var settings = await Settings.GetSettingsAsync();
@ -182,7 +180,7 @@ namespace Ombi.Schedule.Jobs.Ombi
}
Logger.LogDebug(LoggingEvents.Updater, "Starting Download");
await DownloadAsync(download.Url, zipDir, c);
await DownloadAsync(download.Url, zipDir);
Logger.LogDebug(LoggingEvents.Updater, "Finished Download");
}
catch (Exception e)
@ -321,7 +319,7 @@ namespace Ombi.Schedule.Jobs.Ombi
}
}
public async Task DownloadAsync(string requestUri, string filename, PerformContext ctx)
public async Task DownloadAsync(string requestUri, string filename)
{
Logger.LogDebug(LoggingEvents.Updater, "Starting the DownloadAsync");
using (var client = new WebClient())

@ -15,6 +15,7 @@ using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Plex;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
namespace Ombi.Schedule.Jobs.Ombi
{
@ -48,7 +49,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private readonly ISettingsService<EmbySettings> _embySettings;
private readonly IEmbyApi _embyApi;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
_log.LogInformation("Starting the Metadata refresh");
try
@ -93,12 +94,12 @@ namespace Ombi.Schedule.Jobs.Ombi
{
if (plexSettings.Enable)
{
BackgroundJob.Enqueue(() => _plexAvailabilityChecker.Start());
//BackgroundJob.Enqueue(() => _plexAvailabilityChecker.Start()); // TODO
}
if (embySettings.Enable)
{
BackgroundJob.Enqueue(() => _embyAvaliabilityChecker.Start());
//BackgroundJob.Enqueue(() => _embyAvaliabilityChecker.Start()); // TODO
}
}

@ -7,6 +7,7 @@ using Ombi.Core.Senders;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests;
using Quartz;
namespace Ombi.Schedule.Jobs.Ombi
{
@ -32,7 +33,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private readonly ITvRequestRepository _tvRequestRepository;
private readonly IMusicRequestRepository _musicRequestRepository;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
// Get all the failed ones!
var failedRequests = _requestQueue.GetAll().Where(x => !x.Completed.HasValue);

@ -5,6 +5,5 @@ namespace Ombi.Schedule.Jobs.Plex
{
public interface IPlexAvailabilityChecker : IBaseJob
{
Task Start();
}
}

@ -9,7 +9,6 @@ namespace Ombi.Schedule.Jobs.Plex.Interfaces
{
public interface IPlexEpisodeSync : IBaseJob
{
Task Start();
Task<HashSet<PlexEpisode>> ProcessEpsiodes(Metadata[] episodes, IQueryable<PlexEpisode> currentEpisodes);
}
}

@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Plex
{
public interface IPlexUserImporter : IBaseJob
{
Task Start();
}
}

@ -12,6 +12,7 @@ using Ombi.Store.Entities;
using Ombi.Store.Entities.Requests;
using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests;
using Quartz;
namespace Ombi.Schedule.Jobs.Plex
{
@ -35,7 +36,7 @@ namespace Ombi.Schedule.Jobs.Plex
private readonly IBackgroundJobClient _backgroundJobClient;
private readonly ILogger _log;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
try
{

@ -105,7 +105,7 @@ namespace Ombi.Schedule.Jobs.Plex
if (!recentlyAddedSearch)
{
Logger.LogInformation("Starting EP Cacher");
BackgroundJob.Enqueue(() => EpisodeSync.Start());
//BackgroundJob.Enqueue(() => EpisodeSync.Start()); //TODO
}
if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch)
@ -116,7 +116,7 @@ namespace Ombi.Schedule.Jobs.Plex
if ((processedContent?.HasProcessedEpisodes ?? false) && recentlyAddedSearch)
{
BackgroundJob.Enqueue(() => Checker.Start());
//BackgroundJob.Enqueue(() => Checker.Start()); // TODO
}
}

@ -13,6 +13,7 @@ using Ombi.Helpers;
using Ombi.Schedule.Jobs.Plex.Interfaces;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
namespace Ombi.Schedule.Jobs.Plex
{
@ -35,7 +36,7 @@ namespace Ombi.Schedule.Jobs.Plex
private readonly IPlexContentRepository _repo;
private readonly IPlexAvailabilityChecker _availabilityChecker;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
try
{
@ -56,7 +57,7 @@ namespace Ombi.Schedule.Jobs.Plex
_log.LogError(LoggingEvents.Cacher, e, "Caching Episodes Failed");
}
BackgroundJob.Enqueue(() => _availabilityChecker.Start());
//BackgroundJob.Enqueue(() => _availabilityChecker.Start()); // TODO
}
private async Task Cache(PlexServers settings)

@ -11,6 +11,7 @@ using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities;
using Quartz;
namespace Ombi.Schedule.Jobs.Plex
{
@ -35,7 +36,7 @@ namespace Ombi.Schedule.Jobs.Plex
private readonly ISettingsService<UserManagementSettings> _userManagementSettings;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
var userManagementSettings = await _userManagementSettings.GetSettingsAsync();
if (!userManagementSettings.ImportPlexUsers)

@ -6,7 +6,6 @@ namespace Ombi.Schedule.Jobs.Radarr
{
public interface IRadarrSync : IBaseJob
{
Task CacheContent();
Task<IEnumerable<RadarrCache>> GetCachedContent();
}
}

@ -10,6 +10,7 @@ using Ombi.Helpers;
using Ombi.Settings.Settings.Models.External;
using Ombi.Store.Context;
using Ombi.Store.Entities;
using Quartz;
using Serilog;
namespace Ombi.Schedule.Jobs.Radarr
@ -32,7 +33,7 @@ namespace Ombi.Schedule.Jobs.Radarr
private static readonly SemaphoreSlim SemaphoreSlim = new SemaphoreSlim(1, 1);
public async Task CacheContent()
public async Task Execute(IJobExecutionContext job)
{
await SemaphoreSlim.WaitAsync();
try

@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.SickRage
{
public interface ISickRageSync : IBaseJob
{
Task Start();
}
}

@ -11,6 +11,7 @@ using Ombi.Helpers;
using Ombi.Settings.Settings.Models.External;
using Ombi.Store.Context;
using Ombi.Store.Entities;
using Quartz;
namespace Ombi.Schedule.Jobs.SickRage
{
@ -30,7 +31,7 @@ namespace Ombi.Schedule.Jobs.SickRage
private readonly ILogger<SickRageSync> _log;
private readonly IExternalContext _ctx;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
try
{

@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Sonarr
{
public interface ISonarrSync : IBaseJob
{
Task Start();
}
}

@ -14,6 +14,7 @@ using Ombi.Helpers;
using Ombi.Settings.Settings.Models.External;
using Ombi.Store.Context;
using Ombi.Store.Entities;
using Quartz;
namespace Ombi.Schedule.Jobs.Sonarr
{
@ -33,7 +34,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
private readonly ILogger<SonarrSync> _log;
private readonly IExternalContext _ctx;
public async Task Start()
public async Task Execute(IJobExecutionContext job)
{
try
{

@ -17,7 +17,7 @@
<PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" />
<PackageReference Include="Hangfire.SQLite" Version="1.4.2" />
<PackageReference Include="Serilog" Version="2.7.1" />
<PackageReference Include="Quartz" Version="3.0.6" />
<PackageReference Include="Quartz" Version="3.0.7" />
<PackageReference Include="SharpCompress" Version="0.18.2" />
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.6.13" />

@ -35,7 +35,6 @@ namespace Ombi.Schedule
return Scheduler;
}
public async void AddJob<T>(string name, string group, string cronExpression, Dictionary<string, string> jobData = null)
where T : IJob
{
@ -49,13 +48,13 @@ namespace Ombi.Schedule
}
}
var job = jobBuilder.Build();
var job = jobBuilder.Build();
ITrigger jobTrigger = TriggerBuilder.Create()
.WithIdentity(name + "Trigger", group)
.StartNow()
.StartNow()
.WithCronSchedule(cronExpression)
.Build();

@ -2,7 +2,16 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
using Ombi.Core.Settings;
using Ombi.Schedule.Jobs;
using Ombi.Schedule.Jobs.Couchpotato;
using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Lidarr;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Schedule.Jobs.Plex;
using Ombi.Schedule.Jobs.Plex.Interfaces;
using Ombi.Schedule.Jobs.Radarr;
using Ombi.Schedule.Jobs.SickRage;
using Ombi.Schedule.Jobs.Sonarr;
using Ombi.Settings.Settings.Models;
using Quartz;
using Quartz.Spi;
@ -38,12 +47,48 @@ namespace Ombi.Schedule
// Set job factory
OmbiQuartz.Instance.UseJobFactory(jobFactory);
// Run configuration
OmbiQuartz.Instance.AddJob<PlexContentSync>(nameof(PlexContentSync), "Plex", JobSettingsHelper.PlexContent(s), new Dictionary<string, string>{{ "recentlyAddedSearch", "false" } });
OmbiQuartz.Instance.AddJob<PlexContentSync>(nameof(PlexContentSync), "Plex", JobSettingsHelper.PlexContent(s), new Dictionary<string, string> { { "recentlyAddedSearch", "true" } });
// Run Quartz
OmbiQuartz.Start();
// Run configuration
AddPlex(s);
AddEmby(s);
AddDvrApps(s);
AddSystem(s);
}
private static void AddSystem(JobSettings s)
{
OmbiQuartz.Instance.AddJob<IRefreshMetadata>(nameof(IRefreshMetadata), "System", JobSettingsHelper.RefreshMetadata(s));
OmbiQuartz.Instance.AddJob<IIssuesPurge>(nameof(IIssuesPurge), "System", JobSettingsHelper.IssuePurge(s));
//OmbiQuartz.Instance.AddJob<IOmbiAutomaticUpdater>(nameof(IOmbiAutomaticUpdater), "System", JobSettingsHelper.Updater(s));
OmbiQuartz.Instance.AddJob<INewsletterJob>(nameof(INewsletterJob), "System", JobSettingsHelper.Newsletter(s));
OmbiQuartz.Instance.AddJob<IResendFailedRequests>(nameof(IResendFailedRequests), "System", JobSettingsHelper.ResendFailedRequests(s));
OmbiQuartz.Instance.AddJob<IMediaDatabaseRefresh>(nameof(IMediaDatabaseRefresh), "System", JobSettingsHelper.MediaDatabaseRefresh(s));
}
private static void AddDvrApps(JobSettings s)
{
OmbiQuartz.Instance.AddJob<ISonarrSync>(nameof(ISonarrSync), "DVR", JobSettingsHelper.Sonarr(s));
OmbiQuartz.Instance.AddJob<IRadarrSync>(nameof(IRadarrSync), "DVR", JobSettingsHelper.Radarr(s));
OmbiQuartz.Instance.AddJob<ICouchPotatoSync>(nameof(ICouchPotatoSync), "DVR", JobSettingsHelper.CouchPotato(s));
OmbiQuartz.Instance.AddJob<ISickRageSync>(nameof(ISickRageSync), "DVR", JobSettingsHelper.SickRageSync(s));
OmbiQuartz.Instance.AddJob<ILidarrArtistSync>(nameof(ILidarrArtistSync), "DVR", JobSettingsHelper.LidarrArtistSync(s));
}
private static void AddPlex(JobSettings s)
{
OmbiQuartz.Instance.AddJob<IPlexContentSync>(nameof(IPlexContentSync), "Plex", JobSettingsHelper.PlexContent(s), new Dictionary<string, string> { { "recentlyAddedSearch", "false" } });
OmbiQuartz.Instance.AddJob<IPlexContentSync>(nameof(IPlexContentSync) + "RecentlyAdded", "Plex", JobSettingsHelper.PlexContent(s), new Dictionary<string, string> { { "recentlyAddedSearch", "true" } });
OmbiQuartz.Instance.AddJob<IPlexRecentlyAddedSync>(nameof(IPlexRecentlyAddedSync), "Plex", JobSettingsHelper.PlexRecentlyAdded(s));
OmbiQuartz.Instance.AddJob<IPlexUserImporter>(nameof(IPlexUserImporter), "Plex", JobSettingsHelper.UserImporter(s));
}
private static void AddEmby(JobSettings s)
{
OmbiQuartz.Instance.AddJob<IEmbyContentSync>(nameof(IEmbyContentSync), "Emby", JobSettingsHelper.EmbyContent(s));
OmbiQuartz.Instance.AddJob<IEmbyUserImporter>(nameof(IEmbyUserImporter), "Emby", JobSettingsHelper.UserImporter(s));
}
}
}

@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Quartz" Version="3.0.7" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>

@ -13,6 +13,7 @@ namespace Ombi.Settings.Settings.Models
public static string Sonarr(JobSettings s)
{
return Get(s.SonarrSync, Cron.Hourly(10));
//return Get(s.SonarrSync, Cron.Hourly(10));
}
public static string EmbyContent(JobSettings s)
@ -42,7 +43,7 @@ namespace Ombi.Settings.Settings.Models
}
public static string Newsletter(JobSettings s)
{
return Get(s.Newsletter, Cron.Weekly(DayOfWeek.Friday, 12));
return Get(s.Newsletter, Cron.Weekly(Helpers.DayOfWeek.Friday, 12));
}
public static string SickRageSync(JobSettings s)
{

@ -50,7 +50,7 @@ namespace Ombi.Controllers
[HttpPost("update")]
public bool ForceUpdate()
{
BackgroundJob.Enqueue(() => _updater.Update(null));
//BackgroundJob.Enqueue(() => _updater.Update(null));
return true;
}
@ -99,7 +99,7 @@ namespace Ombi.Controllers
[HttpPost("plexuserimporter")]
public bool PlexUserImporter()
{
BackgroundJob.Enqueue(() => _plexUserImporter.Start());
//BackgroundJob.Enqueue(() => _plexUserImporter.Start()); //TODO
return true;
}
@ -110,7 +110,7 @@ namespace Ombi.Controllers
[HttpPost("embyuserimporter")]
public bool EmbyUserImporter()
{
BackgroundJob.Enqueue(() => _embyUserImporter.Start());
//BackgroundJob.Enqueue(() => _embyUserImporter.Start()); // TODO
return true;
}
@ -143,7 +143,7 @@ namespace Ombi.Controllers
[HttpPost("embycontentcacher")]
public bool StartEmbyContentCacher()
{
BackgroundJob.Enqueue(() => _embyContentSync.Start());
//BackgroundJob.Enqueue(() => _embyContentSync.Start()); // TODO
return true;
}
@ -154,7 +154,7 @@ namespace Ombi.Controllers
[HttpPost("newsletter")]
public bool StartNewsletter()
{
BackgroundJob.Enqueue(() => _newsletterJob.Start());
//BackgroundJob.Enqueue(() => _newsletterJob.Start()); // TODO
return true;
}
}

@ -387,7 +387,7 @@ namespace Ombi.Controllers
{
_cache.Remove(CacheKeys.RadarrRootProfiles);
_cache.Remove(CacheKeys.RadarrQualityProfiles);
BackgroundJob.Enqueue(() => _radarrSync.CacheContent());
//BackgroundJob.Enqueue(() => _radarrSync.CacheContent()); // TODO
}
return result;
}

@ -192,8 +192,8 @@ namespace Ombi
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 });
// Setup the scheduler
var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
jobSetup.Setup();
//var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
//jobSetup.Setup();
ctx.Seed();
var settingsctx = serviceProvider.GetService<ISettingsContext>();
var externalctx = serviceProvider.GetService<IExternalContext>();

Loading…
Cancel
Save