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;
|
}
|
});
|
}
|
|
}
|
}
|