Replies: 3 comments 1 reply
-
Hi @gedoFR , I believe you are looking for Rule Chaining instead of the default "Run All" mode. you need to use |
Beta Was this translation helpful? Give feedback.
-
Hi @abbasc52 . I made some tests with your RulesEngineWithActionsTests.cs class I have this response, where I expected to get the error message in the rule. Test2 : (missing error message when the rule fails, even if an action onFailure is defined) I have this, where I also expected to know the reason why a rule failed even though the chaining is correct, For my use, it is really important that I have the details of the failed rules. I won't be using chaining so much. |
Beta Was this translation helpful? Give feedback.
-
Hi all, |
Beta Was this translation helpful? Give feedback.
-
Hello
I have configured the workflow to used the Actions onFailure and onSuccess.
[ { "WorkflowName": "inputWorkflowDECO", "Rules": [ { "RuleName": "checkFlightNumberChaining", "SuccessEvent": "10", "ErrorMessage": "checkFlightNumberChaining FAILED", "ErrorType": "Error", "RuleExpressionType": "LambdaExpression", "Expression": "flight.carrier != null ", "Actions": { "onSuccess": { "Name": "EvaluateRule", "Context": { "workflowName": "nestedWorkflow", "ruleName": "checkSegmentOnSuccess" } } } } ] }, { "WorkflowName": "nestedWorkflow", "Rules": [ { "RuleName": "checkSegmentOnSuccess", "SuccessEvent": "20", "ErrorMessage": "checkSegmentOnSuccess failed ", "ErrorType": "Error", "RuleExpressionType": "LambdaExpression", "Expression": "segment1Start.airport == \"ERROR\" ", "Actions": { "onFailure": { "Name": "EvaluateRule", "Context": { "workflowName": "nestedWorkflow", "ruleName": "checkSegmentOnFailure" } } } }, { "RuleName": "checkSegmentOnFailure", "SuccessEvent": "30", "ErrorMessage": "One or more adjust rules failed. ", "ErrorType": "Error", "RuleExpressionType": "LambdaExpression", "Expression": "segment1End.airport != null ", "Actions": { "onSuccess": { "Name": "OutputExpression", "Context": { "expression": "FINAL chaining rule: outputExpression on success" } } } } ] } ]
I wanted to chain the rules together , to have a final output action and follow what was going on during the process evaluation.
The first rule on success calls a second rule coming from another workflowName which on failure calls a third rule.
As final result, i've got an expected IsSuccess , but I'm not able to follow what is happening during the different rule evaluation.
The onSuccess/OutputExpression from the latest rule is not displayed somewhere.
I wanted to add the ruleResultTree in the result.ActionResult
For that I have changed the RuleEngine.cs code like this :
public async ValueTask<List<RuleResultTree>> ExecuteAllRulesAsync(string workflowName, params RuleParameter[] ruleParams) { var ruleResultList = ValidateWorkflowAndExecuteRule(workflowName, ruleParams); foreach (var ruleResult in ruleResultList) { var actionResult = await ExecuteActionForRuleResult(ruleResult, true); // gedo set to true ruleResult.ActionResult = new ActionRuleResult { // gedo changed to ActionRuleResult Output = actionResult.Output, Exception = actionResult.Exception, Results = actionResult.Results // gedo added Results }; } return ruleResultList;
Is that the right way for having the details of each ruleAction?
But also in that case, if a rule is unsuccess (Rule name = checkSegmentOnSuccess)
-the dedicated errormessage ("checkSegmentOnSuccess failed") is not displayed.
Do you have any feedback about that topic, it that something that will be extended in the future ?
thank you for any updates, and congratulations to the developer for this nice engine
Beta Was this translation helpful? Give feedback.
All reactions