|
@@ -1,5 +1,7 @@
|
|
using Hotline.Caching.Interfaces;
|
|
using Hotline.Caching.Interfaces;
|
|
using Hotline.CallCenter.Calls;
|
|
using Hotline.CallCenter.Calls;
|
|
|
|
+using Hotline.Realtimes;
|
|
|
|
+using Hotline.Share.Dtos.Realtime;
|
|
using Hotline.Share.Enums.CallCenter;
|
|
using Hotline.Share.Enums.CallCenter;
|
|
using Hotline.Share.Notifications;
|
|
using Hotline.Share.Notifications;
|
|
using Hotline.Tools;
|
|
using Hotline.Tools;
|
|
@@ -12,12 +14,14 @@ namespace Hotline.Application.Handlers.CallCenter.CallState
|
|
private readonly ICallRepository _callRepository;
|
|
private readonly ICallRepository _callRepository;
|
|
private readonly ICallDetailRepository _callDetailRepository;
|
|
private readonly ICallDetailRepository _callDetailRepository;
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
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;
|
|
_callRepository = callRepository;
|
|
_callDetailRepository = callDetailRepository;
|
|
_callDetailRepository = callDetailRepository;
|
|
_userCacheManager = userCacheManager;
|
|
_userCacheManager = userCacheManager;
|
|
|
|
+ _realtimeService = realtimeService;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task Handle(AlertExtToOuterNotification notification, CancellationToken cancellationToken)
|
|
public async Task Handle(AlertExtToOuterNotification notification, CancellationToken cancellationToken)
|
|
@@ -26,6 +30,7 @@ namespace Hotline.Application.Handlers.CallCenter.CallState
|
|
if (!string.IsNullOrEmpty(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),true,x=>x.CreationTime, cancellationToken);
|
|
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),true,x=>x.CreationTime, cancellationToken);
|
|
|
|
+ var workModel = _userCacheManager.GetWorkByTel(telNo);
|
|
//如果存在
|
|
//如果存在
|
|
if (model!=null)
|
|
if (model!=null)
|
|
{
|
|
{
|
|
@@ -42,11 +47,13 @@ namespace Hotline.Application.Handlers.CallCenter.CallState
|
|
ToNo = notification.Outer.To
|
|
ToNo = notification.Outer.To
|
|
};
|
|
};
|
|
await _callDetailRepository.AddAsync(detail, cancellationToken);
|
|
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
|
|
else
|
|
{
|
|
{
|
|
- var workModel = _userCacheManager.GetWorkByTel(telNo);
|
|
|
|
var isp = PhoneIspTool.GetPhoneIsp(notification.Outer.To);
|
|
var isp = PhoneIspTool.GetPhoneIsp(notification.Outer.To);
|
|
var callModel = new Call()
|
|
var callModel = new Call()
|
|
{
|
|
{
|
|
@@ -75,6 +82,8 @@ namespace Hotline.Application.Handlers.CallCenter.CallState
|
|
ToNo = notification.Outer.To,
|
|
ToNo = notification.Outer.To,
|
|
};
|
|
};
|
|
await _callDetailRepository.AddAsync(detail, cancellationToken);
|
|
await _callDetailRepository.AddAsync(detail, cancellationToken);
|
|
|
|
+
|
|
|
|
+ await _realtimeService.AlertAsync(workModel.UserId, new AlertDto() { Id = callId, From = telNo, To = notification.Outer.To, CallType = ECallType.ExtToOuter, ConversationId = notification.Outer.Id }, cancellationToken);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|