You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/src/Ombi.Schedule/OmbiScheduler.cs

49 lines
1.8 KiB

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<PlexContentSync>()
// .UsingJobData("recentlyAddedSearch", false)
// .WithIdentity(nameof(PlexContentSync), "Plex")
// .Build();
// var recentlyAdded = JobBuilder.Create<PlexContentSync>()
// .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<JobSettings>)app.ApplicationServices.GetService(typeof(ISettingsService<JobSettings>));
var s = service.GetSettings();
// 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();
}
}
}