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.

82 lines
2.9 KiB
C#

using DS.WMS.Core.Jobs;
using DS.WMS.Core.QuarztJobs;
using Microsoft.Extensions.DependencyInjection;
1 month ago
using Quartz;
namespace DS.Module.QuartzModuleInstall
{
public static class QuartzModuleInstall
{
public static void AddFeeQuartzModuleInstall(this IServiceCollection services)
1 month ago
{
//获取进项发票
var jobKey = new JobKey("InInvoice");
services.AddQuartz(q =>
{
// 配置 Quartz
q.UseMicrosoftDependencyInjectionJobFactory();
1 month ago
q.AddJob<InInvoiceJob>(opts => opts.WithIdentity(jobKey));
q.AddTrigger(opts => opts
.ForJob(jobKey)
.WithIdentity("InInvoice-trigger")
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(60)
.RepeatForever()));
});
//获取银行流水
var BankStatementKey = new JobKey("BankStatement");
1 month ago
services.AddQuartz(q =>
{
// 配置 Quartz
q.UseMicrosoftDependencyInjectionJobFactory();
1 month ago
q.AddJob<BankStatementJob>(opts => opts.WithIdentity(BankStatementKey));
q.AddTrigger(opts => opts
.ForJob(BankStatementKey)
.WithIdentity("BankStatement-trigger")
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(60)
.RepeatForever()));
});
1 month ago
var jobKey3 = new JobKey(nameof(FeeCustTemplateJob));
services.AddQuartz(q =>
{
q.UseMicrosoftDependencyInjectionJobFactory();
q.AddJob<FeeCustTemplateJob>(opts => opts.WithIdentity(jobKey3));
q.AddTrigger(opts => opts
.ForJob(jobKey3)
.WithIdentity(nameof(FeeCustTemplateJob) + "-trigger")
.WithCronSchedule("1 59 23 * * ?")
);
});
// 添加 Quartz 主机服务
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
}
public static void AddOpQuartzModuleInstall(this IServiceCollection services)
{
var jobKey1 = new JobKey(nameof(WSLReportJob));
services.AddQuartz(q =>
{
q.UseMicrosoftDependencyInjectionJobFactory();
q.AddJob<WSLReportJob>(opts => opts.WithIdentity(jobKey1));
q.AddTrigger(opts => opts
.ForJob(jobKey1)
.WithIdentity(nameof(WSLReportJob) + "-trigger")
.WithCronSchedule("0 0 1 * * ?")
);
});
1 month ago
// 添加 Quartz 主机服务
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
}
}
}