using Quartz; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using IStation.Untity; namespace IStation.DataProvider { /// /// 数据任务 /// [DisallowConcurrentExecution]//此特性标识 必须等待这次任务执行完成后,才能执行下次任务 public class DataJob : IJob { /// /// /// public async Task Execute(IJobExecutionContext context) { try { await Task.Run(() => { var srcList = JsonStore.GetCurrentRecord(); var response= HttpRequestHelper.Post(ConfigHelper.StoreUrl,JsonHelper.Object2Json(srcList)); var result = JsonHelper.Json2Object(response); if (result.Code == 0) { if (result.Data) { LogHelper.Info($"成功插入{srcList.Count}条数据!"); } else { LogHelper.Info($"数据插入失败,原因:{result.Message}"); } } else { LogHelper.Info($"数据插入失败,原因:{result.Message}"); } }); } catch (Exception ex) { var e = new JobExecutionException(ex); IStation.LogHelper.Error("数据任务", ex); throw e; } } } }