using System; using System.Collections.Generic; using Microsoft.AspNetCore.Builder; using Ombi.Core.Settings; using Ombi.Schedule.Jobs.Plex; using Ombi.Settings.Settings.Models; using Quartz; using Quartz.Spi; namespace Ombi.Schedule { public static class OmbiScheduler { //public void Setup() //{ // CreateJobDefinitions(); //} //public void CreateJobDefinitions() //{ // var contentSync = JobBuilder.Create() // .UsingJobData("recentlyAddedSearch", false) // .WithIdentity(nameof(PlexContentSync), "Plex") // .Build(); // var recentlyAdded = JobBuilder.Create() // .UsingJobData("recentlyAddedSearch", true) // .WithIdentity("PlexRecentlyAdded", "Plex") // .Build(); //} public static void UseQuartz(this IApplicationBuilder app) { // Job Factory through IOC container var jobFactory = (IJobFactory)app.ApplicationServices.GetService(typeof(IJobFactory)); var service = (ISettingsService)app.ApplicationServices.GetService(typeof(ISettingsService)); var s = service.GetSettings(); // 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(); } } }