_17TrackingSub.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Microsoft.Extensions.Logging;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using XYY.Data.Model.Standard.Tracking._17;
  8. using XYY.TaskTrack.Standard;
  9. namespace XYY.WindowsService.ReshMQ.Works
  10. {
  11. public interface I17TrackingSub : IBaseConsumer<XYY.Data.Model.Standard.Tracking._17._17TrackingWebhook>
  12. {
  13. }
  14. public class _17TrackingSub : I17TrackingSub
  15. {
  16. private readonly ILogger<_17TrackingSub> _logger;
  17. public _17TrackingSub(ILogger<_17TrackingSub> logger)
  18. {
  19. _logger = logger;
  20. }
  21. public async Task Consume(Data.Model.Standard.Tracking._17._17TrackingWebhook message)
  22. {
  23. XYY.WinodwsService.ReshMQ.Client.Api api = new XYY.WinodwsService.ReshMQ.Client.Api(new System.Net.Http.HttpClient());
  24. //17转换
  25. var postRequest = message.Copy<XYY.WinodwsService.ReshMQ.Client._17TrackingMQData>();
  26. var result = await api.PostAsync(postRequest);
  27. if (result.Success)
  28. {
  29. //写入数据库
  30. var insertDB = await api.PostAsync(result.Data);
  31. if (!insertDB.Success)
  32. {
  33. _logger.LogError("执行失败" + insertDB.Error + "@Request", result.Data);
  34. }
  35. }
  36. else
  37. {
  38. _logger.LogError("执行失败" + result.Error + "@Request", message);
  39. }
  40. }
  41. }
  42. }