using Newtonsoft.Json; using Quartz; using RestSharp; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using XYY.Tool.QuotaReduction; using XYY.Tool.TimingTask.Model; namespace XYY.Tool.TimingTask.jobs { public class OrderMailSendJob : IJob { public Task Execute(IJobExecutionContext context) { string msg = string.Empty; var client = new RestClient(JobConfig.OrderMailSendApi); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "token 57AEDE5487260443D6BF2182D31286B1"); request.AddHeader("Content-Type", "application/json"); IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var result = JsonConvert.DeserializeObject(response.Content); if (result.success == true) { msg = "订单邮件发送任务执行成功"; } } else { msg += "订单邮件发送任务接口调用异常!" + response.ErrorMessage ?? response.Content; } if (msg.Contains("异常")) { dingApiRequest.sendDingMessageToChat("OrderMailSendApi", msg); } return null; } } public class OrderSingMailAddJob : IJob { public Task Execute(IJobExecutionContext context) { string msg = string.Empty; var client = new RestClient(JobConfig.OrderSingMailAddApi); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "token 57AEDE5487260443D6BF2182D31286B1"); request.AddHeader("Content-Type", "application/json"); IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var result = JsonConvert.DeserializeObject(response.Content); if (result.success == true) { msg = "签收邮件添加任务,执行成功"; } } else { msg += "签收邮件添加任务,接口调用异常!" + response.ErrorMessage ?? response.Content; } //无论成功失败,都发送 dingApiRequest.sendDingMessageToChat("OrderSingMailAddApi", msg); return null; } } }