diff --git a/PlexRequests.Core.Migration/Migrations/Version195.cs b/PlexRequests.Core.Migration/Migrations/Version195.cs index 01724f3a0..24ddf9ea1 100644 --- a/PlexRequests.Core.Migration/Migrations/Version195.cs +++ b/PlexRequests.Core.Migration/Migrations/Version195.cs @@ -25,39 +25,76 @@ // ************************************************************************/ #endregion +using System; using System.Data; using PlexRequests.Core.SettingModels; +using PlexRequests.Store; +using Quartz; namespace PlexRequests.Core.Migration.Migrations { [Migration(1950, "v1.9.5.0")] public class Version195 : BaseMigration, IMigration { - public Version195(ISettingsService plexRequestSettings, ISettingsService news) + public Version195(ISettingsService plexRequestSettings, ISettingsService news, ISettingsService jobs) { PlexRequestSettings = plexRequestSettings; NewsletterSettings = news; + Jobs = jobs; } public int Version => 1950; private ISettingsService PlexRequestSettings { get; } private ISettingsService NewsletterSettings { get; } + private ISettingsService Jobs { get; } public void Start(IDbConnection con) + { + UpdateApplicationSettings(); + UpdateDb(con); + + UpdateSchema(con, Version); + } + + private void UpdateDb(IDbConnection con) + { + + } + + private void UpdateApplicationSettings() { var plex = PlexRequestSettings.GetSettings(); - + var jobSettings = Jobs.GetSettings(); var newsLetter = NewsletterSettings.GetSettings(); + + newsLetter.SendToPlexUsers = true; + UpdateScheduledSettings(jobSettings); + if (plex.SendRecentlyAddedEmail) { newsLetter.SendRecentlyAddedEmail = plex.SendRecentlyAddedEmail; plex.SendRecentlyAddedEmail = false; - PlexRequestSettings.SaveSettings(plex); - NewsletterSettings.SaveSettings(newsLetter); } - UpdateSchema(con, Version); + + NewsletterSettings.SaveSettings(newsLetter); + Jobs.SaveSettings(jobSettings); + } + + private void UpdateScheduledSettings(ScheduledJobsSettings settings) + { + settings.PlexAvailabilityChecker = 60; + settings.SickRageCacher = 60; + settings.SonarrCacher = 60; + settings.CouchPotatoCacher = 60; + settings.StoreBackup = 24; + settings.StoreCleanup = 24; + settings.UserRequestLimitResetter = 12; + settings.PlexEpisodeCacher = 12; + + var cron = (Quartz.Impl.Triggers.CronTriggerImpl)CronScheduleBuilder.WeeklyOnDayAndHourAndMinute(DayOfWeek.Friday, 7, 0).Build(); + settings.RecentlyAddedCron = cron.CronExpressionString; // Weekly CRON at 7 am on Mondays } } } \ No newline at end of file diff --git a/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj b/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj index bb82fe012..a92ae74d5 100644 --- a/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj +++ b/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj @@ -31,12 +31,24 @@ 4 + + ..\packages\Common.Logging.3.0.0\lib\net40\Common.Logging.dll + True + + + ..\packages\Common.Logging.Core.3.0.0\lib\net40\Common.Logging.Core.dll + True + ..\Assemblies\Mono.Data.Sqlite.dll ..\packages\Ninject.3.2.0.0\lib\net45-full\Ninject.dll + + ..\packages\Quartz.2.3.3\lib\net40\Quartz.dll + True + @@ -66,6 +78,13 @@ PlexRequests.Store + + + + Designer + + + -
- +
+