From c7c94e5a6a89a6fbc2eec9ff2c5265e07a9cebdc Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 13 May 2021 08:52:57 +0800 Subject: [PATCH 1/2] Remove invalid items --- aspnet-core/LINGYUN.MicroService.All.sln | 45 +++++----- .../AbpNRulesModule.cs | 31 ------- .../LINGYUN.Abp.Rules.NRules.csproj | 22 ----- .../LINGYUN/Abp/Rules/AbpNRulesOptions.cs | 14 --- .../LINGYUN/Abp/Rules/AbpRuleRepository.cs | 44 --------- .../LINGYUN/Abp/Rules/DependencyResolver.cs | 20 ----- .../LINGYUN/Abp/Rules/INRulesRepository.cs | 20 ----- .../Abp/Rules/NRulesEntityRuleContributor.cs | 60 ------------- .../LINGYUN/Abp/Rules/RuleActivator.cs | 24 ----- .../NRulesServiceCollectionExtensions.cs | 55 ------------ .../NRules/RuleRepositoryExtensions.cs | 15 ---- .../LINGYUN.Abp.Rules.csproj | 14 --- .../LINGYUN/Abp/Rules/AbpRulesModule.cs | 16 ---- .../Rules/EntityChangedRulesInterceptor.cs | 48 ---------- .../EntityChangedRulesInterceptorRegistrar.cs | 28 ------ .../LINGYUN/Abp/Rules/EntityRuleContext.cs | 18 ---- .../LINGYUN/Abp/Rules/ErrorType.cs | 8 -- .../LINGYUN/Abp/Rules/ExpressionType.cs | 7 -- .../Abp/Rules/IEntityRuleContributor.cs | 9 -- .../LINGYUN/Abp/Rules/INeedRule.cs | 6 -- .../LINGYUN/Abp/Rules/IRuleFinder.cs | 11 --- .../Abp/Rules/NullEntityRuleContributor.cs | 13 --- .../LINGYUN/Abp/Rules/NullRuleFinder.cs | 15 ---- .../LINGYUN/Abp/Rules/Rule.cs | 90 ------------------- .../LINGYUN/Abp/Rules/RuleGroup.cs | 53 ----------- .../LINGYUN/Abp/Rules/RuleNameAttribute.cs | 35 -------- .../LINGYUN/Abp/Rules/RuleParam.cs | 45 ---------- .../common/LINGYUN.Abp.Rules/README.md | 7 -- ...N.Abp.Dapr.Actors.IdentityModel.Web.csproj | 20 ----- ....Dapr.Actors.IdentityModel.Web.csproj.user | 6 -- .../AbpDaprActorsIdentityModelWebModule.cs | 10 --- ...dentityModelDaprActorProxyAuthenticator.cs | 51 ----------- .../Properties/launchSettings.json | 27 ------ .../README.md | 19 ---- ...NGYUN.Abp.Dapr.Actors.IdentityModel.csproj | 18 ---- .../DaprActorConfigurationExtensions.cs | 54 ----------- .../AbpDaprActorsIdentityModelModule.cs | 13 --- ...dentityModelDaprActorProxyAuthenticator.cs | 66 -------------- .../README.md | 19 ---- .../Localization/Xml/XmlLocalizationFile.cs | 2 +- ...LINGYUN.Abp.Localization.Json.Tests.csproj | 1 - 41 files changed, 25 insertions(+), 1054 deletions(-) delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/AbpNRulesModule.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN.Abp.Rules.NRules.csproj delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpNRulesOptions.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpRuleRepository.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/DependencyResolver.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/INRulesRepository.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/NRulesEntityRuleContributor.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/RuleActivator.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/Microsoft/Extensions/DependencyInjection/NRulesServiceCollectionExtensions.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/NRules/RuleRepositoryExtensions.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/AbpRulesModule.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptor.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptorRegistrar.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityRuleContext.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ErrorType.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ExpressionType.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IEntityRuleContributor.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/INeedRule.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IRuleFinder.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullEntityRuleContributor.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullRuleFinder.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/Rule.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleGroup.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleNameAttribute.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleParam.cs delete mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Rules/README.md delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj.user delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/AbpDaprActorsIdentityModelWebModule.cs delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/HttpContextIdentityModelDaprActorProxyAuthenticator.cs delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/Properties/launchSettings.json delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/README.md delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN.Abp.Dapr.Actors.IdentityModel.csproj delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/DaprActorConfigurationExtensions.cs delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/AbpDaprActorsIdentityModelModule.cs delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/IdentityModelDaprActorProxyAuthenticator.cs delete mode 100644 aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/README.md diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index 49afbfbc8..4efb91e18 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -230,10 +230,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Auditing.Applic EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Auditing.HttpApi", "modules\auditing\LINGYUN.Abp.Auditing.HttpApi\LINGYUN.Abp.Auditing.HttpApi.csproj", "{07E19CA8-671D-4D58-9FED-5FEE9AE01A2F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules", "modules\common\LINGYUN.Abp.Rules\LINGYUN.Abp.Rules.csproj", "{8ACB30CF-2311-4C0A-AE79-92C1A7667353}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.NRules", "modules\common\LINGYUN.Abp.Rules.NRules\LINGYUN.Abp.Rules.NRules.csproj", "{0BA9FF71-C55E-483B-B83A-6B4BD8ABBBB1}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "permission-management", "permission-management", "{CC362C67-6FC1-42B3-A130-8120AA8D790C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.PermissionManagement.Domain", "modules\permissions-management\LINGYUN.Abp.PermissionManagement.Domain\LINGYUN.Abp.PermissionManagement.Domain.csproj", "{B46D6DAF-98C6-441F-9FA5-3CAD7CF27727}" @@ -298,8 +294,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Xm EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Xml.Tests", "tests\LINGYUN.Abp.Localization.Xml.Tests\LINGYUN.Abp.Localization.Xml.Tests.csproj", "{A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Json", "modules\localization\LINGYUN.Abp.Localization.Json\LINGYUN.Abp.Localization.Json.csproj", "{EA563F48-A6EF-4886-B607-2A83F7795F1B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Json.Tests", "tests\LINGYUN.Abp.Localization.Json.Tests\LINGYUN.Abp.Localization.Json.Tests.csproj", "{EBCF7D88-49E2-413D-A7A6-1A76BC2E8161}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Dynamic", "modules\common\LINGYUN.Abp.Localization.Dynamic\LINGYUN.Abp.Localization.Dynamic.csproj", "{4A9043FD-24A3-4A4A-956B-9CB71876F415}" @@ -325,6 +319,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "localization", "localizatio EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.LocalizationManagement.HttpApi.Host", "services\localization\LINGYUN.Abp.LocalizationManagement.HttpApi.Host\LINGYUN.Abp.LocalizationManagement.HttpApi.Host.csproj", "{6FFC14FE-F659-4B23-9746-4B767CE520D2}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "rules", "rules", "{6084D52D-775B-4A39-8CD5-AA2F362B5A61}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules", "modules\rules\LINGYUN.Abp.Rules\LINGYUN.Abp.Rules.csproj", "{D60EFB8E-F168-4EF2-8D8F-ED42EB6FB8CF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.NRules", "modules\rules\LINGYUN.Abp.Rules.NRules\LINGYUN.Abp.Rules.NRules.csproj", "{34BB9810-2983-4E55-A96A-132D32310145}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.RulesEngine", "modules\rules\LINGYUN.Abp.Rules.RulesEngine\LINGYUN.Abp.Rules.RulesEngine.csproj", "{4D83BDA7-2059-41C7-85AE-FEFAD5CD9498}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -695,14 +697,6 @@ Global {07E19CA8-671D-4D58-9FED-5FEE9AE01A2F}.Debug|Any CPU.Build.0 = Debug|Any CPU {07E19CA8-671D-4D58-9FED-5FEE9AE01A2F}.Release|Any CPU.ActiveCfg = Release|Any CPU {07E19CA8-671D-4D58-9FED-5FEE9AE01A2F}.Release|Any CPU.Build.0 = Release|Any CPU - {8ACB30CF-2311-4C0A-AE79-92C1A7667353}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8ACB30CF-2311-4C0A-AE79-92C1A7667353}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8ACB30CF-2311-4C0A-AE79-92C1A7667353}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8ACB30CF-2311-4C0A-AE79-92C1A7667353}.Release|Any CPU.Build.0 = Release|Any CPU - {0BA9FF71-C55E-483B-B83A-6B4BD8ABBBB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0BA9FF71-C55E-483B-B83A-6B4BD8ABBBB1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0BA9FF71-C55E-483B-B83A-6B4BD8ABBBB1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0BA9FF71-C55E-483B-B83A-6B4BD8ABBBB1}.Release|Any CPU.Build.0 = Release|Any CPU {B46D6DAF-98C6-441F-9FA5-3CAD7CF27727}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B46D6DAF-98C6-441F-9FA5-3CAD7CF27727}.Debug|Any CPU.Build.0 = Debug|Any CPU {B46D6DAF-98C6-441F-9FA5-3CAD7CF27727}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -811,10 +805,6 @@ Global {A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED}.Debug|Any CPU.Build.0 = Debug|Any CPU {A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED}.Release|Any CPU.ActiveCfg = Release|Any CPU {A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED}.Release|Any CPU.Build.0 = Release|Any CPU - {EA563F48-A6EF-4886-B607-2A83F7795F1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EA563F48-A6EF-4886-B607-2A83F7795F1B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EA563F48-A6EF-4886-B607-2A83F7795F1B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EA563F48-A6EF-4886-B607-2A83F7795F1B}.Release|Any CPU.Build.0 = Release|Any CPU {EBCF7D88-49E2-413D-A7A6-1A76BC2E8161}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EBCF7D88-49E2-413D-A7A6-1A76BC2E8161}.Debug|Any CPU.Build.0 = Debug|Any CPU {EBCF7D88-49E2-413D-A7A6-1A76BC2E8161}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -851,6 +841,18 @@ Global {6FFC14FE-F659-4B23-9746-4B767CE520D2}.Debug|Any CPU.Build.0 = Debug|Any CPU {6FFC14FE-F659-4B23-9746-4B767CE520D2}.Release|Any CPU.ActiveCfg = Release|Any CPU {6FFC14FE-F659-4B23-9746-4B767CE520D2}.Release|Any CPU.Build.0 = Release|Any CPU + {D60EFB8E-F168-4EF2-8D8F-ED42EB6FB8CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D60EFB8E-F168-4EF2-8D8F-ED42EB6FB8CF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D60EFB8E-F168-4EF2-8D8F-ED42EB6FB8CF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D60EFB8E-F168-4EF2-8D8F-ED42EB6FB8CF}.Release|Any CPU.Build.0 = Release|Any CPU + {34BB9810-2983-4E55-A96A-132D32310145}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {34BB9810-2983-4E55-A96A-132D32310145}.Debug|Any CPU.Build.0 = Debug|Any CPU + {34BB9810-2983-4E55-A96A-132D32310145}.Release|Any CPU.ActiveCfg = Release|Any CPU + {34BB9810-2983-4E55-A96A-132D32310145}.Release|Any CPU.Build.0 = Release|Any CPU + {4D83BDA7-2059-41C7-85AE-FEFAD5CD9498}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D83BDA7-2059-41C7-85AE-FEFAD5CD9498}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D83BDA7-2059-41C7-85AE-FEFAD5CD9498}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D83BDA7-2059-41C7-85AE-FEFAD5CD9498}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -965,8 +967,6 @@ Global {F40F88F1-CA90-4A79-B772-80E287E25982} = {67DAB2A0-D407-4CAB-8414-AE3D0AC52FC4} {AC3C8985-73C2-472A-8E76-A0B8786FEC3F} = {67DAB2A0-D407-4CAB-8414-AE3D0AC52FC4} {07E19CA8-671D-4D58-9FED-5FEE9AE01A2F} = {67DAB2A0-D407-4CAB-8414-AE3D0AC52FC4} - {8ACB30CF-2311-4C0A-AE79-92C1A7667353} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} - {0BA9FF71-C55E-483B-B83A-6B4BD8ABBBB1} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} {CC362C67-6FC1-42B3-A130-8120AA8D790C} = {C5CAD011-DF84-4914-939C-0C029DCEF26F} {B46D6DAF-98C6-441F-9FA5-3CAD7CF27727} = {CC362C67-6FC1-42B3-A130-8120AA8D790C} {2D377D3A-70EC-4BB3-9F4C-6C933693DA98} = {52B5D4F7-237B-4E0A-A167-68442164F70A} @@ -999,7 +999,6 @@ Global {90E88EAC-4291-4406-8D88-EFDF61B11292} = {C5CAD011-DF84-4914-939C-0C029DCEF26F} {84868710-ECBB-4025-900A-EEB99EC49534} = {90E88EAC-4291-4406-8D88-EFDF61B11292} {A061D2B4-B650-4F7F-A6CB-5C8FFFD512ED} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} - {EA563F48-A6EF-4886-B607-2A83F7795F1B} = {90E88EAC-4291-4406-8D88-EFDF61B11292} {EBCF7D88-49E2-413D-A7A6-1A76BC2E8161} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} {4A9043FD-24A3-4A4A-956B-9CB71876F415} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} {D3BAA44E-8395-4E8A-AA96-6B463356C537} = {C5CAD011-DF84-4914-939C-0C029DCEF26F} @@ -1011,6 +1010,10 @@ Global {FBE91498-D83B-4873-A67E-0FB9D1C366F0} = {D3BAA44E-8395-4E8A-AA96-6B463356C537} {A2EA6B3F-AD1A-4FDA-B12E-F71B20A43A6B} = {672E1170-7B18-474B-85C7-1961BF2A48AE} {6FFC14FE-F659-4B23-9746-4B767CE520D2} = {A2EA6B3F-AD1A-4FDA-B12E-F71B20A43A6B} + {6084D52D-775B-4A39-8CD5-AA2F362B5A61} = {C5CAD011-DF84-4914-939C-0C029DCEF26F} + {D60EFB8E-F168-4EF2-8D8F-ED42EB6FB8CF} = {6084D52D-775B-4A39-8CD5-AA2F362B5A61} + {34BB9810-2983-4E55-A96A-132D32310145} = {6084D52D-775B-4A39-8CD5-AA2F362B5A61} + {4D83BDA7-2059-41C7-85AE-FEFAD5CD9498} = {6084D52D-775B-4A39-8CD5-AA2F362B5A61} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/AbpNRulesModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/AbpNRulesModule.cs deleted file mode 100644 index c42aecd61..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/AbpNRulesModule.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using Volo.Abp.Modularity; -using NRule = NRules.Fluent.Dsl.Rule; - -namespace LINGYUN.Abp.Rules.NRules -{ - [DependsOn( - typeof(AbpRulesModule) - )] - public class AbpNRulesModule : AbpModule - { - private readonly AbpNRulesOptions options = new AbpNRulesOptions(); - public override void PreConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddObjectAccessor(options); - context.Services.OnRegistred(ctx => - { - if (ctx.ImplementationType.IsAssignableTo(typeof(NRule))) - { - options.Rules.AddIfNotContains(ctx.ImplementationType); - } - }); - } - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddNRules(options); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN.Abp.Rules.NRules.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN.Abp.Rules.NRules.csproj deleted file mode 100644 index 03004c55a..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN.Abp.Rules.NRules.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - netstandard2.0 - - - - - - - - - - - - - - - - diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpNRulesOptions.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpNRulesOptions.cs deleted file mode 100644 index 0fb5079a6..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpNRulesOptions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Volo.Abp.Collections; -using NRule = NRules.Fluent.Dsl.Rule; - -namespace LINGYUN.Abp.Rules -{ - public class AbpNRulesOptions - { - public ITypeList Rules { get; } - public AbpNRulesOptions() - { - Rules = new TypeList(); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpRuleRepository.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpRuleRepository.cs deleted file mode 100644 index 89ff7f9eb..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpRuleRepository.cs +++ /dev/null @@ -1,44 +0,0 @@ -using NRules.RuleModel; -using System; -using System.Collections.Generic; - -namespace LINGYUN.Abp.Rules -{ - public class AbpRuleRepository : INRulesRepository - { - public void Add(IRuleSet ruleSet) - { - throw new NotImplementedException(); - } - - public IEnumerable GetRuleSets() - { - throw new NotImplementedException(); - } - - public void Remove(string ruleSetName) - { - throw new NotImplementedException(); - } - - public void Remove(IRuleSet ruleSet) - { - throw new NotImplementedException(); - } - - public IRuleSet GetRuleSet(string ruleSetName) - { - return new RuleSet(ruleSetName); - } - - public IRuleSet GetRuleSet(RuleGroup group) - { - throw new NotImplementedException(); - } - - public IEnumerable GetRuleSets(IEnumerable groups) - { - throw new NotImplementedException(); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/DependencyResolver.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/DependencyResolver.cs deleted file mode 100644 index d898645e0..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/DependencyResolver.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using NRules.Extensibility; -using System; - -namespace LINGYUN.Abp.Rules -{ - public class DependencyResolver : IDependencyResolver - { - protected IServiceProvider ServiceProvider { get; } - public DependencyResolver(IServiceProvider serviceProvider) - { - ServiceProvider = serviceProvider; - } - - public virtual object Resolve(IResolutionContext context, Type serviceType) - { - return ServiceProvider.GetRequiredService(serviceType); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/INRulesRepository.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/INRulesRepository.cs deleted file mode 100644 index 67b10fcd8..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/INRulesRepository.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NRules.RuleModel; -using System.Collections.Generic; - -namespace LINGYUN.Abp.Rules -{ - public interface INRulesRepository : IRuleRepository - { - void Add(IRuleSet ruleSet); - - void Remove(string ruleSetName); - - void Remove(IRuleSet ruleSet); - - IRuleSet GetRuleSet(string ruleSetName); - - IRuleSet GetRuleSet(RuleGroup group); - - IEnumerable GetRuleSets(IEnumerable groups); - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/NRulesEntityRuleContributor.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/NRulesEntityRuleContributor.cs deleted file mode 100644 index 308f315cb..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/NRulesEntityRuleContributor.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using NRules.RuleModel; -using NRules.RuleModel.Builders; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Dynamic.Core; -using System.Linq.Expressions; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; - -namespace LINGYUN.Abp.Rules -{ - [Dependency(ServiceLifetime.Transient, ReplaceServices = true)] - [ExposeServices(typeof(IEntityRuleContributor))] - public class NRulesEntityRuleContributor : IEntityRuleContributor - { - protected INRulesRepository Repository { get; } - public Task ApplyAsync(EntityRuleContext context) - { - var entityType = context.Entity.GetType(); - var entityRuleName = RuleNameAttribute.GetRuleName(entityType); - - - - IEnumerable groupRuleSets = new List(); - - groupRuleSets = Repository.GetRuleSets(context.Groups); - - var sessionFactory = Repository.Compile(context.Groups); - var session = sessionFactory.CreateSession(); - session.Insert(context.Entity); - - session.Fire(); - - foreach (var groupRuleSet in groupRuleSets) - { - } - - foreach (var group in context.Groups) - { - var groupRuleSet = new RuleSet(group.Name); - - Repository.GetRuleSet(group.Name); - - foreach (var rule in group.Rules) - { - var builder = new RuleBuilder(); - builder.Name(rule.Name); - - PatternBuilder thisRulePattern = builder.LeftHandSide().Pattern(entityType, entityRuleName); - ParameterExpression thisRuleParameter = thisRulePattern.Declaration.ToParameterExpression(); - var ruleCondition = Expression.Lambda(DynamicExpressionParser.ParseLambda(typeof(bool), rule.Expression), thisRuleParameter); - thisRulePattern.Condition(ruleCondition); - } - } - throw new NotImplementedException(); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/RuleActivator.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/RuleActivator.cs deleted file mode 100644 index 4777a20d6..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/RuleActivator.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using NRules.Fluent; -using System; -using System.Collections.Generic; -using Volo.Abp.DependencyInjection; -using NRule = NRules.Fluent.Dsl.Rule; - -namespace LINGYUN.Abp.Rules -{ - [Dependency(ServiceLifetime.Transient, ReplaceServices = true)] - [ExposeServices(typeof(IRuleActivator))] - public class RuleActivator : IRuleActivator - { - protected IServiceProvider ServiceProvider { get; } - public RuleActivator(IServiceProvider serviceProvider) - { - ServiceProvider = serviceProvider; - } - public virtual IEnumerable Activate(Type type) - { - return (IEnumerable)ServiceProvider.GetServices(type); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/Microsoft/Extensions/DependencyInjection/NRulesServiceCollectionExtensions.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/Microsoft/Extensions/DependencyInjection/NRulesServiceCollectionExtensions.cs deleted file mode 100644 index 2097719c5..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/Microsoft/Extensions/DependencyInjection/NRulesServiceCollectionExtensions.cs +++ /dev/null @@ -1,55 +0,0 @@ -using LINGYUN.Abp.Rules; -using NRules; -using NRules.Fluent; -using NRules.RuleModel; -using System; - -namespace Microsoft.Extensions.DependencyInjection -{ - public static class NRulesServiceCollectionExtensions - { - public static IServiceCollection AddNRules(this IServiceCollection services, AbpNRulesOptions options) - { - services.RegisterRepository(); - services.RegisterSessionFactory(); - services.RegisterSession(); - - return services; - } - - public static IServiceCollection RegisterRepository(this IServiceCollection services) - { - services.AddSingleton(); - - services.AddSingleton(); - services.AddSingleton(); - - return services; - } - - public static IServiceCollection RegisterSessionFactory(this IServiceCollection services) - { - services.RegisterSessionFactory((provider) => provider.GetRequiredService().Compile()); - - return services; - } - - public static IServiceCollection RegisterSessionFactory(this IServiceCollection services, Func compileFunc) - { - services.AddSingleton(); - services.AddSingleton(compileFunc); - - return services; - } - - public static IServiceCollection RegisterSession(this IServiceCollection services) - { - return services.RegisterSession((provider) => provider.GetRequiredService().CreateSession()); - } - - public static IServiceCollection RegisterSession(this IServiceCollection services, Func factoryFunc) - { - return services.AddScoped(factoryFunc); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/NRules/RuleRepositoryExtensions.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/NRules/RuleRepositoryExtensions.cs deleted file mode 100644 index 2f29b2f7f..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/NRules/RuleRepositoryExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using NRules; -using System.Collections.Generic; - -namespace LINGYUN.Abp.Rules -{ - public static class RuleRepositoryExtensions - { - public static ISessionFactory Compile(this INRulesRepository repository, IEnumerable groups) - { - var compiler = new RuleCompiler(); - ISessionFactory factory = compiler.Compile(repository.GetRuleSets(groups)); - return factory; - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj deleted file mode 100644 index 3984f255e..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - netstandard2.0 - - - - - - - - diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/AbpRulesModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/AbpRulesModule.cs deleted file mode 100644 index b1167a5cd..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/AbpRulesModule.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Domain; -using Volo.Abp.Modularity; - -namespace LINGYUN.Abp.Rules -{ - [DependsOn( - typeof(AbpDddDomainModule))] - public class AbpRulesModule : AbpModule - { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - context.Services.OnRegistred(EntityChangedRulesInterceptorRegistrar.RegisterIfNeeded); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptor.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptor.cs deleted file mode 100644 index 948dde25f..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptor.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Entities; -using Volo.Abp.DynamicProxy; - -namespace LINGYUN.Abp.Rules -{ - public class EntityChangedRulesInterceptor : AbpInterceptor, ITransientDependency - { - protected IRuleFinder RuleFinder { get; } - protected IEntityRuleContributor EntityRuleContributor { get; } - - public EntityChangedRulesInterceptor( - IRuleFinder ruleFinder, - IEntityRuleContributor entityRuleContributor) - { - RuleFinder = ruleFinder; - EntityRuleContributor = entityRuleContributor; - } - - public override async Task InterceptAsync(IAbpMethodInvocation invocation) - { - var entityObj = invocation.Arguments.First(); - // TODO: 针对实体的变更执行一次定义的规则 - // IBasicRepository.InsertAsync || IBasicRepository.UpdateAsync || IBasicRepository.DeleteAsync - if (entityObj != null && entityObj is IEntity entity) - { - await ApplyEntityRuleAsync(entity); - } - - await invocation.ProceedAsync(); - } - - protected virtual async Task ApplyEntityRuleAsync(IEntity entity) - { - Type entityType = ProxyHelper.GetUnProxiedType(entity); - // 加载规则列表 - var groups = await RuleFinder.GetRuleGroupsAsync(entityType); - if (groups.Any()) - { - // 应用规则 - await EntityRuleContributor.ApplyAsync(new EntityRuleContext(groups, entity)); - } - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptorRegistrar.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptorRegistrar.cs deleted file mode 100644 index 3b7b11a4e..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptorRegistrar.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Repositories; -using Volo.Abp.DynamicProxy; - -namespace LINGYUN.Abp.Rules -{ - public static class EntityChangedRulesInterceptorRegistrar - { - public static void RegisterIfNeeded(IOnServiceRegistredContext context) - { - if (ShouldIntercept(context.ImplementationType)) - { - context.Interceptors.TryAdd(); - } - } - - private static bool ShouldIntercept(Type type) - { - // 拦截器的要求 - // 1、继承自IBasicRepository的仓储 - // 2、继承自INeedRule接口的实体 - return !DynamicProxyIgnoreTypes.Contains(type) && - type.IsAssignableTo(typeof(IBasicRepository<>)) && - type.GetGenericTypeDefinition().IsAssignableTo(typeof(INeedRule)); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityRuleContext.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityRuleContext.cs deleted file mode 100644 index 58bbd744e..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityRuleContext.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using Volo.Abp.Domain.Entities; - -namespace LINGYUN.Abp.Rules -{ - public class EntityRuleContext - { - public List Groups { get; } - public IEntity Entity { get; } - public EntityRuleContext( - List groups, - IEntity entity) - { - Groups = groups; - Entity = entity; - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ErrorType.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ErrorType.cs deleted file mode 100644 index 6b5825435..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ErrorType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace LINGYUN.Abp.Rules -{ - public enum ErrorType - { - Warning = 0, - Error = 1 - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ExpressionType.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ExpressionType.cs deleted file mode 100644 index 49fb8dcc1..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ExpressionType.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace LINGYUN.Abp.Rules -{ - public enum ExpressionType - { - LambdaExpression = 0 - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IEntityRuleContributor.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IEntityRuleContributor.cs deleted file mode 100644 index badbd75ff..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IEntityRuleContributor.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Threading.Tasks; - -namespace LINGYUN.Abp.Rules -{ - public interface IEntityRuleContributor - { - Task ApplyAsync(EntityRuleContext context); - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/INeedRule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/INeedRule.cs deleted file mode 100644 index 7a1faab36..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/INeedRule.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace LINGYUN.Abp.Rules -{ - public interface INeedRule - { - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IRuleFinder.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IRuleFinder.cs deleted file mode 100644 index ee3f61064..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IRuleFinder.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace LINGYUN.Abp.Rules -{ - public interface IRuleFinder - { - Task> GetRuleGroupsAsync(Type entityType); - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullEntityRuleContributor.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullEntityRuleContributor.cs deleted file mode 100644 index 52a170c94..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullEntityRuleContributor.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; - -namespace LINGYUN.Abp.Rules -{ - public class NullEntityRuleContributor : IEntityRuleContributor, ISingletonDependency - { - public Task ApplyAsync(EntityRuleContext context) - { - return Task.CompletedTask; - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullRuleFinder.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullRuleFinder.cs deleted file mode 100644 index 81aaa79cc..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullRuleFinder.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; - -namespace LINGYUN.Abp.Rules -{ - public class NullRuleFinder : IRuleFinder, ISingletonDependency - { - public Task> GetRuleGroupsAsync(Type entityType) - { - return Task.FromResult(new List()); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/Rule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/Rule.cs deleted file mode 100644 index 4d18e8d5a..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/Rule.cs +++ /dev/null @@ -1,90 +0,0 @@ -using JetBrains.Annotations; -using System; -using System.Collections.Generic; -using Volo.Abp; - -namespace LINGYUN.Abp.Rules -{ - /// - /// ref: https://github.com/microsoft/RulesEngine/blob/master/src/RulesEngine/RulesEngine/Models/Rule.cs - /// - public class Rule - { - [NotNull] - public string Name { get; set; } - public string Operator { get; set; } - public string ErrorMessage { get; set; } - public DateTime CreationTime { get; set; } - public ErrorType ErrorType { get; set; } - public ExpressionType? ExpressionType { get; set; } - public List Rules { get; set; } - public List InjectRules { get; set; } - public List Params { get; set; } - public string Expression { get; set; } - public string SuccessEvent { get; set; } - protected Rule() { } - public Rule( - [NotNull] string name, - string operation, - DateTime creationTime, - string expression = null, - string successEvent = null, - ErrorType errorType = ErrorType.Warning, - ExpressionType? expressionType = null) - { - Check.NotNullOrWhiteSpace(name, nameof(name)); - - Name = name; - Operator = operation; - CreationTime = creationTime; - Expression = expression; - SuccessEvent = successEvent; - ErrorType = errorType; - ExpressionType = expressionType; - - Rules = new List(); - Params = new List(); - InjectRules = new List(); - } - - public Rule CreateChildren(Rule rule) - { - Rules.Add(rule); - - return this; - } - - public Rule WithParam(RuleParam param) - { - Params.AddIfNotContains(param); - return this; - } - - public Rule InjectRule(string ruleName) - { - InjectRules.AddIfNotContains(ruleName); - - return this; - } - - public override int GetHashCode() - { - return Name.GetHashCode(); - } - - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (obj is Rule rule) - { - return rule.Name.Equals(Name); - } - - return false; - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleGroup.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleGroup.cs deleted file mode 100644 index f426a5a03..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleGroup.cs +++ /dev/null @@ -1,53 +0,0 @@ -using JetBrains.Annotations; -using System.Collections.Generic; -using Volo.Abp; - -namespace LINGYUN.Abp.Rules -{ - public class RuleGroup - { - [NotNull] - public string Name { get; set; } - public List InjectRules { get; set; } - public List Rules { get; } - protected RuleGroup() { } - public RuleGroup( - [NotNull] string name) - { - Check.NotNullOrWhiteSpace(name, nameof(name)); - - Name = name; - - Rules = new List(); - InjectRules = new List(); - } - - public RuleGroup WithInjectRule(string ruleName) - { - InjectRules.AddIfNotContains(ruleName); - - return this; - } - - public RuleGroup WithInjectRule(IEnumerable ruleNames) - { - InjectRules.AddIfNotContains(ruleNames); - - return this; - } - - public RuleGroup WithRule(Rule rule) - { - Rules.AddIfNotContains(rule); - - return this; - } - - public RuleGroup WithRule(IEnumerable rules) - { - Rules.AddIfNotContains(rules); - - return this; - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleNameAttribute.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleNameAttribute.cs deleted file mode 100644 index 532acde00..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleNameAttribute.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Reflection; - -namespace LINGYUN.Abp.Rules -{ - public class RuleNameAttribute : Attribute - { - public string Name { get; } - public RuleNameAttribute(string name) - { - Name = name; - } - - public virtual string GetRuleNameForType(Type ruleType) - { - return Name; - } - - public static string GetRuleName() - { - return GetRuleName(typeof(TEntity)); - } - - public static string GetRuleName(Type entityType) - { - var ruleAttribute = entityType.GetSingleAttributeOrNull(); - if (ruleAttribute != null) - { - return ruleAttribute.GetRuleNameForType(entityType); - } - - return entityType.Name.RemovePostFix("Rule").ToKebabCase(); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleParam.cs b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleParam.cs deleted file mode 100644 index 086d945b1..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleParam.cs +++ /dev/null @@ -1,45 +0,0 @@ -using JetBrains.Annotations; -using Volo.Abp; - -namespace LINGYUN.Abp.Rules -{ - public class RuleParam - { - [NotNull] - public string Name { get; set; } - - [NotNull] - public string Expression { get; set; } - - protected RuleParam() { } - public RuleParam( - [NotNull] string name, - [NotNull] string expression) - { - Check.NotNullOrWhiteSpace(name, nameof(name)); - Check.NotNullOrWhiteSpace(expression, nameof(expression)); - - Name = name; - Expression = expression; - } - - public override int GetHashCode() - { - return Name.GetHashCode(); - } - - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (obj is RuleParam param) - { - return param.Name.Equals(Name); - } - return base.Equals(obj); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/README.md b/aspnet-core/modules/common/LINGYUN.Abp.Rules/README.md deleted file mode 100644 index b37832f46..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# LINGYUN.Abp.Rules - -规则引擎定义 - -## 配置使用 - -待完善 \ No newline at end of file diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj deleted file mode 100644 index b40c23d89..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - net5.0 - $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; - false - false - false - true - Library - - - - - - - - diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj.user b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj.user deleted file mode 100644 index cff74a90e..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - IIS Express - - \ No newline at end of file diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/AbpDaprActorsIdentityModelWebModule.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/AbpDaprActorsIdentityModelWebModule.cs deleted file mode 100644 index 068dbc8f7..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/AbpDaprActorsIdentityModelWebModule.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Volo.Abp.Modularity; - -namespace LINGYUN.Abp.Dapr.Actors.IdentityModel.Web -{ - [DependsOn( - typeof(AbpDaprActorsIdentityModelModule))] - public class AbpDaprActorsIdentityModelWebModule : AbpModule - { - } -} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/HttpContextIdentityModelDaprActorProxyAuthenticator.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/HttpContextIdentityModelDaprActorProxyAuthenticator.cs deleted file mode 100644 index 2f4cc8dab..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/HttpContextIdentityModelDaprActorProxyAuthenticator.cs +++ /dev/null @@ -1,51 +0,0 @@ -using LINGYUN.Abp.Dapr.Actors.Authentication; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; -using System.Net.Http.Headers; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.IdentityModel; - -namespace LINGYUN.Abp.Dapr.Actors.IdentityModel -{ - [Dependency(ReplaceServices = true)] - public class HttpContextIdentityModelDaprActorProxyAuthenticator : IdentityModelDaprActorProxyAuthenticator - { - public IHttpContextAccessor HttpContextAccessor { get; set; } - - public HttpContextIdentityModelDaprActorProxyAuthenticator( - IIdentityModelAuthenticationService identityModelAuthenticationService) - : base(identityModelAuthenticationService) - { - } - - public override async Task AuthenticateAsync(DaprActorProxyAuthenticateContext context) - { - if (context.RemoteService.GetUseCurrentAccessToken() != false) - { - var accessToken = await GetAccessTokenFromHttpContextOrNullAsync(); - if (accessToken != null) - { - context.Handler.PreConfigure(request => - { - request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - }); - return; - } - } - - await base.AuthenticateAsync(context); - } - - protected virtual async Task GetAccessTokenFromHttpContextOrNullAsync() - { - var httpContext = HttpContextAccessor?.HttpContext; - if (httpContext == null) - { - return null; - } - - return await httpContext.GetTokenAsync("access_token"); - } - } -} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/Properties/launchSettings.json b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/Properties/launchSettings.json deleted file mode 100644 index ea7755ed2..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/Properties/launchSettings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:25348/", - "sslPort": 44377 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "LINGYUN.Abp.Dapr.Actors.IdentityModel.Web": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" - } - } -} \ No newline at end of file diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/README.md b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/README.md deleted file mode 100644 index 359063b86..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# LINGYUN.Abp.Dapr.Actors.IdentityModel.Web - -Dapr.Actors内部使用Http进行服务间调用,此模块用于获取应用当前状态中的身份令牌并传递到远程Actor服务 - -## 配置使用 - -模块按需引用 - -```csharp -[DependsOn(typeof(AbpDaprActorsIdentityModelWebModule))] -public class YouProjectModule : AbpModule -{ - // other -} -``` -## 配置项说明 - - -## 其他 diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN.Abp.Dapr.Actors.IdentityModel.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN.Abp.Dapr.Actors.IdentityModel.csproj deleted file mode 100644 index c22be39ff..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN.Abp.Dapr.Actors.IdentityModel.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - net5.0 - - - - - - - - - - - - diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/DaprActorConfigurationExtensions.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/DaprActorConfigurationExtensions.cs deleted file mode 100644 index 481ea1290..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/DaprActorConfigurationExtensions.cs +++ /dev/null @@ -1,54 +0,0 @@ -using JetBrains.Annotations; -using System.Collections.Generic; -using Volo.Abp; - -namespace LINGYUN.Abp.Dapr.Actors -{ - public static class DaprActorConfigurationExtensions - { - public const string IdentityClientName = "IdentityClient"; - public const string UseCurrentAccessTokenName = "UseCurrentAccessToken"; - - [CanBeNull] - public static string GetIdentityClient([NotNull] this DaprActorConfiguration configuration) - { - Check.NotNullOrEmpty(configuration, nameof(configuration)); - - return configuration.GetOrDefault(IdentityClientName); - } - - public static DaprActorConfiguration SetIdentityClient([NotNull] this DaprActorConfiguration configuration, [CanBeNull] string value) - { - configuration[IdentityClientName] = value; - return configuration; - } - - [CanBeNull] - public static bool? GetUseCurrentAccessToken([NotNull] this DaprActorConfiguration configuration) - { - Check.NotNullOrEmpty(configuration, nameof(configuration)); - - var value = configuration.GetOrDefault(UseCurrentAccessTokenName); - if (value == null) - { - return null; - } - - return bool.Parse(value); - } - - public static DaprActorConfiguration SetUseCurrentAccessToken([NotNull] this DaprActorConfiguration configuration, [CanBeNull] bool? value) - { - if (value == null) - { - configuration.Remove(UseCurrentAccessTokenName); - } - else - { - configuration[UseCurrentAccessTokenName] = value.Value.ToString().ToLowerInvariant(); - } - - return configuration; - } - } -} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/AbpDaprActorsIdentityModelModule.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/AbpDaprActorsIdentityModelModule.cs deleted file mode 100644 index d0d79453f..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/AbpDaprActorsIdentityModelModule.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Volo.Abp.IdentityModel; -using Volo.Abp.Modularity; - -namespace LINGYUN.Abp.Dapr.Actors.IdentityModel -{ - [DependsOn( - typeof(AbpDaprActorsModule), - typeof(AbpIdentityModelModule) - )] - public class AbpDaprActorsIdentityModelModule : AbpModule - { - } -} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/IdentityModelDaprActorProxyAuthenticator.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/IdentityModelDaprActorProxyAuthenticator.cs deleted file mode 100644 index f2c238ac0..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/IdentityModelDaprActorProxyAuthenticator.cs +++ /dev/null @@ -1,66 +0,0 @@ -using LINGYUN.Abp.Dapr.Actors.Authentication; -using LINGYUN.Abp.Dapr.Actors.DynamicProxying; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using System; -using System.Collections.Generic; -using System.Net.Http.Headers; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.IdentityModel; - -namespace LINGYUN.Abp.Dapr.Actors.IdentityModel -{ - [Dependency(ReplaceServices = true)] - public class IdentityModelDaprActorProxyAuthenticator : IDaprActorProxyAuthenticator, ITransientDependency - { - protected AbpIdentityClientOptions ClientOptions { get; } - protected IIdentityModelAuthenticationService IdentityModelAuthenticationService { get; } - - public ILogger Logger { get; set; } - - public IdentityModelDaprActorProxyAuthenticator( - IIdentityModelAuthenticationService identityModelAuthenticationService) - { - IdentityModelAuthenticationService = identityModelAuthenticationService; - Logger = NullLogger.Instance; - } - - public virtual async Task AuthenticateAsync(DaprActorProxyAuthenticateContext context) - { - var identityClientName = context.RemoteService.GetIdentityClient(); - var configuration = GetClientConfiguration(identityClientName); - if (configuration == null) - { - Logger.LogWarning($"Could not find {nameof(IdentityClientConfiguration)} for {identityClientName}. Either define a configuration for {identityClientName} or set a default configuration."); - return; - } - var accessToken = await IdentityModelAuthenticationService.GetAccessTokenAsync(configuration); - if (accessToken == null) - { - return; - } - - SetAccessToken(context.Handler, accessToken); - } - - protected virtual void SetAccessToken(DaprHttpClientHandler handler, string accessToken) - { - handler.PreConfigure(request => - { - request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - }); - } - - private IdentityClientConfiguration GetClientConfiguration(string identityClientName = null) - { - if (identityClientName.IsNullOrEmpty()) - { - return ClientOptions.IdentityClients.Default; - } - - return ClientOptions.IdentityClients.GetOrDefault(identityClientName) ?? - ClientOptions.IdentityClients.Default; - } - } -} diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/README.md b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/README.md deleted file mode 100644 index 28dd4a3f4..000000000 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# LINGYUN.Abp.Dapr.Actors.IdentityModel - -Dapr.Actors内部使用Http进行服务间调用,此模块用于传递服务间调用令牌 - -## 配置使用 - -模块按需引用 - -```csharp -[DependsOn(typeof(AbpDaprActorsIdentityModelModule))] -public class YouProjectModule : AbpModule -{ - // other -} -``` -## 配置项说明 - - -## 其他 diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlLocalizationFile.cs b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlLocalizationFile.cs index b2f93373e..bd003aa49 100644 --- a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlLocalizationFile.cs +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlLocalizationFile.cs @@ -7,7 +7,7 @@ using System.Xml.Serialization; namespace LINGYUN.Abp.Localization.Xml { [Serializable] - [XmlRoot(Namespace = "lingyun.abp", ElementName = "localization")] + [XmlRoot(ElementName = "localization")] public class XmlLocalizationFile { [XmlElement("culture")] diff --git a/aspnet-core/tests/LINGYUN.Abp.Localization.Json.Tests/LINGYUN.Abp.Localization.Json.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Localization.Json.Tests/LINGYUN.Abp.Localization.Json.Tests.csproj index 6aa92b3f2..9acfeff52 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Localization.Json.Tests/LINGYUN.Abp.Localization.Json.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Localization.Json.Tests/LINGYUN.Abp.Localization.Json.Tests.csproj @@ -20,7 +20,6 @@ - From 628f36d6bd6f53a3abc47350f88a546fb4870452 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 13 May 2021 11:50:01 +0800 Subject: [PATCH 2/2] Refactoring RulesEngine integration --- aspnet-core/LINGYUN.MicroService.All.sln | 7 ++ aspnet-core/LINGYUN.MicroService.Common.sln | 9 +-- .../Rules/RulesEngine/AbpRulesEngineModule.cs | 8 +-- .../RulesEngine/AbpRulesEngineOptions.cs | 9 --- .../AbpRulesEngineResolveOptions.cs | 27 ++++++++ ...roviderWorkflowRulesResolveContributor.cs} | 52 +++++++------- ...bpRulesEnginePthsicalFileResolveOptions.cs | 10 +++ .../PhysicalFileWorkflowRulesContributor.cs | 42 ------------ ...icalFileWorkflowRulesResolveContributor.cs | 44 ++++++++++++ .../RulesEngine/IWorkflowRulesContributor.cs | 15 ----- .../IWorkflowRulesResolveContext.cs | 19 ++++++ .../IWorkflowRulesResolveContributor.cs | 15 +++++ .../RulesEngine/IWorkflowRulesResolver.cs | 16 +++++ .../NullWorkflowRulesContributor.cs | 25 ------- .../Persistent/IWorkflowRuleStore.cs | 16 +++++ .../Persistent/NullWorkflowRuleStore.cs | 19 ++++++ ...rsistentWorkflowRulesResolveContributor.cs | 31 +++++++++ .../RulesEngine/RulesEngineContributor.cs | 36 +++------- .../WorkflowRulesResolveContext.cs | 30 +++++++++ .../WorkflowRulesResolveContributorBase.cs | 18 +++++ .../RulesEngine/WorkflowRulesResolveResult.cs | 18 +++++ .../RulesEngine/WorkflowRulesResolver.cs | 67 +++++++++++++++++++ .../LINGYUN.Abp.Rules.RulesEngine/README.md | 14 +++- 23 files changed, 391 insertions(+), 156 deletions(-) create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineResolveOptions.cs rename aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/{FileProviderWorkflowRulesContributor.cs => FileProviderWorkflowRulesResolveContributor.cs} (55%) create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/AbpRulesEnginePthsicalFileResolveOptions.cs delete mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesContributor.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesResolveContributor.cs delete mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesContributor.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContext.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContributor.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolver.cs delete mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/NullWorkflowRulesContributor.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/IWorkflowRuleStore.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/NullWorkflowRuleStore.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/PersistentWorkflowRulesResolveContributor.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContext.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContributorBase.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveResult.cs create mode 100644 aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolver.cs diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index 4efb91e18..d690d53c1 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -327,6 +327,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.NRules", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.RulesEngine", "modules\rules\LINGYUN.Abp.Rules.RulesEngine\LINGYUN.Abp.Rules.RulesEngine.csproj", "{4D83BDA7-2059-41C7-85AE-FEFAD5CD9498}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.RulesEngine.Tests", "tests\LINGYUN.Abp.Rules.RulesEngine.Tests\LINGYUN.Abp.Rules.RulesEngine.Tests.csproj", "{8EF31071-3521-409D-9740-BBFBFC04C50E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -853,6 +855,10 @@ Global {4D83BDA7-2059-41C7-85AE-FEFAD5CD9498}.Debug|Any CPU.Build.0 = Debug|Any CPU {4D83BDA7-2059-41C7-85AE-FEFAD5CD9498}.Release|Any CPU.ActiveCfg = Release|Any CPU {4D83BDA7-2059-41C7-85AE-FEFAD5CD9498}.Release|Any CPU.Build.0 = Release|Any CPU + {8EF31071-3521-409D-9740-BBFBFC04C50E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EF31071-3521-409D-9740-BBFBFC04C50E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EF31071-3521-409D-9740-BBFBFC04C50E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EF31071-3521-409D-9740-BBFBFC04C50E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1014,6 +1020,7 @@ Global {D60EFB8E-F168-4EF2-8D8F-ED42EB6FB8CF} = {6084D52D-775B-4A39-8CD5-AA2F362B5A61} {34BB9810-2983-4E55-A96A-132D32310145} = {6084D52D-775B-4A39-8CD5-AA2F362B5A61} {4D83BDA7-2059-41C7-85AE-FEFAD5CD9498} = {6084D52D-775B-4A39-8CD5-AA2F362B5A61} + {8EF31071-3521-409D-9740-BBFBFC04C50E} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/LINGYUN.MicroService.Common.sln b/aspnet-core/LINGYUN.MicroService.Common.sln index 871b875b8..e48c2a542 100644 --- a/aspnet-core/LINGYUN.MicroService.Common.sln +++ b/aspnet-core/LINGYUN.MicroService.Common.sln @@ -119,8 +119,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.Mvc. EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "localization", "localization", "{E73A0F8B-2B4B-4CED-82A4-1EE5E0B89744}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Json", "modules\localization\LINGYUN.Abp.Localization.Json\LINGYUN.Abp.Localization.Json.csproj", "{DADD5D6E-F09A-4563-A659-7922E26C40AB}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Xml", "modules\localization\LINGYUN.Abp.Localization.Xml\LINGYUN.Abp.Localization.Xml.csproj", "{8CC72F4E-F134-4A43-9037-5D4D1F29B68A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Xml.Tests", "tests\LINGYUN.Abp.Localization.Xml.Tests\LINGYUN.Abp.Localization.Xml.Tests.csproj", "{94FEA59E-3B6D-41A0-9E44-BA5D6477244F}" @@ -156,7 +154,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dapr.Tests", "t EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dapr.AspNetCore.TestHost", "tests\LINGYUN.Abp.Dapr.AspNetCore.TestHost\LINGYUN.Abp.Dapr.AspNetCore.TestHost.csproj", "{8968EDAF-9F5C-4786-AF2A-D3928B70C3EC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Dapr.Actors.Tests", "tests\LINGYUN.Abp.Dapr.Actors.Tests\LINGYUN.Abp.Dapr.Actors.Tests.csproj", "{CF30221B-CA7A-42CD-B91A-B7224AB2F38B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dapr.Actors.Tests", "tests\LINGYUN.Abp.Dapr.Actors.Tests\LINGYUN.Abp.Dapr.Actors.Tests.csproj", "{CF30221B-CA7A-42CD-B91A-B7224AB2F38B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -348,10 +346,6 @@ Global {7F767ACF-754A-4EBC-8936-3C1402B6EF82}.Debug|Any CPU.Build.0 = Debug|Any CPU {7F767ACF-754A-4EBC-8936-3C1402B6EF82}.Release|Any CPU.ActiveCfg = Release|Any CPU {7F767ACF-754A-4EBC-8936-3C1402B6EF82}.Release|Any CPU.Build.0 = Release|Any CPU - {DADD5D6E-F09A-4563-A659-7922E26C40AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DADD5D6E-F09A-4563-A659-7922E26C40AB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DADD5D6E-F09A-4563-A659-7922E26C40AB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DADD5D6E-F09A-4563-A659-7922E26C40AB}.Release|Any CPU.Build.0 = Release|Any CPU {8CC72F4E-F134-4A43-9037-5D4D1F29B68A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8CC72F4E-F134-4A43-9037-5D4D1F29B68A}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CC72F4E-F134-4A43-9037-5D4D1F29B68A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -473,7 +467,6 @@ Global {1B494EA1-28CF-4A61-B0BE-70BBA425C316} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} {7F767ACF-754A-4EBC-8936-3C1402B6EF82} = {086BE5BE-8594-4DA7-8819-935FEF76DABD} {E73A0F8B-2B4B-4CED-82A4-1EE5E0B89744} = {02EA4E78-5891-43BC-944F-3E52FEE032E4} - {DADD5D6E-F09A-4563-A659-7922E26C40AB} = {E73A0F8B-2B4B-4CED-82A4-1EE5E0B89744} {8CC72F4E-F134-4A43-9037-5D4D1F29B68A} = {E73A0F8B-2B4B-4CED-82A4-1EE5E0B89744} {94FEA59E-3B6D-41A0-9E44-BA5D6477244F} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} {BA2F4EC9-BC2C-482A-9123-BDACB8B15295} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineModule.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineModule.cs index 0487d113d..89f980747 100644 --- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineModule.cs +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineModule.cs @@ -1,4 +1,5 @@ using LINGYUN.Abp.Rules.RulesEngine.FileProviders.Physical; +using LINGYUN.Abp.Rules.RulesEngine.Persistent; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Json; using Volo.Abp.Modularity; @@ -19,11 +20,10 @@ namespace LINGYUN.Abp.Rules.RulesEngine options.Contributors.Add(); }); - Configure(options => + Configure(options => { - // 加入防止空引用 - options.Contributors.Add(); - options.Contributors.Add(); + options.WorkflowRulesResolvers.Add(new PersistentWorkflowRulesResolveContributor()); + options.WorkflowRulesResolvers.Add(new PhysicalFileWorkflowRulesResolveContributor()); }); } } diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineOptions.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineOptions.cs index 176358fee..0c57ff987 100644 --- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineOptions.cs +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineOptions.cs @@ -4,22 +4,13 @@ namespace LINGYUN.Abp.Rules.RulesEngine { public class AbpRulesEngineOptions { - /// - /// 本地文件路径 - /// - public string PhysicalPath { get; set; } /// /// 是否忽略租户 /// public bool IgnoreMultiTenancy { get; set; } - /// - /// 规则提供者类型 - /// - public ITypeList Contributors { get; } public AbpRulesEngineOptions() { - Contributors = new TypeList(); } } } diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineResolveOptions.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineResolveOptions.cs new file mode 100644 index 000000000..681a4449e --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineResolveOptions.cs @@ -0,0 +1,27 @@ +using JetBrains.Annotations; +using System.Collections.Generic; + +namespace LINGYUN.Abp.Rules.RulesEngine +{ + public class AbpRulesEngineResolveOptions + { + /// + /// 合并规则 + /// 如果为 true,在上一个提供者解析规则之后继续执行下一个提供者 + /// 如果为 false,在上一个提供者解析规则之后立即执行规则 + /// 默认:false + /// + public bool MergingRuels { get; set; } + /// + /// 规则解析提供者 + /// + [NotNull] + public List WorkflowRulesResolvers { get; } + + public AbpRulesEngineResolveOptions() + { + MergingRuels = false; + WorkflowRulesResolvers = new List(); + } + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesResolveContributor.cs similarity index 55% rename from aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesContributor.cs rename to aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesResolveContributor.cs index b578c31dd..488d14f36 100644 --- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesContributor.cs +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesResolveContributor.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Primitives; using RulesEngine.Models; @@ -10,38 +11,43 @@ using Volo.Abp.Json; namespace LINGYUN.Abp.Rules.RulesEngine.FileProviders { - public abstract class FileProviderWorkflowRulesContributor : IWorkflowRulesContributor + public abstract class FileProviderWorkflowRulesResolveContributor : WorkflowRulesResolveContributorBase { - protected IMemoryCache RulesCache { get; } - protected IJsonSerializer JsonSerializer { get; } + protected IMemoryCache RulesCache { get; private set; } + protected IJsonSerializer JsonSerializer { get; private set; } protected IFileProvider FileProvider { get; private set; } - protected FileProviderWorkflowRulesContributor( - IMemoryCache ruleCache, - IJsonSerializer jsonSerializer) + protected FileProviderWorkflowRulesResolveContributor() { - RulesCache = ruleCache; - JsonSerializer = jsonSerializer; } - public void Initialize() + public override void Initialize(RulesInitializationContext context) + { + Initialize(context.ServiceProvider); + + RulesCache = context.ServiceProvider.GetRequiredService(); + JsonSerializer = context.ServiceProvider.GetRequiredService(); + + FileProvider = BuildFileProvider(context); + } + + protected virtual void Initialize(IServiceProvider serviceProvider) { - FileProvider = BuildFileProvider(); } - protected abstract IFileProvider BuildFileProvider(); + protected abstract IFileProvider BuildFileProvider(RulesInitializationContext context); - public async Task LoadAsync(CancellationToken cancellationToken = default) + public override async Task ResolveAsync(IWorkflowRulesResolveContext context) { if (FileProvider != null) { - return await GetCachedRulesAsync(cancellationToken); + context.WorkflowRules = await GetCachedRulesAsync(context.Type); } - return new WorkflowRules[0]; + context.Handled = true; } - public void Shutdown() + public override void Shutdown() { if (FileProvider != null && FileProvider is IDisposable resource) { @@ -49,28 +55,28 @@ namespace LINGYUN.Abp.Rules.RulesEngine.FileProviders } } - private async Task GetCachedRulesAsync(CancellationToken cancellationToken = default) + private async Task GetCachedRulesAsync(Type type, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - var ruleId = GetRuleId(); + var ruleId = GetRuleId(type); return await RulesCache.GetOrCreateAsync(ruleId, async (entry) => { entry.SetAbsoluteExpiration(TimeSpan.FromMinutes(30)); - return await GetFileSystemRulesAsync(cancellationToken); + return await GetFileSystemRulesAsync(type, cancellationToken); }); } - protected abstract int GetRuleId(); + protected abstract int GetRuleId(Type type); - protected abstract string GetRuleName(); + protected abstract string GetRuleName(Type type); - protected virtual async Task GetFileSystemRulesAsync(CancellationToken cancellationToken = default) + protected virtual async Task GetFileSystemRulesAsync(Type type, CancellationToken cancellationToken = default) { - var ruleId = GetRuleId(); - var ruleFile = GetRuleName(); + var ruleId = GetRuleId(type); + var ruleFile = GetRuleName(type); var fileInfo = FileProvider.GetFileInfo(ruleFile); if (fileInfo != null && fileInfo.Exists) { diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/AbpRulesEnginePthsicalFileResolveOptions.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/AbpRulesEnginePthsicalFileResolveOptions.cs new file mode 100644 index 000000000..9e87a88ab --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/AbpRulesEnginePthsicalFileResolveOptions.cs @@ -0,0 +1,10 @@ +namespace LINGYUN.Abp.Rules.RulesEngine.FileProviders.Physical +{ + public class AbpRulesEnginePthsicalFileResolveOptions + { + /// + /// 本地文件路径 + /// + public string PhysicalPath { get; set; } + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesContributor.cs deleted file mode 100644 index 1060e2631..000000000 --- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesContributor.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Options; -using System; -using System.IO; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Json; - -namespace LINGYUN.Abp.Rules.RulesEngine.FileProviders.Physical -{ - public class PhysicalFileWorkflowRulesContributor : FileProviderWorkflowRulesContributor, ISingletonDependency - { - private readonly RuleIdGenerator _ruleIdGenerator; - private readonly AbpRulesEngineOptions _options; - public PhysicalFileWorkflowRulesContributor( - IMemoryCache ruleCache, - RuleIdGenerator ruleIdGenerator, - IJsonSerializer jsonSerializer, - IOptions options) - : base(ruleCache, jsonSerializer) - { - _ruleIdGenerator = ruleIdGenerator; - - _options = options.Value; - } - - protected override IFileProvider BuildFileProvider() - { - // 未指定路径不启用 - if (!_options.PhysicalPath.IsNullOrWhiteSpace() && - Directory.Exists(_options.PhysicalPath)) - { - return new PhysicalFileProvider(_options.PhysicalPath); - } - return null; - } - - protected override int GetRuleId() => _ruleIdGenerator.CreateRuleId(typeof(T), _options.IgnoreMultiTenancy); - - protected override string GetRuleName() => $"{_ruleIdGenerator.CreateRuleName(typeof(T), _options.IgnoreMultiTenancy)}.json"; - } -} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesResolveContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesResolveContributor.cs new file mode 100644 index 000000000..b63ad2d86 --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesResolveContributor.cs @@ -0,0 +1,44 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Options; +using System; +using System.IO; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.Rules.RulesEngine.FileProviders.Physical +{ + public class PhysicalFileWorkflowRulesResolveContributor : FileProviderWorkflowRulesResolveContributor, ISingletonDependency + { + public override string Name => "PhysicalFile"; + + private RuleIdGenerator _ruleIdGenerator; + private AbpRulesEngineOptions _rulesEngineOptions; + private AbpRulesEnginePthsicalFileResolveOptions _fileResolveOptions; + + public PhysicalFileWorkflowRulesResolveContributor() + { + } + + protected override void Initialize(IServiceProvider serviceProvider) + { + _ruleIdGenerator = serviceProvider.GetRequiredService(); + _rulesEngineOptions = serviceProvider.GetRequiredService>().Value; + _fileResolveOptions = serviceProvider.GetRequiredService>().Value; + } + + protected override IFileProvider BuildFileProvider(RulesInitializationContext context) + { + // 未指定路径不启用 + if (!_fileResolveOptions.PhysicalPath.IsNullOrWhiteSpace() && + Directory.Exists(_fileResolveOptions.PhysicalPath)) + { + return new PhysicalFileProvider(_fileResolveOptions.PhysicalPath); + } + return null; + } + + protected override int GetRuleId(Type type) => _ruleIdGenerator.CreateRuleId(type, _rulesEngineOptions.IgnoreMultiTenancy); + + protected override string GetRuleName(Type type) => $"{_ruleIdGenerator.CreateRuleName(type, _rulesEngineOptions.IgnoreMultiTenancy)}.json"; + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesContributor.cs deleted file mode 100644 index b13da479d..000000000 --- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesContributor.cs +++ /dev/null @@ -1,15 +0,0 @@ -using RulesEngine.Models; -using System.Threading; -using System.Threading.Tasks; - -namespace LINGYUN.Abp.Rules.RulesEngine -{ - public interface IWorkflowRulesContributor - { - void Initialize(); - - Task LoadAsync(CancellationToken cancellationToken = default); - - void Shutdown(); - } -} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContext.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContext.cs new file mode 100644 index 000000000..cc811cbef --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContext.cs @@ -0,0 +1,19 @@ +using JetBrains.Annotations; +using RulesEngine.Models; +using System; +using System.Collections.Generic; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.Rules.RulesEngine +{ + public interface IWorkflowRulesResolveContext : IServiceProviderAccessor + { + [CanBeNull] + IEnumerable WorkflowRules { get; set; } + + [NotNull] + Type Type { get; } + + bool Handled { get; set; } + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContributor.cs new file mode 100644 index 000000000..66649ba1d --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContributor.cs @@ -0,0 +1,15 @@ +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Rules.RulesEngine +{ + public interface IWorkflowRulesResolveContributor + { + string Name { get; } + + Task ResolveAsync(IWorkflowRulesResolveContext context); + + void Initialize(RulesInitializationContext context); + + void Shutdown(); + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolver.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolver.cs new file mode 100644 index 000000000..8fdca6fee --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolver.cs @@ -0,0 +1,16 @@ +using JetBrains.Annotations; +using System; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Rules.RulesEngine +{ + public interface IWorkflowRulesResolver + { + void Initialize(RulesInitializationContext context); + + [NotNull] + Task ResolveWorkflowRulesAsync(Type type); + + void Shutdown(); + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/NullWorkflowRulesContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/NullWorkflowRulesContributor.cs deleted file mode 100644 index c80dca944..000000000 --- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/NullWorkflowRulesContributor.cs +++ /dev/null @@ -1,25 +0,0 @@ -using RulesEngine.Models; -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; - -namespace LINGYUN.Abp.Rules.RulesEngine -{ - public class NullWorkflowRulesContributor : IWorkflowRulesContributor, ISingletonDependency - { - public void Initialize() - { - - } - - public Task LoadAsync(CancellationToken cancellationToken = default) - { - return Task.FromResult(new WorkflowRules[0]); - } - - public void Shutdown() - { - - } - } -} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/IWorkflowRuleStore.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/IWorkflowRuleStore.cs new file mode 100644 index 000000000..682069ae7 --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/IWorkflowRuleStore.cs @@ -0,0 +1,16 @@ +using RulesEngine.Models; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Rules.RulesEngine.Persistent +{ + /// + /// 实现此接口以用于从其他持久化存储中获取规则 + /// + public interface IWorkflowRuleStore + { + Task> GetRulesAsync(Type inputType, CancellationToken cancellationToken = default); + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/NullWorkflowRuleStore.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/NullWorkflowRuleStore.cs new file mode 100644 index 000000000..b51efb69d --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/NullWorkflowRuleStore.cs @@ -0,0 +1,19 @@ +using RulesEngine.Models; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.Rules.RulesEngine.Persistent +{ + [Dependency(TryRegister = true)] + public class NullWorkflowRuleStore : IWorkflowRuleStore, ISingletonDependency + { + public Task> GetRulesAsync(Type inputType, CancellationToken cancellationToken = default) + { + IEnumerable rules = new WorkflowRules[0]; + return Task.FromResult(rules); + } + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/PersistentWorkflowRulesResolveContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/PersistentWorkflowRulesResolveContributor.cs new file mode 100644 index 000000000..c66763d91 --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/PersistentWorkflowRulesResolveContributor.cs @@ -0,0 +1,31 @@ +using Microsoft.Extensions.DependencyInjection; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.Rules.RulesEngine.Persistent +{ + public class PersistentWorkflowRulesResolveContributor : WorkflowRulesResolveContributorBase, ITransientDependency + { + private IWorkflowRuleStore _store; + public override string Name => "Persistent"; + + protected IWorkflowRuleStore Store => _store; + + public PersistentWorkflowRulesResolveContributor() + { + } + + public override void Initialize(RulesInitializationContext context) + { + _store = context.ServiceProvider.GetRequiredService(); + } + + public override async Task ResolveAsync(IWorkflowRulesResolveContext context) + { + var rules = await Store.GetRulesAsync(context.Type); + + context.Handled = true; + context.WorkflowRules = rules; + } + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs index 72534d926..1c8aaa997 100644 --- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs @@ -1,9 +1,6 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using RulesEngine; +using RulesEngine; using RulesEngine.Interfaces; using RulesEngine.Models; -using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -16,50 +13,33 @@ namespace LINGYUN.Abp.Rules.RulesEngine public class RulesEngineContributor : RuleContributorBase, ISingletonDependency { private IRulesEngine _ruleEngine; - private readonly IEnumerable _workflowRulesContributors; + private readonly IWorkflowRulesResolver _workflowRulesResolver; public RulesEngineContributor( - IServiceProvider serviceProvider, - IOptions options) + IWorkflowRulesResolver workflowRulesResolver) { - _workflowRulesContributors = options.Value - .Contributors - .Select(serviceProvider.GetRequiredService) - .Cast() - .ToArray(); + _workflowRulesResolver = workflowRulesResolver; } public override void Initialize(RulesInitializationContext context) { _ruleEngine = CreateRulesEngine(); - foreach (var contributor in _workflowRulesContributors) - { - contributor.Initialize(); - } + _workflowRulesResolver.Initialize(context); } public override async Task ExecuteAsync(T input, object[] @params = null, CancellationToken cancellationToken = default) { - List workflowRules = new(); + var result = await _workflowRulesResolver.ResolveWorkflowRulesAsync(typeof(T)); - foreach (var contributor in _workflowRulesContributors) + if (result.WorkflowRules.Any()) { - workflowRules.AddRange(await contributor.LoadAsync(cancellationToken)); - } - - if (workflowRules.Any()) - { - await ExecuteRulesAsync(input, workflowRules.ToArray(), @params); + await ExecuteRulesAsync(input, result.WorkflowRules.ToArray(), @params); } } public override void Shutdown() { - foreach (var contributor in _workflowRulesContributors) - { - contributor.Shutdown(); - } } /// /// 重写自行构建规则引擎 diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContext.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContext.cs new file mode 100644 index 000000000..8c5f1bdaf --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContext.cs @@ -0,0 +1,30 @@ +using JetBrains.Annotations; +using RulesEngine.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using Volo.Abp; + +namespace LINGYUN.Abp.Rules.RulesEngine +{ + public class WorkflowRulesResolveContext : IWorkflowRulesResolveContext + { + public Type Type { get; } + public IServiceProvider ServiceProvider { get; } + public IEnumerable WorkflowRules { get; set; } + public bool Handled { get; set; } + + public bool HasResolved() + { + return Handled && WorkflowRules?.Any() == true; + } + + public WorkflowRulesResolveContext( + [NotNull] Type type, + IServiceProvider serviceProvider) + { + Type = Check.NotNull(type, nameof(type)); + ServiceProvider = serviceProvider; + } + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContributorBase.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContributorBase.cs new file mode 100644 index 000000000..d670bd342 --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContributorBase.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Rules.RulesEngine +{ + public abstract class WorkflowRulesResolveContributorBase : IWorkflowRulesResolveContributor + { + public abstract string Name { get; } + + public virtual void Initialize(RulesInitializationContext context) + { + } + public abstract Task ResolveAsync(IWorkflowRulesResolveContext context); + + public virtual void Shutdown() + { + } + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveResult.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveResult.cs new file mode 100644 index 000000000..fda3c07ea --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveResult.cs @@ -0,0 +1,18 @@ +using RulesEngine.Models; +using System.Collections.Generic; + +namespace LINGYUN.Abp.Rules.RulesEngine +{ + public class WorkflowRulesResolveResult + { + public List WorkflowRules { get; set; } + + public List AppliedResolvers { get; } + + public WorkflowRulesResolveResult() + { + AppliedResolvers = new List(); + WorkflowRules = new List(); + } + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolver.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolver.cs new file mode 100644 index 000000000..cb3a5add8 --- /dev/null +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolver.cs @@ -0,0 +1,67 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using System; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.Rules.RulesEngine +{ + public class WorkflowRulesResolver : IWorkflowRulesResolver, ITransientDependency + { + private readonly IServiceProvider _serviceProvider; + private readonly AbpRulesEngineResolveOptions _options; + + public WorkflowRulesResolver( + IServiceProvider serviceProvider, + IOptions options) + { + _options = options.Value; + _serviceProvider = serviceProvider; + } + + public virtual void Initialize(RulesInitializationContext context) + { + foreach (var workflowRulesResolver in _options.WorkflowRulesResolvers) + { + workflowRulesResolver.Initialize(context); + } + } + + public virtual async Task ResolveWorkflowRulesAsync(Type type) + { + var result = new WorkflowRulesResolveResult(); + + using (var serviceScope = _serviceProvider.CreateScope()) + { + var context = new WorkflowRulesResolveContext(type, serviceScope.ServiceProvider); + + foreach (var workflowRulesResolver in _options.WorkflowRulesResolvers) + { + await workflowRulesResolver.ResolveAsync(context); + + result.AppliedResolvers.Add(workflowRulesResolver.Name); + + if (context.HasResolved()) + { + result.WorkflowRules.AddRange(context.WorkflowRules); + + if (!_options.MergingRuels) + { + break; + } + } + } + } + + return result; + } + + public virtual void Shutdown() + { + foreach (var workflowRulesResolver in _options.WorkflowRulesResolvers) + { + workflowRulesResolver.Shutdown(); + } + } + } +} diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/README.md b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/README.md index 603c4787b..fcfc5862a 100644 --- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/README.md +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/README.md @@ -4,12 +4,16 @@ 集成微软规则引擎的实现 -默认实现一个本地文件系统规则提供者,根据用户配置的 **PhysicalPath** 路径检索规则文件 +默认实现一个本地文件系统规则提供者,根据用户配置的 **AbpRulesEnginePthsicalFileResolveOptions.PhysicalPath** 路径检索规则文件 文件名如下: PhysicalPath/CurrentTenant.Id[如果存在]/验证规则实体类型名称[typeof(Input).Name].json +自定义的规则提供者需要实现 **IWorkflowRulesResolveContributor** 接口,可能不需要实现初始化与释放资源,因此提供了一个抽象的 **WorkflowRulesResolveContributorBase** + +并添加到 **AbpRulesEngineResolveOptions.WorkflowRulesResolvers** 中 + ### 基础模块 ### 高阶模块 @@ -31,7 +35,13 @@ PhysicalPath/CurrentTenant.Id[如果存在]/验证规则实体类型名称[typeo { public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(options => + Configure(options => + { + // 添加自行实现的规则解析提供者 + options.WorkflowRulesResolvers.Add(new FakeWorkflowRulesResolveContributor()); + }); + + Configure(options => { // 指定真实存在的本地文件路径, 否则将不会检索本地规则文件 options.PhysicalPath = Path.Combine(Directory.GetCurrentDirectory(), "Rules");