소스 검색

callqueue

admin 2 년 전
부모
커밋
025fc5c85c

+ 5 - 2
src/CallCenter.Api/Realtimes/RealtimeService.cs

@@ -3,6 +3,7 @@ using CallCenter.Calls;
 using CallCenter.Realtimes;
 using CallCenter.Users;
 using Microsoft.AspNetCore.SignalR;
+using System.Text.Json;
 using XF.Domain.Dependency;
 using XF.Domain.Exceptions;
 
@@ -12,12 +13,13 @@ namespace CallCenter.Api.Realtimes
     {
         private readonly IHubContext<CallCenterHub> _hubContext;
         private readonly IUserCacheManager _userCacheManager;
+        private readonly ILogger<RealtimeService> _logger;
 
-
-        public RealtimeService(IHubContext<CallCenterHub> hubContext, IUserCacheManager userCacheManager)
+        public RealtimeService(IHubContext<CallCenterHub> hubContext, IUserCacheManager userCacheManager,ILogger<RealtimeService> logger)
         {
             _hubContext = hubContext;
             _userCacheManager = userCacheManager;
+            _logger = logger;
         }
 
         /// <summary>
@@ -80,6 +82,7 @@ namespace CallCenter.Api.Realtimes
             var works = _userCacheManager.GetWorks();
             if (works != null)
             {
+                _logger.LogInformation(JsonSerializer.Serialize(works));
                 var sendlist = works.Where(x => x.SignalRId != null && x.SignalRId != "").Select(x => x.SignalRId).ToList();
                 foreach (var item in sendlist)
                 {

+ 5 - 1
src/CallCenter.Application/Handlers/BaseHandler.cs

@@ -9,6 +9,7 @@ using CallCenter.Devices;
 using Microsoft.Extensions.Options;
 using CallCenter.Caches;
 using CallCenter.Repository.SqlSugar;
+using CallCenter.Realtimes;
 
 namespace CallCenter.Application.Handlers
 {
@@ -18,12 +19,14 @@ namespace CallCenter.Application.Handlers
         private readonly IOptionsSnapshot<DeviceConfigs> _options;
         private readonly ICallCacheManager _callCacheManager;
         private readonly ICallRepository _callRepository;
-        public BaseHandler(INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options,ICallCacheManager callCacheManager, ICallRepository callRepository)
+        private readonly IRealtimeService _realtimeService;
+        public BaseHandler(INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options,ICallCacheManager callCacheManager, ICallRepository callRepository,IRealtimeService realtimeService)
         {
             _newRockClient = newRockClient;
             _options = options;
             _callCacheManager = callCacheManager;
             _callRepository = callRepository;
+            _realtimeService = realtimeService;
         }
 
         public async Task HandlerIvr(IvrAnswer? runResult,Call model,CancellationToken cancellationToken)
@@ -110,6 +113,7 @@ namespace CallCenter.Application.Handlers
 
                         //处理队列记录 TODO
                         _callCacheManager.AddCallCache(model);
+                        await _realtimeService.CallQueueAsync(_callCacheManager.GetCallQueueList(), cancellationToken);
                         break;
                     case EIvrAnswerType.Out:
                         var phoneNo = ivrAnswer.Content;

+ 5 - 1
src/CallCenter.Application/Handlers/FlowControl/IncomingNotificationHandler.cs

@@ -13,6 +13,7 @@ using XF.Domain.Cache;
 using CallCenter.Settings;
 using Microsoft.Extensions.Logging;
 using NewRock.Sdk.Transfer.Queue.Request;
+using CallCenter.Realtimes;
 
 namespace CallCenter.Application.Handlers
 {
@@ -28,6 +29,7 @@ namespace CallCenter.Application.Handlers
         private readonly ILogger<IncomingNotificationHandler> _logger;
         private readonly ICallCacheManager _callCacheManager;
         private readonly IIvrDomainService _ivrDomainService;
+        private readonly IRealtimeService _realtimeService;
         
 
         public IncomingNotificationHandler(
@@ -35,7 +37,7 @@ namespace CallCenter.Application.Handlers
             ISystemSettingCacheManager systemSettingCacheManager, IIvrCacheManager ivrCacheManager,
             INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options,
             ILogger<IncomingNotificationHandler> logger, ICallCacheManager callCacheManager,
-            IIvrDomainService ivrDomainService)
+            IIvrDomainService ivrDomainService,IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -46,6 +48,7 @@ namespace CallCenter.Application.Handlers
             _logger = logger;
             _callCacheManager = callCacheManager;
             _ivrDomainService = ivrDomainService;
+            _realtimeService = realtimeService;
         }
 
         public async Task Handle(IncomingNotification notification, CancellationToken cancellationToken)
@@ -124,6 +127,7 @@ namespace CallCenter.Application.Handlers
                             await _callRepository.UpdateAsync(model, cancellationToken);
                             //处理队列记录 TODO
                             _callCacheManager.AddCallCache(model);
+                            await _realtimeService.CallQueueAsync(_callCacheManager.GetCallQueueList(), cancellationToken);
                             break;
                         default:
                             break;