1234567891011121314151617181920212223242526272829303132333435363738 |
- 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 ExchangeRateJob : IJob
- {
- public Task Execute(IJobExecutionContext context)
- {
- string msg = string.Empty;
- //发起两次请求
- var client = new RestClient(JobConfig.ExchangeRateSyncApi);
- 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<ApiJsonModel>(response.Content);
- Tuple<bool, string> tuple = JsonConvert.DeserializeObject<Tuple<bool, string>>(result.data.ToString());
- msg = tuple.Item2;
- }
- else
- {
- msg += "中国银行汇率同步接口调用失败!";
- }
- dingApiRequest.sendDingMessageToChat("ExchangeRateSync", msg);
- return null;
- }
- }
- }
|