diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN.Abp.Rules.RulesEngine.csproj b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN.Abp.Rules.RulesEngine.csproj
index 1b80529b5..184cf42d8 100644
--- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN.Abp.Rules.RulesEngine.csproj
+++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN.Abp.Rules.RulesEngine.csproj
@@ -8,7 +8,7 @@
-
+
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 0c57ff987..3170b1117 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
@@ -1,16 +1,24 @@
-using Volo.Abp.Collections;
-
-namespace LINGYUN.Abp.Rules.RulesEngine
-{
- public class AbpRulesEngineOptions
- {
- ///
- /// 是否忽略租户
- ///
- public bool IgnoreMultiTenancy { get; set; }
-
- public AbpRulesEngineOptions()
- {
- }
- }
-}
+using RulesEngine.Models;
+
+namespace LINGYUN.Abp.Rules.RulesEngine
+{
+ public class AbpRulesEngineOptions
+ {
+ ///
+ /// 是否忽略租户
+ ///
+ public bool IgnoreMultiTenancy { get; set; }
+ ///
+ /// 规则引擎可配置
+ ///
+ public ReSettings Settings { get; set; }
+
+ public AbpRulesEngineOptions()
+ {
+ Settings = new ReSettings
+ {
+ NestedRuleExecutionMode = NestedRuleExecutionMode.Performance
+ };
+ }
+ }
+}
diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesResolveContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesResolveContributor.cs
index 488d14f36..1702a0425 100644
--- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesResolveContributor.cs
+++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/FileProviderWorkflowRulesResolveContributor.cs
@@ -1,105 +1,104 @@
-using Microsoft.Extensions.Caching.Memory;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.FileProviders;
-using Microsoft.Extensions.Primitives;
-using RulesEngine.Models;
-using System;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using Volo.Abp.Json;
-
-namespace LINGYUN.Abp.Rules.RulesEngine.FileProviders
-{
- public abstract class FileProviderWorkflowRulesResolveContributor : WorkflowRulesResolveContributorBase
- {
- protected IMemoryCache RulesCache { get; private set; }
- protected IJsonSerializer JsonSerializer { get; private set; }
-
- protected IFileProvider FileProvider { get; private set; }
-
- protected FileProviderWorkflowRulesResolveContributor()
- {
- }
-
- 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)
- {
- }
-
- protected abstract IFileProvider BuildFileProvider(RulesInitializationContext context);
-
- public override async Task ResolveAsync(IWorkflowRulesResolveContext context)
- {
- if (FileProvider != null)
- {
- context.WorkflowRules = await GetCachedRulesAsync(context.Type);
- }
- context.Handled = true;
- }
-
- public override void Shutdown()
- {
- if (FileProvider != null && FileProvider is IDisposable resource)
- {
- resource.Dispose();
- }
- }
-
- private async Task GetCachedRulesAsync(Type type, CancellationToken cancellationToken = default)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- var ruleId = GetRuleId(type);
-
- return await RulesCache.GetOrCreateAsync(ruleId,
- async (entry) =>
- {
- entry.SetAbsoluteExpiration(TimeSpan.FromMinutes(30));
-
- return await GetFileSystemRulesAsync(type, cancellationToken);
- });
- }
- protected abstract int GetRuleId(Type type);
-
- protected abstract string GetRuleName(Type type);
-
- protected virtual async Task GetFileSystemRulesAsync(Type type, CancellationToken cancellationToken = default)
- {
- var ruleId = GetRuleId(type);
- var ruleFile = GetRuleName(type);
- var fileInfo = FileProvider.GetFileInfo(ruleFile);
- if (fileInfo != null && fileInfo.Exists)
- {
- // 规则文件监控
- // TODO: 删除模块的规则缓存还需要删除RulesEngine中rulesCache已编译的规则缓存
- ChangeToken.OnChange(
- () => FileProvider.Watch(ruleFile),
- (int ruleId) =>
- {
- RulesCache.Remove(ruleId);
- }, ruleId);
-
- // 打开文本流
- using (var stream = fileInfo.CreateReadStream())
- {
- var result = new byte[stream.Length];
- await stream.ReadAsync(result, 0, (int)stream.Length);
- var ruleDsl = Encoding.UTF8.GetString(result);
- // 解析
- return JsonSerializer.Deserialize(ruleDsl);
- }
- }
- return new WorkflowRules[0];
- }
- }
-}
+using Microsoft.Extensions.Caching.Memory;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.FileProviders;
+using Microsoft.Extensions.Primitives;
+using RulesEngine.Models;
+using System;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Volo.Abp.Json;
+
+namespace LINGYUN.Abp.Rules.RulesEngine.FileProviders
+{
+ public abstract class FileProviderWorkflowRulesResolveContributor : WorkflowRulesResolveContributorBase
+ {
+ protected IMemoryCache RulesCache { get; private set; }
+ protected IJsonSerializer JsonSerializer { get; private set; }
+
+ protected IFileProvider FileProvider { get; private set; }
+ protected FileProviderWorkflowRulesResolveContributor()
+ {
+ }
+
+ public override void Initialize(RulesInitializationContext context)
+ {
+ Initialize(context.ServiceProvider);
+
+ RulesCache = context.GetRequiredService();
+ JsonSerializer = context.GetRequiredService();
+
+ FileProvider = BuildFileProvider(context);
+ }
+
+ protected virtual void Initialize(IServiceProvider serviceProvider)
+ {
+ }
+
+ protected abstract IFileProvider BuildFileProvider(RulesInitializationContext context);
+
+ public override async Task ResolveAsync(IWorkflowRulesResolveContext context)
+ {
+ if (FileProvider != null)
+ {
+ context.WorkflowRules = await GetCachedRulesAsync(context.Type);
+ }
+ context.Handled = true;
+ }
+
+ public override void Shutdown()
+ {
+ if (FileProvider != null && FileProvider is IDisposable resource)
+ {
+ resource.Dispose();
+ }
+ }
+
+ private async Task GetCachedRulesAsync(Type type, CancellationToken cancellationToken = default)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ var ruleId = GetRuleId(type);
+
+ return await RulesCache.GetOrCreateAsync(ruleId,
+ async (entry) =>
+ {
+ entry.SetAbsoluteExpiration(TimeSpan.FromMinutes(30));
+
+ return await GetFileSystemRulesAsync(type, cancellationToken);
+ });
+ }
+ protected abstract int GetRuleId(Type type);
+
+ protected abstract string GetRuleName(Type type);
+
+ protected virtual async Task GetFileSystemRulesAsync(Type type, CancellationToken cancellationToken = default)
+ {
+ var ruleId = GetRuleId(type);
+ var ruleFile = GetRuleName(type);
+ var fileInfo = FileProvider.GetFileInfo(ruleFile);
+ if (fileInfo != null && fileInfo.Exists)
+ {
+ // 规则文件监控
+ ChangeToken.OnChange(
+ () => FileProvider.Watch(ruleFile),
+ (int ruleId) =>
+ {
+ // 清除规则缓存
+ RulesCache.Remove(ruleId);
+ }, ruleId);
+
+ // 打开文本流
+ using (var stream = fileInfo.CreateReadStream())
+ {
+ var result = new byte[stream.Length];
+ await stream.ReadAsync(result, 0, (int)stream.Length);
+ var ruleDsl = Encoding.UTF8.GetString(result);
+ // 解析
+ return JsonSerializer.Deserialize(ruleDsl);
+ }
+ }
+ return new WorkflowRules[0];
+ }
+ }
+}
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/AbpRulesEnginePhysicalFileResolveOptions.cs
similarity index 75%
rename from aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/AbpRulesEnginePthsicalFileResolveOptions.cs
rename to aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/FileProviders/Physical/AbpRulesEnginePhysicalFileResolveOptions.cs
index 9e87a88ab..4f130a9e8 100644
--- 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/AbpRulesEnginePhysicalFileResolveOptions.cs
@@ -1,10 +1,10 @@
-namespace LINGYUN.Abp.Rules.RulesEngine.FileProviders.Physical
-{
- public class AbpRulesEnginePthsicalFileResolveOptions
- {
- ///
- /// 本地文件路径
- ///
- public string PhysicalPath { get; set; }
- }
-}
+namespace LINGYUN.Abp.Rules.RulesEngine.FileProviders.Physical
+{
+ public class AbpRulesEnginePhysicalFileResolveOptions
+ {
+ ///
+ /// 本地文件路径
+ ///
+ public string PhysicalPath { get; set; }
+ }
+}
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
index b63ad2d86..b58a80dc3 100644
--- 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
@@ -1,44 +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";
- }
-}
+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 AbpRulesEnginePhysicalFileResolveOptions _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/RulesEngineContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs
index 1c8aaa997..f975e5794 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,82 +1,81 @@
-using RulesEngine;
-using RulesEngine.Interfaces;
-using RulesEngine.Models;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Volo.Abp.DependencyInjection;
-using Engine = RulesEngine.RulesEngine;
-
-namespace LINGYUN.Abp.Rules.RulesEngine
-{
- public class RulesEngineContributor : RuleContributorBase, ISingletonDependency
- {
- private IRulesEngine _ruleEngine;
- private readonly IWorkflowRulesResolver _workflowRulesResolver;
-
- public RulesEngineContributor(
- IWorkflowRulesResolver workflowRulesResolver)
- {
- _workflowRulesResolver = workflowRulesResolver;
- }
-
- public override void Initialize(RulesInitializationContext context)
- {
- _ruleEngine = CreateRulesEngine();
-
- _workflowRulesResolver.Initialize(context);
- }
-
- public override async Task ExecuteAsync(T input, object[] @params = null, CancellationToken cancellationToken = default)
- {
- var result = await _workflowRulesResolver.ResolveWorkflowRulesAsync(typeof(T));
-
- if (result.WorkflowRules.Any())
- {
- await ExecuteRulesAsync(input, result.WorkflowRules.ToArray(), @params);
- }
- }
-
- public override void Shutdown()
- {
- }
- ///
- /// 重写自行构建规则引擎
- ///
- ///
- protected virtual Engine CreateRulesEngine()
- {
- var reSetting = new ReSettings
- {
- NestedRuleExecutionMode = NestedRuleExecutionMode.Performance
- };
-
- return new Engine(Logger, reSetting);
- }
-
- protected virtual async Task ExecuteRulesAsync(T input, WorkflowRules[] workflowRules, object[] @params = null)
- {
- _ruleEngine.AddWorkflow(workflowRules);
-
- // 传入参与验证的实体参数
- var inputs = new List