Quartz根据配置文件注册

dev
嵇文龙 2 weeks ago
parent 5594d1492f
commit d2b4336e8e

@ -52,16 +52,20 @@ namespace DS.Module.QuartzModuleInstall
});
var jobKey3 = new JobKey(nameof(FeeCustTemplateJob));
services.AddQuartz(q =>
string cron3 = configuration["JobConfig:" + jobKey3.Name];
if (!string.IsNullOrEmpty(cron3))
{
q.UseMicrosoftDependencyInjectionJobFactory();
q.AddJob<FeeCustTemplateJob>(opts => opts.WithIdentity(jobKey3));
q.AddTrigger(opts => opts
.ForJob(jobKey3)
.WithIdentity(nameof(FeeCustTemplateJob) + "-trigger")
.WithCronSchedule(configuration["JobConfig:" + jobKey3.Name])
);
});
services.AddQuartz(q =>
{
q.UseMicrosoftDependencyInjectionJobFactory();
q.AddJob<FeeCustTemplateJob>(opts => opts.WithIdentity(jobKey3));
q.AddTrigger(opts => opts
.ForJob(jobKey3)
.WithIdentity(nameof(FeeCustTemplateJob) + "-trigger")
.WithCronSchedule(cron3)
);
});
}
// 添加 Quartz 主机服务
services.AddQuartzServer(q => q.WaitForJobsToComplete = true);
@ -75,16 +79,21 @@ namespace DS.Module.QuartzModuleInstall
public static void AddOpQuartzModuleInstall(this IServiceCollection services, IConfiguration configuration)
{
var jobKey1 = new JobKey(nameof(WSLReportJob));
services.AddQuartz(q =>
string cron1 = configuration["JobConfig:" + jobKey1.Name];
if (!string.IsNullOrEmpty(cron1))
{
q.UseMicrosoftDependencyInjectionJobFactory();
q.AddJob<WSLReportJob>(opts => opts.WithIdentity(jobKey1));
q.AddTrigger(opts => opts
.ForJob(jobKey1)
.WithIdentity(nameof(WSLReportJob) + "-trigger")
.WithCronSchedule(configuration["JobConfig:" + jobKey1.Name])
);
});
services.AddQuartz(q =>
{
q.UseMicrosoftDependencyInjectionJobFactory();
q.AddJob<WSLReportJob>(opts => opts.WithIdentity(jobKey1));
q.AddTrigger(opts => opts
.ForJob(jobKey1)
.WithIdentity(nameof(WSLReportJob) + "-trigger")
.WithCronSchedule(cron1)
);
});
}
//var jobKey2 = new JobKey(nameof(WSLWeeklyReportJob));
//services.AddQuartz(q =>
//{

Loading…
Cancel
Save