|
@@ -1,6 +1,7 @@
|
|
|
using CallCenter.Caches;
|
|
|
using CallCenter.Calls;
|
|
|
using CallCenter.Notifications;
|
|
|
+using CallCenter.Realtimes;
|
|
|
using CallCenter.Share.Enums;
|
|
|
using CallCenter.Tools;
|
|
|
using MediatR;
|
|
@@ -12,21 +13,24 @@ namespace CallCenter.Application.Handlers
|
|
|
private readonly ICallRepository _callRepository;
|
|
|
private readonly ICallDetailRepository _callDetailRepository;
|
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
|
+ private readonly IRealtimeService _realtimeService;
|
|
|
|
|
|
|
|
|
- public AlertExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager)
|
|
|
+ public AlertExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager,IRealtimeService realtimeService)
|
|
|
{
|
|
|
_callRepository = callRepository;
|
|
|
_callDetailRepository = callDetailRepository;
|
|
|
_userCacheManager = userCacheManager;
|
|
|
+ _realtimeService = realtimeService;
|
|
|
}
|
|
|
|
|
|
public async Task Handle(AlertExtToOuterNotification notification, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- if (!string.IsNullOrEmpty(notification.TelNo))
|
|
|
+ string telNo = notification.Outer.From != "" ? notification.Outer.From : notification.TelNo;
|
|
|
+ if (!string.IsNullOrEmpty(telNo))
|
|
|
{
|
|
|
var model =await _callRepository.GetAsync(x => x.ConversationId==notification.Outer.Id && x.ToNo==notification.Outer.To && x.Trunk==notification.Outer.Trunk && x.CreationTime>=DateTime.Now.AddHours(-2), cancellationToken);
|
|
|
-
|
|
|
+ var workModel = _userCacheManager.GetWorkByTel(telNo);
|
|
|
if (model!=null)
|
|
|
{
|
|
|
model.CallStatus = ECallStatus.Alert;
|
|
@@ -42,12 +46,12 @@ namespace CallCenter.Application.Handlers
|
|
|
ToNo = notification.Outer.To
|
|
|
};
|
|
|
await _callDetailRepository.AddAsync(detail, cancellationToken);
|
|
|
+
|
|
|
+ await _realtimeService.AlertAsync(workModel.UserId, new AlertDto() { Id = model.Id, From = telNo, To = notification.Outer.To, CallType = ECallType.ExtToOuter, ConversationId = notification.Outer.Id }, cancellationToken);
|
|
|
}
|
|
|
//无记录的情况下
|
|
|
else
|
|
|
{
|
|
|
- string telNo = notification.Outer.From != "" ? notification.Outer.From : notification.TelNo;
|
|
|
- var workModel = _userCacheManager.GetWorkByTel(telNo);
|
|
|
if (workModel!=null)
|
|
|
{
|
|
|
var isp = PhoneIspTool.GetPhoneIsp(notification.Outer.To);
|
|
@@ -73,15 +77,16 @@ namespace CallCenter.Application.Handlers
|
|
|
CallStatus = ECallStatus.Alert,
|
|
|
ConversationId = notification.Outer.Id,
|
|
|
OMCallId = notification.Outer.CallId,
|
|
|
- EventName = "Alert",
|
|
|
+ EventName = "ALERT",
|
|
|
FromNo = telNo,
|
|
|
ToNo = notification.Outer.To,
|
|
|
};
|
|
|
await _callDetailRepository.AddAsync(detail, cancellationToken);
|
|
|
+
|
|
|
+ await _realtimeService.AlertAsync(workModel.UserId, new AlertDto() { Id = model.Id, From = telNo, To = notification.Outer.To, CallType = ECallType.ExtToOuter, ConversationId = notification.Outer.Id }, cancellationToken);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|