Exemplo n.º 1
0
        private void ExecuteRuleSet(System.Workflow.Activities.Rules.RuleSet ruleSet,
                                    RuleValidation rv,
                                    ref MSRuleSetExecutionResult ruleSetExecutionResult)
        {
            RuleExecution re = new RuleExecution(rv, _instanceOfObject);

            ruleSet.Execute(re);
            ruleSetExecutionResult.AddExecutionResult(ruleSet.Name, re);
        }
Exemplo n.º 2
0
        public MSRuleSetExecutionResult ExecuteRuleSet(System.Workflow.Activities.Rules.RuleSet ruleSet, bool translatedRule)
        {
            MSRuleSetExecutionResult ruleSetExecutionResult = null;

            if (translatedRule)
            {
                ruleSetExecutionResult = new MSRuleSetExecutionResult(_msRuleSetTranslationResult);
            }
            else
            {
                ruleSetExecutionResult = new MSRuleSetExecutionResult();
            }

            RuleValidation rv = new RuleValidation(typeof(T), null);

            ruleSet.Validate(rv);

            ValidationErrorCollection errors = rv.Errors;

            if (errors.Count > 0)
            {
                ruleSetExecutionResult.AddRuleSetValidationErrors(errors);
            }
            else
            {
                try
                {
                    ExecuteRuleSet(ruleSet, rv, ref ruleSetExecutionResult);
                }
                catch (RuleException rex)
                {
                    _log.Error("RuleSet Name:  " + ruleSet.Name + "threw a Rule Exception during its execution.  ", rex);
                    ruleSetExecutionResult.AddExecutionError(Guid.Empty.ToString(), ruleSet.Name, rex);
                }
                catch (TargetInvocationException tex)
                {
                    _log.Error("RuleSetName:  " + ruleSet.Name +
                               ", threw a Target Invocation Exception which means that the Wrapper object itself probably threw an error, maybe the rule is targeting a property that is null or not a valid value for comparison", tex);
                    ruleSetExecutionResult.AddExecutionError(Guid.Empty.ToString(), ruleSet.Name, tex);
                }
                catch (Exception ex)
                {
                    _log.Error("RuleSetName:  " + ruleSet.Name + "Unhandled exception during execution of", ex);
                    ruleSetExecutionResult.AddExecutionError(Guid.Empty.ToString(), ruleSet.Name, ex);
                }
            }

            return(ruleSetExecutionResult);
        }