|
@@ -0,0 +1,74 @@
|
|
|
+using MapsterMapper;
|
|
|
+using MediatR;
|
|
|
+using Sharing.Notifications;
|
|
|
+using Sharing.Province.Dtos.XieTong.Send;
|
|
|
+using Sharing.Province.XieTong.Send;
|
|
|
+using Sharing.Repository.Province.XieTong.Send;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace Sharing.Province.Handlers
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ public class GetVisitInfoReceiveHandler : INotificationHandler<GetVisitInfoReceiveNotification>
|
|
|
+ {
|
|
|
+ private readonly IChannelConfigurationManager _channelConfigurationManager;
|
|
|
+ private readonly PusherProvider _pusherProvider;
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ private readonly IGetVisitInfoReceiveRepository _getVisitInfoReceiveRepository;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="channelConfigurationManager"></param>
|
|
|
+ /// <param name="pusherProvider"></param>
|
|
|
+ /// <param name="mapper"></param>
|
|
|
+ /// <param name="getVisitInfoReceiveRepository"></param>
|
|
|
+ public GetVisitInfoReceiveHandler(IChannelConfigurationManager channelConfigurationManager, PusherProvider pusherProvider, IMapper mapper
|
|
|
+ , IGetVisitInfoReceiveRepository getVisitInfoReceiveRepository)
|
|
|
+ {
|
|
|
+ _channelConfigurationManager = channelConfigurationManager;
|
|
|
+ _pusherProvider = pusherProvider;
|
|
|
+ _mapper = mapper;
|
|
|
+ _getVisitInfoReceiveRepository = getVisitInfoReceiveRepository;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 服务工单交办评价
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="notification"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task Handle(GetVisitInfoReceiveNotification notification, CancellationToken cancellationToken = default)
|
|
|
+ {
|
|
|
+ var pusher = _pusherProvider.CreatePusher(_channelConfigurationManager);
|
|
|
+
|
|
|
+ var dataReceive = _mapper.Map<GetVisitInfoReceiveInfo>(notification.Data);
|
|
|
+ var data = new GetVisitInfoReceiveData
|
|
|
+ {
|
|
|
+ GetVisitInfoReceiveInfos = new List<GetVisitInfoReceiveInfo>
|
|
|
+ {
|
|
|
+ dataReceive
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ var request = new GetVisitInfoReceiveRequest();
|
|
|
+ request.SetData(data);
|
|
|
+
|
|
|
+ var response = await pusher.PushGetVisitInfoReceiveAsync(request, cancellationToken);
|
|
|
+
|
|
|
+ //如果推送成功修改数据状态
|
|
|
+ if (response != null && response.Code == "1")
|
|
|
+ {
|
|
|
+ notification.Data.SyncState = "1";
|
|
|
+ notification.Data.ReturnResult = Newtonsoft.Json.JsonConvert.SerializeObject(response);
|
|
|
+ await _getVisitInfoReceiveRepository.UpdateAsync(notification.Data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|