FeeBaseFileJobSub.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using XYY.TaskTrack.Standard;
  7. using XYY.TaskTrack.Standard.TaskModel;
  8. namespace XYY.WindowsService.MQ
  9. {
  10. public interface IFeeBaseFileJobSub : IBaseConsumer<GenerateFeeBaseFileMessage>
  11. {
  12. }
  13. public class FeeBaseFileJobSub : IFeeBaseFileJobSub
  14. {
  15. public async Task Consume(GenerateFeeBaseFileMessage message)
  16. {
  17. string msgSubmary = null;
  18. try
  19. {
  20. RestSharp.RestClient client = new RestSharp.RestClient("http://120.24.149.148:9521/api/FinanceQuotation/GenerateFeeBaseFile");
  21. RestSharp.RestRequest request = new RestSharp.RestRequest(RestSharp.Method.POST);
  22. request.AddJsonBody(message);
  23. request.AddHeader("Authorization", "token A2DGA5DGAD2DGC6CEB59F383A6615GE2");
  24. var response = client.Execute(request);
  25. string idStr = string.Join(",", message.FeeBaseIds);
  26. int approveId = message.ApproveId;
  27. string versionName = message.FeeBaseVersionName;
  28. msgSubmary = $"{DateTime.Now.ToString_yyyyMMddHHmmss()} Feebase ID:{idStr},Approve Id: {approveId},Version Name:{versionName}";
  29. if (response.StatusCode == System.Net.HttpStatusCode.OK)
  30. {
  31. Console.WriteLine($"生成报价文件消息推送成功:{msgSubmary}");
  32. }
  33. else
  34. {
  35. Console.WriteLine($"生成报价文件消息推送失败:{msgSubmary}," + (response.Content ?? response.ErrorMessage));
  36. }
  37. }
  38. catch (Exception ex)
  39. {
  40. Console.WriteLine($"生成报价文件消息推送异常:{msgSubmary},消息推送错误 {ex.Message}");
  41. }
  42. }
  43. }
  44. }