123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Quartz;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Net.Http.Headers;
- using System.Text;
- using System.Threading.Tasks;
- namespace XYY.Tool.TimingTask.jobs
- {
- public class PBPostManifestJob : IJob
- {
- public async Task Execute(IJobExecutionContext context)
- {
- System.Threading.Thread.Sleep(10 * 1000);
- HttpClient client = new HttpClient();
- HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, XYY.Tool.QuotaReduction.JobConfig.PBPostManifestAction);
- requestMessage.Headers.Add("Authorization", "token 985833DB91DA7B38C3918D3F1F9D2339");
- requestMessage.Content = new StringContent("{}");
- requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
- try
- {
- var response = client.Send(requestMessage);
- if (response.IsSuccessStatusCode)
- {
- dingApiRequest.sendDingMessageToChat("PBPostManifestJob-PB预报", null);
- Console.WriteLine($"{DateTime.Now}预报成功");
- }
- else
- {
- string message = await response.Content.ReadAsStringAsync();
- dingApiRequest.sendDingMessageToChat("PBPostManifestJob-PB预报", message.Trim());
- }
-
- //Console.WriteLine(message);
- }
- catch (WebException ex)
- {
- //错误消息
- string errorMessage = new System.IO.StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
- dingApiRequest.sendDingMessageToChat("PBPostManifestJob-PB预报", errorMessage.Trim());
- }
- }
- }
- }
|