private void SetTargetAttribute(WonkaBreRule poTargetRule, string psRuleExpression) { char[] acTargetAttributeDelim = new char[1] { '.' }; int nAttrNameStartIdx = psRuleExpression.IndexOf(CONST_RULE_TOKEN_START_DELIM); if (nAttrNameStartIdx >= 0) { int nAttrNameEndIdx = psRuleExpression.IndexOf(CONST_RULE_TOKEN_END_DELIM, nAttrNameStartIdx + 1); if (nAttrNameEndIdx > 0) { string sRecordOfInterest = "N"; string sAttrName = psRuleExpression.Substring(nAttrNameStartIdx + 1, (nAttrNameEndIdx - nAttrNameStartIdx - 1)); if (sAttrName.Contains(acTargetAttributeDelim[0])) { string[] acAttrNameParts = sAttrName.Split(acTargetAttributeDelim); if (acAttrNameParts.Length > 1) { sRecordOfInterest = acAttrNameParts[0]; sAttrName = acAttrNameParts[1]; } } if (sRecordOfInterest == "N") { poTargetRule.RecordOfInterest = TARGET_RECORD.TRID_NEW_RECORD; } else { poTargetRule.RecordOfInterest = TARGET_RECORD.TRID_OLD_RECORD; } if (WonkaRefEnvironment.GetInstance().IsAttribute(sAttrName)) { poTargetRule.TargetAttribute = WonkaRefEnvironment.GetInstance().GetAttributeByAttrName(sAttrName); } else { throw new WonkaBreException(-1, -1, "ERROR! Attribute (" + sAttrName + ") does not exist."); } } } }
/// <summary> /// /// This method will archive the results of a particular rule's execution by storing them as a /// a RuleReportNode and by inserting it into a RuleSetReportNode. /// /// <param name="poRule">The business rule that we have executed</param> /// <param name="peRuleErrCd">The error (i.e., result) code of that rule's execution</param> /// <param name="psRuleErrorDesc">The general description of the rule's error (if there is one)</param> /// <param name="psVerboseError">The verbose description of the rule's error (if there is one)</param> /// <returns>The indicator for whether or not the rule's execution results were successfully archived</returns> /// </summary> public bool ArchiveRuleExecution(WonkaBreRule poRule, ERR_CD peRuleErrCd, string psRuleErrorDesc, string psVerboseError) { bool bResult = true; WonkaBreRuleSetReportNode RuleSetReportNode = FindRuleSetReport(poRule.ParentRuleSetId, true); if (RuleSetReportNode != null) { WonkaBreRuleReportNode RuleReportNode = new WonkaBreRuleReportNode(poRule); RuleReportNode.ErrorCode = peRuleErrCd; RuleReportNode.ErrorDescription = psRuleErrorDesc; RuleReportNode.VerboseError = psVerboseError; RuleSetReportNode.RuleResults.Add(RuleReportNode); } return(bResult); }
public WonkaBreRuleReportNode(WonkaBreRule poRule) : this() { RuleID = poRule.RuleId; TriggerAttrId = poRule.TargetAttribute.AttrId; }
private void SetRuleValues(WonkaBreRule poTargetRule, string psRuleExpression) { char[] acRuleValuesDelim = new char[1] { ',' }; int nValueStartIdx = psRuleExpression.LastIndexOf(CONST_RULE_TOKEN_START_DELIM); if (nValueStartIdx >= 0) { int nValueEndIdx = psRuleExpression.IndexOf(CONST_RULE_TOKEN_END_DELIM, nValueStartIdx + 1); if (nValueEndIdx > 0) { string sValues = psRuleExpression.Substring(nValueStartIdx + 1, (nValueEndIdx - nValueStartIdx - 1)); string[] asValueSet = sValues.Split(acRuleValuesDelim); if (poTargetRule.RuleType == RULE_TYPE.RT_DOMAIN) { DomainRule Rule = (DomainRule)poTargetRule; Rule.SetDomain(asValueSet); } else if (poTargetRule.RuleType == RULE_TYPE.RT_ARITHMETIC) { ArithmeticRule Rule = (ArithmeticRule)poTargetRule; Rule.SetDomain(asValueSet); } else if (poTargetRule.RuleType == RULE_TYPE.RT_ARITH_LIMIT) { ArithmeticLimitRule Rule = (ArithmeticLimitRule)poTargetRule; Rule.SetMinAndMax(psRuleExpression, asValueSet); } else if (poTargetRule.RuleType == RULE_TYPE.RT_ASSIGNMENT) { AssignmentRule Rule = (AssignmentRule)poTargetRule; Rule.SetAssignValue(asValueSet); } else if (poTargetRule.RuleType == RULE_TYPE.RT_DATE_LIMIT) { DateLimitRule Rule = (DateLimitRule)poTargetRule; Rule.SetMinAndMax(psRuleExpression, asValueSet); } else if (poTargetRule.RuleType == RULE_TYPE.RT_CUSTOM_OP) { CustomOperatorRule Rule = (CustomOperatorRule)poTargetRule; string sCustomOpKey = CustomOpSources.Keys.Where(s => psRuleExpression.Contains(s)).FirstOrDefault(); if (!String.IsNullOrEmpty(sCustomOpKey)) { Rule.SetDomain(asValueSet); Rule.CustomOpName = sCustomOpKey; Rule.CustomOpContractSource = CustomOpSources[sCustomOpKey]; } } } } }
private void ParseSingleRule(XmlNode poRuleXmlNode, WonkaBreRuleSet poTargetRuleSet) { int nNewRuleId = ++(this.RuleIdCounter); string sRuleExpression = poRuleXmlNode.InnerText; WonkaBreRule NewRule = null; if (this.CustomOpSources.Keys.Any(s => sRuleExpression.Contains(s))) { NewRule = new CustomOperatorRule() { RuleId = nNewRuleId } } ; else if (this.ArithmeticLimitOps.Any(s => sRuleExpression.Contains(s))) { NewRule = new ArithmeticLimitRule() { RuleId = nNewRuleId } } ; else if (this.DateLimitOps.Any(s => sRuleExpression.Contains(s))) { NewRule = new DateLimitRule() { RuleId = nNewRuleId } } ; else if (sRuleExpression.Contains("NOT POPULATED")) { NewRule = new PopulatedRule() { RuleId = nNewRuleId, NotOperator = true } } ; else if (sRuleExpression.Contains("POPULATED")) { NewRule = new PopulatedRule() { RuleId = nNewRuleId, NotOperator = false } } ; else if (sRuleExpression.Contains("!=")) { NewRule = new DomainRule() { RuleId = nNewRuleId, NotOperator = true } } ; else if (sRuleExpression.Contains("==")) { NewRule = new DomainRule() { RuleId = nNewRuleId, NotOperator = false } } ; else if (sRuleExpression.Contains("NOT IN")) { NewRule = new DomainRule() { RuleId = nNewRuleId, NotOperator = true } } ; else if (sRuleExpression.Contains("IN")) { NewRule = new DomainRule() { RuleId = nNewRuleId, NotOperator = false } } ; else if (sRuleExpression.Contains("EXISTS AS")) { NewRule = new DomainRule() { RuleId = nNewRuleId, NotOperator = false, SearchAllDataRows = true } } ; else if (sRuleExpression.Contains("DEFAULT")) { NewRule = new AssignmentRule() { RuleId = nNewRuleId, NotOperator = false, DefaultAssignment = true } } ; else if (sRuleExpression.Contains("ASSIGN_SUM")) { NewRule = new ArithmeticRule() { RuleId = nNewRuleId, NotOperator = false, OpType = ARITH_OP_TYPE.AOT_SUM } } ; else if (sRuleExpression.Contains("ASSIGN_DIFF")) { NewRule = new ArithmeticRule() { RuleId = nNewRuleId, NotOperator = false, OpType = ARITH_OP_TYPE.AOT_DIFF } } ; else if (sRuleExpression.Contains("ASSIGN_PROD")) { NewRule = new ArithmeticRule() { RuleId = nNewRuleId, NotOperator = false, OpType = ARITH_OP_TYPE.AOT_PROD } } ; else if (sRuleExpression.Contains("ASSIGN_QUOT")) { NewRule = new ArithmeticRule() { RuleId = nNewRuleId, NotOperator = false, OpType = ARITH_OP_TYPE.AOT_QUOT } } ; else if (sRuleExpression.Contains("ASSIGN")) { NewRule = new AssignmentRule() { RuleId = nNewRuleId, NotOperator = false } } ; if (NewRule != null) { var RuleId = poRuleXmlNode.Attributes.GetNamedItem(CONST_RULE_ID_ATTR); if (RuleId != null) { NewRule.DescRuleId = RuleId.Value; } NewRule.ParentRuleSetId = poTargetRuleSet.RuleSetId; SetTargetAttribute(NewRule, sRuleExpression); if (NewRule.RuleType != RULE_TYPE.RT_POPULATED) { SetRuleValues(NewRule, sRuleExpression); } } if (NewRule != null) { poTargetRuleSet.AddRule(NewRule); } }