123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- 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<bool, string> 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<ApiJsonModel>(response.Content);
- return JsonConvert.DeserializeObject<Tuple<bool, string>>(responseData.data.ToString());
- }
- else
- {
- return Tuple.Create<bool, string>(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<bool, string> 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<ApiJsonModel>(response.Content);
- return JsonConvert.DeserializeObject<Tuple<bool, string>>(responseData.data.ToString());
- }
- else
- {
- return Tuple.Create<bool, string>(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<bool, string> 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<ApiJsonModel>(response.Content);
- return JsonConvert.DeserializeObject<Tuple<bool, string>>(responseData.data.ToString());
- }
- else
- {
- return Tuple.Create<bool, string>(false, "生成客户报价数据接口:GenerateQuotation,请求异常");
- }
- }
- }
- }
|