From 52d9a7a5863ee3524230451f8f84486f5e45334f Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 9 Apr 2019 23:24:30 +0100 Subject: [PATCH] moved the jobs to use quartz --- src/Ombi.Helpers/Cron.cs | 48 ++++++++++++++--- src/Ombi.Schedule/JobSetup.cs | 32 +++++------ .../Jobs/Couchpotato/CouchPotatoSync.cs | 3 +- .../Jobs/Couchpotato/ICouchPotatoSync.cs | 1 - .../Jobs/Emby/EmbyAvaliabilityChecker.cs | 3 +- .../Jobs/Emby/EmbyContentSync.cs | 7 +-- .../Jobs/Emby/EmbyEpisodeSync.cs | 5 +- .../Jobs/Emby/EmbyUserImporter.cs | 3 +- .../Jobs/Emby/IEmbyAvaliabilityChecker.cs | 1 - .../Jobs/Emby/IEmbyContentSync.cs | 1 - .../Jobs/Emby/IEmbyEpisodeSync.cs | 1 - .../Jobs/Emby/IEmbyUserImporter.cs | 1 - src/Ombi.Schedule/Jobs/IBaseJob.cs | 3 +- .../Jobs/Lidarr/ILidarrArtistSync.cs | 4 +- .../Jobs/Lidarr/LidarrArtistSync.cs | 3 +- .../Jobs/Ombi/Interfaces/IIssuesPurge.cs | 3 +- .../Ombi/Interfaces/IMediaDatabaseRefresh.cs | 1 - .../Jobs/Ombi/Interfaces/INewsletterJob.cs | 1 - .../Ombi/Interfaces/IOmbiAutomaticUpdater.cs | 1 - .../Jobs/Ombi/Interfaces/IRefreshMetadata.cs | 1 - .../Ombi/Interfaces/IResendFailedRequests.cs | 6 +-- .../Jobs/Ombi/Interfaces/IWelcomeEmail.cs | 2 +- .../Jobs/Ombi/Interfaces/IssuesPurge.cs | 3 +- .../Jobs/Ombi/MediaDatabaseRefresh.cs | 5 +- src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs | 3 +- .../Jobs/Ombi/OmbiAutomaticUpdater.cs | 10 ++-- .../Jobs/Ombi/RefreshMetadata.cs | 7 +-- .../Jobs/Ombi/ResendFailedRequests.cs | 3 +- .../Interfaces/IPlexAvailabilityChecker.cs | 1 - .../Jobs/Plex/Interfaces/IPlexEpisodeSync.cs | 1 - .../Jobs/Plex/Interfaces/IPlexUserImporter.cs | 1 - .../Jobs/Plex/PlexAvailabilityChecker.cs | 3 +- .../Jobs/Plex/PlexContentSync.cs | 4 +- .../Jobs/Plex/PlexEpisodeSync.cs | 5 +- .../Jobs/Plex/PlexUserImporter.cs | 3 +- src/Ombi.Schedule/Jobs/Radarr/IRadarrSync.cs | 1 - src/Ombi.Schedule/Jobs/Radarr/RadarrSync.cs | 3 +- .../Jobs/SickRage/ISickRageSync.cs | 1 - .../Jobs/SickRage/SickRageSync.cs | 3 +- src/Ombi.Schedule/Jobs/Sonarr/ISonarrSync.cs | 1 - src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs | 3 +- src/Ombi.Schedule/Ombi.Schedule.csproj | 2 +- src/Ombi.Schedule/OmbiQuartz.cs | 9 ++-- src/Ombi.Schedule/OmbiScheduler.cs | 53 +++++++++++++++++-- src/Ombi.Settings/Ombi.Settings.csproj | 1 + .../Settings/Models/JobSettingsHelper.cs | 3 +- src/Ombi/Controllers/JobController.cs | 10 ++-- src/Ombi/Controllers/SettingsController.cs | 2 +- src/Ombi/Startup.cs | 4 +- 49 files changed, 178 insertions(+), 98 deletions(-) diff --git a/src/Ombi.Helpers/Cron.cs b/src/Ombi.Helpers/Cron.cs index 35b141eda..8197dae77 100644 --- a/src/Ombi.Helpers/Cron.cs +++ b/src/Ombi.Helpers/Cron.cs @@ -16,7 +16,6 @@ // You should have received a copy of the GNU Lesser General Public // License along with Hangfire. If not, see . - using System; /// /// Helper class that provides common values for the cron expressions. /// @@ -44,7 +43,7 @@ /// The minute in which the schedule will be activated (0-59). public static string Hourly(int minute) { - return $"{minute} * * * *"; + return $"0 {minute} 0/1 1/1 * ? *"; } /// @@ -73,7 +72,7 @@ /// The minute in which the schedule will be activated (0-59). public static string Daily(int hour, int minute) { - return $"{minute} {hour} * * *"; + return $"0 {minute} {hour} 1/1 * ? *"; } /// @@ -114,7 +113,7 @@ /// The minute in which the schedule will be activated (0-59). public static string Weekly(DayOfWeek dayOfWeek, int hour, int minute) { - return $"{minute} {hour} * * {(int)dayOfWeek}"; + return $"0 {minute} {hour} ? * {(int)dayOfWeek} *"; } /// @@ -219,7 +218,7 @@ /// The number of minutes to wait between every activation. public static string MinuteInterval(int interval) { - return $"*/{interval} * * * *"; + return $" 0 0/{interval} * 1/1 * ? *"; } /// @@ -228,7 +227,7 @@ /// The number of hours to wait between every activation. public static string HourInterval(int interval) { - return $"0 */{interval} * * *"; + return $"0 0 0/{interval} 1/1 * ? *"; } /// @@ -237,7 +236,7 @@ /// The number of days to wait between every activation. public static string DayInterval(int interval) { - return $"0 0 */{interval} * *"; + return $"0 0 12 1/{interval} * ? *"; } /// @@ -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 + } } \ No newline at end of file diff --git a/src/Ombi.Schedule/JobSetup.cs b/src/Ombi.Schedule/JobSetup.cs index 1f3752c78..f0f53f128 100644 --- a/src/Ombi.Schedule/JobSetup.cs +++ b/src/Ombi.Schedule/JobSetup.cs @@ -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; diff --git a/src/Ombi.Schedule/Jobs/Couchpotato/CouchPotatoSync.cs b/src/Ombi.Schedule/Jobs/Couchpotato/CouchPotatoSync.cs index 5e9f13534..ca848e56f 100644 --- a/src/Ombi.Schedule/Jobs/Couchpotato/CouchPotatoSync.cs +++ b/src/Ombi.Schedule/Jobs/Couchpotato/CouchPotatoSync.cs @@ -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 _log; private readonly IExternalContext _ctx; - public async Task Start() + public async Task Execute(IJobExecutionContext job) { var settings = await _settings.GetSettingsAsync(); if (!settings.Enabled) diff --git a/src/Ombi.Schedule/Jobs/Couchpotato/ICouchPotatoSync.cs b/src/Ombi.Schedule/Jobs/Couchpotato/ICouchPotatoSync.cs index caa390834..fa23d5030 100644 --- a/src/Ombi.Schedule/Jobs/Couchpotato/ICouchPotatoSync.cs +++ b/src/Ombi.Schedule/Jobs/Couchpotato/ICouchPotatoSync.cs @@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Couchpotato { public interface ICouchPotatoSync : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs index 7007b3743..929f8d7b9 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs @@ -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 _log; - public async Task Start() + public async Task Execute(IJobExecutionContext job) { await ProcessMovies(); await ProcessTv(); diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs index e22c0ca51..656719a1f 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs @@ -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()); } diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs index 962b08cda..82dbb06a0 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs @@ -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) diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyUserImporter.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyUserImporter.cs index 280a61ab4..5cb7b368d 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyUserImporter.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyUserImporter.cs @@ -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; private readonly ISettingsService _userManagementSettings; - public async Task Start() + public async Task Execute(IJobExecutionContext job) { var userManagementSettings = await _userManagementSettings.GetSettingsAsync(); if (!userManagementSettings.ImportEmbyUsers) diff --git a/src/Ombi.Schedule/Jobs/Emby/IEmbyAvaliabilityChecker.cs b/src/Ombi.Schedule/Jobs/Emby/IEmbyAvaliabilityChecker.cs index ce9792f3b..ce2d7dba7 100644 --- a/src/Ombi.Schedule/Jobs/Emby/IEmbyAvaliabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Emby/IEmbyAvaliabilityChecker.cs @@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Emby { public interface IEmbyAvaliabilityChecker : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Emby/IEmbyContentSync.cs b/src/Ombi.Schedule/Jobs/Emby/IEmbyContentSync.cs index 5ba8ea6f9..8dd85bab4 100644 --- a/src/Ombi.Schedule/Jobs/Emby/IEmbyContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Emby/IEmbyContentSync.cs @@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Emby { public interface IEmbyContentSync : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Emby/IEmbyEpisodeSync.cs b/src/Ombi.Schedule/Jobs/Emby/IEmbyEpisodeSync.cs index 42d761832..bff623ff8 100644 --- a/src/Ombi.Schedule/Jobs/Emby/IEmbyEpisodeSync.cs +++ b/src/Ombi.Schedule/Jobs/Emby/IEmbyEpisodeSync.cs @@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Emby { public interface IEmbyEpisodeSync : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Emby/IEmbyUserImporter.cs b/src/Ombi.Schedule/Jobs/Emby/IEmbyUserImporter.cs index c8bd6fc0e..1c3a51340 100644 --- a/src/Ombi.Schedule/Jobs/Emby/IEmbyUserImporter.cs +++ b/src/Ombi.Schedule/Jobs/Emby/IEmbyUserImporter.cs @@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Emby { public interface IEmbyUserImporter : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/IBaseJob.cs b/src/Ombi.Schedule/Jobs/IBaseJob.cs index d43d21b9a..bec0db7a0 100644 --- a/src/Ombi.Schedule/Jobs/IBaseJob.cs +++ b/src/Ombi.Schedule/Jobs/IBaseJob.cs @@ -25,11 +25,12 @@ // ************************************************************************/ #endregion +using Quartz; using System; namespace Ombi.Schedule { - public interface IBaseJob : IDisposable + public interface IBaseJob : IJob, IDisposable { } diff --git a/src/Ombi.Schedule/Jobs/Lidarr/ILidarrArtistSync.cs b/src/Ombi.Schedule/Jobs/Lidarr/ILidarrArtistSync.cs index 1d3424756..3ba74e7cf 100644 --- a/src/Ombi.Schedule/Jobs/Lidarr/ILidarrArtistSync.cs +++ b/src/Ombi.Schedule/Jobs/Lidarr/ILidarrArtistSync.cs @@ -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> GetCachedContent(); } diff --git a/src/Ombi.Schedule/Jobs/Lidarr/LidarrArtistSync.cs b/src/Ombi.Schedule/Jobs/Lidarr/LidarrArtistSync.cs index e9a64f2a3..200c50223 100644 --- a/src/Ombi.Schedule/Jobs/Lidarr/LidarrArtistSync.cs +++ b/src/Ombi.Schedule/Jobs/Lidarr/LidarrArtistSync.cs @@ -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 { diff --git a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IIssuesPurge.cs b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IIssuesPurge.cs index fbd1e3aaf..d72b062ce 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IIssuesPurge.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IIssuesPurge.cs @@ -3,7 +3,6 @@ namespace Ombi.Schedule.Jobs.Ombi { public interface IIssuesPurge : IBaseJob - { - Task Start(); + { } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IMediaDatabaseRefresh.cs b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IMediaDatabaseRefresh.cs index 11fe7c51a..06ac9421c 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IMediaDatabaseRefresh.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IMediaDatabaseRefresh.cs @@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Plex.Interfaces { public interface IMediaDatabaseRefresh : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/INewsletterJob.cs b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/INewsletterJob.cs index 887508d34..d8b5c3f3f 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/INewsletterJob.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/INewsletterJob.cs @@ -5,7 +5,6 @@ namespace Ombi.Schedule.Jobs.Ombi { public interface INewsletterJob : IBaseJob { - Task Start(); Task Start(NewsletterSettings settings, bool test); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IOmbiAutomaticUpdater.cs b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IOmbiAutomaticUpdater.cs index 48f03b65d..484700c85 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IOmbiAutomaticUpdater.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IOmbiAutomaticUpdater.cs @@ -5,7 +5,6 @@ namespace Ombi.Schedule.Jobs.Ombi { public interface IOmbiAutomaticUpdater : IBaseJob { - Task Update(PerformContext context); string[] GetVersion(); Task UpdateAvailable(string branch, string currentVersion); } diff --git a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IRefreshMetadata.cs b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IRefreshMetadata.cs index ed13280b0..a7e7d5fdc 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IRefreshMetadata.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IRefreshMetadata.cs @@ -5,7 +5,6 @@ namespace Ombi.Schedule.Jobs.Ombi { public interface IRefreshMetadata : IBaseJob { - Task Start(); Task ProcessPlexServerContent(IEnumerable contentIds); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IResendFailedRequests.cs b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IResendFailedRequests.cs index b55c0f69b..c740b71d9 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IResendFailedRequests.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IResendFailedRequests.cs @@ -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(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IWelcomeEmail.cs b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IWelcomeEmail.cs index 6b1270669..b4be7cbef 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IWelcomeEmail.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IWelcomeEmail.cs @@ -3,7 +3,7 @@ using Ombi.Store.Entities; namespace Ombi.Schedule.Jobs.Ombi { - public interface IWelcomeEmail : IBaseJob + public interface IWelcomeEmail { Task SendEmail(OmbiUser user); } diff --git a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IssuesPurge.cs b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IssuesPurge.cs index 5af4b565d..6a16aad70 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IssuesPurge.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IssuesPurge.cs @@ -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 _issuesRepository; private readonly ISettingsService _settings; - public async Task Start() + public async Task Execute(IJobExecutionContext job) { var settings = await _settings.GetSettingsAsync(); if (!settings.DeleteIssues) diff --git a/src/Ombi.Schedule/Jobs/Ombi/MediaDatabaseRefresh.cs b/src/Ombi.Schedule/Jobs/Ombi/MediaDatabaseRefresh.cs index fcf8529ce..8dc8fcf1f 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/MediaDatabaseRefresh.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/MediaDatabaseRefresh.cs @@ -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) { diff --git a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs index 12415f6e4..84798cc61 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs @@ -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); diff --git a/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs b/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs index 783fe5f9d..4c66b2e2f 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs @@ -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 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()) diff --git a/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs b/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs index c9ba5c6b3..b1240593d 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs @@ -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; 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 } } diff --git a/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs b/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs index bc8f93a97..344e3a874 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/ResendFailedRequests.cs @@ -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); diff --git a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexAvailabilityChecker.cs index 2d115ab88..112e3be38 100644 --- a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexAvailabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexAvailabilityChecker.cs @@ -5,6 +5,5 @@ namespace Ombi.Schedule.Jobs.Plex { public interface IPlexAvailabilityChecker : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexEpisodeSync.cs b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexEpisodeSync.cs index 7de7c3c0c..8eed35066 100644 --- a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexEpisodeSync.cs +++ b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexEpisodeSync.cs @@ -9,7 +9,6 @@ namespace Ombi.Schedule.Jobs.Plex.Interfaces { public interface IPlexEpisodeSync : IBaseJob { - Task Start(); Task> ProcessEpsiodes(Metadata[] episodes, IQueryable currentEpisodes); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexUserImporter.cs b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexUserImporter.cs index 431ce3ee3..fede60475 100644 --- a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexUserImporter.cs +++ b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexUserImporter.cs @@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Plex { public interface IPlexUserImporter : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs index e0278f854..9a7a8601a 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs @@ -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 { diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs index 3131e5963..add1a9674 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs @@ -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 } } diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeSync.cs b/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeSync.cs index 5652d126b..7e751d0d9 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeSync.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeSync.cs @@ -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) diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs b/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs index 53c82465c..7d30d780a 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs @@ -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; - public async Task Start() + public async Task Execute(IJobExecutionContext job) { var userManagementSettings = await _userManagementSettings.GetSettingsAsync(); if (!userManagementSettings.ImportPlexUsers) diff --git a/src/Ombi.Schedule/Jobs/Radarr/IRadarrSync.cs b/src/Ombi.Schedule/Jobs/Radarr/IRadarrSync.cs index a9f8edfcd..1fb191fd1 100644 --- a/src/Ombi.Schedule/Jobs/Radarr/IRadarrSync.cs +++ b/src/Ombi.Schedule/Jobs/Radarr/IRadarrSync.cs @@ -6,7 +6,6 @@ namespace Ombi.Schedule.Jobs.Radarr { public interface IRadarrSync : IBaseJob { - Task CacheContent(); Task> GetCachedContent(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Radarr/RadarrSync.cs b/src/Ombi.Schedule/Jobs/Radarr/RadarrSync.cs index 5c954def8..8212aad3b 100644 --- a/src/Ombi.Schedule/Jobs/Radarr/RadarrSync.cs +++ b/src/Ombi.Schedule/Jobs/Radarr/RadarrSync.cs @@ -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 diff --git a/src/Ombi.Schedule/Jobs/SickRage/ISickRageSync.cs b/src/Ombi.Schedule/Jobs/SickRage/ISickRageSync.cs index df51698fe..2fcd435a8 100644 --- a/src/Ombi.Schedule/Jobs/SickRage/ISickRageSync.cs +++ b/src/Ombi.Schedule/Jobs/SickRage/ISickRageSync.cs @@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.SickRage { public interface ISickRageSync : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/SickRage/SickRageSync.cs b/src/Ombi.Schedule/Jobs/SickRage/SickRageSync.cs index 92e0c2d55..8c5652f3a 100644 --- a/src/Ombi.Schedule/Jobs/SickRage/SickRageSync.cs +++ b/src/Ombi.Schedule/Jobs/SickRage/SickRageSync.cs @@ -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 _log; private readonly IExternalContext _ctx; - public async Task Start() + public async Task Execute(IJobExecutionContext job) { try { diff --git a/src/Ombi.Schedule/Jobs/Sonarr/ISonarrSync.cs b/src/Ombi.Schedule/Jobs/Sonarr/ISonarrSync.cs index a1ba9f3c2..f190be3c5 100644 --- a/src/Ombi.Schedule/Jobs/Sonarr/ISonarrSync.cs +++ b/src/Ombi.Schedule/Jobs/Sonarr/ISonarrSync.cs @@ -4,6 +4,5 @@ namespace Ombi.Schedule.Jobs.Sonarr { public interface ISonarrSync : IBaseJob { - Task Start(); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs b/src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs index e4c00c726..eaa285cc7 100644 --- a/src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs +++ b/src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs @@ -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 _log; private readonly IExternalContext _ctx; - public async Task Start() + public async Task Execute(IJobExecutionContext job) { try { diff --git a/src/Ombi.Schedule/Ombi.Schedule.csproj b/src/Ombi.Schedule/Ombi.Schedule.csproj index 15128f768..ef6b1d447 100644 --- a/src/Ombi.Schedule/Ombi.Schedule.csproj +++ b/src/Ombi.Schedule/Ombi.Schedule.csproj @@ -17,7 +17,7 @@ - + diff --git a/src/Ombi.Schedule/OmbiQuartz.cs b/src/Ombi.Schedule/OmbiQuartz.cs index 20c12bf23..de9209738 100644 --- a/src/Ombi.Schedule/OmbiQuartz.cs +++ b/src/Ombi.Schedule/OmbiQuartz.cs @@ -35,7 +35,6 @@ namespace Ombi.Schedule return Scheduler; } - public async void AddJob(string name, string group, string cronExpression, Dictionary 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(); diff --git a/src/Ombi.Schedule/OmbiScheduler.cs b/src/Ombi.Schedule/OmbiScheduler.cs index f728a9ba4..17b68fdd9 100644 --- a/src/Ombi.Schedule/OmbiScheduler.cs +++ b/src/Ombi.Schedule/OmbiScheduler.cs @@ -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(nameof(PlexContentSync), "Plex", JobSettingsHelper.PlexContent(s), new Dictionary{{ "recentlyAddedSearch", "false" } }); - OmbiQuartz.Instance.AddJob(nameof(PlexContentSync), "Plex", JobSettingsHelper.PlexContent(s), new Dictionary { { "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(nameof(IRefreshMetadata), "System", JobSettingsHelper.RefreshMetadata(s)); + OmbiQuartz.Instance.AddJob(nameof(IIssuesPurge), "System", JobSettingsHelper.IssuePurge(s)); + //OmbiQuartz.Instance.AddJob(nameof(IOmbiAutomaticUpdater), "System", JobSettingsHelper.Updater(s)); + OmbiQuartz.Instance.AddJob(nameof(INewsletterJob), "System", JobSettingsHelper.Newsletter(s)); + OmbiQuartz.Instance.AddJob(nameof(IResendFailedRequests), "System", JobSettingsHelper.ResendFailedRequests(s)); + OmbiQuartz.Instance.AddJob(nameof(IMediaDatabaseRefresh), "System", JobSettingsHelper.MediaDatabaseRefresh(s)); + } + + private static void AddDvrApps(JobSettings s) + { + OmbiQuartz.Instance.AddJob(nameof(ISonarrSync), "DVR", JobSettingsHelper.Sonarr(s)); + OmbiQuartz.Instance.AddJob(nameof(IRadarrSync), "DVR", JobSettingsHelper.Radarr(s)); + OmbiQuartz.Instance.AddJob(nameof(ICouchPotatoSync), "DVR", JobSettingsHelper.CouchPotato(s)); + OmbiQuartz.Instance.AddJob(nameof(ISickRageSync), "DVR", JobSettingsHelper.SickRageSync(s)); + OmbiQuartz.Instance.AddJob(nameof(ILidarrArtistSync), "DVR", JobSettingsHelper.LidarrArtistSync(s)); + } + + private static void AddPlex(JobSettings s) + { + OmbiQuartz.Instance.AddJob(nameof(IPlexContentSync), "Plex", JobSettingsHelper.PlexContent(s), new Dictionary { { "recentlyAddedSearch", "false" } }); + OmbiQuartz.Instance.AddJob(nameof(IPlexContentSync) + "RecentlyAdded", "Plex", JobSettingsHelper.PlexContent(s), new Dictionary { { "recentlyAddedSearch", "true" } }); + OmbiQuartz.Instance.AddJob(nameof(IPlexRecentlyAddedSync), "Plex", JobSettingsHelper.PlexRecentlyAdded(s)); + OmbiQuartz.Instance.AddJob(nameof(IPlexUserImporter), "Plex", JobSettingsHelper.UserImporter(s)); + } + + private static void AddEmby(JobSettings s) + { + OmbiQuartz.Instance.AddJob(nameof(IEmbyContentSync), "Emby", JobSettingsHelper.EmbyContent(s)); + OmbiQuartz.Instance.AddJob(nameof(IEmbyUserImporter), "Emby", JobSettingsHelper.UserImporter(s)); } } } \ No newline at end of file diff --git a/src/Ombi.Settings/Ombi.Settings.csproj b/src/Ombi.Settings/Ombi.Settings.csproj index 6db0768aa..39e53c9ff 100644 --- a/src/Ombi.Settings/Ombi.Settings.csproj +++ b/src/Ombi.Settings/Ombi.Settings.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs b/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs index e2080e3cb..e03ba28ba 100644 --- a/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs +++ b/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs @@ -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) { diff --git a/src/Ombi/Controllers/JobController.cs b/src/Ombi/Controllers/JobController.cs index d9f21f67d..42f332af4 100644 --- a/src/Ombi/Controllers/JobController.cs +++ b/src/Ombi/Controllers/JobController.cs @@ -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; } } diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index 823461e35..e77a8fd7a 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -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; } diff --git a/src/Ombi/Startup.cs b/src/Ombi/Startup.cs index 4a46a0840..308e37a69 100644 --- a/src/Ombi/Startup.cs +++ b/src/Ombi/Startup.cs @@ -192,8 +192,8 @@ namespace Ombi GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 }); // Setup the scheduler - var jobSetup = app.ApplicationServices.GetService(); - jobSetup.Setup(); + //var jobSetup = app.ApplicationServices.GetService(); + //jobSetup.Setup(); ctx.Seed(); var settingsctx = serviceProvider.GetService(); var externalctx = serviceProvider.GetService();