using IRaCIS.Application.Services.BackGroundJob; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Quartz; namespace IRaCIS.Core.API { public static class QuartZSetup { public static void AddQuartZSetup(this IServiceCollection services, IConfiguration configuration) { services.AddTransient(); services.AddQuartz(q => { // base quartz scheduler, job and trigger configuration // as of 3.3.2 this also injects scoped services (like EF DbContext) without problems q.UseMicrosoftDependencyInjectionJobFactory(); // 基本Quartz调度器、作业和触发器配置 //var jobKey = new JobKey("RegularTrialWork", "regularWorkGroup"); //q.AddJob(jobKey, j => j // .WithDescription("Trial regular work") //); //q.AddTrigger(t => t // .WithIdentity("TrialStatusTrigger") // .ForJob(jobKey) // .WithCronSchedule("0 0 * * * ?") // .WithDescription("My regular trial work trigger") //); }); // ASP.NET Core hosting services.AddQuartzHostedService(options => { // when shutting down we want jobs to complete gracefully options.WaitForJobsToComplete = true; }); } } }