You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Quartz;
using DS.WMS.Core.Jobs;
namespace DS.Module.QuartzModuleInstall
{
public static class QuartzModuleInstall
{
public static void AddQuartzModuleInstall(this IServiceCollection services)
{
//获取进项发票
var jobKey = new JobKey("InInvoice");
services.AddQuartz(q =>
{
// 配置 Quartz
q.UseMicrosoftDependencyInjectionJobFactory();
q.AddJob<InInvoiceJob>(opts => opts.WithIdentity(jobKey));
q.AddTrigger(opts => opts
.ForJob(jobKey)
.WithIdentity("InInvoice-trigger")
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(60)
.RepeatForever()));
});
//打印时间 使用cron表达式
//var TimeJobjobKey = new JobKey("TimeJob");
//services.AddQuartz(q =>
//{
// // 配置 Quartz
// q.UseMicrosoftDependencyInjectionJobFactory();
// q.AddJob<TimeJob>(opts => opts.WithIdentity(TimeJobjobKey));
// q.AddTrigger(opts => opts
// .ForJob(TimeJobjobKey)
// .WithIdentity("Time-trigger")
// .WithCronSchedule("0 0/1 * 1/1 * ? *"));
//});
// 添加 Quartz 主机服务
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
}
}
}