Navigation

Categories
Show Navigation Next Topic  »

Understanding Rule Editor Modes in Code Effects

Rule Editor can be rendered on the client in 5 modes: Evaluation, Execution, Filter, Ruleset, and Loop. To switch the Rule Editor into a different mode, set the value of CodeEffects.Rule.Web.RuleEditor.Mode property to one of the members of RyleType enumeration.

CodeEffects.Rule.Web.RuleEditor editor = new RuleEditor("divRuleEditor")
{
	SourceType = typeof(Patient),
	Mode = CodeEffects.Rule.Common.RuleType.Execution
};

The different modes of the Rule Editor control its behavior:

  • Evaluation Mode. This is the default mode. It allows rule authors to create only evaluation type rules, and the options in the Toolbar's Rules menu enforce that restriction if Toolbar is enabled.

    editor-evaluation

  • Execution Mode. This mode allows rule authors to create both evaluation and execution type rules. Again, the options in the Toolbar's Rules menu enforce that restriction if Tootlbar is enabled in the Rule Editor.

    editor-execution

  • Filter Mode. This mode sets up Rule Editor for rule-based data filtering. It allows only evaluation type rules because, in a nutshell, filtering queries are nothing more than evaluation type rules. This mode changes all labels and messages and hides the Toolbar, but you can show the Toolbar in filter mode by setting the RuleEditor.ShowToolBar to True if you'd like to let users manage their filters. The implementation of that is up to you. Data filtering is a huge topic, please make sure to read details in these related articles.

    editor-filter

  • Ruleset Mode. This mode allows rule authors to create a set of execution type rules, and evaluate those rules against a source object in a single evaluation step. In other words, using this mode the rule authors can evaluate a set of rules as if they were a single business rule.

    editor-labels

    This is the only mode that allows multiple If flow elements in the rule area, which serve as rule separators. No other flow elements such as Else If and Else are allowed in this mode.

    rulestes

    The following is a simple example of a rule created using the Ruleset mode:

    rule-mode

    You can control the behavior of the ruleset evaluation with an instance of the EvaluationParameters class when you use it to initialize one of the Evaluator classes.

  • Loop Mode. This mode allows rule authors to create only execution type rules, and evaluate those rules against a source object in a continuous loop until the rule returns True, or until the loop reaches a predefined number of iterations.

    editor-rules

    The Loop mode alows only a single if flow element per rule meaning that the rule can contain only one section (see the Code Effects Basics topic for details on rule elements). This mode changes the flow label from if to while and the action clause from then to do. Using the EvaluationParameters class you can define the max number of iterations after which the Evauator class terminates evaluation while the rule still returns False. The default max number of iterations is -1 meaning the indefinite number of iterations.

    The following is a simple example of a rule created using the Loop mode:

    loop-rules


Post your questions on Stackoverflow and become a part of our growing community

Comments: 0