Jason 1 year ago
parent
commit
02c7a4e0a2

+ 19 - 4
src/CallCenter.Api/Controllers/TestController.cs

@@ -5,11 +5,15 @@ using CallCenter.Calls;
 using CallCenter.Devices;
 using CallCenter.Ivrs;
 using CallCenter.Realtimes;
+using CallCenter.Repository.SqlSugar;
 using CallCenter.Users;
+using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
 using NewRock.Sdk;
 using NewRock.Sdk.Security;
+using SqlSugar;
+using System.Reactive;
 using XF.Domain.Authentications;
 using XF.Domain.Cache;
 
@@ -29,6 +33,7 @@ namespace CallCenter.Api.Controllers
         private readonly IIvrDomainService _ivrDomainService;
         private readonly ICallCacheManager _callCacheManager;
         private readonly ICallRepository _callRepository;
+        private readonly ISugarUnitOfWork<CallCenterDbContext> _uow;
         //private readonly ITypedCache<List<User>> _cache;
         //private readonly ICacheManager<User> _cache;
 
@@ -46,7 +51,8 @@ namespace CallCenter.Api.Controllers
             IBlacklistDomainService blacklistDomainService,
             IIvrDomainService ivrDomainService,
             ICallCacheManager callCacheManager,
-            ICallRepository callRepository
+            ICallRepository callRepository,
+            ISugarUnitOfWork<CallCenterDbContext> uow
             )
         {
             _logger = logger;
@@ -60,13 +66,22 @@ namespace CallCenter.Api.Controllers
             _ivrDomainService = ivrDomainService;
             _callCacheManager = callCacheManager;
             _callRepository = callRepository;
+            _uow = uow;
         }
-
+        [AllowAnonymous]
         [HttpGet]
         public async Task Test1()
         {
-            var user = User;
-            var uid = _sessionContext.UserId;
+            //var user = User;
+            //var uid = _sessionContext.UserId;
+
+
+            //await _callRepository.GetExtAsync(
+            //    x => x.ConversationId == "2" &&
+            //         x.FromNo == "13408389849" && x.CreationTime >= DateTime.Now.AddHours(-2), x => x.Includes(d => d.CallDetails));
+
+            var list = await _uow.Db.Queryable<Call>().Includes(x => x.CallDetails).Where(x => x.ConversationId == "2" &&
+                     x.FromNo == "13408389849").ToListAsync() ;
             //var user = await _userRepository.GetAsync("08da8016-72af-48b3-8c8f-b39251229f79");
             //_cache.Add(user.Id, user, ExpireMode.None, TimeSpan.FromMinutes(1));
             //var user1 = _cache.Get(user.Id);

+ 4 - 3
src/CallCenter.Application/Handlers/FlowControl/AnsweredVisitorToExtNotificationHandler.cs

@@ -30,9 +30,9 @@ namespace CallCenter.Application.Handlers
 
         public async Task Handle(AnsweredVisitorToExtNotification notification, CancellationToken cancellationToken)
         {
-            var model = await _callRepository.GetAsync(
+            var model = await _callRepository.GetExtAsync(
                 x => x.ConversationId == notification.Visitor.Id &&
-                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2), cancellationToken);
+                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2),x=>x.Includes(d=>d.CallDetails));
             if (model != null)
             {
                 model.CallStatus = ECallStatus.Answered;
@@ -58,7 +58,8 @@ namespace CallCenter.Application.Handlers
                 _logger.LogInformation(JsonSerializer.Serialize(_callCacheManager.GetCallQueueList()));
                 await _realtimeService.CallQueueAsync(_callCacheManager.GetCallQueueList(), cancellationToken);
 
-                var callDetail = _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER");
+                //var callDetail = _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER" && x.CreationTime >= model.CreationTime);
+                var callDetail = model.CallDetails.Where(x => x.CallId == model.Id && x.EventName == "ANSWER");
                 if (callDetail == null)
                 {
                     //调用业务通知 通知前端