任务启动恢复改为异步

This commit is contained in:
不做码农
2023-06-13 12:09:32 +08:00
parent 9170b3e999
commit df99da04fb
2 changed files with 9 additions and 6 deletions

View File

@@ -1,4 +1,6 @@
using Quartz.Spi;
using SqlSugar.IOC;
using ZR.Model.System;
using ZR.Tasks;
namespace ZR.Admin.WebApi.Extensions
@@ -31,11 +33,11 @@ namespace ZR.Admin.WebApi.Extensions
{
ITaskSchedulerServer _schedulerServer = app.ApplicationServices.GetRequiredService<ITaskSchedulerServer>();
var tasks = SqlSugar.IOC.DbScoped.SugarScope.Queryable<Model.System.SysTasks>()
.Where(m => m.IsStart == 1).ToList();
var tasks = DbScoped.SugarScope.Queryable<SysTasks>()
.Where(m => m.IsStart == 1).ToListAsync();
//程序启动后注册所有定时任务
foreach (var task in tasks)
foreach (var task in tasks.Result)
{
var result = _schedulerServer.AddTaskScheduleAsync(task);
if (result.Result.Code == 200)