using Newtonsoft.Json; using Quartz; using RestSharp; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using XYY.Tool.QuotaReduction; using XYY.Tool.TimingTask.Model; namespace XYY.Tool.TimingTask.jobs { public class GenerateCustomerQuotationJob : IJob { public Task Execute(IJobExecutionContext context) { var result = GenerateQuotationRequest(); if (!result.Item1) { dingApiRequest.sendDingMessageToChat("GenerateCustomerQuotationJob", "\r\n -->生成数据任务异常:" + result.Item2); } return null; } private Tuple GenerateQuotationRequest() { var client = new RestClient(JobConfig.GenerateQuotationApi); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "token 57AEDE5487260443D6BF2182D31286B1"); IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var responseData = JsonConvert.DeserializeObject(response.Content); return JsonConvert.DeserializeObject>(responseData.data.ToString()); } else { return Tuple.Create(false, "生成客户报价数据接口:GenerateQuotation,请求异常"); } } } public class GenerateCustomerFileJob : IJob { public Task Execute(IJobExecutionContext context) { var result = GenerateCustomerFileRequest(); if (!result.Item1) { dingApiRequest.sendDingMessageToChat("GenerateCustomerFileJob", "\r\n -->生成报价文件任务异常:" + result.Item2); } return null; } private Tuple GenerateCustomerFileRequest() { var client = new RestClient(JobConfig.GenerateCustomerFileApi); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "token 57AEDE5487260443D6BF2182D31286B1"); IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var responseData = JsonConvert.DeserializeObject(response.Content); return JsonConvert.DeserializeObject>(responseData.data.ToString()); } else { return Tuple.Create(false, "生成报价文件接口:GenerateCustomerFile,请求异常"); } } } public class GenerateZipFileJob : IJob { public Task Execute(IJobExecutionContext context) { var result = GenerateZipFileRequest(); if (!result.Item1) { dingApiRequest.sendDingMessageToChat("GenerateZipFileJob", "\r\n -->发送报价文件任务异常:" + result.Item2); } return null; } private Tuple GenerateZipFileRequest() { var client = new RestClient(JobConfig.GenerateZipFileApi); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "token 57AEDE5487260443D6BF2182D31286B1"); IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var responseData = JsonConvert.DeserializeObject(response.Content); return JsonConvert.DeserializeObject>(responseData.data.ToString()); } else { return Tuple.Create(false, "生成客户报价数据接口:GenerateQuotation,请求异常"); } } } }