Browse Source

create a rule engine module

pull/97/head
cKey 5 years ago
parent
commit
610b0511bd
  1. 20
      aspnet-core/LINGYUN.MicroService.sln
  2. 14
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj
  3. 16
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/AbpRulesEngineModule.cs
  4. 48
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptor.cs
  5. 28
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityChangedRulesInterceptorRegistrar.cs
  6. 18
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/EntityRuleContext.cs
  7. 8
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ErrorType.cs
  8. 7
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/ExpressionType.cs
  9. 9
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IEntityRuleContributor.cs
  10. 6
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/INeedRule.cs
  11. 11
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/IRuleFinder.cs
  12. 13
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullEntityRuleContributor.cs
  13. 15
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/NullRuleFinder.cs
  14. 90
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/Rule.cs
  15. 39
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleGroup.cs
  16. 43
      aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN/Abp/Rules/RuleParam.cs
  17. 7
      aspnet-core/modules/common/LINGYUN.Abp.Rules/README.md
  18. 19
      aspnet-core/modules/common/LINGYUN.Abp.RulesEngine/LINGYUN.Abp.RulesEngine.csproj
  19. 22
      aspnet-core/modules/common/LINGYUN.Abp.RulesEngine/LINGYUN/Abp/RulesEngine/AbpMsRulesEngineModule.cs
  20. 50
      aspnet-core/modules/common/LINGYUN.Abp.RulesEngine/LINGYUN/Abp/RulesEngine/MsEntityRuleContributor.cs
  21. 27
      aspnet-core/modules/common/LINGYUN.Abp.RulesEngine/LINGYUN/Abp/RulesEngine/MsRulesEngineMapperProfile.cs
  22. 7
      aspnet-core/modules/common/LINGYUN.Abp.RulesEngine/README.md
  23. BIN
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/event-bus-cap.db
  24. 5
      docker-compose.yml
  25. 2
      vueJs/src/api/auditing.ts
  26. 2
      vueJs/src/views/admin/auditing/audit-log/index.vue
  27. 2
      vueJs/src/views/admin/auditing/security-log/index.vue

20
aspnet-core/LINGYUN.MicroService.sln

@ -233,11 +233,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Features.Client
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "auditing", "auditing", "{67DAB2A0-D407-4CAB-8414-AE3D0AC52FC4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Auditing.Application.Contracts", "modules\auditing\LINGYUN.Abp.Auditing.Application.Contracts\LINGYUN.Abp.Auditing.Application.Contracts.csproj", "{F40F88F1-CA90-4A79-B772-80E287E25982}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Auditing.Application.Contracts", "modules\auditing\LINGYUN.Abp.Auditing.Application.Contracts\LINGYUN.Abp.Auditing.Application.Contracts.csproj", "{F40F88F1-CA90-4A79-B772-80E287E25982}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Auditing.Application", "modules\auditing\LINGYUN.Abp.Auditing.Application\LINGYUN.Abp.Auditing.Application.csproj", "{AC3C8985-73C2-472A-8E76-A0B8786FEC3F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Auditing.Application", "modules\auditing\LINGYUN.Abp.Auditing.Application\LINGYUN.Abp.Auditing.Application.csproj", "{AC3C8985-73C2-472A-8E76-A0B8786FEC3F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Auditing.HttpApi", "modules\auditing\LINGYUN.Abp.Auditing.HttpApi\LINGYUN.Abp.Auditing.HttpApi.csproj", "{07E19CA8-671D-4D58-9FED-5FEE9AE01A2F}"
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.RulesEngine", "modules\common\LINGYUN.Abp.RulesEngine\LINGYUN.Abp.RulesEngine.csproj", "{FD007B55-A0F1-4EF8-9CFD-6D8AD1B61B65}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -633,6 +637,14 @@ 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
{FD007B55-A0F1-4EF8-9CFD-6D8AD1B61B65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD007B55-A0F1-4EF8-9CFD-6D8AD1B61B65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD007B55-A0F1-4EF8-9CFD-6D8AD1B61B65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD007B55-A0F1-4EF8-9CFD-6D8AD1B61B65}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -753,6 +765,8 @@ 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}
{FD007B55-A0F1-4EF8-9CFD-6D8AD1B61B65} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718}

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

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

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

@ -0,0 +1,16 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Domain;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Rules
{
[DependsOn(
typeof(AbpDddDomainModule))]
public class AbpRulesEngineModule : 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

@ -0,0 +1,48 @@
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

@ -0,0 +1,28 @@
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

@ -0,0 +1,18 @@
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

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

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

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

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

@ -0,0 +1,9 @@
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

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

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

@ -0,0 +1,11 @@
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

@ -0,0 +1,13 @@
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

@ -0,0 +1,15 @@
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

@ -0,0 +1,90 @@
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; }
public string Operator { get; }
public string ErrorMessage { get; }
public DateTime CreationTime { get; }
public ErrorType ErrorType { get; }
public ExpressionType? ExpressionType { get; }
public List<Rule> Rules { get; }
public List<string> InjectRules { get; }
public List<RuleParam> Params { get; }
public string Expression { get; }
public string SuccessEvent { get; }
public Rule(
[NotNull] string name,
string @operator,
DateTime creationTime,
string expression = null,
string successEvent = null,
ErrorType errorType = ErrorType.Warning,
ExpressionType? expressionType = null)
{
Check.NotNullOrWhiteSpace(name, nameof(name));
Name = name;
Operator = @operator;
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;
}
}
}

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

@ -0,0 +1,39 @@
using JetBrains.Annotations;
using System.Collections.Generic;
using Volo.Abp;
namespace LINGYUN.Abp.Rules
{
public class RuleGroup
{
[NotNull]
public string Name { get; }
public List<string> InjectRules { get; }
public List<Rule> Rules { get; }
public RuleGroup(
[NotNull] string name)
{
Check.NotNullOrWhiteSpace(name, nameof(name));
Name = name;
Rules = new List<Rule>();
InjectRules = new List<string>();
}
public RuleGroup InjectRule(string ruleName)
{
InjectRules.AddIfNotContains(ruleName);
return this;
}
public RuleGroup WithRule(Rule rule)
{
Rules.AddIfNotContains(rule);
return this;
}
}
}

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

@ -0,0 +1,43 @@
using JetBrains.Annotations;
using Volo.Abp;
namespace LINGYUN.Abp.Rules
{
public class RuleParam
{
[NotNull]
public string Name { get; }
[NotNull]
public string Expression { get; }
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

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

19
aspnet-core/modules/common/LINGYUN.Abp.RulesEngine/LINGYUN.Abp.RulesEngine.csproj

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RulesEngine" Version="2.1.2" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Rules\LINGYUN.Abp.Rules.csproj" />
</ItemGroup>
</Project>

22
aspnet-core/modules/common/LINGYUN.Abp.RulesEngine/LINGYUN/Abp/RulesEngine/AbpMsRulesEngineModule.cs

@ -0,0 +1,22 @@
using LINGYUN.Abp.Rules;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.RulesEngine
{
[DependsOn(
typeof(AbpRulesEngineModule),
typeof(AbpAutoMapperModule))]
public class AbpMsRulesEngineModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<AbpMsRulesEngineModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<MsRulesEngineMapperProfile>(validate: true);
});
}
}
}

50
aspnet-core/modules/common/LINGYUN.Abp.RulesEngine/LINGYUN/Abp/RulesEngine/MsEntityRuleContributor.cs

@ -0,0 +1,50 @@
using LINGYUN.Abp.Rules;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using RulesEngine.Extensions;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.ObjectMapping;
using MsRulesEngine = RulesEngine.RulesEngine;
using MsWorkflowRules = RulesEngine.Models.WorkflowRules;
namespace LINGYUN.Abp.RulesEngine
{
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)]
[ExposeServices(typeof(IEntityRuleContributor))]
public class MsEntityRuleContributor : IEntityRuleContributor
{
protected ILogger Logger { get; }
protected IObjectMapper ObjectMapper { get; }
public MsEntityRuleContributor(
IObjectMapper objectMapper,
ILogger<MsEntityRuleContributor> logger)
{
Logger = logger;
ObjectMapper = objectMapper;
}
public Task ApplyAsync(EntityRuleContext context)
{
var workflowRules = ObjectMapper.Map<List<RuleGroup>, List<MsWorkflowRules>>(context.Groups);
var rulesEngine = new MsRulesEngine(workflowRules.ToArray(), Logger);
foreach(var workflow in workflowRules)
{
var ruleRsults = rulesEngine.ExecuteRule(workflow.WorkflowName, context.Entity);
ruleRsults.OnSuccess((eventName) =>
{
Logger.LogDebug($"{workflow.WorkflowName} evaluation resulted in succees - {eventName}");
});
ruleRsults.OnFail(() =>
{
Logger.LogWarning($"{workflow.WorkflowName} evaluation resulted in failure");
});
}
return Task.CompletedTask;
}
}
}

27
aspnet-core/modules/common/LINGYUN.Abp.RulesEngine/LINGYUN/Abp/RulesEngine/MsRulesEngineMapperProfile.cs

@ -0,0 +1,27 @@
using AutoMapper;
using LINGYUN.Abp.Rules;
using MsExpressionType = RulesEngine.Models.RuleExpressionType;
using MsRule = RulesEngine.Models.Rule;
using MsRuleErrorType = RulesEngine.Models.ErrorType;
using MsRuleParam = RulesEngine.Models.LocalParam;
using MsWorkflowRules = RulesEngine.Models.WorkflowRules;
namespace LINGYUN.Abp.RulesEngine
{
public class MsRulesEngineMapperProfile : Profile
{
public MsRulesEngineMapperProfile()
{
CreateMap<RuleParam, MsRuleParam>();
CreateMap<Rule, MsRule>()
.ForMember(r => r.LocalParams, map => map.MapFrom(m => m.Params))
.ForMember(r => r.WorkflowRulesToInject, map => map.MapFrom(m => m.InjectRules))
.ForMember(r => r.ErrorType, map => map.MapFrom(m => (MsRuleErrorType)m.ErrorType.GetHashCode()))
.ForMember(r => r.RuleExpressionType, map => map.MapFrom(m => (MsExpressionType)m.ExpressionType.GetHashCode()));
CreateMap<RuleGroup, MsWorkflowRules>()
.ForMember(wr => wr.WorkflowName, map => map.MapFrom(m => m.Name))
.ForMember(wr => wr.Rules, map => map.MapFrom(m => m.Rules))
.ForMember(wr => wr.WorkflowRulesToInject, map => map.MapFrom(m => m.InjectRules));
}
}
}

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

@ -0,0 +1,7 @@
# LINGYUN.Abp.RulesEngine
规则引擎 [microsoft/RulesEngine](https://github.com/microsoft/RulesEngine) (RulesEngine) 实现
## 配置使用
待完善

BIN
aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/event-bus-cap.db

Binary file not shown.

5
docker-compose.yml

@ -67,10 +67,7 @@ services:
abp-vue-admin-client:
build:
context: ./vueJs
volumes:
- /var/opt/abp/data/client/nginx:/etc/nginx/nginx.conf
- /var/opt/abp/data/client/nginx/conf.d:/etc/nginx/conf.d/default.conf
context: ./aspnet-core/services/Publish/client
restart: always
volumes:

2
vueJs/src/api/auditing.ts

@ -9,7 +9,7 @@ export default class AuditingService {
const _url = '/api/auditing/audit-log/' + id
return ApiService.Get<AuditLog>(_url, serviceUrl)
}
public static getAuditLogs(payload: AuditLogGetPaged) {
let _url = '/api/auditing/audit-log?'
payload.skipCount = abpPagerFormat(payload.skipCount, payload.maxResultCount)

2
vueJs/src/views/admin/auditing/audit-log/index.vue

@ -125,7 +125,7 @@
<el-table
v-loading="dataLoading"
row-key="itemId"
row-key="id"
:data="dataList"
border
fit

2
vueJs/src/views/admin/auditing/security-log/index.vue

@ -97,7 +97,7 @@
<el-table
v-loading="dataLoading"
row-key="itemId"
row-key="id"
:data="dataList"
border
fit

Loading…
Cancel
Save