xf 2 年 前
コミット
08ddf5765b

+ 0 - 75
src/Hotline.Api/Controllers/TelController.cs

@@ -45,81 +45,6 @@ namespace Hotline.Api.Controllers
             _callRepository = callRepository;
             _sessionContext = sessionContext;
         }
-        
-
-        ///// <summary>
-        ///// 查询所有分机(高频)
-        ///// </summary>
-        ///// <returns></returns>
-        //[HttpGet("tels-frequency")]
-        //public async Task<IReadOnlyList<TelDto>> QueryTelsFrequency()
-        //{
-        //    var tels = _telCacheManager.GetTels();
-        //    var dtos = new List<TelDto>();
-        //    foreach (var tel in tels)
-        //    {
-        //        var telModel = _mapper.Map<TelDto>(_telCacheManager.GetTel(tel.No));
-        //        var telDto = await _deviceManager.QueryTelAsync(tel.No, HttpContext.RequestAborted);
-
-        //        if (telDto!=null)
-        //        {
-        //            telModel.CPN = telDto.CPN;
-        //            telModel.CDPN = telDto.CDPN;
-        //            telModel.TelStatusInfo = telDto.TelStatusInfo;
-        //            telModel.ConversationId = telDto.ConversationId;
-        //            if (telModel.TelStatus == ETelStatus.Active)
-        //                telModel.TelStatus = telDto.TelStatus;
-
-        //            if (telModel.TelStatusInfo == ETelStatusInfo.Out)
-        //            {
-        //                var temp = await _callRepository.GetAsync(x => x.FromNo == telDto.CPN && x.ToNo == telDto.CDPN && x.CallDirection == ECallDirection.Out && x.ConversationId == telModel.ConversationId);
-        //                telModel.CallId = temp?.Id;
-        //            }
-        //            else if (telModel.TelStatusInfo == ETelStatusInfo.Into)
-        //            {
-        //                var temp = await _callRepository.GetAsync(x => x.FromNo == telDto.CPN && x.ToNo == telDto.CDPN && x.CallDirection == ECallDirection.In && x.ConversationId == telModel.ConversationId);
-        //                telModel.CallId = temp?.Id;
-        //            }
-        //        }
-        //        dtos.Add(telModel);
-        //    }
-        //    return dtos;
-        //}
-
-        ///// <summary>
-        ///// 查询当前用户分机(高频)
-        ///// </summary>
-        ///// <returns></returns>
-        //[HttpGet("tel-frequency")]
-        //public async Task<TelDto>  QueryTelByToken()
-        //{
-        //    var userid = _sessionContext.RequiredUserId;
-        //    var work = _userCacheManager.GetWorkByUser(userid);
-        //    var telModel = _mapper.Map<TelDto>(_telCacheManager.GetTel(work.TelNo));
-        //    var telDto = await _deviceManager.QueryTelAsync(work.TelNo, HttpContext.RequestAborted);
-
-        //    if (telDto!=null)
-        //    {
-        //        telModel.CPN = telDto.CPN;
-        //        telModel.CDPN = telDto.CDPN;
-        //        telModel.TelStatusInfo = telDto.TelStatusInfo;
-        //        telModel.ConversationId = telDto.ConversationId;
-        //        if (telModel.TelStatus == ETelStatus.Active)
-        //            telModel.TelStatus = telDto.TelStatus;
-
-        //        if(telModel.TelStatusInfo== ETelStatusInfo.Out)
-        //        {
-        //            var temp = await _callRepository.GetAsync(x => x.FromNo == telDto.CPN && x.ToNo == telDto.CDPN && x.CallDirection== ECallDirection.Out && x.ConversationId == telModel.ConversationId);
-        //            telModel.CallId = temp?.Id;
-        //        }
-        //        else if(telModel.TelStatusInfo == ETelStatusInfo.Into)
-        //        {
-        //            var temp = await _callRepository.GetAsync(x => x.FromNo == telDto.CPN && x.CallDirection == ECallDirection.In && x.ConversationId == telModel.ConversationId);
-        //            telModel.CallId = temp?.Id;
-        //        }
-        //    }
-        //    return telModel;
-        //}
 
 
     }

+ 6 - 1
src/Hotline.Api/Controllers/TestController.cs

@@ -18,6 +18,7 @@ using Hotline.Users;
 using MediatR;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.SignalR;
 using Microsoft.Extensions.Options;
 using NewRock.Sdk;
 using NewRock.Sdk.Security;
@@ -51,6 +52,7 @@ public class TestController : BaseController
     private readonly IMediator _mediator;
 
     private readonly ITimeLimitApplication _timeLimitApplication;
+    private readonly IGroupManager _goupManager;
 
     //private readonly ITypedCache<List<User>> _cache;
     //private readonly ICacheManager<User> _cache;
@@ -72,7 +74,8 @@ public class TestController : BaseController
         ISugarUnitOfWork<HotlineDbContext> uow,
         IRoleRepository roleRepository,
         IMediator mediator,
-        ITimeLimitApplication timeLimitApplication
+        ITimeLimitApplication timeLimitApplication,
+        IGroupManager groupManager
     )
     {
         _logger = logger;
@@ -88,6 +91,8 @@ public class TestController : BaseController
         _roleRepository = roleRepository;
         _mediator = mediator;
         _timeLimitApplication = timeLimitApplication;
+
+        groupManager.AddToGroupAsync("123", "123");
     }
 
     [HttpGet("pgsql")]

+ 1 - 1
src/Hotline.Api/StartupHelper.cs

@@ -204,7 +204,7 @@ namespace Hotline.Api
                 throw new UserFriendlyException("未配置signalR的redis连接");
             services.AddSignalR().AddStackExchangeRedis(connectionString, options =>
             {
-                options.Configuration.ChannelPrefix = "callcenter:signalR:";
+                options.Configuration.ChannelPrefix = "Hotline:signalr:";
             });
 
             return services;

+ 14 - 1
src/Hotline/Orders/OrderDomainService.cs

@@ -1,5 +1,9 @@
-using Hotline.FlowEngine;
+using DotNetCore.CAP;
+using Hotline.FlowEngine;
+using Hotline.Share.Dtos.Order;
 using Hotline.Share.Enums.Order;
+using Hotline.Share.Mq;
+using MapsterMapper;
 using Microsoft.Extensions.Logging;
 using XF.Domain.Authentications;
 using XF.Domain.Cache;
@@ -16,17 +20,23 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
     private readonly IOrderRepository _orderRepository;
     private readonly ITypedCache<CacheOrderNO> _cacheOrderNo;
     private readonly ISessionContext _sessionContext;
+    private readonly ICapPublisher _capPublisher;
+    private readonly IMapper _mapper;
     private readonly ILogger<OrderDomainService> _logger;
 
     public OrderDomainService(
         IOrderRepository orderRepository,
         ITypedCache<CacheOrderNO> cacheOrderNo,
         ISessionContext sessionContext,
+        ICapPublisher capPublisher,
+        IMapper mapper,
         ILogger<OrderDomainService> logger)
     {
         _orderRepository = orderRepository;
         _cacheOrderNo = cacheOrderNo;
         _sessionContext = sessionContext;
+        _capPublisher = capPublisher;
+        _mapper = mapper;
         _logger = logger;
     }
 
@@ -85,6 +95,9 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
         order.ManageFlow(isCountersignStart, false, currentStepTime, currentStepName, expiredTime);
 
         await _orderRepository.UpdateAsync(order, cancellationToken);
+
+        await _capPublisher.PublishAsync(EventNames.HotlineOrderCreated, _mapper.Map<OrderDto>(order),
+            cancellationToken: cancellationToken);
     }
 
     /// <summary>