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 FuelSurchargeJob : IJob { public Task Execute(IJobExecutionContext context) { string msg = string.Empty; //发起两次请求 var client = new RestClient(JobConfig.FedexSurchargesSyncApi); client.Timeout = -1; var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var result = JsonConvert.DeserializeObject(response.Content); Tuple tuple = JsonConvert.DeserializeObject>(result.data.ToString()); msg = tuple.Item2; } else { msg += "fedex燃油费同步接口调用失败!"; } string msg2 = string.Empty; var client2 = new RestClient(JobConfig.DHLSurchargesSyncApi); client2.Timeout = -1; var request2 = new RestRequest(Method.GET); IRestResponse response2 = client2.Execute(request2); if (response2.StatusCode == System.Net.HttpStatusCode.OK) { var result = JsonConvert.DeserializeObject(response2.Content); Tuple tuple = JsonConvert.DeserializeObject>(result.data.ToString()); msg2 = tuple.Item2; } else { msg2 += "dhl燃油费同步接口调用失败!"; } //string msg = "调用服务";string msg2 = "服务2"; dingApiRequest.sendMessageToWeChat("FedexSurchargesSyncApi", msg,new List() { "LiuZhengKai","33", "fanlihang" }); dingApiRequest.sendMessageToWeChat("DHLSurchargesSyncApi", msg2, new List() { "LiuZhengKai","33", "fanlihang" }); Console.WriteLine("燃油附加费任务已执行,请注意查看钉钉消息"); return null; } } }