程序启动时定时任务不立即执行 修改调度数据时立即生效 生成点巡检计划精度补齐

This commit is contained in:
2023-06-07 15:50:06 +08:00
parent 82be8aebe7
commit ee66d46595
2 changed files with 9 additions and 4 deletions

View File

@@ -284,7 +284,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
// 非多租户模式启动自启任务
if (!KeyVariable.MultiTenancy)
{
_repository.AsQueryable().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(AddTimerJob);
_repository.AsQueryable().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(x=>AddTimerJob(x,false));//modifyby zhoukeda 20230607
}
}
@@ -332,7 +332,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
/// 新增定时任务.
/// </summary>
/// <param name="input"></param>
private async void AddTimerJob(TimeTaskEntity input)
private async void AddTimerJob(TimeTaskEntity input,bool startNow = true)
{
Action<SpareTimer, long>? action = null;
ContentModel? comtentModel = input.ExecuteContent.ToObject<ContentModel>();
@@ -369,7 +369,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
{
interval = (starTime.ParseToDateTime() - DateTime.Now).TotalMilliseconds.ParseToInt();
}
if (taskMethod.StartNow) //modifyby zhoukeda 20230516
if (startNow) //modifyby zhoukeda 20230516
{
SpareTime.DoOnce(interval, action, "Once_" + input.Id);
}