定时任务

This commit is contained in:
tongfei
2024-03-30 16:03:03 +08:00
parent 45d509c576
commit b76111b79a
4 changed files with 24 additions and 0 deletions

View File

@@ -86,6 +86,7 @@
//执行Cron表达式可以是几小时or几分钟or几秒钟or几天or几周
"JobStartExpre": "0 0/30 * * * ?",
"JobStartExpreAmount": "0 50 23 * * ?",
"JobStartExpreSend": "0 0 12,16,20 * * ?",
//a.是否启用集群:键和值
"JobStoreClusteredKey": "quartz.jobStore.clustered",

View File

@@ -4455,6 +4455,11 @@
</summary>
</member>
<member name="P:WMS.Web.Domain.Options.QuartzJobOptions.JobStartExpreSend">
<summary>
发送通知执行cron表达式每天121620整点发送
</summary>
</member>
<member name="P:WMS.Web.Domain.Options.QuartzJobOptions.JobStoreClusteredKey">
<summary>
是否启用集群:键

View File

@@ -90,6 +90,11 @@ namespace WMS.Web.Domain.Options
/// </summary>
public string JobStartExpreAmount { get; set; }
/// <summary>
/// 发送通知执行cron表达式每天121620整点发送
/// </summary>
public string JobStartExpreSend { get; set; }
/// <summary>
/// 是否启用集群:键

View File

@@ -196,6 +196,7 @@ namespace WMS.Web.Repositories.DependencyInjection
Services.AddTransient<InStockOrderQuartzJob>();//添加注入定时服务
Services.AddTransient<OutStockOrderQuartzJob>();//添加注入定时服务
Services.AddTransient<BoxQuartzJob>();//添加注入定时服务
Services.AddTransient<SendQuartzJob>();//添加注入定时服务
//Services.AddTransient<OrderContractQuartzJob>();//添加注入定时服务
Services.AddQuartz(q =>
{
@@ -259,6 +260,18 @@ namespace WMS.Web.Repositories.DependencyInjection
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
.WithDescription("BoxQuartzJobTriggerDecs"));
#endregion
#region
var jobKey_send = new JobKey("SendQuartzJob", options.QuartzJobValue);
q.AddJob<SendQuartzJob>(jobKey_box, j => j.WithDescription("SendQuartzJob"));
q.AddTrigger(t => t
.WithIdentity("SendQuartzJobTrigger")
.ForJob(jobKey_send)
.StartNow()
.WithCronSchedule(options.JobStartExpreSend)
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
.WithDescription("SendQuartzJobTriggerDecs"));
#endregion
});
//.net core核心托管-添加Quartz服务器
Services.AddQuartzServer(options =>