using IStation.DataDockingSocket; using IStation.Untity; using Quartz; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.Server { /// /// 用户登录日志报表任务 /// [DisallowConcurrentExecution]//此特性标识 必须等待这次任务执行完成后,才能执行下次任务 public class UserLoginLogReportJob : IJob { /// /// /// public Task Execute(IJobExecutionContext context) { var otherDay = DateTime.Today.AddDays(-AppParasHelper.UserLoginLog.OtherDay); return Task.Run(() => { try { try { LogHelper.Info("调用API"); var url = $" {AppParasHelper.UserLoginLog.GenerateUrl}{otherDay}"; var responseText = HttpRequestHelper.Post(url); var result = JsonHelper.Json2Object(responseText); if (result.Code != 0) { throw new Exception(result.Message); } } catch (Exception ex) { LogHelper.Error(ex.Message); } } catch (Exception ex) { LogHelper.Error($"用户登陆日志统计,保存{otherDay.ToString("d")}数据出错", ex); var e = new JobExecutionException(ex); throw e; } }); } } }