updated package version and documentation update (#289)
parent
fa9c512c49
commit
4a2b345fe9
|
@ -2,6 +2,10 @@
|
|||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [3.5.0]
|
||||
- `EvaluateRule` action now support custom inputs and filtered inputs
|
||||
- Added `ContainsWorkflow` method in RulesEngine (by @okolobaxa)
|
||||
- Fixed minor bugs (#258 & #259)
|
||||
|
||||
## [3.4.0]
|
||||
- Made RulesEngine Strong Name and Authenticode signed
|
||||
|
|
|
@ -37,7 +37,6 @@ namespace RulesEngine.Data
|
|||
v => JsonSerializer.Serialize(v, null),
|
||||
v => JsonSerializer.Deserialize<RuleActions>(v, null));
|
||||
|
||||
entity.Ignore(b => b.WorkflowRulesToInject);
|
||||
entity.Ignore(b => b.WorkflowsToInject);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ RulesEngine is a highly extensible library to build rule based system using C# e
|
|||
- [Inbuilt Actions](#inbuilt-actions)
|
||||
- [OutputExpression](#outputexpression)
|
||||
- [Usage](#usage)
|
||||
- [EvaluateRule](#evaluaterule)
|
||||
- [Usage](#usage-1)
|
||||
- [Custom Actions](#custom-actions)
|
||||
- [Steps to use a custom Action](#steps-to-use-a-custom-action)
|
||||
|
||||
|
@ -320,6 +322,83 @@ Call `ExecuteAllRulesAsync` with the workflowName, ruleName and ruleParameters
|
|||
|
||||
```
|
||||
|
||||
#### EvaluateRule
|
||||
This action allows chaining of rules along with their actions. It also supports filtering inputs provided to chained rule as well as providing custom inputs
|
||||
|
||||
##### Usage
|
||||
Define OnSuccess or OnFailure Action for your Rule:
|
||||
```jsonc
|
||||
{
|
||||
"WorkflowName": "inputWorkflow",
|
||||
"Rules": [
|
||||
{
|
||||
"RuleName": "GiveDiscount20Percent",
|
||||
"Expression": "input1.couy == \"india\" AND input1.loyalityFactor <= 5 AND input1.totalPurchasesToDate >= 20000",
|
||||
"Actions": {
|
||||
"OnSuccess": {
|
||||
"Name": "OutputExpression", //Name of action you want to call
|
||||
"Context": { //This is passed to the action as action context
|
||||
"Expression": "input1.TotalBilled * 0.8"
|
||||
}
|
||||
},
|
||||
"OnFailure": { // This will execute if the Rule evaluates to failure
|
||||
"Name": "EvaluateRule",
|
||||
"Context": {
|
||||
"WorkflowName": "inputWorkflow",
|
||||
"ruleName": "GiveDiscount10Percent"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"RuleName": "GiveDiscount10Percent",
|
||||
"SuccessEvent": "10",
|
||||
"ErrorMessage": "One or more adjust rules failed.",
|
||||
"ErrorType": "Error",
|
||||
"RuleExpressionType": "LambdaExpression",
|
||||
"Expression": "input1.couy == \"india\" AND input1.loyalityFactor <= 2 AND input1.totalPurchasesToDate >= 5000 AND input2.totalOrders > 2 AND input2.noOfVisitsPerMonth > 2",
|
||||
"Actions": {
|
||||
"OnSuccess": {
|
||||
"Name": "OutputExpression", //Name of action you want to call
|
||||
"Context": { //This is passed to the action as action context
|
||||
"Expression": "input1.TotalBilled * 0.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
Call `ExecuteActionWorkflowAsync` with the workflowName, ruleName and ruleParameters
|
||||
```c#
|
||||
var result = await rulesEngine.ExecuteActionWorkflowAsync("inputWorkflow","GiveDiscount20Percent",ruleParameters);
|
||||
Console.WriteLine(result.Output); //result.Output contains the evaluated value of the action
|
||||
```
|
||||
|
||||
In the above scenario if `GiveDiscount20Percent` succeeds, it will return 20 percent discount in output. If it fails, `EvaluateRule` action will call `GiveDiscount10Percent` internally and if it succeeds, it will return 10 percent discount in output.
|
||||
|
||||
EvaluateRule also supports passing filtered inputs and computed inputs to chained rule
|
||||
```jsonc
|
||||
"Actions": {
|
||||
"OnSuccess": {
|
||||
"Name": "EvaluateRule",
|
||||
"Context": {
|
||||
"WorkflowName": "inputWorkflow",
|
||||
"ruleName": "GiveDiscount10Percent",
|
||||
"inputFilter": ["input2"], //will only pass input2 from existing inputs,scopedparams to the chained rule
|
||||
"additionalInputs":[ // will pass a new input named currentDiscount with the result of the expression to the chained rule
|
||||
{
|
||||
"Name": "currentDiscount",
|
||||
"Expression": "input1.TotalBilled * 0.9"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Custom Actions
|
||||
RulesEngine allows registering custom actions which can be used in the rules workflow.
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Version>3.4.0</Version>
|
||||
<Version>3.5.0</Version>
|
||||
<Copyright>Copyright (c) Microsoft Corporation.</Copyright>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageProjectUrl>https://github.com/microsoft/RulesEngine</PackageProjectUrl>
|
||||
<Authors>Abbas Cyclewala, Dishant Munjal, Yogesh Prajapati</Authors>
|
||||
<Authors>Abbas Cyclewala</Authors>
|
||||
<Description>Rules Engine is a package for abstracting business logic/rules/policies out of the system. This works in a very simple way by giving you an ability to put your rules in a store outside the core logic of the system thus ensuring that any change in rules doesn't affect the core system.</Description>
|
||||
<PackageReleaseNotes>https://github.com/microsoft/RulesEngine/blob/main/CHANGELOG.md</PackageReleaseNotes>
|
||||
<PackageTags>BRE, Rules Engine, Abstraction</PackageTags>
|
||||
|
|
Loading…
Reference in New Issue