dss 2 anni fa
parent
commit
9d3242d0ff

+ 15 - 2
src/CallCenter.Application/Handlers/FlowControl/AnsweredExtToOuterToExtNotificationHandler.cs

@@ -1,4 +1,6 @@
-using CallCenter.Calls;
+using CallCenter.Caches;
+using CallCenter.Calls;
+using CallCenter.Realtimes;
 using CallCenter.Share.Enums;
 using CallCenter.Share.Notifications;
 using MediatR;
@@ -9,11 +11,15 @@ namespace CallCenter.Application.Handlers
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
+        private readonly IUserCacheManager _userCacheManager;
+        private readonly IRealtimeService _realtimeService;
 
-        public AnsweredExtToOuterToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository)
+        public AnsweredExtToOuterToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
+            _userCacheManager = userCacheManager;
+            _realtimeService = realtimeService;
         }
 
         public async Task Handle(AnsweredExtToOuterToExtNotification notification, CancellationToken cancellationToken)
@@ -37,6 +43,13 @@ namespace CallCenter.Application.Handlers
                     ToNo = notification.Outer.To,
                 };
                 await _callDetailRepository.AddAsync(detail, cancellationToken);
+
+                //调用业务通知 通知前端
+                var workModel = _userCacheManager.GetWorkByTel(notification.Outer.From);
+                if (workModel != null)
+                {
+                    await _realtimeService.AnsweredAsync(workModel.UserId, new AnseredDto() { ConversationId = notification.Outer.Id, From = notification.Outer.From, Id = model.Id, To = notification.Outer.To, CallType= ECallType.ExtToOuter }, cancellationToken);
+                }
             }
         }
     }

+ 1 - 1
src/CallCenter.Application/Handlers/FlowControl/AnsweredVisitorToExtNotificationHandler.cs

@@ -50,7 +50,7 @@ namespace CallCenter.Application.Handlers
                 var workModel = _userCacheManager.GetWorkByTel(notification.TelNo);
                 if (workModel != null)
                 {
-                    await _realtimeService.AnsweredAsync(workModel.UserId, new AnseredDto() { ConversationId= notification.Visitor.Id , From = notification.Visitor.From, Id = model.Id, To = notification.TelNo }, cancellationToken);
+                    await _realtimeService.AnsweredAsync(workModel.UserId, new AnseredDto() { ConversationId= notification.Visitor.Id , From = notification.Visitor.From, Id = model.Id, To = notification.TelNo, CallType= ECallType.VisitorCallIn}, cancellationToken);
                 }
             }
         }

+ 17 - 2
src/CallCenter.Application/Handlers/FlowControl/ByeExtAndOuterOneNotificationHandler.cs

@@ -1,5 +1,7 @@
-using CallCenter.Calls;
+using CallCenter.Caches;
+using CallCenter.Calls;
 using CallCenter.Notifications;
+using CallCenter.Realtimes;
 using CallCenter.Share.Enums;
 using MediatR;
 
@@ -9,11 +11,15 @@ namespace CallCenter.Application.Handlers
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
+        private readonly IUserCacheManager _userCacheManager;
+        private readonly IRealtimeService _realtimeService;
 
-        public ByeExtAndOuterOneNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository)
+        public ByeExtAndOuterOneNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
+            _userCacheManager = userCacheManager;
+            _realtimeService = realtimeService;
         }
 
 
@@ -40,6 +46,15 @@ namespace CallCenter.Application.Handlers
                     Recording = notification.Recording,
                 };
                 await _callDetailRepository.AddAsync(detail, cancellationToken);
+
+                //调用业务通知 通知前端
+                var workModel = _userCacheManager.GetWorkByTel(notification.TelNo);
+                if (workModel != null)
+                {
+                    await _realtimeService.ByeAsync(workModel.UserId, new ByeDto() { Id = model.Id }, cancellationToken);
+                }
+                //TODO 推送呼出记录
+
             }
         }
     }

+ 17 - 2
src/CallCenter.Application/Handlers/FlowControl/ByeExtAndOuterTwoNotificationHandler.cs

@@ -1,5 +1,7 @@
-using CallCenter.Calls;
+using CallCenter.Caches;
+using CallCenter.Calls;
 using CallCenter.Notifications;
+using CallCenter.Realtimes;
 using CallCenter.Share.Enums;
 using MediatR;
 
@@ -9,11 +11,15 @@ namespace CallCenter.Application.Handlers
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
+        private readonly IUserCacheManager _userCacheManager;
+        private readonly IRealtimeService _realtimeService;
 
-        public ByeExtAndOuterTwoNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository)
+        public ByeExtAndOuterTwoNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
+            _userCacheManager = userCacheManager;
+            _realtimeService = realtimeService;
         }
 
         public async Task Handle(ByeExtAndOuterTwoNotification notification, CancellationToken cancellationToken)
@@ -38,6 +44,15 @@ namespace CallCenter.Application.Handlers
                     Recording = notification.Recording
                 };
                 await _callDetailRepository.AddAsync(detail, cancellationToken);
+
+                //调用业务通知 通知前端
+                var workModel = _userCacheManager.GetWorkByTel(notification.Outer.From);
+                if (workModel != null)
+                {
+                    await _realtimeService.ByeAsync(workModel.UserId, new ByeDto() { Id = model.Id }, cancellationToken);
+                }
+                //TODO 推送呼出记录
+
             }
         }
     }

+ 1 - 0
src/CallCenter.NewRock/Mappers/EventConfigs.cs

@@ -106,6 +106,7 @@ namespace CallCenter.NewRock.Mappers
             //分机和去电的通话结束,分机挂断 类型一
             config.NewConfig<ByeEvent, ByeExtAndOuterOneNotification>()
                 .Map(d => d.TelNo, x => x.Ext.Id);
+            //
             #endregion
 
             #region 呼叫转移事件

+ 3 - 0
src/CallCenter/Realtimes/IRealtimeService.cs

@@ -40,6 +40,9 @@ namespace CallCenter.Realtimes
         public string From { get; set; }
 
         public string To { get; set; }
+
+        public ECallType CallType { get; set; }
+
         public string ConversationId { get; set; }
     }
 }