Browse Source

Merge pull request #259 from colinin/4.3

Refactoring RulesEngine integration
pull/274/head
cKey 5 years ago
committed by GitHub
parent
commit
262948bde0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 52
      aspnet-core/LINGYUN.MicroService.All.sln
  2. 9
      aspnet-core/LINGYUN.MicroService.Common.sln
  3. 31
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/AbpNRulesModule.cs
  4. 22
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN.Abp.Rules.NRules.csproj
  5. 14
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpNRulesOptions.cs
  6. 44
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpRuleRepository.cs
  7. 20
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/DependencyResolver.cs
  8. 20
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/INRulesRepository.cs
  9. 60
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/NRulesEntityRuleContributor.cs
  10. 24
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/RuleActivator.cs
  11. 55
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/Microsoft/Extensions/DependencyInjection/NRulesServiceCollectionExtensions.cs
  12. 15
      aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/NRules/RuleRepositoryExtensions.cs
  13. 14
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj
  14. 16
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/AbpRulesModule.cs
  15. 48
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptor.cs
  16. 28
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptorRegistrar.cs
  17. 18
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityRuleContext.cs
  18. 8
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ErrorType.cs
  19. 7
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ExpressionType.cs
  20. 9
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IEntityRuleContributor.cs
  21. 6
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/INeedRule.cs
  22. 11
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IRuleFinder.cs
  23. 13
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullEntityRuleContributor.cs
  24. 15
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullRuleFinder.cs
  25. 90
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/Rule.cs
  26. 53
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleGroup.cs
  27. 35
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleNameAttribute.cs
  28. 45
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleParam.cs
  29. 7
      aspnet-core/modules/common/LINGYUN.Abp.Rules/README.md
  30. 20
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj
  31. 6
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj.user
  32. 10
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/AbpDaprActorsIdentityModelWebModule.cs
  33. 51
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/HttpContextIdentityModelDaprActorProxyAuthenticator.cs
  34. 27
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/Properties/launchSettings.json
  35. 19
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/README.md
  36. 18
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN.Abp.Dapr.Actors.IdentityModel.csproj
  37. 54
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/DaprActorConfigurationExtensions.cs
  38. 13
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/AbpDaprActorsIdentityModelModule.cs
  39. 66
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/IdentityModelDaprActorProxyAuthenticator.cs
  40. 19
      aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/README.md
  41. 2
      aspnet-core/modules/localization/LINGYUN.Abp.Localization.Xml/LINGYUN/Abp/Localization/Xml/XmlLocalizationFile.cs
  42. 8
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineModule.cs
  43. 9
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineOptions.cs
  44. 27
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/AbpRulesEngineResolveOptions.cs
  45. 52
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesResolveContributor.cs
  46. 10
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/AbpRulesEnginePthsicalFileResolveOptions.cs
  47. 42
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesContributor.cs
  48. 44
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesResolveContributor.cs
  49. 15
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesContributor.cs
  50. 19
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContext.cs
  51. 15
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolveContributor.cs
  52. 16
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesResolver.cs
  53. 25
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/NullWorkflowRulesContributor.cs
  54. 16
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/IWorkflowRuleStore.cs
  55. 19
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/NullWorkflowRuleStore.cs
  56. 31
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/Persistent/PersistentWorkflowRulesResolveContributor.cs
  57. 36
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs
  58. 30
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContext.cs
  59. 18
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveContributorBase.cs
  60. 18
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolveResult.cs
  61. 67
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/WorkflowRulesResolver.cs
  62. 14
      aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/README.md
  63. 1
      aspnet-core/tests/LINGYUN.Abp.Localization.Json.Tests/LINGYUN.Abp.Localization.Json.Tests.csproj

52
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,16 @@ 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
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
@ -695,14 +699,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 +807,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 +843,22 @@ 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
{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
@ -965,8 +973,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 +1005,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 +1016,11 @@ 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}
{8EF31071-3521-409D-9740-BBFBFC04C50E} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718}

9
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}

31
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/AbpNRulesModule.cs

@ -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);
}
}
}

22
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN.Abp.Rules.NRules.csproj

@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NRules" Version="0.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Rules\LINGYUN.Abp.Rules.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="LINGYUN\Abp\Rules\NRules\" />
</ItemGroup>
</Project>

14
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpNRulesOptions.cs

@ -1,14 +0,0 @@
using Volo.Abp.Collections;
using NRule = NRules.Fluent.Dsl.Rule;
namespace LINGYUN.Abp.Rules
{
public class AbpNRulesOptions
{
public ITypeList<NRule> Rules { get; }
public AbpNRulesOptions()
{
Rules = new TypeList<NRule>();
}
}
}

44
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/AbpRuleRepository.cs

@ -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<IRuleSet> 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<IRuleSet> GetRuleSets(IEnumerable<RuleGroup> groups)
{
throw new NotImplementedException();
}
}
}

20
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/DependencyResolver.cs

@ -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);
}
}
}

20
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/INRulesRepository.cs

@ -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<IRuleSet> GetRuleSets(IEnumerable<RuleGroup> groups);
}
}

60
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/NRulesEntityRuleContributor.cs

@ -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<IRuleSet> groupRuleSets = new List<IRuleSet>();
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();
}
}
}

24
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/LINGYUN/Abp/Rules/RuleActivator.cs

@ -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<NRule> Activate(Type type)
{
return (IEnumerable<NRule>)ServiceProvider.GetServices(type);
}
}
}

55
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/Microsoft/Extensions/DependencyInjection/NRulesServiceCollectionExtensions.cs

@ -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<IRuleActivator, RuleActivator>();
services.AddSingleton<IRuleRepository, AbpRuleRepository>();
services.AddSingleton<INRulesRepository, AbpRuleRepository>();
return services;
}
public static IServiceCollection RegisterSessionFactory(this IServiceCollection services)
{
services.RegisterSessionFactory((provider) => provider.GetRequiredService<IRuleRepository>().Compile());
return services;
}
public static IServiceCollection RegisterSessionFactory(this IServiceCollection services, Func<IServiceProvider, ISessionFactory> compileFunc)
{
services.AddSingleton<IRuleActivator, RuleActivator>();
services.AddSingleton(compileFunc);
return services;
}
public static IServiceCollection RegisterSession(this IServiceCollection services)
{
return services.RegisterSession((provider) => provider.GetRequiredService<ISessionFactory>().CreateSession());
}
public static IServiceCollection RegisterSession(this IServiceCollection services, Func<IServiceProvider, ISession> factoryFunc)
{
return services.AddScoped(factoryFunc);
}
}
}

15
aspnet-core/modules/common/LINGYUN.Abp.Rules.NRules/NRules/RuleRepositoryExtensions.cs

@ -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<RuleGroup> groups)
{
var compiler = new RuleCompiler();
ISessionFactory factory = compiler.Compile(repository.GetRuleSets(groups));
return factory;
}
}
}

14
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj

@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="4.3.0" />
</ItemGroup>
</Project>

16
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/AbpRulesModule.cs

@ -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);
}
}
}

48
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptor.cs

@ -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));
}
}
}
}

28
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptorRegistrar.cs

@ -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<EntityChangedRulesInterceptor>();
}
}
private static bool ShouldIntercept(Type type)
{
// 拦截器的要求
// 1、继承自IBasicRepository的仓储
// 2、继承自INeedRule接口的实体
return !DynamicProxyIgnoreTypes.Contains(type) &&
type.IsAssignableTo(typeof(IBasicRepository<>)) &&
type.GetGenericTypeDefinition().IsAssignableTo(typeof(INeedRule));
}
}
}

18
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityRuleContext.cs

@ -1,18 +0,0 @@
using System.Collections.Generic;
using Volo.Abp.Domain.Entities;
namespace LINGYUN.Abp.Rules
{
public class EntityRuleContext
{
public List<RuleGroup> Groups { get; }
public IEntity Entity { get; }
public EntityRuleContext(
List<RuleGroup> groups,
IEntity entity)
{
Groups = groups;
Entity = entity;
}
}
}

8
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ErrorType.cs

@ -1,8 +0,0 @@
namespace LINGYUN.Abp.Rules
{
public enum ErrorType
{
Warning = 0,
Error = 1
}
}

7
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ExpressionType.cs

@ -1,7 +0,0 @@
namespace LINGYUN.Abp.Rules
{
public enum ExpressionType
{
LambdaExpression = 0
}
}

9
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IEntityRuleContributor.cs

@ -1,9 +0,0 @@
using System.Threading.Tasks;
namespace LINGYUN.Abp.Rules
{
public interface IEntityRuleContributor
{
Task ApplyAsync(EntityRuleContext context);
}
}

6
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/INeedRule.cs

@ -1,6 +0,0 @@
namespace LINGYUN.Abp.Rules
{
public interface INeedRule
{
}
}

11
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IRuleFinder.cs

@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace LINGYUN.Abp.Rules
{
public interface IRuleFinder
{
Task<List<RuleGroup>> GetRuleGroupsAsync(Type entityType);
}
}

13
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullEntityRuleContributor.cs

@ -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;
}
}
}

15
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullRuleFinder.cs

@ -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<List<RuleGroup>> GetRuleGroupsAsync(Type entityType)
{
return Task.FromResult(new List<RuleGroup>());
}
}
}

90
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/Rule.cs

@ -1,90 +0,0 @@
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Volo.Abp;
namespace LINGYUN.Abp.Rules
{
/// <summary>
/// ref: https://github.com/microsoft/RulesEngine/blob/master/src/RulesEngine/RulesEngine/Models/Rule.cs
/// </summary>
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<Rule> Rules { get; set; }
public List<string> InjectRules { get; set; }
public List<RuleParam> 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<Rule>();
Params = new List<RuleParam>();
InjectRules = new List<string>();
}
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;
}
}
}

53
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleGroup.cs

@ -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<string> InjectRules { get; set; }
public List<Rule> Rules { get; }
protected RuleGroup() { }
public RuleGroup(
[NotNull] string name)
{
Check.NotNullOrWhiteSpace(name, nameof(name));
Name = name;
Rules = new List<Rule>();
InjectRules = new List<string>();
}
public RuleGroup WithInjectRule(string ruleName)
{
InjectRules.AddIfNotContains(ruleName);
return this;
}
public RuleGroup WithInjectRule(IEnumerable<string> ruleNames)
{
InjectRules.AddIfNotContains(ruleNames);
return this;
}
public RuleGroup WithRule(Rule rule)
{
Rules.AddIfNotContains(rule);
return this;
}
public RuleGroup WithRule(IEnumerable<Rule> rules)
{
Rules.AddIfNotContains(rules);
return this;
}
}
}

35
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleNameAttribute.cs

@ -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<TEntity>()
{
return GetRuleName(typeof(TEntity));
}
public static string GetRuleName(Type entityType)
{
var ruleAttribute = entityType.GetSingleAttributeOrNull<RuleNameAttribute>();
if (ruleAttribute != null)
{
return ruleAttribute.GetRuleNameForType(entityType);
}
return entityType.Name.RemovePostFix("Rule").ToKebabCase();
}
}
}

45
aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleParam.cs

@ -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);
}
}
}

7
aspnet-core/modules/common/LINGYUN.Abp.Rules/README.md

@ -1,7 +0,0 @@
# LINGYUN.Abp.Rules
规则引擎定义
## 配置使用
待完善

20
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj

@ -1,20 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<IsPackable>true</IsPackable>
<OutputType>Library</OutputType>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Dapr.Actors.IdentityModel\LINGYUN.Abp.Dapr.Actors.IdentityModel.csproj" />
</ItemGroup>
</Project>

6
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web.csproj.user

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
</PropertyGroup>
</Project>

10
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/AbpDaprActorsIdentityModelWebModule.cs

@ -1,10 +0,0 @@
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Dapr.Actors.IdentityModel.Web
{
[DependsOn(
typeof(AbpDaprActorsIdentityModelModule))]
public class AbpDaprActorsIdentityModelWebModule : AbpModule
{
}
}

51
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/LINGYUN/Abp/Dapr/Actors/IdentityModel/Web/HttpContextIdentityModelDaprActorProxyAuthenticator.cs

@ -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<string> GetAccessTokenFromHttpContextOrNullAsync()
{
var httpContext = HttpContextAccessor?.HttpContext;
if (httpContext == null)
{
return null;
}
return await httpContext.GetTokenAsync("access_token");
}
}
}

27
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/Properties/launchSettings.json

@ -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"
}
}
}

19
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel.Web/README.md

@ -1,19 +0,0 @@
# LINGYUN.Abp.Dapr.Actors.IdentityModel.Web
Dapr.Actors内部使用Http进行服务间调用,此模块用于获取应用当前状态中的身份令牌并传递到远程Actor服务
## 配置使用
模块按需引用
```csharp
[DependsOn(typeof(AbpDaprActorsIdentityModelWebModule))]
public class YouProjectModule : AbpModule
{
// other
}
```
## 配置项说明
## 其他

18
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN.Abp.Dapr.Actors.IdentityModel.csproj

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.IdentityModel" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Dapr.Actors\LINGYUN.Abp.Dapr.Actors.csproj" />
</ItemGroup>
</Project>

54
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/DaprActorConfigurationExtensions.cs

@ -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;
}
}
}

13
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/AbpDaprActorsIdentityModelModule.cs

@ -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
{
}
}

66
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/LINGYUN/Abp/Dapr/Actors/IdentityModel/IdentityModelDaprActorProxyAuthenticator.cs

@ -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<IdentityModelDaprActorProxyAuthenticator> Logger { get; set; }
public IdentityModelDaprActorProxyAuthenticator(
IIdentityModelAuthenticationService identityModelAuthenticationService)
{
IdentityModelAuthenticationService = identityModelAuthenticationService;
Logger = NullLogger<IdentityModelDaprActorProxyAuthenticator>.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;
}
}
}

19
aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.IdentityModel/README.md

@ -1,19 +0,0 @@
# LINGYUN.Abp.Dapr.Actors.IdentityModel
Dapr.Actors内部使用Http进行服务间调用,此模块用于传递服务间调用令牌
## 配置使用
模块按需引用
```csharp
[DependsOn(typeof(AbpDaprActorsIdentityModelModule))]
public class YouProjectModule : AbpModule
{
// other
}
```
## 配置项说明
## 其他

2
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")]

8
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<RulesEngineContributor>();
});
Configure<AbpRulesEngineOptions>(options =>
Configure<AbpRulesEngineResolveOptions>(options =>
{
// 加入防止空引用
options.Contributors.Add<NullWorkflowRulesContributor>();
options.Contributors.Add<PhysicalFileWorkflowRulesContributor>();
options.WorkflowRulesResolvers.Add(new PersistentWorkflowRulesResolveContributor());
options.WorkflowRulesResolvers.Add(new PhysicalFileWorkflowRulesResolveContributor());
});
}
}

9
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
{
/// <summary>
/// 本地文件路径
/// </summary>
public string PhysicalPath { get; set; }
/// <summary>
/// 是否忽略租户
/// </summary>
public bool IgnoreMultiTenancy { get; set; }
/// <summary>
/// 规则提供者类型
/// </summary>
public ITypeList<IWorkflowRulesContributor> Contributors { get; }
public AbpRulesEngineOptions()
{
Contributors = new TypeList<IWorkflowRulesContributor>();
}
}
}

27
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
{
/// <summary>
/// 合并规则
/// 如果为 true,在上一个提供者解析规则之后继续执行下一个提供者
/// 如果为 false,在上一个提供者解析规则之后立即执行规则
/// 默认:false
/// </summary>
public bool MergingRuels { get; set; }
/// <summary>
/// 规则解析提供者
/// </summary>
[NotNull]
public List<IWorkflowRulesResolveContributor> WorkflowRulesResolvers { get; }
public AbpRulesEngineResolveOptions()
{
MergingRuels = false;
WorkflowRulesResolvers = new List<IWorkflowRulesResolveContributor>();
}
}
}

52
aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesContributor.cs → 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<IMemoryCache>();
JsonSerializer = context.ServiceProvider.GetRequiredService<IJsonSerializer>();
FileProvider = BuildFileProvider(context);
}
protected virtual void Initialize(IServiceProvider serviceProvider)
{
FileProvider = BuildFileProvider();
}
protected abstract IFileProvider BuildFileProvider();
protected abstract IFileProvider BuildFileProvider(RulesInitializationContext context);
public async Task<WorkflowRules[]> LoadAsync<T>(CancellationToken cancellationToken = default)
public override async Task ResolveAsync(IWorkflowRulesResolveContext context)
{
if (FileProvider != null)
{
return await GetCachedRulesAsync<T>(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<WorkflowRules[]> GetCachedRulesAsync<T>(CancellationToken cancellationToken = default)
private async Task<WorkflowRules[]> GetCachedRulesAsync(Type type, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var ruleId = GetRuleId<T>();
var ruleId = GetRuleId(type);
return await RulesCache.GetOrCreateAsync(ruleId,
async (entry) =>
{
entry.SetAbsoluteExpiration(TimeSpan.FromMinutes(30));
return await GetFileSystemRulesAsync<T>(cancellationToken);
return await GetFileSystemRulesAsync(type, cancellationToken);
});
}
protected abstract int GetRuleId<T>();
protected abstract int GetRuleId(Type type);
protected abstract string GetRuleName<T>();
protected abstract string GetRuleName(Type type);
protected virtual async Task<WorkflowRules[]> GetFileSystemRulesAsync<T>(CancellationToken cancellationToken = default)
protected virtual async Task<WorkflowRules[]> GetFileSystemRulesAsync(Type type, CancellationToken cancellationToken = default)
{
var ruleId = GetRuleId<T>();
var ruleFile = GetRuleName<T>();
var ruleId = GetRuleId(type);
var ruleFile = GetRuleName(type);
var fileInfo = FileProvider.GetFileInfo(ruleFile);
if (fileInfo != null && fileInfo.Exists)
{

10
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
{
/// <summary>
/// 本地文件路径
/// </summary>
public string PhysicalPath { get; set; }
}
}

42
aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/PhysicalFileWorkflowRulesContributor.cs

@ -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<AbpRulesEngineOptions> 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<T>() => _ruleIdGenerator.CreateRuleId(typeof(T), _options.IgnoreMultiTenancy);
protected override string GetRuleName<T>() => $"{_ruleIdGenerator.CreateRuleName(typeof(T), _options.IgnoreMultiTenancy)}.json";
}
}

44
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<RuleIdGenerator>();
_rulesEngineOptions = serviceProvider.GetRequiredService<IOptions<AbpRulesEngineOptions>>().Value;
_fileResolveOptions = serviceProvider.GetRequiredService<IOptions<AbpRulesEnginePthsicalFileResolveOptions>>().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";
}
}

15
aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/IWorkflowRulesContributor.cs

@ -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<WorkflowRules[]> LoadAsync<T>(CancellationToken cancellationToken = default);
void Shutdown();
}
}

19
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> WorkflowRules { get; set; }
[NotNull]
Type Type { get; }
bool Handled { get; set; }
}
}

15
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();
}
}

16
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<WorkflowRulesResolveResult> ResolveWorkflowRulesAsync(Type type);
void Shutdown();
}
}

25
aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/NullWorkflowRulesContributor.cs

@ -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<WorkflowRules[]> LoadAsync<T>(CancellationToken cancellationToken = default)
{
return Task.FromResult(new WorkflowRules[0]);
}
public void Shutdown()
{
}
}
}

16
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
{
/// <summary>
/// 实现此接口以用于从其他持久化存储中获取规则
/// </summary>
public interface IWorkflowRuleStore
{
Task<IEnumerable<WorkflowRules>> GetRulesAsync(Type inputType, CancellationToken cancellationToken = default);
}
}

19
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<IEnumerable<WorkflowRules>> GetRulesAsync(Type inputType, CancellationToken cancellationToken = default)
{
IEnumerable<WorkflowRules> rules = new WorkflowRules[0];
return Task.FromResult(rules);
}
}
}

31
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<IWorkflowRuleStore>();
}
public override async Task ResolveAsync(IWorkflowRulesResolveContext context)
{
var rules = await Store.GetRulesAsync(context.Type);
context.Handled = true;
context.WorkflowRules = rules;
}
}
}

36
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<IWorkflowRulesContributor> _workflowRulesContributors;
private readonly IWorkflowRulesResolver _workflowRulesResolver;
public RulesEngineContributor(
IServiceProvider serviceProvider,
IOptions<AbpRulesEngineOptions> options)
IWorkflowRulesResolver workflowRulesResolver)
{
_workflowRulesContributors = options.Value
.Contributors
.Select(serviceProvider.GetRequiredService)
.Cast<IWorkflowRulesContributor>()
.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>(T input, object[] @params = null, CancellationToken cancellationToken = default)
{
List<WorkflowRules> workflowRules = new();
var result = await _workflowRulesResolver.ResolveWorkflowRulesAsync(typeof(T));
foreach (var contributor in _workflowRulesContributors)
if (result.WorkflowRules.Any())
{
workflowRules.AddRange(await contributor.LoadAsync<T>(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();
}
}
/// <summary>
/// 重写自行构建规则引擎

30
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> 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;
}
}
}

18
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()
{
}
}
}

18
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> WorkflowRules { get; set; }
public List<string> AppliedResolvers { get; }
public WorkflowRulesResolveResult()
{
AppliedResolvers = new List<string>();
WorkflowRules = new List<WorkflowRules>();
}
}
}

67
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<AbpRulesEngineResolveOptions> 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<WorkflowRulesResolveResult> 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();
}
}
}
}

14
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<AbpRulesEngineOptions>(options =>
Configure<AbpRulesEngineResolveOptions>(options =>
{
// 添加自行实现的规则解析提供者
options.WorkflowRulesResolvers.Add(new FakeWorkflowRulesResolveContributor());
});
Configure<AbpRulesEnginePthsicalFileResolveOptions>(options =>
{
// 指定真实存在的本地文件路径, 否则将不会检索本地规则文件
options.PhysicalPath = Path.Combine(Directory.GetCurrentDirectory(), "Rules");

1
aspnet-core/tests/LINGYUN.Abp.Localization.Json.Tests/LINGYUN.Abp.Localization.Json.Tests.csproj

@ -20,7 +20,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\modules\localization\LINGYUN.Abp.Localization.Json\LINGYUN.Abp.Localization.Json.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj" />
</ItemGroup>

Loading…
Cancel
Save