xf 8 months ago
parent
commit
4182e2b4af
69 changed files with 548 additions and 450 deletions
  1. 0 1
      src/Hotline.Api/Controllers/AiController.cs
  2. 5 5
      src/Hotline.Api/Controllers/CommonPController.cs
  3. 12 12
      src/Hotline.Api/Controllers/OrderController.cs
  4. 39 34
      src/Hotline.Api/Controllers/PbxController.cs
  5. 7 17
      src/Hotline.Api/Controllers/QualityController.cs
  6. 0 1
      src/Hotline.Api/Controllers/ReportController.cs
  7. 0 1
      src/Hotline.Api/Controllers/TelController.cs
  8. 0 20
      src/Hotline.Api/Controllers/TestController.cs
  9. 0 1
      src/Hotline.Api/Controllers/TestSdkController.cs
  10. 41 34
      src/Hotline.Api/StartupExtensions.cs
  11. 13 7
      src/Hotline.Api/StartupHelper.cs
  12. 36 27
      src/Hotline.Api/config/appsettings.Development.json
  13. 2 0
      src/Hotline.Application/Handlers/CallCenter/CallState/AlertExtToExtNotificationHandler.cs
  14. 2 0
      src/Hotline.Application/Handlers/CallCenter/CallState/AlertExtToOuterNotificationHandler.cs
  15. 2 0
      src/Hotline.Application/Handlers/CallCenter/CallState/AlertMenuToOuterNotificationHandler.cs
  16. 2 0
      src/Hotline.Application/Handlers/CallCenter/CallState/AlertVisitorToExtNotificationHandler.cs
  17. 4 3
      src/Hotline.Application/Handlers/CallCenter/CallState/DtmfNotificationHandler.cs
  18. 2 0
      src/Hotline.Application/Handlers/CallCenter/CallState/FailedNotificationHandler.cs
  19. 2 0
      src/Hotline.Application/Handlers/CallCenter/CallState/RingExtToExtNotificationHandler.cs
  20. 9 7
      src/Hotline.Application/Handlers/CallCenter/CallState/RingExtToOuterNotificationHandler.cs
  21. 3 1
      src/Hotline.Application/Handlers/CallCenter/CallState/RingMenuToExtNotificationHandler.cs
  22. 8 6
      src/Hotline.Application/Handlers/CallCenter/CallState/RingVisitorToExtNotificationHandler.cs
  23. 2 0
      src/Hotline.Application/Handlers/CallCenter/ExtState/BusyNotificationHandler.cs
  24. 20 8
      src/Hotline.Application/Handlers/CallCenter/ExtState/IdleNotificationHandler.cs
  25. 2 0
      src/Hotline.Application/Handlers/CallCenter/ExtState/OfflineNotificationHandler.cs
  26. 2 0
      src/Hotline.Application/Handlers/CallCenter/ExtState/OnlineNotificationHandler.cs
  27. 3 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnswerExtToExtNoificationHandler.cs
  28. 8 6
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnswerExtToOuterNotificationHandler.cs
  29. 5 3
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnswerViisitorToExtNotificationHandler.cs
  30. 2 0
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredExtToExtNotificationHandler.cs
  31. 5 3
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredExtToOuterNotificationHandler.cs
  32. 5 3
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredExtToOuterToExtNotificationHandler.cs
  33. 6 4
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredVisitorToExtNotificationHandler.cs
  34. 4 2
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeExtAndExtNotificationHandler.cs
  35. 5 3
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeExtAndOuterOneNotificationHandler.cs
  36. 4 2
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeExtAndOuterTwoNotificationHandler.cs
  37. 5 3
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeOuterAndOuterNotificationHandler.cs
  38. 9 7
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndExtNotificationHandler.cs
  39. 3 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndMenuNotificationHandler.cs
  40. 3 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndOuterNotificationHandler.cs
  41. 8 6
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorOffNotificationHandler.cs
  42. 5 3
      src/Hotline.Application/Handlers/CallCenter/FlowControl/CdrNotificationHandler.cs
  43. 6 4
      src/Hotline.Application/Handlers/CallCenter/FlowControl/DivertVisitorToExtNotificationHandler.cs
  44. 9 8
      src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnOuterToMenuNotificationHandler.cs
  45. 8 8
      src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnVisitorToMenuNotificationHandler.cs
  46. 2 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/IncomingNotificationHandler.cs
  47. 2 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/InviteNotificationHandler.cs
  48. 5 3
      src/Hotline.Application/Handlers/CallCenter/FlowControl/QueueVisitorToGroupBusyNotificationHandler.cs
  49. 10 5
      src/Hotline.Application/Handlers/CallCenter/NewRockBaseHandler.cs
  50. 18 8
      src/Hotline.Application/Handlers/CallCenter/System/BootupNotificationHandler.cs
  51. 4 2
      src/Hotline.Application/Handlers/CallCenter/Transient/TransientOuterNotificationHandler.cs
  52. 3 1
      src/Hotline.Application/Handlers/CallCenter/Transient/TransinetVisitorNotificationHandler.cs
  53. 6 57
      src/Hotline.Application/Handlers/FlowEngine/WorkflowEndHandler.cs
  54. 8 23
      src/Hotline.Application/Handlers/FlowEngine/WorkflowStartHandler.cs
  55. 5 5
      src/Hotline.Application/Quality/QualityApplication.cs
  56. 0 1
      src/Hotline.NewRock/Handlers/DeviceEventHandler.cs
  57. 3 3
      src/Hotline.NewRock/NewRockDeviceManager.cs
  58. 1 3
      src/Hotline.NewRock/NewRockStartupExtensions.cs
  59. 46 0
      src/Hotline/AppConfiguration.cs
  60. 22 18
      src/Hotline/CallCenter/Calls/CallDomainService.cs
  61. 0 2
      src/Hotline/CallCenter/Configs/CallCenterConfiguration.cs
  62. 1 3
      src/Hotline/CallCenter/Devices/INewRockDeviceManager.cs
  63. 13 8
      src/Hotline/CallCenter/Ivrs/IvrDomainService.cs
  64. 16 7
      src/Hotline/CallCenter/Manage/VoiceFileDomainService.cs
  65. 28 19
      src/Hotline/CallCenter/Tels/TelDomainService.cs
  66. 15 0
      src/Hotline/EventBus/HandlerInjectAttribute.cs
  67. 1 2
      src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs
  68. 3 9
      src/Hotline/Push/FWMessage/PushDomainService.cs
  69. 18 16
      src/Hotline/Users/UserDomainService.cs

+ 0 - 1
src/Hotline.Api/Controllers/AiController.cs

@@ -8,7 +8,6 @@ using Hotline.Application.Orders;
 using Hotline.Application.Quality;
 using Hotline.Caching.Interfaces;
 using Hotline.Caching.Services;
-using Hotline.CallCenter.Devices;
 using Hotline.Orders;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Settings;

+ 5 - 5
src/Hotline.Api/Controllers/CommonPController.cs

@@ -39,7 +39,7 @@ namespace Hotline.Api.Controllers
         private readonly IOrderScreenRepository _orderScreenRepository;
         private readonly IRepository<OrderVisitDetail> _orderVisitedDetailRepository;
         private readonly ICallApplication _callApplication;
-        private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
+        private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
 
         public CommonPController(
             ISystemCommonOpinionDomainService commonOpinionDomainService,
@@ -53,7 +53,7 @@ namespace Hotline.Api.Controllers
             IOrderScreenRepository orderScreenRepository,
             IRepository<OrderVisitDetail> orderVisitedDetailRepository,
             ICallApplication callApplication,
-            IOptionsSnapshot<CallCenterConfiguration> callcenterOptions)
+            IOptionsSnapshot<AppConfiguration> appOptions)
         {
             _commonOpinionDomainService = commonOpinionDomainService;
             _systemAreaDomainService = systemAreaDomainService;
@@ -66,7 +66,7 @@ namespace Hotline.Api.Controllers
             _orderScreenRepository = orderScreenRepository;
             _orderVisitedDetailRepository = orderVisitedDetailRepository;
             _callApplication = callApplication;
-            _callcenterOptions = callcenterOptions;
+            _appOptions = appOptions;
         }
 
 
@@ -110,7 +110,7 @@ namespace Hotline.Api.Controllers
                 int callNum = 0, validCallNum = 0, answeredNum = 0;
                 var answeredRate = string.Empty;
                 var today = DateTime.Today.Date;
-                if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+                if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
                 {
                     var calls = await _callApplication.QueryTianrunCallsAsync(
                         direction: ECallDirection.In,
@@ -125,7 +125,7 @@ namespace Hotline.Api.Controllers
                         ? Math.Round((double.Parse(answeredNum.ToString()) / double.Parse(validCallNum.ToString())) * 100, 2) + "%"
                         : "-";
                 }
-                else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+                else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
                 {
                     var calls = await _callApplication.QueryCallsAsync(
                         callStartTimeStart: today,

+ 12 - 12
src/Hotline.Api/Controllers/OrderController.cs

@@ -125,7 +125,7 @@ public class OrderController : BaseController
     private readonly IRepository<ExternalCitizens> _externalCitizensRepository;
     private readonly IRepository<OrderModifyingRecords> _orderModifyingRecordsRepository;
     private readonly ICallApplication _callApplication;
-    private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
+    private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
     private readonly IOrderSendBackAuditApplication _orderSendBackAuditApplication;
     private readonly Publisher _publisher;
 
@@ -183,7 +183,7 @@ public class OrderController : BaseController
         IRepository<OrderCopy> orderCopyRepository,
         IRepository<ExternalCitizens> externalCitizensRepository,
         ICallApplication callApplication,
-        IOptionsSnapshot<CallCenterConfiguration> callcenterOptions,
+        IOptionsSnapshot<AppConfiguration> appOptions,
         IRepository<OrderModifyingRecords> orderModifyingRecordsRepository,
         IOrderSendBackAuditApplication orderSendBackAuditApplication,
         Publisher publisher
@@ -243,7 +243,7 @@ public class OrderController : BaseController
         _externalCitizensRepository = externalCitizensRepository;
         _orderModifyingRecordsRepository = orderModifyingRecordsRepository;
         _callApplication = callApplication;
-        _callcenterOptions = callcenterOptions;
+        _appOptions = appOptions;
         _orderSendBackAuditApplication = orderSendBackAuditApplication;
         _publisher = publisher;
     }
@@ -830,7 +830,7 @@ public class OrderController : BaseController
         var recordingBaseAddress = "";
         var recordingAbsolutePath = "";
         var aiVisitVoiceBaseUrl = "";
-        if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+        if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
         {
             var callRecord = await _callApplication.GetTianrunCallAsync(orderVisit.CallId, HttpContext.RequestAborted);
             if (callRecord != null)
@@ -840,7 +840,7 @@ public class OrderController : BaseController
                 recordingAbsolutePath = callRecord.RecordingAbsolutePath;
             }
         }
-        else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+        else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
         {
             var call = await _callApplication.GetCallAsync(orderVisit.CallId, HttpContext.RequestAborted);
             if (call is not null)
@@ -2784,7 +2784,7 @@ public class OrderController : BaseController
 
         if (!string.IsNullOrEmpty(order.CallId))
         {
-            if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+            if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
             {
                 var callRecord = await _callApplication.GetTianrunCallAsync(order.CallId, HttpContext.RequestAborted);
                 if (callRecord != null)
@@ -2793,7 +2793,7 @@ public class OrderController : BaseController
                     dto.RecordingAbsolutePath = callRecord.RecordingAbsolutePath;
                 }
             }
-            else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+            else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
             {
                 var call = await _callApplication.GetCallAsync(order.CallId, HttpContext.RequestAborted);
                 if (call is not null)
@@ -2889,7 +2889,7 @@ public class OrderController : BaseController
         //    callRecord.CallOrderType = Share.Enums.CallCenter.ECallOrderType.Order;
         //    await _trCallRecordRepository.UpdateAsync(callRecord, HttpContext.RequestAborted);
         //}
-        if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+        if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
         {
             if (!string.IsNullOrEmpty(order.CallId))
                 await _callApplication.RelateTianrunCallWithOrderAsync(order.CallId, order.Id, HttpContext.RequestAborted);
@@ -4993,14 +4993,14 @@ public class OrderController : BaseController
 
         var oneCallTime = DateTime.Now;
         var lastCallTime = DateTime.Now;
-        if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+        if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
         {
             var calls = await _callApplication.QueryTianrunCallsAsync(phone, ECallDirection.In, cancellationToken: HttpContext.RequestAborted);
             oneCallTime = calls.FirstOrDefault()?.CreatedTime ?? DateTime.Now;
             var count = calls.Count;
             lastCallTime = count > 1 ? calls[count - 2].CreatedTime : oneCallTime;
         }
-        else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+        else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
         {
             var calls = await _callApplication.QueryCallsAsync(phone, ECallDirection.In, cancellationToken: HttpContext.RequestAborted);
             oneCallTime = calls.FirstOrDefault()?.BeginIvrTime ?? DateTime.Now;
@@ -5034,7 +5034,7 @@ public class OrderController : BaseController
         //    callBackNum = callsHistory.Count(x => x.CallDirection == ECallDirection.Out);
         //}
 
-        if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+        if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
         {
             var callsHistory =
                 await _callApplication.QueryTianrunCallsAsync(phone, cancellationToken: HttpContext.RequestAborted);
@@ -5045,7 +5045,7 @@ public class OrderController : BaseController
                 callBackNum = callsHistory.Count(x => x.CallDirection == ECallDirection.Out);
             }
         }
-        else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+        else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
         {
             var histories =
                 await _callApplication.QueryCallsAsync(phone, cancellationToken: HttpContext.RequestAborted);

+ 39 - 34
src/Hotline.Api/Controllers/PbxController.cs

@@ -1,7 +1,6 @@
 using Hotline.Application.FlowEngine;
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
-using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Ivrs;
 using Hotline.CallCenter.Tels;
 using Hotline.Permissions;
@@ -24,7 +23,9 @@ using XF.Domain.Exceptions;
 using XF.Utility.EnumExtensions;
 using System.Linq;
 using Hotline.CallCenter.Configs;
+using Hotline.CallCenter.Devices;
 using Hotline.FlowEngine.WorkflowModules;
+using Hotline.NewRock;
 using Hotline.Share.Dtos;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.Extensions.Options;
@@ -46,7 +47,7 @@ namespace Hotline.Api.Controllers
         private readonly ITelGroupRepository _telGroupRepository;
         private readonly IMapper _mapper;
         private readonly IWorkRepository _workRepository;
-        private readonly IDeviceManager _deviceManager;
+        private readonly INewRockDeviceManager _newRockDeviceManager;
         private readonly IUserCacheManager _userCacheManager;
         private readonly ISessionContext _sessionContext;
         private readonly ICallRepository _callRepository;
@@ -66,6 +67,7 @@ namespace Hotline.Api.Controllers
 
 
         public PbxController(
+            IServiceProvider serviceProvider,
             ITelRepository telRepository,
             ITelRestRepository telRestRepository,
             ITelDomainService telDomainService,
@@ -74,7 +76,6 @@ namespace Hotline.Api.Controllers
             ITelGroupRepository telGroupRepository,
             IMapper mapper,
             IWorkRepository workRepository,
-            IDeviceManager deviceManager,
             IUserCacheManager userCacheManager,
             ISessionContext sessionContext,
             ICallRepository callRepository,
@@ -89,6 +90,7 @@ namespace Hotline.Api.Controllers
             IRepository<User> userRepository,
             IWexClient wexClient,
             IWexTelGroupRepository wexTelGroupRepository,
+            IOptionsSnapshot<AppConfiguration> appOptions,
             IOptionsSnapshot<CallCenterConfiguration> options,
             ISystemDicDataCacheManager systemDicDataCacheManager)
         {
@@ -100,7 +102,6 @@ namespace Hotline.Api.Controllers
             _telGroupRepository = telGroupRepository;
             _mapper = mapper;
             _workRepository = workRepository;
-            _deviceManager = deviceManager;
             _userCacheManager = userCacheManager;
             _sessionContext = sessionContext;
             _callRepository = callRepository;
@@ -117,6 +118,10 @@ namespace Hotline.Api.Controllers
             _wexTelGroupRepository = wexTelGroupRepository;
             _options = options;
             _systemDicDataCacheManager = systemDicDataCacheManager;
+            if (appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XunShi)
+            {
+                _newRockDeviceManager = serviceProvider.GetRequiredService<INewRockDeviceManager>();
+            }
         }
 
 
@@ -201,7 +206,7 @@ namespace Hotline.Api.Controllers
         {
             var works = await _workRepository.QueryAsync(d => dto.TelNos.Contains(d.TelNo) && !d.EndTime.HasValue);
 
-            await _deviceManager.AssginConfigGroupAsync(
+            await _newRockDeviceManager.AssginConfigGroupAsync(
                 _options.Value.NewRock, dto.No,
                 dto.Distribution,
                 ext: works.Select(d => d.TelNo).ToList(),
@@ -225,7 +230,7 @@ namespace Hotline.Api.Controllers
         {
             var works = await _workRepository.QueryAsync(d => dto.TelNos.Contains(d.TelNo) && !d.EndTime.HasValue);
 
-            await _deviceManager.AssginConfigGroupAsync(
+            await _newRockDeviceManager.AssginConfigGroupAsync(
                 _options.Value.NewRock, dto.No,
                 dto.Distribution,
                 ext: works.Select(d => d.TelNo).ToList(),
@@ -484,7 +489,7 @@ namespace Hotline.Api.Controllers
                 throw UserFriendlyException.SameMessage("转接分机未进行工作");
 
             //判断分机状态
-            var telState = await _deviceManager.QueryTelState(_options.Value.NewRock, dto.TelNo, HttpContext.RequestAborted);
+            var telState = await _newRockDeviceManager.QueryTelState(_options.Value.NewRock, dto.TelNo, HttpContext.RequestAborted);
             if (telState != ETelStatus.Ready)
                 throw UserFriendlyException.SameMessage("被叫分机不在线或正在通话中");
 
@@ -492,7 +497,7 @@ namespace Hotline.Api.Controllers
             if (isRest)
                 throw new UserFriendlyException("被叫分机正在休息不能转接");
 
-            await _deviceManager.ExtToExtAsync(_options.Value.NewRock, work.TelNo, dto.TelNo, HttpContext.RequestAborted);
+            await _newRockDeviceManager.ExtToExtAsync(_options.Value.NewRock, work.TelNo, dto.TelNo, HttpContext.RequestAborted);
         }
 
         /// <summary>
@@ -506,7 +511,7 @@ namespace Hotline.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
-            await _deviceManager.ExtToOuterAsync(_options.Value.NewRock, work.TelNo, dto.OuterNo, HttpContext.RequestAborted);
+            await _newRockDeviceManager.ExtToOuterAsync(_options.Value.NewRock, work.TelNo, dto.OuterNo, HttpContext.RequestAborted);
         }
 
         /// <summary>
@@ -522,7 +527,7 @@ namespace Hotline.Api.Controllers
             if (work is null)
                 throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
             string newOuter = dto.LineId + "," + dto.OuterNo;
-            await _deviceManager.ExtToOuterAsync(_options.Value.NewRock, work.TelNo, newOuter, HttpContext.RequestAborted);
+            await _newRockDeviceManager.ExtToOuterAsync(_options.Value.NewRock, work.TelNo, newOuter, HttpContext.RequestAborted);
         }
 
         /// <summary>
@@ -540,7 +545,7 @@ namespace Hotline.Api.Controllers
             if (toWork is null)
                 throw UserFriendlyException.SameMessage("转接分机未进行工作");
 
-            var totelState = await _deviceManager.QueryTelState(_options.Value.NewRock, dto.TelNo, HttpContext.RequestAborted);
+            var totelState = await _newRockDeviceManager.QueryTelState(_options.Value.NewRock, dto.TelNo, HttpContext.RequestAborted);
             if (totelState != ETelStatus.Ready)
                 throw UserFriendlyException.SameMessage("被叫分机不在线或正在通话中");
 
@@ -549,9 +554,9 @@ namespace Hotline.Api.Controllers
                 throw new UserFriendlyException("被叫分机正在休息不能转接");
 
 
-            var tel = await _deviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
+            var tel = await _newRockDeviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
             if (!string.IsNullOrEmpty(tel.ConversationId))
-                await _deviceManager.VisitorToExtAsync(_options.Value.NewRock, tel.ConversationId, dto.TelNo, HttpContext.RequestAborted);
+                await _newRockDeviceManager.VisitorToExtAsync(_options.Value.NewRock, tel.ConversationId, dto.TelNo, HttpContext.RequestAborted);
             else
                 throw UserFriendlyException.SameMessage("当前分机没有通话");
         }
@@ -567,9 +572,9 @@ namespace Hotline.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
-            var tel = await _deviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
+            var tel = await _newRockDeviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
             if (!string.IsNullOrEmpty(tel.ConversationId))
-                await _deviceManager.VisitorToOuterAsync(_options.Value.NewRock, tel.ConversationId, dto.OuterNo, HttpContext.RequestAborted);
+                await _newRockDeviceManager.VisitorToOuterAsync(_options.Value.NewRock, tel.ConversationId, dto.OuterNo, HttpContext.RequestAborted);
             else
                 throw UserFriendlyException.SameMessage("当前分机没有通话");
         }
@@ -586,9 +591,9 @@ namespace Hotline.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
-            var tel = await _deviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
+            var tel = await _newRockDeviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
             if (!string.IsNullOrEmpty(tel.ConversationId))
-                await _deviceManager.VisitorToGroupAsync(_options.Value.NewRock, tel.ConversationId, dto.groupid, HttpContext.RequestAborted);
+                await _newRockDeviceManager.VisitorToGroupAsync(_options.Value.NewRock, tel.ConversationId, dto.groupid, HttpContext.RequestAborted);
             else
                 throw UserFriendlyException.SameMessage("当前分机没有通话");
         }
@@ -605,9 +610,9 @@ namespace Hotline.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
-            var tel = await _deviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
+            var tel = await _newRockDeviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
             if (!string.IsNullOrEmpty(tel.ConversationId))
-                await _deviceManager.OuterToOuterAsync(_options.Value.NewRock, tel.ConversationId, dto.OuterNo, HttpContext.RequestAborted);
+                await _newRockDeviceManager.OuterToOuterAsync(_options.Value.NewRock, tel.ConversationId, dto.OuterNo, HttpContext.RequestAborted);
             else
                 throw UserFriendlyException.SameMessage("当前分机没有通话");
         }
@@ -628,7 +633,7 @@ namespace Hotline.Api.Controllers
             if (toWork is null)
                 throw UserFriendlyException.SameMessage("转接分机未进行工作");
 
-            var totelState = await _deviceManager.QueryTelState(_options.Value.NewRock, dto.TelNo, HttpContext.RequestAborted);
+            var totelState = await _newRockDeviceManager.QueryTelState(_options.Value.NewRock, dto.TelNo, HttpContext.RequestAborted);
             if (totelState != ETelStatus.Ready)
                 throw UserFriendlyException.SameMessage("被叫分机不在线或正在通话中");
 
@@ -636,9 +641,9 @@ namespace Hotline.Api.Controllers
             if (isRest)
                 throw new UserFriendlyException("被叫分机正在休息不能转接");
 
-            var tel = await _deviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
+            var tel = await _newRockDeviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
             if (!string.IsNullOrEmpty(tel.ConversationId))
-                await _deviceManager.OuterToExtAsync(_options.Value.NewRock, tel.ConversationId, dto.TelNo, HttpContext.RequestAborted);
+                await _newRockDeviceManager.OuterToExtAsync(_options.Value.NewRock, tel.ConversationId, dto.TelNo, HttpContext.RequestAborted);
             else
                 throw UserFriendlyException.SameMessage("当前分机没有通话");
         }
@@ -660,9 +665,9 @@ namespace Hotline.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
-            var tel = await _deviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
+            var tel = await _newRockDeviceManager.QueryTelAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
             if (!string.IsNullOrEmpty(tel.ConversationId))
-                await _deviceManager.ConferenceMeetingAsync(_options.Value.NewRock, dto.TelNo, HttpContext.RequestAborted);
+                await _newRockDeviceManager.ConferenceMeetingAsync(_options.Value.NewRock, dto.TelNo, HttpContext.RequestAborted);
             else
                 throw UserFriendlyException.SameMessage("当前分机没有通话");
         }
@@ -678,7 +683,7 @@ namespace Hotline.Api.Controllers
         [HttpPost("monitor-ext")]
         public async Task MonitorExt([FromBody] MonitorExtRequest request)
         {
-            await _deviceManager.MonitorExtAsync(_options.Value.NewRock, request.firstTelNo, request.secondTelNo, HttpContext.RequestAborted);
+            await _newRockDeviceManager.MonitorExtAsync(_options.Value.NewRock, request.firstTelNo, request.secondTelNo, HttpContext.RequestAborted);
         }
 
 
@@ -693,7 +698,7 @@ namespace Hotline.Api.Controllers
         [HttpPost("monitor-ext-to-talk")]
         public async Task MonitorExtToTalk([FromBody] MonitorExtToTalkRequest request)
         {
-            await _deviceManager.MonitorExtToTalkAsync(_options.Value.NewRock, request.telNo, HttpContext.RequestAborted);
+            await _newRockDeviceManager.MonitorExtToTalkAsync(_options.Value.NewRock, request.telNo, HttpContext.RequestAborted);
         }
 
 
@@ -708,7 +713,7 @@ namespace Hotline.Api.Controllers
         [HttpPost("monitor-ext-to-listen")]
         public async Task MonitorExtToListen([FromBody] MonitorExtToListenRequest request)
         {
-            await _deviceManager.MonitorExtToListenAsync(_options.Value.NewRock, request.telNo, HttpContext.RequestAborted);
+            await _newRockDeviceManager.MonitorExtToListenAsync(_options.Value.NewRock, request.telNo, HttpContext.RequestAborted);
         }
 
 
@@ -727,7 +732,7 @@ namespace Hotline.Api.Controllers
         [HttpPost("bargein-ext")]
         public async Task BargeinExt([FromBody] BargeinExtRequest request)
         {
-            await _deviceManager.BargeinExtAsync(_options.Value.NewRock, request.firstTelNo, request.secondTelNo, HttpContext.RequestAborted);
+            await _newRockDeviceManager.BargeinExtAsync(_options.Value.NewRock, request.firstTelNo, request.secondTelNo, HttpContext.RequestAborted);
         }
 
         #endregion
@@ -749,7 +754,7 @@ namespace Hotline.Api.Controllers
             //if (call.CallStatus == ECallStatus.Bye)
             //    throw UserFriendlyException.SameMessage("通话已结束");
 
-            await _deviceManager.ClearExtAsync(_options.Value.NewRock, request.CallId, HttpContext.RequestAborted);
+            await _newRockDeviceManager.ClearExtAsync(_options.Value.NewRock, request.CallId, HttpContext.RequestAborted);
         }
 
         /// <summary>
@@ -766,7 +771,7 @@ namespace Hotline.Api.Controllers
                 throw UserFriendlyException.SameMessage("无效通话,无法挂断");
             if (call.CallStatus == ECallStatus.Bye)
                 throw UserFriendlyException.SameMessage("通话已结束");
-            await _deviceManager.ClearVisitorAsync(_options.Value.NewRock, call.ConversationId, HttpContext.RequestAborted);
+            await _newRockDeviceManager.ClearVisitorAsync(_options.Value.NewRock, call.ConversationId, HttpContext.RequestAborted);
         }
 
         /// <summary>
@@ -783,7 +788,7 @@ namespace Hotline.Api.Controllers
                 throw UserFriendlyException.SameMessage("无效通话,无法挂断");
             if (call.CallStatus == ECallStatus.Bye)
                 throw UserFriendlyException.SameMessage("通话已结束");
-            await _deviceManager.ClearOuterAsync(_options.Value.NewRock, call.ConversationId, HttpContext.RequestAborted);
+            await _newRockDeviceManager.ClearOuterAsync(_options.Value.NewRock, call.ConversationId, HttpContext.RequestAborted);
         }
 
         #endregion
@@ -800,7 +805,7 @@ namespace Hotline.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
-            await _deviceManager.MuteAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
+            await _newRockDeviceManager.MuteAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
         }
 
         /// <summary>
@@ -813,7 +818,7 @@ namespace Hotline.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
-            await _deviceManager.UnMuteAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
+            await _newRockDeviceManager.UnMuteAsync(_options.Value.NewRock, work.TelNo, HttpContext.RequestAborted);
         }
 
         #endregion
@@ -969,7 +974,7 @@ namespace Hotline.Api.Controllers
 
             await _callDetailRepository.AddAsync(detail, HttpContext.RequestAborted);
 
-            await _deviceManager.VisitorToMenuAsync(_options.Value.NewRock, call.ConversationId, ivr.No, HttpContext.RequestAborted);
+            await _newRockDeviceManager.VisitorToMenuAsync(_options.Value.NewRock, call.ConversationId, ivr.No, HttpContext.RequestAborted);
         }
 
         #endregion

+ 7 - 17
src/Hotline.Api/Controllers/QualityController.cs

@@ -7,29 +7,19 @@ using Hotline.Permissions;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Settings;
 using Hotline.Share.Dtos;
-using Hotline.Share.Dtos.File;
 using Microsoft.AspNetCore.Mvc;
 using XF.Domain.Exceptions;
 using Hotline.Share.Dtos.Quality;
-using Hotline.Share.Dtos.Order;
 using Hotline.Share.Enums.Quality;
-using Hotline.Share.Enums.Order;
 using XF.Utility.EnumExtensions;
-using System.Xml.Linq;
-using System.Threading;
-using Hotline.CallCenter.Calls;
 using Hotline.Application.Quality;
 using Microsoft.AspNetCore.Authorization;
 using Hotline.Orders;
 using Hotline.Ai.Quality;
-using Newtonsoft.Json;
-using Polly;
 using Hotline.Api.Filter;
 using Hotline.Application.CallCenter;
 using Hotline.CallCenter.Configs;
 using Microsoft.Extensions.Options;
-using XF.Domain.Constants;
-using Hotline.Repository.SqlSugar.CallCenter;
 
 namespace Hotline.Api.Controllers
 {
@@ -51,7 +41,7 @@ namespace Hotline.Api.Controllers
         private readonly ILogger<QualityController> _logger;
         private readonly ISystemSettingCacheManager _systemSettingCacheManager;
         private readonly ICallApplication _callApplication;
-        private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
+        private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
         private readonly IRepository<SystemLog> _logRepository;
 
 		public QualityController(
@@ -71,7 +61,7 @@ namespace Hotline.Api.Controllers
             ILogger<QualityController> logger,
             ISystemSettingCacheManager systemSettingCacheManager,
             ICallApplication callApplication,
-            IOptionsSnapshot<CallCenterConfiguration> callcenterOptions,
+            IOptionsSnapshot<AppConfiguration> appOptions,
             IRepository<SystemLog> logRepository)
         {
             _sessionContext = sessionContext;
@@ -90,7 +80,7 @@ namespace Hotline.Api.Controllers
             _logger = logger;
             _systemSettingCacheManager = systemSettingCacheManager;
             _callApplication = callApplication;
-            _callcenterOptions = callcenterOptions;
+            _appOptions = appOptions;
             _logRepository = logRepository;
 		}
         #region 质检管理
@@ -184,7 +174,7 @@ namespace Hotline.Api.Controllers
             //              }
             //          }
 
-            if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+            if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
             {
                 if (qualityDto.Order != null)
                 {
@@ -209,7 +199,7 @@ namespace Hotline.Api.Controllers
                     }
                 }
             }
-            else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+            else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
             {
                 if (!string.IsNullOrEmpty(qualityDto?.Order?.CallId))
                 {
@@ -671,14 +661,14 @@ namespace Hotline.Api.Controllers
                 var audioFile = string.Empty;
                 var fromNo = string.Empty;
                 DateTime? callStartTime = null;
-                if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+                if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
                 {
                     var call = await _callApplication.GetTianrunCallAsync(order.CallId, HttpContext.RequestAborted);
                     audioFile = call.RecordingAbsolutePath;
                     fromNo = call.CPN;
                     callStartTime = call.CreatedTime;
                 }
-                else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+                else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
                 {
                     var call = await _callApplication.GetCallAsync(order.CallId, HttpContext.RequestAborted);
                     audioFile = call.AudioFile;

+ 0 - 1
src/Hotline.Api/Controllers/ReportController.cs

@@ -1,6 +1,5 @@
 using Hotline.CallCenter;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
 using Hotline.NewRock;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;

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

@@ -1,6 +1,5 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
-using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Tels;
 using Hotline.Share.Dtos.CallCenter;
 using Hotline.Share.Enums.CallCenter;

+ 0 - 20
src/Hotline.Api/Controllers/TestController.cs

@@ -17,7 +17,6 @@ using Hotline.Authentications;
 using Hotline.CallCenter.BlackLists;
 using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Ivrs;
 using Hotline.ContingencyManagement;
 using Hotline.FlowEngine;
@@ -131,7 +130,6 @@ public class TestController : BaseController
     private readonly IEnforcementApplication _enforcementApplication;
     private readonly IWorkflowDomainService _workflowDomainService;
     private readonly IMapper _mapper;
-    private readonly IOptionsSnapshot<SendSmsConfiguration> _sendSmsConfiguration;
     private readonly IOrderReportApplication _orderReportApplication;
     private readonly IRepository<EnforcementOrders> _enforcementOrdersRepository;
     private readonly IRepository<JudicialManagementOrders> _judicialManagementOrdersRepository;
@@ -186,7 +184,6 @@ public class TestController : BaseController
         IOrderApplication orderApplication,
 
 
-   IOptionsSnapshot<SendSmsConfiguration> sendSmsConfiguration,
    IOrderReportApplication orderReportApplication,
 IRepository<EnforcementOrders> enforcementOrdersRepository,
 IRepository<JudicialManagementOrders> judicialManagementOrdersRepository,
@@ -230,7 +227,6 @@ IRepository<Hotspot> hotspotRepository
         _workflowDomainService = workflowDomainService;
         _orderRepository = orderRepository;
         _mapper = mapper;
-        _sendSmsConfiguration = sendSmsConfiguration;
         _orderReportApplication = orderReportApplication;
         _enforcementOrdersRepository = enforcementOrdersRepository;
         _judicialManagementOrdersRepository = judicialManagementOrdersRepository;
@@ -440,22 +436,6 @@ IRepository<Hotspot> hotspotRepository
     [AllowAnonymous]
     public async Task<OpenResponse> TestOrigin()
     {
-        var messageDto = new Share.Dtos.Push.MessageDto
-        {
-            PushBusiness = EPushBusiness.OrderAccept,
-            ExternalId = "123456789",
-            OrderId = "123456789",
-            PushPlatform = EPushPlatform.Sms,
-            Remark = " order.Title",
-            Name = "张三",
-            TemplateCode = "1005",
-            Params = new List<string>() { "20240610000022", "12345" },
-            TelNumber = "15881689499",
-
-        };
-        await _mediator.Publish(new PushMessageNotify(messageDto), HttpContext.RequestAborted);
-
-        var t = _sendSmsConfiguration.Value.Url;
         var now = DateTime.Now.ToString();
         return OpenResponse.Ok(now);
     }

+ 0 - 1
src/Hotline.Api/Controllers/TestSdkController.cs

@@ -1,5 +1,4 @@
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;

+ 41 - 34
src/Hotline.Api/StartupExtensions.cs

@@ -3,7 +3,6 @@ using FluentValidation.AspNetCore;
 using Hotline.Api.Realtimes;
 using Hotline.Application;
 using Hotline.Application.Contracts;
-using Hotline.CallCenter.Devices;
 using Hotline.NewRock;
 using Hotline.Permissions;
 using Hotline.Repository.SqlSugar.Extensions;
@@ -47,17 +46,22 @@ internal static class StartupExtensions
 #endif
 
         services.Configure<IdentityConfiguration>(d => configuration.GetSection(nameof(IdentityConfiguration)).Bind(d));
-        services.Configure<CallCenterConfiguration>(d => configuration.GetSection(nameof(CallCenterConfiguration)).Bind(d));
-        services.Configure<AiVisitConfig>(d => configuration.GetSection("AiVisit").Bind(d));
-        services.Configure<SendSmsConfiguration>(d => configuration.GetSection("SendSms").Bind(d));
+
+        var appConfigurationSection = configuration.GetRequiredSection(nameof(AppConfiguration));
+        var appConfiguration = appConfigurationSection.Get<AppConfiguration>();
+        services.Configure<AppConfiguration>(d => appConfigurationSection.Bind(d));
+
+        var callCenterConfigurationSection = configuration.GetRequiredSection(nameof(CallCenterConfiguration));
+        var callCenterConfiguration = callCenterConfigurationSection.Get<CallCenterConfiguration>();
+        services.Configure<CallCenterConfiguration>(d => callCenterConfigurationSection.Bind(d));
+
+        //services.Configure<SendSmsConfiguration>(d => configuration.GetSection("SendSms").Bind(d));
 
         // Add services to the container.
         services
             .BatchInjectServices()
             .RegisterRepository()
             .AddApplication()
-            //.AddClientCore(configuration)
-            //.AddScoped<IPasswordHasher<Account>, PasswordHasher<Account>>()
             .AddScoped(typeof(IPasswordHasher<>), typeof(PasswordHasher<>))
             ;
 
@@ -96,17 +100,40 @@ internal static class StartupExtensions
         services.RegisterMapper();
 
         //mediatr
-        //todo 
-        services.RegisterMediatR(AppDefaults.AppScope.YiBin);
+        services.RegisterMediatR(appConfiguration);
+
+        //app scope
+        switch (appConfiguration.AppScope)
+        {
+            case AppDefaults.AppScope.YiBin:
+                //jths 
+                services.AddAiJths(configuration.GetSection("AiQuality").Get<AiQualityConfig>().Url);
+
+                var aiVisitConfigSection = configuration.GetSection("AiVisit");
+                var aiVisitConfig = aiVisitConfigSection.Get<AiVisitConfig>();
+                services.AddAiVisitService(
+                    aiVisitConfig.Url,
+                    aiVisitConfig.Appkey,
+                    aiVisitConfig.ServiceVersion);
+                services.Configure<AiVisitConfig>(d => aiVisitConfigSection.Bind(d));
+
+                //宜宾企业服务
+                services.Configure<EnterpriseConfig>(d => configuration.GetSection("Enterprise").Bind(d));
+                var enterpriseConfig = configuration.GetSection("Enterprise").Get<EnterpriseConfig>();
+                services.AddYbEnterpriseSdk(enterpriseConfig?.AddressUrl);
+                break;
+            case AppDefaults.AppScope.ZiGong:
+                break;
+            case AppDefaults.AppScope.LuZhou:
+                break;
+        }
 
         //callcenter
-        var callCenterConfiguration = configuration
-            .GetRequiredSection(nameof(CallCenterConfiguration))
-            .Get<CallCenterConfiguration>();
-        services.AddNewRock(callCenterConfiguration.NewRock);
-        switch (callCenterConfiguration.CallCenterType)
+        var callcenterType = appConfiguration.GetDefaultAppScopeConfiguration().CallCenterType;
+        switch (callcenterType)
         {
             case AppDefaults.CallCenterType.XunShi:
+                services.AddNewRock(callCenterConfiguration.NewRock);
                 break;
             case AppDefaults.CallCenterType.WeiErXin:
                 services
@@ -134,26 +161,6 @@ internal static class StartupExtensions
         }
 
 
-
-
-        ////tr
-        //var trConfig = configuration.GetRequiredSection("Tr").Get<TianrunConfiguration>();
-
-
-        //jths 
-        services.AddAiJths(configuration.GetSection("AiQuality").Get<AiQualityConfig>().Url);
-
-        //宜宾企业服务
-        services.Configure<EnterpriseConfig>(d => configuration.GetSection("Enterprise").Bind(d));
-        var enterpriseConfig = configuration.GetSection("Enterprise").Get<EnterpriseConfig>();
-        services.AddYbEnterpriseSdk(enterpriseConfig?.AddressUrl);
-
-        var aiVisitConfig = configuration.GetSection("AiVisit").Get<AiVisitConfig>();
-        services.AddAiVisitService(
-            aiVisitConfig.Url,
-            aiVisitConfig.Appkey,
-            aiVisitConfig.ServiceVersion);
-
         //sqlsugar
         services.AddSqlSugar(configuration);
 
@@ -168,7 +175,7 @@ internal static class StartupExtensions
         services.AddMq(configuration);
 
         //job
-        services.RegisterJob(callCenterConfiguration);
+        services.RegisterJob(callcenterType);
 
         services.AddSingleton<IAuthorizationPolicyProvider, AuthorizationPolicyProvider>();
         services.AddSingleton<IAuthorizationHandler, PermissionHandler>();

+ 13 - 7
src/Hotline.Api/StartupHelper.cs

@@ -244,7 +244,7 @@ namespace Hotline.Api
             return services;
         }
 
-        public static IServiceCollection RegisterJob(this IServiceCollection services, CallCenterConfiguration callCenterConfiguration)
+        public static IServiceCollection RegisterJob(this IServiceCollection services, string callcenterType)
         {
             services.AddQuartz(d =>
             {
@@ -263,7 +263,7 @@ namespace Hotline.Api
                     .WithCronSchedule("0 10 9 * * ?")
                 );
 
-                switch (callCenterConfiguration.CallCenterType)
+                switch (callcenterType)
                 {
                     case AppDefaults.CallCenterType.XingTang:
                         var getCallsJobKey = new JobKey(nameof(XingTangCallsSyncJob));
@@ -305,7 +305,7 @@ namespace Hotline.Api
             return services;
         }
 
-        public static IServiceCollection RegisterMediatR(this IServiceCollection services, string appScope)
+        public static IServiceCollection RegisterMediatR(this IServiceCollection services, AppConfiguration appConfiguration)
         {
             services.AddScoped<Publisher>();
             services.AddMediatR(cfg =>
@@ -314,10 +314,16 @@ namespace Hotline.Api
                 {
                     var attr = d.GetCustomAttribute(typeof(HandlerInjectAttribute)) as HandlerInjectAttribute;
                     if (attr is null) return true;
-                    return attr.Enable &&
-                           attr.AppScopes.ToString()
-                               .Split(',', StringSplitOptions.RemoveEmptyEntries)
-                               .Any(x => string.Compare(x, appScope, StringComparison.Ordinal) == 0);
+                    if (!attr.Enable) return false;
+                    switch (attr.EventHandlerType)
+                    {
+                        case EEventHandlerType.CallCenter:
+                            return attr.Label == appConfiguration.GetDefaultAppScopeConfiguration().CallCenterType;
+                        default:
+                            return attr.AppScopes.ToString()
+                                .Split(',', StringSplitOptions.RemoveEmptyEntries)
+                                .Any(x => string.Compare(x, appConfiguration.AppScope, StringComparison.Ordinal) == 0);
+                    }
                 };
                 //cfg.RegisterServicesFromAssemblyContaining<Program>();
                 cfg.RegisterServicesFromAssembly(typeof(ApplicationStartupExtensions).Assembly);

+ 36 - 27
src/Hotline.Api/config/appsettings.Development.json

@@ -1,7 +1,19 @@
 {
   "AllowedHosts": "*",
+  "AppConfiguration": {
+    "AppScope": "YiBin",
+    "YiBin": {
+      "CallCenterType": "TianRun" //XunShi、WeiErXin、TianRun、XingTang
+    },
+    "ZiGong": {
+      "CallCenterType": "XingTang"
+    },
+    "LuZhou": {
+      "CallCenterType": "XingTang"
+    }
+  },
   "CallCenterConfiguration": {
-    "CallCenterType": "TianRun", //XunShi、WeiErXin、TianRun、XingTang
+    //"CallCenterType": "TianRun", //XunShi、WeiErXin、TianRun、XingTang
     "NewRock": {
       "Address": "http://192.168.100.100/xml",
       "Authorize": true,
@@ -29,10 +41,7 @@
     }
   },
   "ConnectionStrings": {
-    "Hotline": "PORT=5432;DATABASE=hotline_dev;HOST=110.188.24.182;PASSWORD=fengwo11!!;USER ID=dev;"
-    //"Redis": "110.188.24.182:50179",
-    //"MongoDB": "mongodb://192.168.100.121:27017",
-    //"Wex": "server=222.212.82.225;Port=4509;Database=fs_kft;Uid=root;Pwd=Wex@12345;"
+    "Hotline": "PORT=5432;DATABASE=hotline;HOST=110.188.24.182;PASSWORD=fengwo11!!;USER ID=dev;"
   },
   "Cache": {
     "Host": "110.188.24.182",
@@ -86,31 +95,31 @@
       "VirtualHost": "fwt-master"
     }
   },
-  "SmsAccountInfo": {
-    "MessageServerUrl": "http://webservice.fway.com.cn:1432/FWebService.asmx/FWay_Service", //短信发送地址
-    "AccountUser": "CS12345", //短信系统账号
-    "AccountPwd": "9EE3899305A8FC97D6146CAC6B802E6F", //短信系统密码
-    "ReturnAccountUser": "fwkj", //短信回传账号
-    "ReturnAccountPwd": "fwkj12" //短信回传密码
-  },
+  //"SmsAccountInfo": {
+  //  "MessageServerUrl": "http://webservice.fway.com.cn:1432/FWebService.asmx/FWay_Service", //短信发送地址
+  //  "AccountUser": "CS12345", //短信系统账号
+  //  "AccountPwd": "9EE3899305A8FC97D6146CAC6B802E6F", //短信系统密码
+  //  "ReturnAccountUser": "fwkj", //短信回传账号
+  //  "ReturnAccountPwd": "fwkj12" //短信回传密码
+  //},
   "FwClient": {
     "ClientId": "hotline",
     "ClientSecret": "08db29cc-0da0-4adf-850c-1b2689bd535d"
   },
-  "ConfigCenter": {
-    "ServerAddresses": [ "http://110.188.24.28:8848" ],
-    "Namespace": "17503980-9b0d-4d3e-8e35-c842c41fb888", //debug
-    "ServiceName": "hotline"
-  },
-  "Tr": {
-    //"Address": "http://internal.ttf-cti.com:8080",
-    //"Username": "yscs",
-    //"Password": "123456",
-    "Address": "http://222.213.23.229:29003/",
-    "Username": "root",
-    "Password": "12345678aa",
-    "Ip": "222.213.23.229"
-  },
+  //"ConfigCenter": {
+  //  "ServerAddresses": [ "http://110.188.24.28:8848" ],
+  //  "Namespace": "17503980-9b0d-4d3e-8e35-c842c41fb888", //debug
+  //  "ServiceName": "hotline"
+  //},
+  //"Tr": {
+  //  //"Address": "http://internal.ttf-cti.com:8080",
+  //  //"Username": "yscs",
+  //  //"Password": "123456",
+  //  "Address": "http://222.213.23.229:29003/",
+  //  "Username": "root",
+  //  "Password": "12345678aa",
+  //  "Ip": "222.213.23.229"
+  //},
   //智能回访
   "AiVisit": {
     "Url": "http://118.122.73.80:19061",
@@ -119,7 +128,7 @@
   },
   //智能质检
   "AiQuality": {
-    "Url": "http://118.122.73.80:19072/", // 正式
+    "Url": "http://118.122.73.80:19072/" // 正式
     //"Url": "http://118.122.73.80:19072/", // 测试
   },
   //企业服务

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/CallState/AlertExtToExtNotificationHandler.cs

@@ -1,4 +1,5 @@
 using Hotline.Caching.Interfaces;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -8,6 +9,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AlertExtToExtNotificationHandler : INotificationHandler<AlertExtToExtNotification>
     {
         private readonly IRealtimeService _realtimeService;

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/CallState/AlertExtToOuterNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -9,6 +10,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AlertExtToOuterNotificationHandler:INotificationHandler<AlertExtToOuterNotification>
     {
         private readonly ICallRepository _callRepository;

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/CallState/AlertMenuToOuterNotificationHandler.cs

@@ -1,10 +1,12 @@
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AlertMenuToOuterNotificationHandler:INotificationHandler<AlertMenuToOuterNotification>
     {
         private readonly ICallRepository _callRepository;

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/CallState/AlertVisitorToExtNotificationHandler.cs

@@ -1,10 +1,12 @@
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AlertVisitorToExtNotificationHandler: INotificationHandler<AlertVisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;

+ 4 - 3
src/Hotline.Application/Handlers/CallCenter/CallState/DtmfNotificationHandler.cs

@@ -1,8 +1,8 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Ivrs;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
@@ -12,14 +12,15 @@ using NewRock.Sdk;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    public class DtmfNotificationHandler : BaseHandler, INotificationHandler<DtmfNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class DtmfNotificationHandler : NewRockBaseHandler, INotificationHandler<DtmfNotification>
     {
         private readonly IIvrDomainService _ivrDomainService;
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
 
 
-        public DtmfNotificationHandler(IIvrDomainService ivrDomainService, ICallDetailRepository callDetailRepository, ICallRepository callRepository, INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options,ICallCacheManager callCacheManager,IRealtimeService realtimeService) :base(newRockClient, options,callRepository, callCacheManager,realtimeService)
+        public DtmfNotificationHandler(IIvrDomainService ivrDomainService, ICallDetailRepository callDetailRepository, ICallRepository callRepository, INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> callcenterOptions,ICallCacheManager callCacheManager,IRealtimeService realtimeService) :base(newRockClient, callcenterOptions,callRepository, callCacheManager,realtimeService)
         {
             _ivrDomainService = ivrDomainService;
             _callDetailRepository = callDetailRepository;

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/CallState/FailedNotificationHandler.cs

@@ -1,9 +1,11 @@
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class FailedNotificationHandler:INotificationHandler<FailedNotification>
     {
         private readonly ICallRepository _callRepository;

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/CallState/RingExtToExtNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -13,6 +14,7 @@ using System.Threading.Tasks;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class RingExtToExtNotificationHandler : INotificationHandler<RingExtToExtNotification>
     {
         private readonly IRealtimeService _realtimeService;

+ 9 - 7
src/Hotline.Application/Handlers/CallCenter/CallState/RingExtToOuterNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using Hotline.Tools;
@@ -7,13 +8,14 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    public class RingExtToOuterNotificationHandler:INotificationHandler<RingExtToOuterNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class RingExtToOuterNotificationHandler : INotificationHandler<RingExtToOuterNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
         private readonly IUserCacheManager _userCacheManager;
 
-        public RingExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager)
+        public RingExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IUserCacheManager userCacheManager)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -23,15 +25,15 @@ namespace Hotline.Application.Handlers.CallCenter.CallState
         public async Task Handle(RingExtToOuterNotification notification, CancellationToken cancellationToken)
         {
             var model = await _callRepository.GetAsync(x =>
-                x.FromNo == notification.TelNo && x.ToNo == notification.Outer.To && x.CreationTime >=DateTime.Now.AddHours(-2),true,x=>x.CreationTime, cancellationToken);
-            if (model==null)
+                x.FromNo == notification.TelNo && x.ToNo == notification.Outer.To && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
+            if (model == null)
             {
                 model = await _callRepository.GetAsync(
                     x => x.ConversationId == notification.Outer.Id && x.ToNo == notification.Outer.To &&
-                         x.Trunk == notification.Outer.Trunk,true,x=>x.CreationTime, cancellationToken);
+                         x.Trunk == notification.Outer.Trunk, true, x => x.CreationTime, cancellationToken);
             }
-                       
-            if (model!=null)
+
+            if (model != null)
             {
                 var workModel = _userCacheManager.GetWorkByTel(notification.TelNo);
                 model.UserId = workModel.UserId;

+ 3 - 1
src/Hotline.Application/Handlers/CallCenter/CallState/RingMenuToExtNotificationHandler.cs

@@ -1,8 +1,10 @@
-using Hotline.Share.Notifications.NewRockCallCenter;
+using Hotline.EventBus;
+using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class RingMenuToExtNotificationHandler:INotificationHandler<RingMenuToExtNotification>
     {
         //TODO 无法定位数据暂无操作

+ 8 - 6
src/Hotline.Application/Handlers/CallCenter/CallState/RingVisitorToExtNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
@@ -7,14 +8,15 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    public class RingVisitorToExtNotificationHandler:INotificationHandler<RingVisitorToExtNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class RingVisitorToExtNotificationHandler : INotificationHandler<RingVisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
         private readonly IRealtimeService _realtimeService;
         private readonly IUserCacheManager _userCacheManager;
 
-        public RingVisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IRealtimeService realtimeService, IUserCacheManager userCacheManager)
+        public RingVisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IRealtimeService realtimeService, IUserCacheManager userCacheManager)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -27,9 +29,9 @@ namespace Hotline.Application.Handlers.CallCenter.CallState
         {
             var model = await _callRepository.GetAsync(
                 x => x.ConversationId == notification.Visitor.Id &&
-                     x.FromNo == notification.Visitor.From && x.CreationTime>=DateTime.Now.AddHours(-2),true,x=>x.CreationTime, cancellationToken);
-            
-            if (model!=null)
+                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
+
+            if (model != null)
             {
                 model.CallStatus = ECallStatus.Ring;
                 model.RingTime = DateTime.Now;
@@ -48,7 +50,7 @@ namespace Hotline.Application.Handlers.CallCenter.CallState
 
                 //调用业务弹屏 通知前端
                 var workModel = _userCacheManager.GetWorkByTel(notification.TelNo);
-                if (workModel!=null)
+                if (workModel != null)
                 {
                     await _realtimeService.RingAsync(workModel.UserId, new Share.Dtos.Realtime.RingDto() { From = notification.Visitor.From, Id = model.Id, To = notification.TelNo, CallType = ECallType.VisitorCallIn }, cancellationToken);
                 }

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/ExtState/BusyNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Tels;
+using Hotline.EventBus;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
@@ -7,6 +8,7 @@ using XF.Domain.Cache;
 
 namespace Hotline.Application.Handlers.CallCenter.ExtState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class BusyNotificationHandler : INotificationHandler<BusyNotification>
     {
         private readonly ITelRepository _telRepository;

+ 20 - 8
src/Hotline.Application/Handlers/CallCenter/ExtState/IdleNotificationHandler.cs

@@ -3,17 +3,21 @@ using Hotline.Caching.Services;
 using Hotline.CallCenter.Configs;
 using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Tels;
+using Hotline.EventBus;
+using Hotline.NewRock;
 using Hotline.Realtimes;
 using Hotline.Repository.SqlSugar.CallCenter;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
+using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Options;
 using XF.Domain.Cache;
 using XF.Domain.Exceptions;
 
 namespace Hotline.Application.Handlers.CallCenter.ExtState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class IdleNotificationHandler : INotificationHandler<IdleNotification>
     {
         private readonly ITelRepository _telRepository;
@@ -21,24 +25,32 @@ namespace Hotline.Application.Handlers.CallCenter.ExtState
         private readonly ITypedCache<Tel> _typedCache;
         private readonly IUserCacheManager _userCacheManager;
         private readonly IRealtimeService _realtimeService;
-        private readonly IDeviceManager _deviceManager;
+        private readonly INewRockDeviceManager _newRockDeviceManager;
         private readonly ITelRestRepository _telRestRepository;
-        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
+        private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
 
-        public IdleNotificationHandler(ITelRepository telRepository, ITelCacheManager telCacheManager, 
+        public IdleNotificationHandler(
+            IServiceProvider serviceProvider,
+            ITelRepository telRepository, ITelCacheManager telCacheManager, 
             ITypedCache<Tel> typedCache,IUserCacheManager userCacheManager,
-            IRealtimeService realtimeService,IDeviceManager deviceManager,
+            IRealtimeService realtimeService,
             ITelRestRepository telRestRepository,
-            IOptionsSnapshot<CallCenterConfiguration> options)
+            IOptionsSnapshot<AppConfiguration> appOptions,
+            IOptionsSnapshot<CallCenterConfiguration> callcenterOptions)
         {
             _telRepository = telRepository;
             _telCacheManager = telCacheManager;
             _typedCache = typedCache;
             _userCacheManager = userCacheManager;
             _realtimeService = realtimeService;
-            _deviceManager = deviceManager;
             _telRestRepository = telRestRepository;
-            _options = options;
+            _appOptions = appOptions;
+            _callcenterOptions = callcenterOptions;
+            if (appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XunShi)
+            {
+                _newRockDeviceManager = serviceProvider.GetRequiredService<INewRockDeviceManager>();
+            }
         }
 
         public async Task Handle(IdleNotification notification, CancellationToken cancellationToken)
@@ -68,7 +80,7 @@ namespace Hotline.Application.Handlers.CallCenter.ExtState
             {
                 foreach (var group in telModel.Groups)
                 {
-                    await _deviceManager.AssginConfigGroupAsync(_options.Value.NewRock, group.No, group.Distribution, new List<string>() { notification.TelNo }, group.Voice, cancellationToken);
+                    await _newRockDeviceManager.AssginConfigGroupAsync(_callcenterOptions.Value.NewRock, group.No, group.Distribution, new List<string>() { notification.TelNo }, group.Voice, cancellationToken);
                 }
             }
         }

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/ExtState/OfflineNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Tels;
+using Hotline.EventBus;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
@@ -7,6 +8,7 @@ using XF.Domain.Cache;
 
 namespace Hotline.Application.Handlers.CallCenter.ExtState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class OfflineNotificationHandler: INotificationHandler<OfflineNotification>
     {
         private readonly ITelRepository _telRepository;

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/ExtState/OnlineNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Tels;
+using Hotline.EventBus;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
@@ -7,6 +8,7 @@ using XF.Domain.Cache;
 
 namespace Hotline.Application.Handlers.CallCenter.ExtState
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class OnlineNotificationHandler : INotificationHandler<OnlineNotification>
     {
         private readonly ITelRepository _telRepository;

+ 3 - 1
src/Hotline.Application/Handlers/CallCenter/FlowControl/AnswerExtToExtNoificationHandler.cs

@@ -1,4 +1,5 @@
 using Hotline.Caching.Interfaces;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -7,13 +8,14 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AnswerExtToExtNoificationHandler : INotificationHandler<AnswerExtToExtNotification>
     {
         private readonly IUserCacheManager _userCacheManager;
         private readonly IRealtimeService _realtimeService;
 
 
-        public AnswerExtToExtNoificationHandler(IUserCacheManager userCacheManager,IRealtimeService realtimeService)
+        public AnswerExtToExtNoificationHandler(IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _userCacheManager = userCacheManager;
             _realtimeService = realtimeService;

+ 8 - 6
src/Hotline.Application/Handlers/CallCenter/FlowControl/AnswerExtToOuterNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -8,14 +9,15 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class AnswerExtToOuterNotificationHandler:INotificationHandler<AnswerExtToOuterNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class AnswerExtToOuterNotificationHandler : INotificationHandler<AnswerExtToOuterNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
         private readonly IUserCacheManager _userCacheManager;
         private readonly IRealtimeService _realtimeService;
 
-        public AnswerExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager,IRealtimeService realtimeService)
+        public AnswerExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -25,11 +27,11 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
 
         public async Task Handle(AnswerExtToOuterNotification notification, CancellationToken cancellationToken)
         {
-            var model =await _callRepository.GetAsync(
+            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,
+                     x.Trunk == notification.Outer.Trunk && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime,
                 cancellationToken);
-            if (model!=null)
+            if (model != null)
             {
                 model.CallStatus = ECallStatus.Answer;
                 await _callRepository.UpdateAsync(model, cancellationToken);
@@ -38,7 +40,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                     CallId = model.Id,
                     CallStatus = ECallStatus.Answer,
                     OMCallId = notification.Outer.CallId,
-                    ConversationId =notification.Outer.Id,
+                    ConversationId = notification.Outer.Id,
                     EventName = notification.Attribute,
                     FromNo = notification.Outer.From,
                     ToNo = notification.Outer.To,

+ 5 - 3
src/Hotline.Application/Handlers/CallCenter/FlowControl/AnswerViisitorToExtNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -8,7 +9,8 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class AnswerViisitorToExtNotificationHandler:INotificationHandler<AnswerViisitorToExtNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class AnswerViisitorToExtNotificationHandler : INotificationHandler<AnswerViisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -17,7 +19,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly IRealtimeService _realtimeService;
 
 
-        public AnswerViisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,ICallCacheManager callCacheManager,IUserCacheManager userCacheManager,IRealtimeService realtimeService)
+        public AnswerViisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, ICallCacheManager callCacheManager, IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -30,7 +32,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         {
             var model = await _callRepository.GetAsync(
                 x => x.ConversationId == notification.Visitor.Id &&
-                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2),true,x=>x.CreationTime, cancellationToken);
+                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
             if (model != null)
             {
                 model.CallStatus = ECallStatus.Answer;

+ 2 - 0
src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredExtToExtNotificationHandler.cs

@@ -1,4 +1,5 @@
 using Hotline.Caching.Interfaces;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -7,6 +8,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AnsweredExtToExtNotificationHandler : INotificationHandler<AnsweredExtToExtNotification>
     {
         private readonly IUserCacheManager _userCacheManager;

+ 5 - 3
src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredExtToOuterNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -8,14 +9,15 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class AnsweredExtToOuterNotificationHandler:INotificationHandler<AnsweredExtToOuterNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class AnsweredExtToOuterNotificationHandler : INotificationHandler<AnsweredExtToOuterNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
         private readonly IUserCacheManager _userCacheManager;
         private readonly IRealtimeService _realtimeService;
 
-        public AnsweredExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager,IRealtimeService realtimeService)
+        public AnsweredExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -27,7 +29,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         {
             var model = await _callRepository.GetAsync(
                 x => x.ConversationId == notification.Outer.Id &&
-                     x.FromNo == notification.Outer.From && x.ToNo == notification.Outer.To && x.CreationTime >= DateTime.Now.AddHours(-2),true,x=>x.CreationTime, cancellationToken);
+                     x.FromNo == notification.Outer.From && x.ToNo == notification.Outer.To && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
             if (model != null)
             {
                 model.CallStatus = ECallStatus.Answered;

+ 5 - 3
src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredExtToOuterToExtNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -8,7 +9,8 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class AnsweredExtToOuterToExtNotificationHandler:INotificationHandler<AnsweredExtToOuterToExtNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class AnsweredExtToOuterToExtNotificationHandler : INotificationHandler<AnsweredExtToOuterToExtNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -23,8 +25,8 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         {
             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);
-            if (model!=null)
+                x.Trunk == notification.Outer.Trunk && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
+            if (model != null)
             {
                 model.CallStatus = ECallStatus.Answered;
                 model.AnsweredTime = DateTime.Now;

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

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
@@ -7,7 +8,8 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class AnsweredVisitorToExtNotificationHandler:INotificationHandler<AnsweredVisitorToExtNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class AnsweredVisitorToExtNotificationHandler : INotificationHandler<AnsweredVisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -15,7 +17,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly IRealtimeService _realtimeService;
         private readonly ICallCacheManager _callCacheManager;
 
-        public AnsweredVisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService, ICallCacheManager callCacheManager)
+        public AnsweredVisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IUserCacheManager userCacheManager, IRealtimeService realtimeService, ICallCacheManager callCacheManager)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -28,7 +30,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         {
             var model = await _callRepository.GetAsync(
                 x => x.ConversationId == notification.Visitor.Id &&
-                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2),true,x=>x.CreationTime, cancellationToken);
+                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
             var workModel = _userCacheManager.GetWorkByTel(notification.TelNo);
             if (model != null)
             {
@@ -56,7 +58,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                 await _realtimeService.CallQueueAsync(_callCacheManager.GetCallQueueList(), cancellationToken);
 
                 var callDetail = _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER");
-                if (callDetail==null)
+                if (callDetail == null)
                 {
                     //调用业务通知 通知前端
                     await _realtimeService.AnsweredAsync(workModel.UserId, new Share.Dtos.Realtime.AnsweredDto() { Id = model.Id, From = notification.Visitor.From, To = notification.TelNo }, cancellationToken);

+ 4 - 2
src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeExtAndExtNotificationHandler.cs

@@ -1,4 +1,5 @@
 using Hotline.Caching.Interfaces;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Notifications.NewRockCallCenter;
@@ -7,14 +8,15 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeExtAndExtNotificationHandler : INotificationHandler<ByeExtAndExtNotification>
     {
         private readonly IUserCacheManager _userCacheManager;
         private readonly IRealtimeService _realtimeService;
 
-        public ByeExtAndExtNotificationHandler(IUserCacheManager userCacheManager,IRealtimeService realtimeService)
+        public ByeExtAndExtNotificationHandler(IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
-           _userCacheManager = userCacheManager;
+            _userCacheManager = userCacheManager;
             _realtimeService = realtimeService;
         }
 

+ 5 - 3
src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeExtAndOuterOneNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -8,7 +9,8 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class ByeExtAndOuterOneNotificationHandler:INotificationHandler<ByeExtAndOuterOneNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class ByeExtAndOuterOneNotificationHandler : INotificationHandler<ByeExtAndOuterOneNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -27,8 +29,8 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         public async Task Handle(ByeExtAndOuterOneNotification notification, CancellationToken cancellationToken)
         {
             var model = await _callRepository.GetAsync(
-                x => x.ConversationId == notification.Outer.Id && 
-                     x.Trunk==notification.Outer.Trunk && x.ToNo == notification.Outer.To && x.CreationTime>=DateTime.Now.AddHours(-2),true,x=>x.CreationTime, cancellationToken);
+                x => x.ConversationId == notification.Outer.Id &&
+                     x.Trunk == notification.Outer.Trunk && x.ToNo == notification.Outer.To && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
             if (model != null)
             {
                 model.CallStatus = ECallStatus.Bye;

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

@@ -1,6 +1,7 @@
 using Hotline.Caching.Interfaces;
 using Hotline.Caching.Services;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -9,6 +10,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeExtAndOuterTwoNotificationHandler : INotificationHandler<ByeExtAndOuterTwoNotification>
     {
         private readonly ICallRepository _callRepository;
@@ -16,7 +18,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly IUserCacheManager _userCacheManager;
         private readonly IRealtimeService _realtimeService;
 
-        public ByeExtAndOuterTwoNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager,IRealtimeService realtimeService)
+        public ByeExtAndOuterTwoNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -27,7 +29,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         public async Task Handle(ByeExtAndOuterTwoNotification notification, CancellationToken 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);
+                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);
             if (model != null)
             {
                 model.CallStatus = ECallStatus.Bye;

+ 5 - 3
src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeOuterAndOuterNotificationHandler.cs

@@ -1,11 +1,13 @@
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class ByeOuterAndOuterNotificationHandler:INotificationHandler<ByeOuterAndOuterNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class ByeOuterAndOuterNotificationHandler : INotificationHandler<ByeOuterAndOuterNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -20,8 +22,8 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         {
             var model = await _callRepository.GetAsync(x =>
                 x.ConversationId == notification.Outer.Id && x.FromNo == notification.Outer.From &&
-                x.ToNo == notification.Outer.To && x.CreationTime >= DateTime.Now.AddHours(-2),true,x=>x.CreationTime,cancellationToken);
-            if (model!=null)
+                x.ToNo == notification.Outer.To && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
+            if (model != null)
             {
                 model.CallStatus = ECallStatus.Bye;
                 model.RingOffType = ERingOffType.Normal;

+ 9 - 7
src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndExtNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
@@ -7,7 +8,8 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class ByeVisitorAndExtNotificationHandler:INotificationHandler<ByeVisitorAndExtNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class ByeVisitorAndExtNotificationHandler : INotificationHandler<ByeVisitorAndExtNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -15,7 +17,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly IRealtimeService _realtimeService;
         private readonly ICallCacheManager _callCacheManager;
 
-        public ByeVisitorAndExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService, ICallCacheManager callCacheManager)
+        public ByeVisitorAndExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IUserCacheManager userCacheManager, IRealtimeService realtimeService, ICallCacheManager callCacheManager)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -27,8 +29,8 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         public async Task Handle(ByeVisitorAndExtNotification notification, CancellationToken cancellationToken)
         {
             var model = await _callRepository.GetAsync(
-                x => x.ConversationId == notification.Visitor.Id && 
-                     x.FromNo == notification.Visitor.From && x.CreationTime>=DateTime.Now.AddHours(-2),true,x=>x.CreationTime, cancellationToken);
+                x => x.ConversationId == notification.Visitor.Id &&
+                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
             if (model != null)
             {
                 model.CallStatus = ECallStatus.Bye;
@@ -54,11 +56,11 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                 await _realtimeService.CallQueueAsync(_callCacheManager.GetCallQueueList(), cancellationToken);
 
                 //查询应答分机分机号
-                var callDetailAnswer = await _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER", true, d => d.CreationTime,cancellationToken);
-                if (callDetailAnswer!=null)
+                var callDetailAnswer = await _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER", true, d => d.CreationTime, cancellationToken);
+                if (callDetailAnswer != null)
                 {
                     var workModel = _userCacheManager.GetWorkByTel(callDetailAnswer.AnswerNo);
-                    if (workModel!=null)
+                    if (workModel != null)
                     {
                         //调用业务通知 通知前端
                         await _realtimeService.ByeAsync(workModel.UserId, new Share.Dtos.Realtime.ByeDto() { Id = model.Id }, cancellationToken);

+ 3 - 1
src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndMenuNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -13,6 +14,7 @@ using System.Threading.Tasks;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeVisitorAndMenuNotificationHandler : INotificationHandler<ByeVisitorAndMenuNotification>
     {
         private readonly ICallRepository _callRepository;
@@ -20,7 +22,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly IRealtimeService _realtimeService;
         private readonly IUserCacheManager _userCacheManager;
 
-        public ByeVisitorAndMenuNotificationHandler(ICallRepository callRepository,ICallDetailRepository callDetailRepository,IRealtimeService realtimeService,IUserCacheManager userCacheManager)
+        public ByeVisitorAndMenuNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IRealtimeService realtimeService, IUserCacheManager userCacheManager)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;

+ 3 - 1
src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndOuterNotificationHandler.cs

@@ -1,10 +1,12 @@
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class ByeVisitorAndOuterNotificationHandler:INotificationHandler<ByeVisitorAndOuterNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class ByeVisitorAndOuterNotificationHandler : INotificationHandler<ByeVisitorAndOuterNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;

+ 8 - 6
src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorOffNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
@@ -8,7 +9,8 @@ using Serilog.Enrichers.Span;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class ByeVisitorOffNotificationHandler:INotificationHandler<ByeVisitorOffNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class ByeVisitorOffNotificationHandler : INotificationHandler<ByeVisitorOffNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -16,7 +18,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly IUserCacheManager _userCacheManager;
         private readonly IRealtimeService _realtimeService;
 
-        public ByeVisitorOffNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, ICallCacheManager callCacheManager, IUserCacheManager userCacheManager,IRealtimeService realtimeService)
+        public ByeVisitorOffNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, ICallCacheManager callCacheManager, IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -29,7 +31,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         {
             var model = await _callRepository.GetAsync(
                 x => x.ConversationId == notification.Visitor.Id &&
-                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2),true,x=>x.CreationTime, cancellationToken);
+                     x.FromNo == notification.Visitor.From && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
             if (model != null)
             {
                 model.CallStatus = ECallStatus.Bye;
@@ -55,12 +57,12 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                 await _realtimeService.CallQueueAsync(_callCacheManager.GetCallQueueList(), cancellationToken);
 
                 //查询应答分机号
-                var callDetailAnswer = await _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER", true, x => x.CreationTime,cancellationToken);
-                if (callDetailAnswer!=null)
+                var callDetailAnswer = await _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER", true, x => x.CreationTime, cancellationToken);
+                if (callDetailAnswer != null)
                 {
                     //调用业务通知 通知前端
                     var workModel = _userCacheManager.GetWorkByTel(callDetailAnswer.AnswerNo);
-                    if (workModel!=null)
+                    if (workModel != null)
                     {
                         await _realtimeService.ByeAsync(workModel.UserId, new Share.Dtos.Realtime.ByeDto() { Id = model.Id }, cancellationToken);
                     }

+ 5 - 3
src/Hotline.Application/Handlers/CallCenter/FlowControl/CdrNotificationHandler.cs

@@ -1,6 +1,7 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Tels;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
@@ -9,7 +10,8 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class CdrNotificationHandler:INotificationHandler<CdrNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class CdrNotificationHandler : INotificationHandler<CdrNotification>
     {
         private readonly ICallRecordRepository _callRecordRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -18,7 +20,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly IUserCacheManager _userCacheManager;
         private readonly IRealtimeService _realtimeService;
 
-        public CdrNotificationHandler(ICallRecordRepository callRecordRepository, ICallDetailRepository callDetailRepository, ICallRepository callRepository,ITelHoldRepository telHoldRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService)
+        public CdrNotificationHandler(ICallRecordRepository callRecordRepository, ICallDetailRepository callDetailRepository, ICallRepository callRepository, ITelHoldRepository telHoldRepository, IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRecordRepository = callRecordRepository;
             _callDetailRepository = callDetailRepository;
@@ -51,7 +53,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
             else
             {
                 var callDetail = await
-                _callDetailRepository.GetAsync(x => x.OMCallId == notification.CallId,true,x=>x.CreationTime, cancellationToken);
+                _callDetailRepository.GetAsync(x => x.OMCallId == notification.CallId, true, x => x.CreationTime, cancellationToken);
 
                 if (callDetail != null)
                 {

+ 6 - 4
src/Hotline.Application/Handlers/CallCenter/FlowControl/DivertVisitorToExtNotificationHandler.cs

@@ -1,11 +1,13 @@
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class DivertVisitorToExtNotificationHandler:INotificationHandler<DivertVisitorToExtNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class DivertVisitorToExtNotificationHandler : INotificationHandler<DivertVisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -20,9 +22,9 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         {
             var model = await _callRepository.GetAsync(
                 x => x.ConversationId == notification.Visitor.Id && x.FromNo == notification.Visitor.From &&
-                     x.ToNo == notification.Visitor.To && x.CreationTime >= DateTime.Now.AddHours(-2),true,x=>x.CreationTime,
+                     x.ToNo == notification.Visitor.To && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime,
                 cancellationToken);
-            if (model!=null)
+            if (model != null)
             {
                 model.CallStatus = ECallStatus.Divert;
                 await _callRepository.UpdateAsync(model, cancellationToken);
@@ -36,7 +38,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                     FromNo = notification.Visitor.From,
                     ToNo = notification.Visitor.To
                 };
-                await _callDetailRepository.AddAsync(detail,cancellationToken);
+                await _callDetailRepository.AddAsync(detail, cancellationToken);
             }
         }
     }

+ 9 - 8
src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnOuterToMenuNotificationHandler.cs

@@ -1,8 +1,8 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Ivrs;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
@@ -12,12 +12,13 @@ using NewRock.Sdk;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class EndOfAnnOuterToMenuNotificationHandler:BaseHandler,INotificationHandler<EndOfAnnOuterToMenuNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class EndOfAnnOuterToMenuNotificationHandler : NewRockBaseHandler, INotificationHandler<EndOfAnnOuterToMenuNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
         private readonly IIvrDomainService _ivrDomainService;
-        public EndOfAnnOuterToMenuNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IIvrDomainService ivrDomainService, INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options,ICallCacheManager callCacheManager,IRealtimeService realtimeService) : base(newRockClient, options,callRepository,callCacheManager, realtimeService)
+        public EndOfAnnOuterToMenuNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IIvrDomainService ivrDomainService, INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> callcenterOptions, ICallCacheManager callCacheManager, IRealtimeService realtimeService) : base(newRockClient, callcenterOptions, callRepository, callCacheManager, realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -26,13 +27,13 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
 
         public async Task Handle(EndOfAnnOuterToMenuNotification notification, CancellationToken cancellationToken)
         {
-            var model =await _callRepository.GetAsync(
+            var model = await _callRepository.GetAsync(
                 x => x.ConversationId == notification.Outer.Id && x.FromNo == notification.Outer.From &&
-                     x.ToNo == notification.Outer.To && x.CreationTime >= DateTime.Now.AddHours(-2),true,x=>x.CreationTime, cancellationToken);
-            if (model!=null)
+                     x.ToNo == notification.Outer.To && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime, cancellationToken);
+            if (model != null)
             {
                 model.CallStatus = ECallStatus.EndOfAnn;
-                await _callRepository.UpdateAsync(model,cancellationToken);
+                await _callRepository.UpdateAsync(model, cancellationToken);
                 var detail = new CallDetail()
                 {
                     CallId = model.Id,
@@ -45,7 +46,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                 };
                 await _callDetailRepository.AddAsync(detail, cancellationToken);
 
-                var runModel = await _ivrDomainService.GetVoiceEndAnswerAsync(notification.MenuId,cancellationToken);
+                var runModel = await _ivrDomainService.GetVoiceEndAnswerAsync(notification.MenuId, cancellationToken);
 
                 await HandlerIvr(runModel, model, cancellationToken);
             }

+ 8 - 8
src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnVisitorToMenuNotificationHandler.cs

@@ -1,8 +1,8 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Ivrs;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
@@ -12,14 +12,14 @@ using NewRock.Sdk;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-
-    public class EndOfAnnVisitorToMenuNotificationHandler:BaseHandler,INotificationHandler<EndOfAnnVisitorToMenuNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class EndOfAnnVisitorToMenuNotificationHandler : NewRockBaseHandler, INotificationHandler<EndOfAnnVisitorToMenuNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
         private readonly IIvrDomainService _ivrDomainService;
 
-        public EndOfAnnVisitorToMenuNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IIvrDomainService ivrDomainService,INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options,ICallCacheManager callCacheManager,IRealtimeService realtimeService):base(newRockClient,options,callRepository,callCacheManager, realtimeService)
+        public EndOfAnnVisitorToMenuNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IIvrDomainService ivrDomainService, INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> callcenterOptions, ICallCacheManager callCacheManager, IRealtimeService realtimeService) : base(newRockClient, callcenterOptions, callRepository, callCacheManager, realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -30,10 +30,10 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         {
             var model = await _callRepository.GetAsync(
                 x => x.ConversationId == notification.Visitor.Id && x.FromNo == notification.Visitor.From &&
-                     x.ToNo == notification.Visitor.To && x.CreationTime >= DateTime.Now.AddHours(-2),true,x=>x.CreationTime,
+                     x.ToNo == notification.Visitor.To && x.CreationTime >= DateTime.Now.AddHours(-2), true, x => x.CreationTime,
                 cancellationToken);
 
-            if (model!=null)
+            if (model != null)
             {
                 model.CallStatus = ECallStatus.EndOfAnn;
                 await _callRepository.UpdateAsync(model, cancellationToken);
@@ -49,12 +49,12 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                 };
                 await _callDetailRepository.AddAsync(detail, cancellationToken);
 
-                var runModel = await _ivrDomainService.GetVoiceEndAnswerAsync(notification.MenuId,cancellationToken);
+                var runModel = await _ivrDomainService.GetVoiceEndAnswerAsync(notification.MenuId, cancellationToken);
 
                 await HandlerIvr(runModel, model, cancellationToken);
             }
 
-           
+
         }
     }
 }

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

@@ -1,7 +1,7 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Settings;
 using Hotline.Share.Enums.CallCenter;
@@ -19,6 +19,7 @@ using XF.Domain.Repository;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class IncomingNotificationHandler : INotificationHandler<IncomingNotification>
     {
         private readonly ICallRepository _callRepository;

+ 2 - 1
src/Hotline.Application/Handlers/CallCenter/FlowControl/InviteNotificationHandler.cs

@@ -2,7 +2,7 @@
 using Hotline.CallCenter.BlackLists;
 using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
+using Hotline.EventBus;
 using Hotline.Settings;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
@@ -15,6 +15,7 @@ using NewRock.Sdk.Control.Request;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class InviteNotificationHandler : INotificationHandler<InviteNotification>
     {
         private readonly ICallRepository _callRepository;

+ 5 - 3
src/Hotline.Application/Handlers/CallCenter/FlowControl/QueueVisitorToGroupBusyNotificationHandler.cs

@@ -1,19 +1,21 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    public class QueueVisitorToGroupBusyNotificationHandler:INotificationHandler<QueueVisitorToGroupBusyNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class QueueVisitorToGroupBusyNotificationHandler : INotificationHandler<QueueVisitorToGroupBusyNotification>
     {
         private readonly ICallCacheManager _callCacheManager;
         private readonly IRealtimeService _realtimeService;
 
-        public QueueVisitorToGroupBusyNotificationHandler(ICallCacheManager callCacheManager,IRealtimeService realtimeService)
+        public QueueVisitorToGroupBusyNotificationHandler(ICallCacheManager callCacheManager, IRealtimeService realtimeService)
         {
-            _callCacheManager= callCacheManager;
+            _callCacheManager = callCacheManager;
             _realtimeService = realtimeService;
         }
 

+ 10 - 5
src/Hotline.Application/Handlers/CallCenter/BaseHandler.cs → src/Hotline.Application/Handlers/CallCenter/NewRockBaseHandler.cs

@@ -1,7 +1,7 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
+using Hotline.EventBus;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.CallCenter;
 using Hotline.Share.Enums.CallCenter;
@@ -13,14 +13,19 @@ using NewRock.Sdk.Transfer.Queue.Request;
 
 namespace Hotline.Application.Handlers.CallCenter
 {
-    public class BaseHandler
+    public class NewRockBaseHandler
     {
         private readonly INewRockClient _newRockClient;
         private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
         private readonly ICallRepository _callRepository;
         private readonly ICallCacheManager _callCacheManager;
         private readonly IRealtimeService _realtimeService;
-        public BaseHandler(INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options,ICallRepository callRepository,ICallCacheManager callCacheManager,IRealtimeService realtimeService)
+        public NewRockBaseHandler(
+            INewRockClient newRockClient,
+            IOptionsSnapshot<CallCenterConfiguration> options,
+            ICallRepository callRepository,
+            ICallCacheManager callCacheManager,
+            IRealtimeService realtimeService)
         {
             _newRockClient = newRockClient;
             _options = options;
@@ -97,7 +102,7 @@ namespace Hotline.Application.Handlers.CallCenter
                         break;
                     case EIvrAnswerType.TelGroup:
                         var groupId = ivrAnswer.Content;
-                        model.InQueueTime= DateTime.Now;
+                        model.InQueueTime = DateTime.Now;
                         await _callRepository.UpdateAsync(model);
                         await _newRockClient.VisitorToGroupQueue(new VisitorToGroupQueueRequest()
                         {
@@ -110,7 +115,7 @@ namespace Hotline.Application.Handlers.CallCenter
                         _callCacheManager.AddCallCache(model);
                         await _realtimeService.CallQueueAsync(_callCacheManager.GetCallQueueList(), cancellationToken);
                         break;
-                        
+
                     case EIvrAnswerType.Out:
                         var phoneNo = ivrAnswer.Content;
                         switch (model.CallType)

+ 18 - 8
src/Hotline.Application/Handlers/CallCenter/System/BootupNotificationHandler.cs

@@ -3,29 +3,39 @@ using Hotline.CallCenter.Configs;
 using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Ivrs;
 using Hotline.CallCenter.Tels;
+using Hotline.EventBus;
+using Hotline.NewRock;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
+using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Options;
 
 namespace Hotline.Application.Handlers.CallCenter.System
 {
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class BootupNotificationHandler : INotificationHandler<BootupNotification>
     {
         private readonly ITelGroupRepository _telGroupRepository;
         private readonly IIvrRepository _ivrRepository;
-        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
-        private readonly IDeviceManager _deviceManager;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
+        private readonly INewRockDeviceManager _newRockDeviceManager;
         private readonly IUserCacheManager _userCacheManager;
 
-        public BootupNotificationHandler(ITelGroupRepository telGroupRepository, IDeviceManager deviceManager,
+        public BootupNotificationHandler(
+            IServiceProvider serviceProvider,
+            ITelGroupRepository telGroupRepository,
             IUserCacheManager userCacheManager, IIvrRepository ivrRepository,
-            IOptionsSnapshot<CallCenterConfiguration> options)
+            IOptionsSnapshot<AppConfiguration> appOptions,
+            IOptionsSnapshot<CallCenterConfiguration> callcenterOptions)
         {
             _telGroupRepository = telGroupRepository;
-            _deviceManager = deviceManager;
             _userCacheManager = userCacheManager;
             _ivrRepository = ivrRepository;
-            _options = options;
+            _callcenterOptions = callcenterOptions;
+            if (appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XunShi)
+            {
+                _newRockDeviceManager = serviceProvider.GetRequiredService<INewRockDeviceManager>();
+            }
         }
 
         public async Task Handle(BootupNotification notification, CancellationToken cancellationToken)
@@ -44,7 +54,7 @@ namespace Hotline.Application.Handlers.CallCenter.System
 
                 }
                 //轮循还原设备分机组信息
-                await _deviceManager.AssginConfigGroupAsync(_options.Value.NewRock, groupItem.No, groupItem.Distribution, exts, groupItem.Voice,
+                await _newRockDeviceManager.AssginConfigGroupAsync(_callcenterOptions.Value.NewRock, groupItem.No, groupItem.Distribution, exts, groupItem.Voice,
                     cancellationToken);
             }
 
@@ -55,7 +65,7 @@ namespace Hotline.Application.Handlers.CallCenter.System
             var ivrlist = await _ivrRepository.QueryAsync();
             foreach (var item in ivrlist)
             {
-                await _deviceManager.AssginConfigMenuAsync(_options.Value.NewRock, item.No, item.Voice, item.Repeat.ToString(), item.InfoLength.ToString(), item.Exit, cancellationToken);
+                await _newRockDeviceManager.AssginConfigMenuAsync(_callcenterOptions.Value.NewRock, item.No, item.Voice, item.Repeat.ToString(), item.InfoLength.ToString(), item.Exit, cancellationToken);
             }
             #endregion
 

+ 4 - 2
src/Hotline.Application/Handlers/CallCenter/Transient/TransientOuterNotificationHandler.cs

@@ -1,5 +1,6 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using Hotline.Tools;
@@ -7,7 +8,8 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.Transient
 {
-    public class TransientOuterNotificationHandler:INotificationHandler<TransientOuterNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class TransientOuterNotificationHandler : INotificationHandler<TransientOuterNotification>
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
@@ -46,7 +48,7 @@ namespace Hotline.Application.Handlers.CallCenter.Transient
                     CallStatus = ECallStatus.ExtOuterReady,
                     ConversationId = notification.Outer.Id,
                     OMCallId = notification.Outer.CallId,
-                    EventName =  "ExtOuterReady", //去电
+                    EventName = "ExtOuterReady", //去电
                     FromNo = notification.Outer.From,
                     ToNo = notification.Outer.To,
                 };

+ 3 - 1
src/Hotline.Application/Handlers/CallCenter/Transient/TransinetVisitorNotificationHandler.cs

@@ -1,10 +1,12 @@
 using Hotline.CallCenter.Calls;
+using Hotline.EventBus;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.Transient
 {
-    public class TransinetVisitorNotificationHandler:INotificationHandler<TransientVisitorNotification>
+    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    public class TransinetVisitorNotificationHandler : INotificationHandler<TransientVisitorNotification>
     {
         private readonly ICallRepository _callRepository;
 

+ 6 - 57
src/Hotline.Application/Handlers/FlowEngine/WorkflowEndHandler.cs

@@ -2,10 +2,6 @@
 using Hotline.Application.CallCenter;
 using Hotline.Application.JudicialManagement;
 using Hotline.Application.Orders;
-using Hotline.Application.Quality;
-using Hotline.Article;
-using Hotline.Caching.Interfaces;
-using Hotline.CallCenter.Configs;
 using Hotline.CallCenter.Tels;
 using Hotline.EventBus;
 using Hotline.FlowEngine.Notifications;
@@ -23,7 +19,6 @@ using MapsterMapper;
 using MediatR;
 using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Options;
-using XF.Domain.Authentications;
 using XF.Domain.Repository;
 
 namespace Hotline.Application.Handlers.FlowEngine;
@@ -38,28 +33,13 @@ public class WorkflowEndHandler : INotificationHandler<EndWorkflowNotify>
     private readonly IOrderRepository _orderRepository;
     private readonly ICapPublisher _capPublisher;
     private readonly IMapper _mapper;
-    private readonly IRepository<OrderVisitDetail> _orderVisitedDetailRepository;
-    private readonly IRepository<OrderScreen> _orderScreenRepository;
-    private readonly IRepository<Circular> _circularRepository;
-    private readonly IRepositorySqlSugar<CircularReadGroup> _circularReadGroupRepository;
-    private readonly IRepositorySqlSugar<CircularRecord> _circularRecordRepository;
-    private readonly ICircularRecordDomainService _circularRecordDomainService;
-    private readonly IRepository<OrderVisit> _orderVisitRepository;
     private readonly IRepository<OrderDelay> _orderDelayRepository;
-    private readonly IRepository<OrderVisitApply> _orderVisitApplyRepository;
     private readonly ITimeLimitDomainService _timeLimitDomainService;
-    private readonly IMediator _mediator;
     private readonly ILogger<WorkflowEndHandler> _logger;
     private readonly IKnowledgeRepository _knowledgeRepository;
-    private readonly IKnowledgeWorkFlowRepository _knowledgeWorkFlowRepository;
-    private readonly IQualityApplication _qualityApplication;
     private readonly IEnforcementApplication _enforcementApplication;
     private readonly ICallApplication _callApplication;
-    private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
-    private readonly ISessionContext _sessionContext;
-    private readonly IRepository<OrderScreenDetail> _orderScreenDetailRepository;
-    private readonly Publisher _publisher;
-    private readonly ISystemSettingCacheManager _systemSettingCacheManager;
+    private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
 
     public WorkflowEndHandler(
         IKnowledgeDomainService knowledgeDomainService,
@@ -69,29 +49,13 @@ public class WorkflowEndHandler : INotificationHandler<EndWorkflowNotify>
         IOrderRepository orderRepository,
         ICapPublisher capPublisher,
         IMapper mapper,
-        IRepository<OrderVisitDetail> orderVisitedDetailRepository,
-        IRepository<OrderScreen> orderScreenRepository,
-        IRepository<Bulletin> bulletinRepository,
-        IRepository<Circular> circularRepository,
-        IRepository<CircularReadGroup> circularReadGroupRepository,
-        IRepository<CircularRecord> circularRecordRepository,
-        ICircularRecordDomainService circularRecordDomainService,
         IRepository<OrderDelay> orderDelayRepository,
-        IRepository<OrderVisit> orderVisitRepository,
-        IRepository<OrderVisitApply> orderVisitApplyRepository,
         ITimeLimitDomainService timeLimitDomainService,
-        IMediator mediator,
         IKnowledgeRepository knowledgeRepository,
-        IKnowledgeWorkFlowRepository knowledgeWorkFlowRepository,
         ILogger<WorkflowEndHandler> logger,
-         IQualityApplication qualityApplication,
         IEnforcementApplication enforcementApplication,
         ICallApplication callApplication,
-        IOptionsSnapshot<CallCenterConfiguration> callcenterOptions,
-        ISessionContext sessionContext,
-        IRepository<OrderScreenDetail> orderScreenDetailRepository,
-        Publisher publisher,
-        ISystemSettingCacheManager systemSettingCacheManager)
+        IOptionsSnapshot<AppConfiguration> appOptions)
     {
         _knowledgeDomainService = knowledgeDomainService;
         _orderDomainService = orderDomainService;
@@ -100,28 +64,13 @@ public class WorkflowEndHandler : INotificationHandler<EndWorkflowNotify>
         _orderRepository = orderRepository;
         _capPublisher = capPublisher;
         _mapper = mapper;
-        _orderScreenRepository = orderScreenRepository;
-        _orderVisitedDetailRepository = orderVisitedDetailRepository;
-        _circularRepository = circularRepository;
-        _circularReadGroupRepository = circularReadGroupRepository;
-        _circularRecordRepository = circularRecordRepository;
-        _circularRecordDomainService = circularRecordDomainService;
         _orderDelayRepository = orderDelayRepository;
-        _orderVisitRepository = orderVisitRepository;
-        _orderVisitApplyRepository = orderVisitApplyRepository;
         _timeLimitDomainService = timeLimitDomainService;
-        _mediator = mediator;
         _logger = logger;
         _knowledgeRepository = knowledgeRepository;
-        _knowledgeWorkFlowRepository = knowledgeWorkFlowRepository;
-        _qualityApplication = qualityApplication;
         _enforcementApplication = enforcementApplication;
         _callApplication = callApplication;
-        _callcenterOptions = callcenterOptions;
-        _sessionContext = sessionContext;
-        _orderScreenDetailRepository = orderScreenDetailRepository;
-        _publisher = publisher;
-        _systemSettingCacheManager = systemSettingCacheManager;
+        _appOptions = appOptions;
     }
 
     /// <summary>Handles a notification</summary>
@@ -206,7 +155,7 @@ public class WorkflowEndHandler : INotificationHandler<EndWorkflowNotify>
                     {
                         order.FileUserRole = EFileUserType.Org;
                     }
-                    
+
                     //是否已解决
                     order.IsResolved = notification.Dto.External == null ? false : notification.Dto.External.IsResolved;
 
@@ -225,7 +174,7 @@ public class WorkflowEndHandler : INotificationHandler<EndWorkflowNotify>
                     if (order.SourceChannelCode == AppDefaults.SourceChannel.DianHua &&
                         !string.IsNullOrEmpty(order.CallId))
                     {
-                        if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+                        if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
                         {
                             // var callRecord = await _trCallRecordRepository.GetAsync(p => p.OtherAccept == order.CallId, cancellationToken);
                             var callRecord = await _callApplication.GetTianrunCallAsync(order.CallId, cancellationToken);
@@ -234,7 +183,7 @@ public class WorkflowEndHandler : INotificationHandler<EndWorkflowNotify>
                                 orderFlowDto.TrCallRecordDto = _mapper.Map<TrCallDto>(callRecord);
                             }
                         }
-                        else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+                        else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
                         {
                             var call = await _callApplication.GetCallAsync(order.CallId, cancellationToken);
                             if (call is not null)

+ 8 - 23
src/Hotline.Application/Handlers/FlowEngine/WorkflowStartHandler.cs

@@ -1,26 +1,21 @@
 using DotNetCore.CAP;
 using Hotline.Application.CallCenter;
 using Hotline.Application.Quality;
-using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Tels;
 using Hotline.FlowEngine.Notifications;
 using Hotline.FlowEngine.WorkflowModules;
-using Hotline.FlowEngine.Workflows;
 using Hotline.KnowledgeBase;
 using Hotline.Orders;
 using Hotline.Push.Notifies;
 using Hotline.Share.Dtos.FlowEngine.Workflow;
 using Hotline.Share.Dtos.Order;
 using Hotline.Share.Dtos.TrCallCenter;
-using Hotline.Share.Enums.KnowledgeBase;
 using Hotline.Share.Enums.Push;
 using Hotline.Share.Enums.Quality;
 using Hotline.Share.Mq;
 using Hotline.Users;
 using MapsterMapper;
 using MediatR;
-using Microsoft.AspNetCore.Http;
 using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Options;
 using XF.Domain.Entities;
@@ -32,57 +27,47 @@ namespace Hotline.Application.Handlers.FlowEngine
     {
         private readonly IOrderDomainService _orderDomainService;
         private readonly IKnowledgeDomainService _knowledgeDomainService;
-        private readonly ITelDomainService _telDomainService;
         private readonly IOrderRepository _orderRepository;
         private readonly ICapPublisher _capPublisher;
         private readonly IMapper _mapper;
         private readonly ILogger<WorkflowStartHandler> _logger;
         private readonly IQualityApplication _qualityApplication;
         // private readonly IRepository<TrCallRecord> _trCallRecordRepository;
-        private readonly IOrderScreenRepository _orderScreenRepository;
         private readonly IOrderDelayRepository _orderDelayRepository;
         private readonly IRepository<User> _userRepository;
         private readonly ICallApplication _callApplication;
-        private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
+        private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
         private readonly IMediator _mediator;
-        private readonly IKnowledgeRepository _knowledgeRepository;
 
-		public WorkflowStartHandler(
+        public WorkflowStartHandler(
             IOrderDomainService orderDomainService,
             IKnowledgeDomainService knowledgeDomainService,
-            ITelDomainService telDomainService,
             IOrderRepository orderRepository,
             ICapPublisher capPublisher,
             IQualityApplication qualityApplication,
             IMapper mapper,
             ILogger<WorkflowStartHandler> logger,
-            // IRepository<TrCallRecord> trCallRecordRepository,
-            IOrderScreenRepository orderScreenRepository,
             IOrderDelayRepository orderDelayRepository,
             IRepository<User> userRepository,
             ICallApplication callApplication,
-            IOptionsSnapshot<CallCenterConfiguration> callcenterOptions,
-            IMediator mediator,
-            IKnowledgeRepository knowledgeRepository
+            IOptionsSnapshot<AppConfiguration> appOptions,
+            IMediator mediator
 		)
         {
             _orderDomainService = orderDomainService;
             _knowledgeDomainService = knowledgeDomainService;
-            _telDomainService = telDomainService;
             _orderRepository = orderRepository;
             _capPublisher = capPublisher;
             _qualityApplication = qualityApplication;
             _mapper = mapper;
             _logger = logger;
             // _trCallRecordRepository = trCallRecordRepository;
-            _orderScreenRepository = orderScreenRepository;
             _orderDelayRepository = orderDelayRepository;
             _userRepository = userRepository;
             _callApplication = callApplication;
-            _callcenterOptions = callcenterOptions;
+            _appOptions = appOptions;
             _mediator = mediator;
-            _knowledgeRepository = knowledgeRepository;
-		}
+        }
 
         /// <summary>Handles a notification</summary>
         /// <param name="notification">The notification</param>
@@ -121,7 +106,7 @@ namespace Hotline.Application.Handlers.FlowEngine
                         if (order.SourceChannelCode == AppDefaults.SourceChannel.DianHua &&
                             !string.IsNullOrEmpty(order.CallId))
                         {
-                            if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+                            if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
                             {
                                 // var callRecord = await _trCallRecordRepository.GetAsync(p => p.OtherAccept == order.CallId, cancellationToken);
                                 var callRecord = await _callApplication.GetTianrunCallAsync(order?.CallId, cancellationToken);
@@ -130,7 +115,7 @@ namespace Hotline.Application.Handlers.FlowEngine
                                     publishCallRecordDto.TrCallRecordDto = _mapper.Map<TrCallDto>(callRecord);
                                 }
                             }
-                            else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+                            else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
                             {
                                 var call = await _callApplication.GetCallAsync(order?.CallId, cancellationToken);
                                 if (call is not null)

+ 5 - 5
src/Hotline.Application/Quality/QualityApplication.cs

@@ -41,7 +41,7 @@ namespace Hotline.Application.Quality
         private readonly ISystemSettingCacheManager _systemSettingCacheManager;
         private readonly ILogger<Hotline.Quality.Quality> _logger;
         private readonly ICallApplication _callApplication;
-        private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
+        private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
         private readonly Publisher _publisher;
         private readonly IRepository<TrCallRecord> _trCallRecordRepository;
 
@@ -56,7 +56,7 @@ namespace Hotline.Application.Quality
             IOrderRepository orderRepository,
             ISystemSettingCacheManager systemSettingCacheManager,
             ICallApplication callApplication,
-            IOptionsSnapshot<CallCenterConfiguration> callcenterOptions,
+            IOptionsSnapshot<AppConfiguration> appOptions,
             ILogger<Hotline.Quality.Quality> logger,
             Publisher publisher,
             IRepository<TrCallRecord> trCallRecordRepository)
@@ -71,7 +71,7 @@ namespace Hotline.Application.Quality
             _orderRepository = orderRepository;
             _systemSettingCacheManager = systemSettingCacheManager;
             _callApplication = callApplication;
-            _callcenterOptions = callcenterOptions;
+            _appOptions = appOptions;
             _logger = logger;
             _publisher = publisher;
             _trCallRecordRepository = trCallRecordRepository;
@@ -167,14 +167,14 @@ namespace Hotline.Application.Quality
                     var audioFile = string.Empty;
                     var fromNo = string.Empty;
                     DateTime? callStartTime = null;
-                    if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.TianRun)
+                    if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
                     {
                         var call = await _callApplication.GetTianrunCallAsync(order.CallId, cancellationToken);
                         audioFile = call.RecordingAbsolutePath;
                         fromNo = call.CPN;
                         callStartTime = call.CreatedTime;
                     }
-                    else if (_callcenterOptions.Value.CallCenterType == AppDefaults.CallCenterType.XingTang)
+                    else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
                     {
                         var call = await _callApplication.GetCallAsync(order.CallId, cancellationToken);
                         audioFile = call.AudioFile;

+ 0 - 1
src/Hotline.NewRock/Handlers/DeviceEventHandler.cs

@@ -1,7 +1,6 @@
 using System.Security.Authentication;
 using Hotline.CallCenter;
 using Hotline.CallCenter.Configs;
-using Hotline.CallCenter.Devices;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MapsterMapper;
 using MediatR;

+ 3 - 3
src/Hotline.NewRock/DeviceManager.cs → src/Hotline.NewRock/NewRockDeviceManager.cs

@@ -1,5 +1,4 @@
 using Hotline.CallCenter.Calls;
-using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Tels;
 using MapsterMapper;
 using Microsoft.Extensions.Options;
@@ -19,11 +18,12 @@ using Hotline.Share.Dtos.CallCenter;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Configs;
+using Hotline.CallCenter.Devices;
 using Group = NewRock.Sdk.Control.Request.Group;
 
 namespace Hotline.NewRock
 {
-    public class DeviceManager : IDeviceManager, IScopeDependency
+    public class NewRockDeviceManager : INewRockDeviceManager
     {
         private readonly INewRockClient _newRockClient;
         private readonly ICallRepository _callRepository;
@@ -34,7 +34,7 @@ namespace Hotline.NewRock
         private readonly ITelRestRepository _telRestRepository;
         private readonly ITelCacheManager _telCacheManager;
 
-        public DeviceManager(
+        public NewRockDeviceManager(
             INewRockClient newRockClient, 
             //IOptionsSnapshot<CallCenterConfiguration> options, 
             IMapper mapper, 

+ 1 - 3
src/Hotline.NewRock/NewRockStartupExtensions.cs

@@ -2,10 +2,8 @@
 using Hotline.CallCenter.Devices;
 using Hotline.NewRock.Mappers;
 using Mapster;
-using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using NewRock.Sdk;
-using XF.Domain.Options;
 
 namespace Hotline.NewRock
 {
@@ -15,7 +13,7 @@ namespace Hotline.NewRock
         {
             services
                 .AddNewRockSdk(newrockConfig.Address)
-                //.AddScoped<IDeviceManager, DeviceManager>()
+                .AddScoped<INewRockDeviceManager, NewRockDeviceManager>()
                 ;
 
             TypeAdapterConfig.GlobalSettings.Scan(typeof(EventConfigs).Assembly);

+ 46 - 0
src/Hotline/AppConfiguration.cs

@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline
+{
+    public class AppConfiguration
+    {
+        public string AppScope { get; set; }
+        public YiBinConfiguration YiBin { get; set; }
+        public ZiGongConfiguration ZiGong { get; set; }
+        public LuZhouConfiguration LuZhou { get; set; }
+
+        public DefaultAppScopeConfiguration GetDefaultAppScopeConfiguration()
+        {
+            return AppScope switch
+            {
+                AppDefaults.AppScope.YiBin => YiBin,
+                AppDefaults.AppScope.ZiGong => ZiGong,
+                AppDefaults.AppScope.LuZhou => LuZhou,
+                _ => throw new ArgumentOutOfRangeException()
+            };
+        }
+    }
+
+    public class YiBinConfiguration : DefaultAppScopeConfiguration
+    {
+    }
+
+    public class ZiGongConfiguration : DefaultAppScopeConfiguration
+    {
+
+    }
+
+    public class LuZhouConfiguration : DefaultAppScopeConfiguration
+    {
+
+    }
+
+    public abstract class DefaultAppScopeConfiguration
+    {
+        public string CallCenterType { get; set; }
+    }
+}

+ 22 - 18
src/Hotline/CallCenter/Calls/CallDomainService.cs

@@ -1,28 +1,34 @@
 using Hotline.CallCenter.Configs;
 using Hotline.CallCenter.Devices;
 using Hotline.Share.Requests;
+using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Options;
 using XF.Domain.Dependency;
+using static Hotline.AppDefaults;
 
 namespace Hotline.CallCenter.Calls
 {
     public class CallDomainService : ICallDomainService, IScopeDependency
     {
-        private readonly IDeviceManager _deviceManager;
+        private readonly INewRockDeviceManager _newRockDeviceManager;
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
-        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
 
         public CallDomainService(
-            IDeviceManager deviceManager, 
+            IServiceProvider serviceProvider,
             ICallRepository callRepository, 
             ICallDetailRepository callDetailRepository,
-            IOptionsSnapshot<CallCenterConfiguration> options)
+            IOptionsSnapshot<AppConfiguration> appOptions,
+            IOptionsSnapshot<CallCenterConfiguration> callcenterOptions)
         {
-            _deviceManager = deviceManager;
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
-            _options = options;
+            _callcenterOptions = callcenterOptions;
+            if (appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XunShi)
+            {
+                _newRockDeviceManager = serviceProvider.GetRequiredService<INewRockDeviceManager>();
+            }
         }
 
         #region 来电
@@ -34,7 +40,7 @@ namespace Hotline.CallCenter.Calls
         public async Task VisitorToTelAsync(VisitorIdToTelRequest request, CancellationToken cancellationToken)
         {
             ////调用设备拨打电话
-            //await _deviceManager.VisitorToExtAsync(request.VisitorId, request.ToExtId, cancellationToken);
+            //await _newRockDeviceManager.VisitorToExtAsync(request.VisitorId, request.ToExtId, cancellationToken);
             //var model = await _callRepository.GetAsync(x =>
             //    x.CallType == ECallType.VisitorToExt && x.ConversationId == request.VisitorId &&
             //    x.ToNo == request.ToExtId && x.CallStatus != ECallStatus.Bye && x.CallStatus != ECallStatus.Failed, cancellationToken);
@@ -68,7 +74,7 @@ namespace Hotline.CallCenter.Calls
         public async Task VisitorToOuterAsync(VisitorToOuterRequest request, CancellationToken cancellationToken)
         {
             //调用设备接口转外线
-            await _deviceManager.VisitorToOuterAsync(_options.Value.NewRock, request.VisitorId, request.OuterPhoneNum, cancellationToken);
+            await _newRockDeviceManager.VisitorToOuterAsync(_callcenterOptions.Value.NewRock, request.VisitorId, request.OuterPhoneNum, cancellationToken);
             //写入数据库通话记录
         }
 
@@ -81,7 +87,7 @@ namespace Hotline.CallCenter.Calls
         public async Task VisitorToIvrAsync(VisitorToIvrRequest request, CancellationToken cancellationToken)
         {
             //调用设备接口转语音菜单
-            await _deviceManager.VisitorToMenuAsync(_options.Value.NewRock, request.VisitorId, request.MenuId, cancellationToken);
+            await _newRockDeviceManager.VisitorToMenuAsync(_callcenterOptions.Value.NewRock, request.VisitorId, request.MenuId, cancellationToken);
             //写入数据库通话记录
         }
 
@@ -93,7 +99,7 @@ namespace Hotline.CallCenter.Calls
         /// <returns></returns>
         public async Task VisitorToTelGroupAsync(VisitorToTelGroupRequest request, CancellationToken cancellationToken)
         {
-            await _deviceManager.VisitorToGroupAsync(_options.Value.NewRock, request.VisitorId, request.GroupId, cancellationToken);
+            await _newRockDeviceManager.VisitorToGroupAsync(_callcenterOptions.Value.NewRock, request.VisitorId, request.GroupId, cancellationToken);
             //写入数据库通话记录
         }
 
@@ -128,12 +134,10 @@ namespace Hotline.CallCenter.Calls
             //};
             //await _callDetailRepository.AddAsync(detail, cancellationToken);
             //调用设备拨打电话
-            await _deviceManager.ExtToOuterAsync(_options.Value.NewRock, request.ExtId, request.OuterPhoneNum, cancellationToken);
+            await _newRockDeviceManager.ExtToOuterAsync(_callcenterOptions.Value.NewRock, request.ExtId, request.OuterPhoneNum, cancellationToken);
         }
 
         #endregion
-        
-        
 
         #region 来电受理
 
@@ -146,7 +150,7 @@ namespace Hotline.CallCenter.Calls
         public async Task AcceptVisitorAsync(AcceptVisitorRequest request, CancellationToken cancellationToken)
         {
             //调用设备受理
-            await _deviceManager.AcceptVisitorAsync(_options.Value.NewRock, request.VisitorId, cancellationToken);
+            await _newRockDeviceManager.AcceptVisitorAsync(_callcenterOptions.Value.NewRock, request.VisitorId, cancellationToken);
         }
 
         #endregion
@@ -161,7 +165,7 @@ namespace Hotline.CallCenter.Calls
         /// <returns></returns>
         public async Task MonitorExt(MonitorExtRequest request,CancellationToken cancellationToken)
         {
-            await _deviceManager.MonitorExtAsync(_options.Value.NewRock, request.firstTelNo, request.secondTelNo, cancellationToken);
+            await _newRockDeviceManager.MonitorExtAsync(_callcenterOptions.Value.NewRock, request.firstTelNo, request.secondTelNo, cancellationToken);
         }
 
         /// <summary>
@@ -175,7 +179,7 @@ namespace Hotline.CallCenter.Calls
         /// <returns></returns>
         public async Task MonitorExtToTalk(MonitorExtToTalkRequest request,CancellationToken cancellationToken)
         {
-            await _deviceManager.MonitorExtToTalkAsync(_options.Value.NewRock, request.telNo, cancellationToken);
+            await _newRockDeviceManager.MonitorExtToTalkAsync(_callcenterOptions.Value.NewRock, request.telNo, cancellationToken);
         }
 
         /// <summary>
@@ -189,7 +193,7 @@ namespace Hotline.CallCenter.Calls
         /// <returns></returns>
         public async Task MonitorExtToListen(MonitorExtToListenRequest request,CancellationToken cancellationToken)
         {
-            await _deviceManager.MonitorExtToListenAsync(_options.Value.NewRock, request.telNo, cancellationToken);
+            await _newRockDeviceManager.MonitorExtToListenAsync(_callcenterOptions.Value.NewRock, request.telNo, cancellationToken);
         }
 
         #endregion
@@ -207,7 +211,7 @@ namespace Hotline.CallCenter.Calls
         /// <returns></returns>
         public async Task BargeinExt(BargeinExtRequest request,CancellationToken cancellationToken)
         {
-            await _deviceManager.BargeinExtAsync(_options.Value.NewRock, request.firstTelNo, request.secondTelNo, cancellationToken);
+            await _newRockDeviceManager.BargeinExtAsync(_callcenterOptions.Value.NewRock, request.firstTelNo, request.secondTelNo, cancellationToken);
         }
 
         #endregion

+ 0 - 2
src/Hotline/CallCenter/Configs/CallCenterConfiguration.cs

@@ -2,8 +2,6 @@
 
 public class CallCenterConfiguration
 {
-    public string CallCenterType { get; set; }
-
     public NewRockConfiguration NewRock { get; set; }
 
     public WexConfiguration Wex { get; set; }

+ 1 - 3
src/Hotline/CallCenter/Devices/IDeviceManager.cs → src/Hotline/CallCenter/Devices/INewRockDeviceManager.cs

@@ -5,7 +5,7 @@ using Hotline.Share.Enums.CallCenter;
 
 namespace Hotline.CallCenter.Devices
 {
-    public interface IDeviceManager
+    public interface INewRockDeviceManager
     {
         #region 查询
 
@@ -325,7 +325,6 @@ namespace Hotline.CallCenter.Devices
 
         #endregion
 
-
         #region 监听和插播
 
         /// <summary>
@@ -364,7 +363,6 @@ namespace Hotline.CallCenter.Devices
 
         #endregion
 
-
         #region 强插
 
         /// <summary>

+ 13 - 8
src/Hotline/CallCenter/Ivrs/IvrDomainService.cs

@@ -5,6 +5,7 @@ using Hotline.Settings;
 using Hotline.Share.Dtos.CallCenter;
 using Hotline.Share.Enums.CallCenter;
 using MapsterMapper;
+using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Options;
 using XF.Domain.Cache;
@@ -16,7 +17,7 @@ namespace Hotline.CallCenter.Ivrs;
 
 public class IvrDomainService : IIvrDomainService, IScopeDependency
 {
-    private readonly IDeviceManager _deviceManager;
+    private readonly INewRockDeviceManager _newRockDeviceManager;
     private readonly IIvrRepository _ivrRepository;
     private readonly ITypedCache<List<Ivr>> _cacheIvrList;
     private readonly IIvrCacheManager _ivrCacheManager;
@@ -25,11 +26,11 @@ public class IvrDomainService : IIvrDomainService, IScopeDependency
     private readonly IMapper _mapper;
     private readonly ILogger<IvrDomainService> _logger;
     private readonly ITypedCache<List<TrunkIvrManager>> _worktimeCache;
-    private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
+    private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
     private readonly IRepository<TrunkIvrManager> _trunkIvrManagerRepository;
 
     public IvrDomainService(
-        IDeviceManager deviceManager,
+        IServiceProvider serviceProvider,
         IIvrRepository ivrRepository,
         ITypedCache<List<Ivr>> cacheIvrList,
         IIvrCacheManager ivrCacheManager,
@@ -38,10 +39,10 @@ public class IvrDomainService : IIvrDomainService, IScopeDependency
         IMapper mapper,
         ILogger<IvrDomainService> logger,
         ITypedCache<List<TrunkIvrManager>> worktimeCache,
-        IOptionsSnapshot<CallCenterConfiguration> options,
+        IOptionsSnapshot<AppConfiguration> appOptions,
+        IOptionsSnapshot<CallCenterConfiguration> callcenterOptions,
         IRepository<TrunkIvrManager> trunkIvrManagerRepository)
     {
-        _deviceManager = deviceManager;
         _ivrRepository = ivrRepository;
         _cacheIvrList = cacheIvrList;
         _ivrCacheManager = ivrCacheManager;
@@ -50,8 +51,12 @@ public class IvrDomainService : IIvrDomainService, IScopeDependency
         _mapper = mapper;
         _logger = logger;
         _worktimeCache = worktimeCache;
-        _options = options;
+        _callcenterOptions = callcenterOptions;
         _trunkIvrManagerRepository = trunkIvrManagerRepository;
+        if (appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XunShi)
+        {
+            _newRockDeviceManager = serviceProvider.GetRequiredService<INewRockDeviceManager>();
+        }
     }
 
     /// <summary>
@@ -169,7 +174,7 @@ public class IvrDomainService : IIvrDomainService, IScopeDependency
         if (existNo)
             throw new UserFriendlyException("IVR编号已存在");
 
-        await _deviceManager.AssginConfigMenuAsync(_options.Value.NewRock, ivr.No, ivr.Voice, ivr.Repeat.ToString(), ivr.InfoLength.ToString(), ivr.Exit, cancellationToken);
+        await _newRockDeviceManager.AssginConfigMenuAsync(_callcenterOptions.Value.NewRock, ivr.No, ivr.Voice, ivr.Repeat.ToString(), ivr.InfoLength.ToString(), ivr.Exit, cancellationToken);
 
         var exists = await _ivrRepository.AnyAsync(d => d.IvrCategoryId == ivr.IvrCategoryId, cancellationToken);
         ivr.IsRoot = !exists;
@@ -180,7 +185,7 @@ public class IvrDomainService : IIvrDomainService, IScopeDependency
 
     public async Task UpdateIvrAsync(Ivr ivr, CancellationToken cancellationToken = default)
     {
-        await _deviceManager.AssginConfigMenuAsync(_options.Value.NewRock, ivr.No, ivr.Voice, ivr.Repeat.ToString(), ivr.InfoLength.ToString(), ivr.Exit, cancellationToken);
+        await _newRockDeviceManager.AssginConfigMenuAsync(_callcenterOptions.Value.NewRock, ivr.No, ivr.Voice, ivr.Repeat.ToString(), ivr.InfoLength.ToString(), ivr.Exit, cancellationToken);
 
         await _ivrRepository.UpdateWithoutStrategiesAsync(ivr, cancellationToken);
         _cacheIvrList.Remove(Ivr.Key);

+ 16 - 7
src/Hotline/CallCenter/Manage/VoiceFileDomainService.cs

@@ -1,6 +1,7 @@
 using Hotline.CallCenter.Configs;
 using Hotline.CallCenter.Devices;
 using Hotline.Share.Requests;
+using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Options;
 using XF.Domain.Dependency;
 
@@ -8,13 +9,21 @@ namespace Hotline.CallCenter.Manage
 {
     public class VoiceFileDomainService:IVoiceFileDomainService, IScopeDependency
     {
-        private readonly IDeviceManager _deviceManager;
-        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
+        private readonly INewRockDeviceManager _newRockDeviceManager;
+        private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
 
-        public VoiceFileDomainService(IDeviceManager deviceManager, IOptionsSnapshot<CallCenterConfiguration> options)
+        public VoiceFileDomainService(
+            IServiceProvider serviceProvider,
+            IOptionsSnapshot<AppConfiguration> appOptions,
+            IOptionsSnapshot<CallCenterConfiguration> callcenterOptions)
         {
-            _deviceManager = deviceManager;
-            _options = options;
+            _appOptions = appOptions;
+            _callcenterOptions = callcenterOptions;
+            if (appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XunShi)
+            {
+                _newRockDeviceManager = serviceProvider.GetRequiredService<INewRockDeviceManager>();
+            }
         }
 
         /// <summary>
@@ -24,7 +33,7 @@ namespace Hotline.CallCenter.Manage
         /// <returns></returns>
         public async Task<List<string>> VoiceQueryListAsync(CancellationToken cancellationToken)
         {
-            var result = await _deviceManager.VoiceQueryListAsync(_options.Value.NewRock, cancellationToken);
+            var result = await _newRockDeviceManager.VoiceQueryListAsync(_callcenterOptions.Value.NewRock, cancellationToken);
             var list =  result.Replace(".dat","").Replace(".pcm","").Split("|").ToList();
 
             return list.Distinct().ToList();
@@ -38,7 +47,7 @@ namespace Hotline.CallCenter.Manage
         /// <returns></returns>
         public async Task RemoveVoiceFileAsync(RemoveVoiceFileRequest request, CancellationToken cancellationToken)
         {
-            await _deviceManager.RemoveVoiceFileAsync(_options.Value.NewRock, request.VoiceFileNames, cancellationToken);
+            await _newRockDeviceManager.RemoveVoiceFileAsync(_callcenterOptions.Value.NewRock, request.VoiceFileNames, cancellationToken);
         }
 
 

+ 28 - 19
src/Hotline/CallCenter/Tels/TelDomainService.cs

@@ -11,35 +11,44 @@ using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Configs;
 using Microsoft.Extensions.Options;
 using Hotline.Share.Dtos.CallCenter;
+using Microsoft.Extensions.DependencyInjection;
 
 namespace Hotline.CallCenter.Tels;
 
 public class TelDomainService : ITelDomainService, IScopeDependency
 {
-    private readonly IDeviceManager _deviceManager;
+    private readonly INewRockDeviceManager _newRockDeviceManager;
     private readonly ITelRepository _telRepository;
     private readonly ITelRestRepository _telRestRepository;
     private readonly ITelHoldRepository _telHoldRepository;
     private readonly IRealtimeService _realtimeService;
     private readonly ITelCacheManager _telCacheManager;
-    private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
+    private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
+    private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
+    private readonly string _callcenterType;
 
     public TelDomainService(
-        IDeviceManager deviceManager,
+        IServiceProvider serviceProvider,
         ITelRepository telRepository,
         ITelRestRepository telRestRepository,
         ITelHoldRepository telHoldRepository,
         IRealtimeService realtimeService,
         ITelCacheManager telCacheManager,
-        IOptionsSnapshot<CallCenterConfiguration> options)
+        IOptionsSnapshot<AppConfiguration> appOptions,
+        IOptionsSnapshot<CallCenterConfiguration> callcenterOptions)
     {
-        _deviceManager = deviceManager;
         _telRepository = telRepository;
         _telRestRepository = telRestRepository;
         _telHoldRepository = telHoldRepository;
         _realtimeService = realtimeService;
         _telCacheManager = telCacheManager;
-        _options = options;
+        _appOptions = appOptions;
+        _callcenterOptions = callcenterOptions;
+        _callcenterType = appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType;
+        if (_callcenterType == AppDefaults.CallCenterType.XunShi)
+        {
+            _newRockDeviceManager = serviceProvider.GetRequiredService<INewRockDeviceManager>();
+        }
     }
 
 
@@ -49,7 +58,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
     public Task<List<Tel>> QueryTelsAsync(CancellationToken cancellationToken)
-        => _deviceManager.QueryTelsAsync(_options.Value.NewRock, cancellationToken);
+        => _newRockDeviceManager.QueryTelsAsync(_callcenterOptions.Value.NewRock, cancellationToken);
 
     /// <summary>
     /// 查询所有分机组
@@ -57,7 +66,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
     public Task<List<TelGroup>> QueryTelGroupsAsync(CancellationToken cancellationToken)
-        => _deviceManager.QueryTelGroupsAsync(_options.Value.NewRock, cancellationToken);
+        => _newRockDeviceManager.QueryTelGroupsAsync(_callcenterOptions.Value.NewRock, cancellationToken);
 
     /// <summary>
     /// 分机休息审批流程开始
@@ -85,7 +94,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
     //    var isResting = await _telRepository.IsRestingAsync(currentWork.TelNo, cancellationToken);
     //    if (!isResting)
     //    {
-    //        await _deviceManager.TelRestAsync(currentWork.TelNo, cancellationToken);
+    //        await _newRockDeviceManager.TelRestAsync(currentWork.TelNo, cancellationToken);
 
     //        return await _telRestRepository.AddAsync(new TelRest(currentWork.TelId, currentWork.TelNo, currentWork.UserId, currentWork.UserName, reason, isApply),
     //            cancellationToken);
@@ -127,9 +136,9 @@ public class TelDomainService : ITelDomainService, IScopeDependency
         if (telRest == null)
             throw new UserFriendlyException($"无效分机休息编号, telRestId: {id}", "无效分机休息编号");
 
-        //await _deviceManager.TelRestAsync(telRest.TelNo, cancellationToken);
+        //await _newRockDeviceManager.TelRestAsync(telRest.TelNo, cancellationToken);
 
-        if (_options.Value.CallCenterType == AppDefaults.CallCenterType.XunShi)
+        if (_callcenterType == AppDefaults.CallCenterType.XunShi)
         {
             telRest.StartTime = DateTime.Now;
             telRest.ApplyStatus = ETelRestApplyStatus.Resting;
@@ -138,7 +147,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
             var tel = _telCacheManager.GetTel(telRest.TelNo);
             foreach (var group in tel.Groups)
             {
-                await _deviceManager.ModifyGroupExtAsync(_options.Value.NewRock, group.No, group.Distribution, group.Voice, tel.No, true, cancellationToken);
+                await _newRockDeviceManager.ModifyGroupExtAsync(_callcenterOptions.Value.NewRock, group.No, group.Distribution, group.Voice, tel.No, true, cancellationToken);
             }
             #endregion
         }
@@ -177,20 +186,20 @@ public class TelDomainService : ITelDomainService, IScopeDependency
         var tel = await _telRepository.GetAsync(telId, cancellationToken);
         if (tel is null)
             throw new UserFriendlyException("无效分机编号");
-        //await _deviceManager.TelEndRestAsync(tel.No, cancellationToken);
+        //await _newRockDeviceManager.TelEndRestAsync(tel.No, cancellationToken);
         var restingTel = await _telRestRepository.GetAsync(d => d.TelId == telId && !d.EndTime.HasValue, cancellationToken);
         if (restingTel is null)
             throw new UserFriendlyException("未查询到分机休息信息");
         restingTel.EndRest();
         await _telRestRepository.UpdateAsync(restingTel, cancellationToken);
-        if (_options.Value.CallCenterType == AppDefaults.CallCenterType.XunShi)
+        if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XunShi)
         {
             #region 处理设备
             var telCache = _telCacheManager.GetTel(tel.No);
             //更新分机组
             foreach (var group in telCache.Groups)
             {
-                await _deviceManager.ModifyGroupExtAsync(_options.Value.NewRock, group.No, group.Distribution, group.Voice, "", true, cancellationToken);
+                await _newRockDeviceManager.ModifyGroupExtAsync(_callcenterOptions.Value.NewRock, group.No, group.Distribution, group.Voice, "", true, cancellationToken);
             }
 
             #endregion
@@ -212,7 +221,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
             var tel = await _telRepository.GetAsync(telId, cancellationToken);
             if (tel is null)
                 throw new UserFriendlyException("无效分机编号");
-            await _deviceManager.HoldAsync(_options.Value.NewRock, tel.No, cancellationToken);
+            await _newRockDeviceManager.HoldAsync(_callcenterOptions.Value.NewRock, tel.No, cancellationToken);
             await _telHoldRepository.AddAsync(new Calls.TelHold() { TelId = telId, TelNo = tel.No, UserId = userId, UserName = userName, CallId = callId }, cancellationToken);
         }
     }
@@ -228,7 +237,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
         var tel = await _telRepository.GetAsync(telId, cancellationToken);
         if (tel is null)
             throw new UserFriendlyException("无效分机编号");
-        await _deviceManager.UnHoldAsync(_options.Value.NewRock, tel.No, cancellationToken);
+        await _newRockDeviceManager.UnHoldAsync(_callcenterOptions.Value.NewRock, tel.No, cancellationToken);
         var holdingTel = await _telHoldRepository.GetAsync(d => d.TelId == telId && d.TelNo == tel.No && d.UserId == userId && d.CallId == callId && !d.EndTime.HasValue);
         if (holdingTel is null)
             throw new UserFriendlyException("未找到分机保持信息");
@@ -248,7 +257,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
         var tel = await _telRepository.GetAsync(telId, cancellationToken);
         if (tel is null)
             throw new UserFriendlyException("无效分机编号");
-        await _deviceManager.MuteAsync(_options.Value.NewRock, tel.No, cancellationToken);
+        await _newRockDeviceManager.MuteAsync(_callcenterOptions.Value.NewRock, tel.No, cancellationToken);
     }
 
     /// <summary>
@@ -262,6 +271,6 @@ public class TelDomainService : ITelDomainService, IScopeDependency
         var tel = await _telRepository.GetAsync(telId, cancellationToken);
         if (tel is null)
             throw new UserFriendlyException("无效分机编号");
-        await _deviceManager.MuteAsync(_options.Value.NewRock, tel.No, cancellationToken);
+        await _newRockDeviceManager.MuteAsync(_callcenterOptions.Value.NewRock, tel.No, cancellationToken);
     }
 }

+ 15 - 0
src/Hotline/EventBus/HandlerInjectAttribute.cs

@@ -18,5 +18,20 @@ namespace Hotline.EventBus
         /// 是否启用
         /// </summary>
         public bool Enable { get; set; } = true;
+
+        /// <summary>
+        /// handler的业务类型
+        /// </summary>
+        public EEventHandlerType EventHandlerType { get; set; }
+
+        /// <summary>
+        /// value,value
+        /// </summary>
+        public string Label { get; set; }
+    }
+
+    public enum EEventHandlerType
+    {
+        CallCenter = 1
     }
 }

+ 1 - 2
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -119,8 +119,7 @@ namespace Hotline.FlowEngine.Workflows
                 workflow.UpdateCurrentStepWhenHandle(startStep,
                     current.OrgAreaCode, current.OrgAreaName, current.OrgLevel);
 
-                var endTrace = await EndAsync(workflow, dto, firstStepDefine,
-                    startStep, current, expiredTime, cancellationToken);
+                var endTrace = await EndAsync(workflow, dto, firstStepDefine, startStep, current, expiredTime, cancellationToken);
                 return;
             }
 

+ 3 - 9
src/Hotline/Push/FWMessage/PushDomainService.cs

@@ -25,12 +25,10 @@ public class PushDomainService : IPushDomainService, IScopeDependency
     #region 注入
     private readonly IRepository<Message> _messageRepository;
     private readonly IMapper _mapper;
-    private readonly IMediator _mediator;
     private readonly IRepository<MessageTemplate> _messageTemplateRepository;
     private readonly ICapPublisher _capPublisher;
     private readonly IHttpClientFactory _httpClientFactory;
     private readonly ILogger<PushDomainService> _logger;
-    private readonly IOptionsSnapshot<SendSmsConfiguration> _sendSmsConfiguration;
 
     /// <summary>
     /// 
@@ -45,22 +43,18 @@ public class PushDomainService : IPushDomainService, IScopeDependency
     /// <param name="sendSmsConfiguration"></param>
     public PushDomainService(IRepository<Message> messageRepository,
         IMapper mapper,
-        IMediator mediator,
         IRepository<MessageTemplate> messageTemplateRepository,
         ICapPublisher capPublisher,
         IHttpClientFactory httpClientFactory,
-        ILogger<PushDomainService> logger,
-     IOptionsSnapshot<SendSmsConfiguration> sendSmsConfiguration
+        ILogger<PushDomainService> logger
         )
     {
         _messageRepository = messageRepository;
         _mapper = mapper;
-        _mediator = mediator;
         _messageTemplateRepository = messageTemplateRepository;
         _capPublisher = capPublisher;
         _httpClientFactory = httpClientFactory;
         _logger = logger;
-        _sendSmsConfiguration = sendSmsConfiguration;
     }
     #endregion
 
@@ -120,7 +114,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
             TelNumber = message.TelNumber
         };
         //消息队列
-         await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.SendSms, pushMessage, cancellationToken: cancellation);
+        await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.SendSms, pushMessage, cancellationToken: cancellation);
 
         ////http请求
         //var result = await ExecuteAsync<PushMessageDto, SendSmsReponse>(_sendSmsConfiguration.Value.Url, pushMessage, cancellationToken: cancellation);
@@ -166,7 +160,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
                 data.IsSmsReply = dto.IsSmsReply;
                 data.SmsReplyTime = Convert.ToDateTime(dto.SmsReplyTime);
                 data.SmsReplyContent = dto.SmsReplyContent;
-                
+
             }
             data.Reason = dto.Reason;
             await _messageRepository.UpdateAsync(data, cancellation);

+ 18 - 16
src/Hotline/Users/UserDomainService.cs

@@ -1,20 +1,16 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Tels;
-using Hotline.Share.Dtos.CallCenter;
-using Hotline.Share.Dtos.TrCallCenter;
 using Hotline.Share.Dtos.Users;
 using MapsterMapper;
-using Microsoft.AspNetCore.Http;
-using System.Security.Cryptography;
 using Hotline.CallCenter.Configs;
 using Microsoft.Extensions.Options;
 using XF.Domain.Authentications;
 using XF.Domain.Cache;
-using XF.Domain.Constants;
 using XF.Domain.Dependency;
 using XF.Domain.Exceptions;
 using XF.Domain.Repository;
+using Microsoft.Extensions.DependencyInjection;
 
 namespace Hotline.Users
 {
@@ -22,38 +18,44 @@ namespace Hotline.Users
     {
         private readonly IRepository<User> _userRepository;
         private readonly IWorkRepository _workRepository;
-        private readonly IDeviceManager _deviceManager;
+        private readonly INewRockDeviceManager _newRockDeviceManager;
         private readonly IUserCacheManager _userCacheManager;
         private readonly ITelCacheManager _telCacheManager;
         private readonly ITypedCache<Work> _cacheWork;
         private readonly IMapper _mapper;
         private readonly ISystemSettingCacheManager _systemSettingCacheManager;
         private readonly ISessionContext _sessionContext;
-        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
+        private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
 
 
         public UserDomainService(
+            IServiceProvider serviceProvider,
             IRepository<User> userRepository,
             IWorkRepository workRepository,
-            IDeviceManager deviceManager,
             ITypedCache<Work> cacheWork,
             IUserCacheManager userCacheManager,
             IMapper mapper,
             ITelCacheManager telCacheManager,
             ISystemSettingCacheManager systemSettingCacheManager,
             ISessionContext sessionContext,
-            IOptionsSnapshot<CallCenterConfiguration> options)
+            IOptionsSnapshot<AppConfiguration> appOptions,
+            IOptionsSnapshot<CallCenterConfiguration> callcenterOptions)
         {
             _userRepository = userRepository;
             _workRepository = workRepository;
-            _deviceManager = deviceManager;
             _userCacheManager = userCacheManager;
             _cacheWork = cacheWork;
             _mapper = mapper;
             _telCacheManager = telCacheManager;
             _systemSettingCacheManager = systemSettingCacheManager;
             _sessionContext = sessionContext;
-            _options = options;
+            _appOptions = appOptions;
+            _callcenterOptions = callcenterOptions;
+            if (appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XunShi)
+            {
+                _newRockDeviceManager = serviceProvider.GetRequiredService<INewRockDeviceManager>();
+            }
         }
 
         /// <summary>
@@ -81,12 +83,12 @@ namespace Hotline.Users
             await _workRepository.AddAsync(work, cancellationToken);
 
             if (!string.IsNullOrEmpty(user.StaffNo))
-                await _deviceManager.UpdateStaffNoAsync(_options.Value.NewRock, tel.No, user.StaffNo, tel.LineId, cancellationToken);
+                await _newRockDeviceManager.UpdateStaffNoAsync(_callcenterOptions.Value.NewRock, tel.No, user.StaffNo, tel.LineId, cancellationToken);
 
             //更新分机组
             foreach (var group in tel.Groups)
             {
-                await _deviceManager.AssginConfigGroupAsync(_options.Value.NewRock, group.No, group.Distribution, new List<string>() { tel.No }, group.Voice, cancellationToken);
+                await _newRockDeviceManager.AssginConfigGroupAsync(_callcenterOptions.Value.NewRock, group.No, group.Distribution, new List<string>() { tel.No }, group.Voice, cancellationToken);
             }
 
 
@@ -104,17 +106,17 @@ namespace Hotline.Users
             var tel = _telCacheManager.GetTel(work.TelNo);
             work.OffDuty();
             await _workRepository.UpdateAsync(work, cancellationToken);
-            await _deviceManager.UpdateStaffNoAsync(_options.Value.NewRock, work.TelNo, string.Empty, tel.LineId, cancellationToken);
+            await _newRockDeviceManager.UpdateStaffNoAsync(_callcenterOptions.Value.NewRock, work.TelNo, string.Empty, tel.LineId, cancellationToken);
             _cacheWork.Remove(work.GetKey(KeyMode.UserId));
             _cacheWork.Remove(work.GetKey(KeyMode.TelNo));
             #region 初始化话机
 
             //初始化解除静音
-            await _deviceManager.UnMuteAsync(_options.Value.NewRock, tel.No, cancellationToken);
+            await _newRockDeviceManager.UnMuteAsync(_callcenterOptions.Value.NewRock, tel.No, cancellationToken);
 
             foreach (var group in tel.Groups)
             {
-                await _deviceManager.ModifyGroupExtAsync(_options.Value.NewRock, group.No, group.Distribution, group.Voice, "", false, cancellationToken);
+                await _newRockDeviceManager.ModifyGroupExtAsync(_callcenterOptions.Value.NewRock, group.No, group.Distribution, group.Voice, "", false, cancellationToken);
             }
 
             #endregion