ningshuxia
2025-04-16 a67da735b33be01b24845ce03ae7551cf55ddbbc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Quartz; 
 
namespace IStation.Server
{
    /// <summary>
    /// 调度配置更新辅助类
    /// </summary>
    [DisallowConcurrentExecution]//此特性标识 必须等待这次任务执行完成后,才能执行下次任务
    public class ScheduleConfigUpdateHelperJob : IJob
    {
        public Task Execute(IJobExecutionContext context)
        {
            return Task.Run(() =>
            {
                var update_id = Yw.YitIdHelper.NextId();
                var update_time = DateTime.Now;
                try
                {
                    var url = ConfigHelper.ScheduleConfigUpdateHttpUrl;
                    if (string.IsNullOrEmpty(url))
                    {
                        Log.Info(update_id, "调度配置更新任务中, ScheduleConfigUpdateHttpUrl 接口为空,自动跳过!");
                        return;
                    }
 
                    var response_text = Yw.Untity.HttpRequestHelper.Get(url);
                    var dto = Yw.JsonHelper.Json2Object<Dto.SaveChScheduleConfigOutput>(response_text);
                    if (dto == null || !dto.Result)
                    {
                        Log.Info(update_id, "调度配置更新任务中,接口更新失败,自动跳过!");
                        return;
                    }
                    Log.Info(update_id, $"调度配置更新任务中,接口更新,[{update_time:G}]更新成功!");
                    Log.Info(update_id, dto.Msg);
                }
                catch (Exception ex)
                {
                    Log.Error(update_id, "调度配置更新任务中,出错", ex);
                    var e = new JobExecutionException(ex);
                    throw e;
                }
            });
        }
 
    }
}