NewLife/AntJob

作业没有数据时间时,自动设置为今天
大石头 编写于 2024-10-31 09:32:16
共计: 修改1个文件,增加6行、删除0行。
修改 +6 -0
修改 +6 -0
diff --git a/AntJob.Server/Services/JobService.cs b/AntJob.Server/Services/JobService.cs
index 99b2c0a..22acad1 100644
--- a/AntJob.Server/Services/JobService.cs
+++ b/AntJob.Server/Services/JobService.cs
@@ -83,6 +83,12 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
             if (job.Cron.IsNullOrEmpty()) job.Cron = model.Cron;
             if (job.Topic.IsNullOrEmpty()) job.Topic = model.Topic;
 
+            // 定时调度和数据调度,自动设置DataTime
+            if (job.Mode is JobModes.Time or JobModes.Data)
+            {
+                if (job.DataTime.Year < 2000) job.DataTime = DateTime.Today;
+            }
+
             // 添加定时作业时,计算下一次执行时间
             if (job.ID == 0 && job.Mode == JobModes.Time)
             {