浏览代码

InjectionAttribute

xf 8 月之前
父节点
当前提交
e234d8efe9
共有 51 个文件被更改,包括 142 次插入134 次删除
  1. 0 3
      src/Hotline.Api/Program.cs
  2. 12 8
      src/Hotline.Api/StartupExtensions.cs
  3. 15 12
      src/Hotline.Api/StartupHelper.cs
  4. 1 1
      src/Hotline.Application/ContingencyManagement/ContingencyManagementNotifyHandler.cs
  5. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/AlertExtToExtNotificationHandler.cs
  6. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/AlertExtToOuterNotificationHandler.cs
  7. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/AlertMenuToOuterNotificationHandler.cs
  8. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/AlertVisitorToExtNotificationHandler.cs
  9. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/DtmfNotificationHandler.cs
  10. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/FailedNotificationHandler.cs
  11. 2 8
      src/Hotline.Application/Handlers/CallCenter/CallState/RingExtToExtNotificationHandler.cs
  12. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/RingExtToOuterNotificationHandler.cs
  13. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/RingMenuToExtNotificationHandler.cs
  14. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/RingVisitorToExtNotificationHandler.cs
  15. 1 1
      src/Hotline.Application/Handlers/CallCenter/ExtState/BusyNotificationHandler.cs
  16. 1 5
      src/Hotline.Application/Handlers/CallCenter/ExtState/IdleNotificationHandler.cs
  17. 1 1
      src/Hotline.Application/Handlers/CallCenter/ExtState/OfflineNotificationHandler.cs
  18. 1 1
      src/Hotline.Application/Handlers/CallCenter/ExtState/OnlineNotificationHandler.cs
  19. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnswerExtToExtNoificationHandler.cs
  20. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnswerExtToOuterNotificationHandler.cs
  21. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnswerViisitorToExtNotificationHandler.cs
  22. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredExtToExtNotificationHandler.cs
  23. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredExtToOuterNotificationHandler.cs
  24. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredExtToOuterToExtNotificationHandler.cs
  25. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/AnsweredVisitorToExtNotificationHandler.cs
  26. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeExtAndExtNotificationHandler.cs
  27. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeExtAndOuterOneNotificationHandler.cs
  28. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeExtAndOuterTwoNotificationHandler.cs
  29. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeOuterAndOuterNotificationHandler.cs
  30. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndExtNotificationHandler.cs
  31. 2 7
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndMenuNotificationHandler.cs
  32. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndOuterNotificationHandler.cs
  33. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorOffNotificationHandler.cs
  34. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/CdrNotificationHandler.cs
  35. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/DivertVisitorToExtNotificationHandler.cs
  36. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnOuterToMenuNotificationHandler.cs
  37. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnVisitorToMenuNotificationHandler.cs
  38. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/IncomingNotificationHandler.cs
  39. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/InviteNotificationHandler.cs
  40. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/QueueVisitorToGroupBusyNotificationHandler.cs
  41. 1 3
      src/Hotline.Application/Handlers/CallCenter/System/BootupNotificationHandler.cs
  42. 1 1
      src/Hotline.Application/Handlers/CallCenter/Transient/TransientOuterNotificationHandler.cs
  43. 1 1
      src/Hotline.Application/Handlers/CallCenter/Transient/TransinetVisitorNotificationHandler.cs
  44. 2 2
      src/Hotline.Application/Handlers/Order/TranspondCityNotifyHandler.cs
  45. 1 1
      src/Hotline.Application/JudicialManagement/AddPassTheBuckOrderNotifyHandler.cs
  46. 1 1
      src/Hotline.Application/JudicialManagement/JudicialManagementOrderNotifyHandler.cs
  47. 2 2
      src/Hotline.Application/Quality/AiOrderQualityHandler.cs
  48. 1 1
      src/Hotline.YbEnterprise.Sdk/EnterpriseService.cs
  49. 0 37
      src/Hotline/DI/HandlerInjectAttribute.cs
  50. 55 0
      src/Hotline/DI/InjectionAttribute.cs
  51. 11 8
      src/XF.Domain/Dependency/DependencyInjectionExtensions.cs

+ 0 - 3
src/Hotline.Api/Program.cs

@@ -1,7 +1,4 @@
-using EnumsNET;
 using Hotline.Api;
-using Hotline.EventBus;
-using Novacode;
 using Serilog;
 
 Log.Logger = new LoggerConfiguration()

+ 12 - 8
src/Hotline.Api/StartupExtensions.cs

@@ -1,4 +1,5 @@
-using FluentValidation;
+using System.Reflection;
+using FluentValidation;
 using FluentValidation.AspNetCore;
 using Hotline.Api.Realtimes;
 using Hotline.Application;
@@ -19,16 +20,13 @@ using XF.Utility.MQ;
 using Hotline.Ai.Jths;
 using Hotline.Api.Sdk;
 using Hotline.CallCenter.Configs;
-using Hotline.YbEnterprise.Sdk;
-using Hotline.Share.Dtos.SendSms;
 using Hotline.Wex;
 using Hotline.Application.CallCenter.Calls;
 using Hotline.Application.CallCenter;
 using Hotline.CallCenter.Calls;
 using Swashbuckle.AspNetCore.SwaggerUI;
-using Hotline.EventBus;
-using MediatR.Pipeline;
 using Hotline.Configurations;
+using Hotline.DI;
 
 namespace Hotline.Api;
 
@@ -45,7 +43,7 @@ internal static class StartupExtensions
 #if DEBUG
         builder.WebHost.UseUrls("http://*:50100");
 #endif
-
+        
         services.Configure<IdentityConfiguration>(d => configuration.GetSection(nameof(IdentityConfiguration)).Bind(d));
 
         var appConfigurationSection = configuration.GetRequiredSection(nameof(AppConfiguration));
@@ -61,7 +59,13 @@ internal static class StartupExtensions
 
         // Add services to the container.
         services
-            .BatchInjectServices()
+            .BatchInjectServices(d =>
+            {
+                var attr = d.GetCustomAttribute(typeof(InjectionAttribute)) as InjectionAttribute;
+                if (attr is null) return true;
+                return attr.IsEnable(appConfiguration.AppScope,
+                    appConfiguration.GetDefaultAppScopeConfiguration().CallCenterType);
+            })
             .RegisterRepository()
             .AddApplication()
             .AddScoped(typeof(IPasswordHasher<>), typeof(PasswordHasher<>))
@@ -191,7 +195,7 @@ internal static class StartupExtensions
             app.UseSwagger();
             app.UseSwaggerUI(c =>
             {
-                c.DocExpansion(DocExpansion.None);
+                //c.DocExpansion(DocExpansion.None);
                 //c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
             });
         }

+ 15 - 12
src/Hotline.Api/StartupHelper.cs

@@ -5,8 +5,8 @@ using Hotline.Application;
 using Hotline.Application.Jobs;
 using Hotline.Application.Orders;
 using Hotline.CallCenter.Configs;
-using Hotline.DI;
 using Hotline.Configurations;
+using Hotline.DI;
 using Hotline.EventBus;
 using Hotline.Identity;
 using Hotline.Repository.SqlSugar;
@@ -314,18 +314,21 @@ namespace Hotline.Api
             {
                 cfg.TypeEvaluator = d =>
                 {
-                    var attr = d.GetCustomAttribute(typeof(HandlerInjectAttribute)) as HandlerInjectAttribute;
+                    var attr = d.GetCustomAttribute(typeof(InjectionAttribute)) as InjectionAttribute;
                     if (attr is null) return true;
-                    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);
-                    }
+                    return attr.IsEnable(appConfiguration.AppScope,
+                        appConfiguration.GetDefaultAppScopeConfiguration().CallCenterType);
+
+                    //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);

+ 1 - 1
src/Hotline.Application/ContingencyManagement/ContingencyManagementNotifyHandler.cs

@@ -10,7 +10,7 @@ using XF.Domain.Repository;
 
 namespace Hotline.Application.ContingencyManagement
 {
-    [HandlerInject(AppScopes = EAppScope.YiBin)]
+    [Injection(AppScopes = EAppScope.YiBin)]
     public class ContingencyManagementNotifyHandler : INotificationHandler<ContingencyManagementNotify>
     {
         private readonly IRepository<ContingencyManagementOrders> _contingencyManagementOrdersRepository;

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

@@ -9,7 +9,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AlertExtToExtNotificationHandler : INotificationHandler<AlertExtToExtNotification>
     {
         private readonly IRealtimeService _realtimeService;

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

@@ -10,7 +10,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AlertExtToOuterNotificationHandler:INotificationHandler<AlertExtToOuterNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -6,7 +6,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AlertMenuToOuterNotificationHandler:INotificationHandler<AlertMenuToOuterNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -6,7 +6,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AlertVisitorToExtNotificationHandler: INotificationHandler<AlertVisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -12,7 +12,7 @@ using NewRock.Sdk;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class DtmfNotificationHandler : NewRockBaseHandler, INotificationHandler<DtmfNotification>
     {
         private readonly IIvrDomainService _ivrDomainService;

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

@@ -5,7 +5,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class FailedNotificationHandler:INotificationHandler<FailedNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -1,20 +1,14 @@
 using Hotline.Caching.Interfaces;
-using Hotline.CallCenter.Calls;
-using Hotline.DI;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Hotline.DI;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class RingExtToExtNotificationHandler : INotificationHandler<RingExtToExtNotification>
     {
         private readonly IRealtimeService _realtimeService;

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

@@ -8,7 +8,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class RingExtToOuterNotificationHandler : INotificationHandler<RingExtToOuterNotification>
     {
         private readonly ICallRepository _callRepository;

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

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

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

@@ -8,7 +8,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.CallState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class RingVisitorToExtNotificationHandler : INotificationHandler<RingVisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -8,7 +8,7 @@ using XF.Domain.Cache;
 
 namespace Hotline.Application.Handlers.CallCenter.ExtState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class BusyNotificationHandler : INotificationHandler<BusyNotification>
     {
         private readonly ITelRepository _telRepository;

+ 1 - 5
src/Hotline.Application/Handlers/CallCenter/ExtState/IdleNotificationHandler.cs

@@ -1,14 +1,10 @@
 using Hotline.Caching.Interfaces;
-using Hotline.Caching.Services;
 using Hotline.CallCenter.Configs;
 using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Tels;
 using Hotline.Configurations;
-using Hotline.EventBus;
 using Hotline.DI;
-using Hotline.NewRock;
 using Hotline.Realtimes;
-using Hotline.Repository.SqlSugar.CallCenter;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
@@ -19,7 +15,7 @@ using XF.Domain.Exceptions;
 
 namespace Hotline.Application.Handlers.CallCenter.ExtState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class IdleNotificationHandler : INotificationHandler<IdleNotification>
     {
         private readonly ITelRepository _telRepository;

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

@@ -8,7 +8,7 @@ using XF.Domain.Cache;
 
 namespace Hotline.Application.Handlers.CallCenter.ExtState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class OfflineNotificationHandler: INotificationHandler<OfflineNotification>
     {
         private readonly ITelRepository _telRepository;

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

@@ -8,7 +8,7 @@ using XF.Domain.Cache;
 
 namespace Hotline.Application.Handlers.CallCenter.ExtState
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class OnlineNotificationHandler : INotificationHandler<OnlineNotification>
     {
         private readonly ITelRepository _telRepository;

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

@@ -8,7 +8,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AnswerExtToExtNoificationHandler : INotificationHandler<AnswerExtToExtNotification>
     {
         private readonly IUserCacheManager _userCacheManager;

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

@@ -9,7 +9,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AnswerExtToOuterNotificationHandler : INotificationHandler<AnswerExtToOuterNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -9,7 +9,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AnswerViisitorToExtNotificationHandler : INotificationHandler<AnswerViisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -8,7 +8,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AnsweredExtToExtNotificationHandler : INotificationHandler<AnsweredExtToExtNotification>
     {
         private readonly IUserCacheManager _userCacheManager;

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

@@ -9,7 +9,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AnsweredExtToOuterNotificationHandler : INotificationHandler<AnsweredExtToOuterNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -9,7 +9,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AnsweredExtToOuterToExtNotificationHandler : INotificationHandler<AnsweredExtToOuterToExtNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -8,7 +8,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class AnsweredVisitorToExtNotificationHandler : INotificationHandler<AnsweredVisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -8,7 +8,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeExtAndExtNotificationHandler : INotificationHandler<ByeExtAndExtNotification>
     {
         private readonly IUserCacheManager _userCacheManager;

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

@@ -9,7 +9,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeExtAndOuterOneNotificationHandler : INotificationHandler<ByeExtAndOuterOneNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -10,7 +10,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeExtAndOuterTwoNotificationHandler : INotificationHandler<ByeExtAndOuterTwoNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -6,7 +6,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeOuterAndOuterNotificationHandler : INotificationHandler<ByeOuterAndOuterNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -8,7 +8,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeVisitorAndExtNotificationHandler : INotificationHandler<ByeVisitorAndExtNotification>
     {
         private readonly ICallRepository _callRepository;

+ 2 - 7
src/Hotline.Application/Handlers/CallCenter/FlowControl/ByeVisitorAndMenuNotificationHandler.cs

@@ -1,20 +1,15 @@
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Calls;
-using Hotline.DI;
 using Hotline.Realtimes;
 using Hotline.Share.Dtos.Realtime;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Hotline.DI;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeVisitorAndMenuNotificationHandler : INotificationHandler<ByeVisitorAndMenuNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -5,7 +5,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeVisitorAndOuterNotificationHandler : INotificationHandler<ByeVisitorAndOuterNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -9,7 +9,7 @@ using Serilog.Enrichers.Span;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class ByeVisitorOffNotificationHandler : INotificationHandler<ByeVisitorOffNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -10,7 +10,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class CdrNotificationHandler : INotificationHandler<CdrNotification>
     {
         private readonly ICallRecordRepository _callRecordRepository;

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

@@ -6,7 +6,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class DivertVisitorToExtNotificationHandler : INotificationHandler<DivertVisitorToExtNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -12,7 +12,7 @@ using NewRock.Sdk;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class EndOfAnnOuterToMenuNotificationHandler : NewRockBaseHandler, INotificationHandler<EndOfAnnOuterToMenuNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -12,7 +12,7 @@ using NewRock.Sdk;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class EndOfAnnVisitorToMenuNotificationHandler : NewRockBaseHandler, INotificationHandler<EndOfAnnVisitorToMenuNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -19,7 +19,7 @@ using XF.Domain.Repository;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class IncomingNotificationHandler : INotificationHandler<IncomingNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -15,7 +15,7 @@ using NewRock.Sdk.Control.Request;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class InviteNotificationHandler : INotificationHandler<InviteNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -7,7 +7,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class QueueVisitorToGroupBusyNotificationHandler : INotificationHandler<QueueVisitorToGroupBusyNotification>
     {
         private readonly ICallCacheManager _callCacheManager;

+ 1 - 3
src/Hotline.Application/Handlers/CallCenter/System/BootupNotificationHandler.cs

@@ -4,9 +4,7 @@ using Hotline.CallCenter.Devices;
 using Hotline.CallCenter.Ivrs;
 using Hotline.CallCenter.Tels;
 using Hotline.Configurations;
-using Hotline.EventBus;
 using Hotline.DI;
-using Hotline.NewRock;
 using Hotline.Share.Notifications.NewRockCallCenter;
 using MediatR;
 using Microsoft.Extensions.DependencyInjection;
@@ -14,7 +12,7 @@ using Microsoft.Extensions.Options;
 
 namespace Hotline.Application.Handlers.CallCenter.System
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class BootupNotificationHandler : INotificationHandler<BootupNotification>
     {
         private readonly ITelGroupRepository _telGroupRepository;

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

@@ -8,7 +8,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.Transient
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class TransientOuterNotificationHandler : INotificationHandler<TransientOuterNotification>
     {
         private readonly ICallRepository _callRepository;

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

@@ -5,7 +5,7 @@ using MediatR;
 
 namespace Hotline.Application.Handlers.CallCenter.Transient
 {
-    [HandlerInject(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
+    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
     public class TransinetVisitorNotificationHandler : INotificationHandler<TransientVisitorNotification>
     {
         private readonly ICallRepository _callRepository;

+ 2 - 2
src/Hotline.Application/Handlers/Order/TranspondCityNotifyHandler.cs

@@ -1,5 +1,4 @@
 using DotNetCore.CAP;
-using Hotline.DI;
 using Hotline.EventBus;
 using Hotline.Orders;
 using Hotline.Orders.Notifications;
@@ -11,11 +10,12 @@ using MediatR;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Logging;
 using System;
+using Hotline.DI;
 using XF.Domain.Repository;
 
 namespace Hotline.Application.Handlers.Order
 {
-    [HandlerInject(AppScopes = EAppScope.YiBin)]
+    [Injection(AppScopes = EAppScope.YiBin)]
     public class TranspondCityNotifyHandler : INotificationHandler<OrderStartWorkflowNotify>
     {
         private readonly IMapper _mapper;

+ 1 - 1
src/Hotline.Application/JudicialManagement/AddPassTheBuckOrderNotifyHandler.cs

@@ -12,7 +12,7 @@ using XF.Domain.Repository;
 
 namespace Hotline.Application.JudicialManagement
 {
-    [HandlerInject(AppScopes = EAppScope.YiBin)]
+    [Injection(AppScopes = EAppScope.YiBin)]
     public class AddPassTheBuckOrderNotifyHandler : INotificationHandler<AddPassTheBuckOrderNotify>
     {
         private readonly IRepository<EnforcementOrderHander> _enforcementOrderHanderRepository;

+ 1 - 1
src/Hotline.Application/JudicialManagement/JudicialManagementOrderNotifyHandler.cs

@@ -12,7 +12,7 @@ using XF.Domain.Repository;
 
 namespace Hotline.Application.JudicialManagement
 {
-    [HandlerInject(AppScopes = EAppScope.YiBin)]
+    [Injection(AppScopes = EAppScope.YiBin)]
     public class JudicialManagementOrderNotifyHandler : INotificationHandler<JudicialManagementOrderNotify>
     {
         private readonly IRepository<EnforcementHotspot> _enforcementHotspotRepository;

+ 2 - 2
src/Hotline.Application/Quality/AiOrderQualityHandler.cs

@@ -9,13 +9,13 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Hotline.DI;
 using Hotline.EventBus;
 using Hotline.Quality.Notifications;
-using Hotline.DI;
 
 namespace Hotline.Application.Quality
 {
-    [HandlerInject(AppScopes = EAppScope.YiBin)]
+    [Injection(AppScopes = EAppScope.YiBin)]
 	public class AiOrderQualityHandler : INotificationHandler<AiOrderQualityNotify>
 	{
 		private readonly IAiQualityService _aiQualityService;

+ 1 - 1
src/Hotline.YbEnterprise.Sdk/EnterpriseService.cs

@@ -46,7 +46,7 @@ namespace Hotline.YbEnterprise.Sdk
                 Current = current,
                 Size = size
             };
-
+            
             var token = await GetTokenAsync(YbEnterpriseDefaults.KeyOfToken, cancellationToken);
             var result = await ExecuteAsync<YbEnterprisesRequest, YbEnterpriseResponse<YbEnterprisePaged>>(
                 YbEnterpriseDefaults.PathEnterprises,

+ 0 - 37
src/Hotline/DI/HandlerInjectAttribute.cs

@@ -1,37 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Hotline.DI
-{
-    [AttributeUsage(AttributeTargets.Class)]
-    public class HandlerInjectAttribute : Attribute
-    {
-        /// <summary>
-        /// 适用范围
-        /// </summary>
-        public EAppScope AppScopes { get; set; }
-
-        /// <summary>
-        /// 是否启用
-        /// </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
-    }
-}

+ 55 - 0
src/Hotline/DI/InjectionAttribute.cs

@@ -0,0 +1,55 @@
+using Hotline.Configurations;
+
+namespace Hotline.DI
+{
+    [AttributeUsage(AttributeTargets.Class)]
+    public class InjectionAttribute : Attribute
+    {
+        /// <summary>
+        /// 适用范围
+        /// </summary>
+        public EAppScope AppScopes { get; set; }
+
+        /// <summary>
+        /// 是否启用
+        /// </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 bool IsEnable(string? appScope, string? callcenterType)
+        {
+            if (!Enable) return false;
+            if (!string.IsNullOrEmpty(appScope))
+            {
+                return AppScopes.ToString()
+                    .Split(',', StringSplitOptions.RemoveEmptyEntries)
+                    .Any(x => string.Compare(x, appScope, StringComparison.Ordinal) == 0);
+            }
+
+            if (!string.IsNullOrEmpty(callcenterType))
+            {
+                switch (EventHandlerType)
+                {
+                    case EEventHandlerType.CallCenter:
+                        return Label == callcenterType;
+                }
+            }
+
+            return true;
+        }
+    }
+
+    public enum EEventHandlerType
+    {
+        CallCenter = 1
+    }
+}

+ 11 - 8
src/XF.Domain/Dependency/DependencyInjectionExtensions.cs

@@ -6,35 +6,38 @@ namespace XF.Domain.Dependency;
 
 public static class DependencyInjectionExtensions
 {
-    public static IServiceCollection BatchInjectServices(this IServiceCollection services)
+    public static IServiceCollection BatchInjectServices(this IServiceCollection services, Func<Type, bool>? predicate = null)
     {
         var assemblies = GetAllAssembly();
 
-        InjectConventionServices(services, assemblies);
-        InjectBackgroundServices(services, assemblies);
+        predicate ??= d => true;
+        InjectConventionServices(services, assemblies, predicate);
+        InjectBackgroundServices(services, assemblies, predicate);
 
         return services;
     }
 
-    private static void InjectBackgroundServices(IServiceCollection services, List<Assembly> assemblies)
+    private static void InjectBackgroundServices(IServiceCollection services, List<Assembly> assemblies, Func<Type, bool> predicate)
     {
         var types = assemblies.SelectMany(t => t.GetTypes())
-            .Where(t => typeof(BackgroundService).IsAssignableFrom(t) && t.IsClass && !t.IsAbstract
-            && t.GetInterfaces().All(d => d != typeof(IIgnoreDependency))).ToList();
+            .Where(t => typeof(BackgroundService).IsAssignableFrom(t) &&
+                        t.IsClass && !t.IsAbstract && predicate(t) &&
+                        t.GetInterfaces().All(d => d != typeof(IIgnoreDependency))).ToList();
 
         foreach (var type in types)
         {
             services.AddSingleton(typeof(IHostedService), type);
         }
     }
-    private static void InjectConventionServices(IServiceCollection services, List<Assembly> assemblies)
+    private static void InjectConventionServices(IServiceCollection services, List<Assembly> assemblies, Func<Type, bool> predicate)
     {
         assemblies.SelectMany(d => d.GetTypes())
             .Where(d => d.GetInterfaces().Any(x =>
                 x == typeof(IScopeDependency)
                 || x == typeof(ISingletonDependency)
                 || x == typeof(ITransientDependency))
-                        && d.GetInterfaces().All(x => x != typeof(IIgnoreDependency)))
+                        && d.GetInterfaces().All(x => x != typeof(IIgnoreDependency))
+                        && predicate(d))
             .ToList()
             .ForEach(d => ServiceRegister.Register(services, d));
     }