Worker.cs 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using _4PXOrder;
  2. using EasyNetQ;
  3. using Microsoft.Extensions.Hosting;
  4. using Microsoft.Extensions.Logging;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using XYY.Core.Standard.Data.Infrastructure;
  11. using XYY.Service.JobManage;
  12. using XYY.Service.Standard.Finance.Charging.CustomerOrderFee;
  13. using XYY.Service.Standard.First.JobSubscribe;
  14. using XYY.Service.Standard.Order;
  15. using XYY.Service.Strandard.EMailService;
  16. using XYY.TaskTrack.Standard;
  17. namespace XYY.WindowsService.MQ
  18. {
  19. public class Worker : BackgroundService
  20. {
  21. private readonly ILogger<Worker> _logger;
  22. private readonly IMQManager _mQManager;
  23. private readonly IJobSubscribe _jobSubscribe;
  24. private readonly ITrackSupplement _trackSupplement;
  25. private readonly IAddHNJobSubscribe _hNJobSubscribe;
  26. private readonly ISendFirstSubscribe _sendFirstSubscribe;
  27. private readonly ISendFirstNoteSubscribe _sendFirstNoteSubscribe;
  28. private readonly IFinanceQuotationJobSub _financeQuotationJobSub;
  29. private readonly IFeeBaseFileJobSub _feeBaseFileJobSub;
  30. private readonly ICancelOrderJobSubscribe _cancelOrderJobSubscribe;
  31. private readonly IFinanceChargeConsumer _financeChargeConsumer;
  32. private readonly IEmailService emailService;
  33. private readonly IUnitOfWork unitOfWork;
  34. private readonly IBus bus;
  35. private readonly XiKeTrackingSendJobSubscribe XiKeTrackingSendJobSubscribe;
  36. public Worker(ILogger<Worker> logger, IMQManager mQManager,
  37. IJobSubscribe jobSubscribe, IAddHNJobSubscribe hNJobSubscribe,
  38. ISendFirstSubscribe sendFirstSubscribe,
  39. ISendFirstNoteSubscribe sendFirstNoteSubscribe,
  40. IFinanceQuotationJobSub financeQuotationJobSub,
  41. ITrackSupplement trackSupplement, IFeeBaseFileJobSub feeBaseFileJobSub,
  42. ICancelOrderJobSubscribe cancelOrderJobSubscribe,
  43. IFinanceChargeConsumer financeChargeConsumer
  44. , XiKeTrackingSendJobSubscribe xiKeTrackingSendJobSubscribe
  45. , IEmailService emailService, IUnitOfWork unitOfWork, IBus bus)
  46. {
  47. _logger = logger;
  48. _mQManager = mQManager;
  49. _jobSubscribe = jobSubscribe;
  50. _hNJobSubscribe = hNJobSubscribe;
  51. _sendFirstSubscribe = sendFirstSubscribe;
  52. _sendFirstNoteSubscribe = sendFirstNoteSubscribe;
  53. _financeQuotationJobSub = financeQuotationJobSub;
  54. _trackSupplement = trackSupplement;
  55. _feeBaseFileJobSub = feeBaseFileJobSub;
  56. _cancelOrderJobSubscribe = cancelOrderJobSubscribe;
  57. _financeChargeConsumer = financeChargeConsumer;
  58. XiKeTrackingSendJobSubscribe = xiKeTrackingSendJobSubscribe;
  59. this.emailService = emailService;
  60. this.unitOfWork = unitOfWork;
  61. this.bus = bus;
  62. }
  63. protected override async Task ExecuteAsync(CancellationToken stoppingToken)
  64. {
  65. await _mQManager.Subscribe(_jobSubscribe);
  66. await _mQManager.Subscribe(_hNJobSubscribe);
  67. await _mQManager.Subscribe(_sendFirstSubscribe);
  68. await _mQManager.Subscribe(_sendFirstNoteSubscribe);
  69. await _mQManager.Subscribe(_financeQuotationJobSub);
  70. await _mQManager.Subscribe(_trackSupplement);
  71. await _mQManager.Subscribe(_feeBaseFileJobSub);
  72. await _mQManager.Subscribe(_cancelOrderJobSubscribe);
  73. await _mQManager.Subscribe(_financeChargeConsumer);
  74. await _mQManager.Subscribe(XiKeTrackingSendJobSubscribe);
  75. /*通用服务MQ订阅*/
  76. var manage = new WebApiJobManage<ExpressFeechargesModel>(_mQManager,
  77. "http://120.24.149.148:9503/api/ExpressFee/Charges2",
  78. new Dictionary<string, string> { { "Authorization", "token 132A7468DE079C6CEB59F383A661E612" } },
  79. emailService,
  80. new string[] { "fanlihang@xingyunyi.cn" },
  81. "郑州分公司重算",
  82. new JobDbService(unitOfWork),
  83. new BatchRechargingJobGetService(unitOfWork)
  84. );
  85. manage.ClientReg();
  86. }
  87. }
  88. }