|
@@ -1,6 +1,8 @@
|
|
|
-using CallCenter.Calls;
|
|
|
+using CallCenter.Caches;
|
|
|
+using CallCenter.Calls;
|
|
|
using CallCenter.Notifications;
|
|
|
using CallCenter.Share.Enums;
|
|
|
+using CallCenter.Tools;
|
|
|
using MediatR;
|
|
|
|
|
|
namespace CallCenter.Application.Handlers
|
|
@@ -9,12 +11,14 @@ namespace CallCenter.Application.Handlers
|
|
|
{
|
|
|
private readonly ICallRepository _callRepository;
|
|
|
private readonly ICallDetailRepository _callDetailRepository;
|
|
|
+ private readonly IUserCacheManager _userCacheManager;
|
|
|
|
|
|
|
|
|
- public AlertExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository)
|
|
|
+ public AlertExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager)
|
|
|
{
|
|
|
_callRepository = callRepository;
|
|
|
_callDetailRepository = callDetailRepository;
|
|
|
+ _userCacheManager = userCacheManager;
|
|
|
}
|
|
|
|
|
|
public async Task Handle(AlertExtToOuterNotification notification, CancellationToken cancellationToken)
|
|
@@ -39,7 +43,43 @@ namespace CallCenter.Application.Handlers
|
|
|
};
|
|
|
await _callDetailRepository.AddAsync(detail, 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);
|
|
|
+ var callModel = new Call()
|
|
|
+ {
|
|
|
+ CallStatus = ECallStatus.Alert,
|
|
|
+ CallDirection = ECallDirection.Out,
|
|
|
+ CallType = ECallType.ExtToOuter,
|
|
|
+ ConversationId = notification.Outer.Id,
|
|
|
+ FromNo = telNo,
|
|
|
+ ToNo = notification.Outer.To,
|
|
|
+ Trunk = notification.Outer.Trunk,
|
|
|
+ UserId = workModel.UserId,
|
|
|
+ UserName = workModel.UserName,
|
|
|
+ PhoneIsp = isp
|
|
|
+ };
|
|
|
+ callModel.Modified();
|
|
|
+ var callId = await _callRepository.AddAsync(callModel, cancellationToken);
|
|
|
+ //写入明细
|
|
|
+ var detail = new CallDetail()
|
|
|
+ {
|
|
|
+ CallId = callId,
|
|
|
+ CallStatus = ECallStatus.Alert,
|
|
|
+ ConversationId = notification.Outer.Id,
|
|
|
+ OMCallId = notification.Outer.CallId,
|
|
|
+ EventName = "Alert",
|
|
|
+ FromNo = telNo,
|
|
|
+ ToNo = notification.Outer.To,
|
|
|
+ };
|
|
|
+ await _callDetailRepository.AddAsync(detail, cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|