Exemple #1
0
        public WonkaBizRuleSetReportNode GetRuleSetFailure(int pnIndex = 0)
        {
            WonkaBizRuleSetReportNode FailureReportNode = null;

            if (pnIndex < RuleSetFailures.Count)
            {
                FailureReportNode = RuleSetFailures[pnIndex];
            }

            return(FailureReportNode);
        }
Exemple #2
0
        /// <summary>
        ///
        /// This method will find the RuleReports found within a sought RuleSetReport.  If the RuleSetReport
        /// is not found and if the caller has flagged it, the function will initialize a new one
        /// (with the provided ID) and return its empty list.
        ///
        /// <param name="pnRuleSetId">The ID of the RuleSet whose report we are interested in</param>
        /// <param name="pbCreateNew">Indicator for whether or not we should create a new RuleSetReport if one is not found</param>
        /// <returns>The list of RuleReports that describes the execution of a specific RuleSet</returns>
        /// </summary>
        public List <WonkaBizRuleReportNode> FindRuleReports(int pnRuleSetId, bool pbCreateNew)
        {
            List <WonkaBizRuleReportNode> RuleReportNodes = null;

            WonkaBizRuleSetReportNode SoughtRuleSetReport = FindRuleSetReport(pnRuleSetId, pbCreateNew);

            if (SoughtRuleSetReport != null)
            {
                RuleReportNodes = SoughtRuleSetReport.RuleResults;
            }

            return(RuleReportNodes);
        }
Exemple #3
0
        /// <summary>
        ///
        /// This method will find the RuleReport for a specific Rule.
        ///
        /// <param name="pnRuleSetId">The ID of the RuleSet who contains the Rule of interest</param>
        /// <param name="pnRuleId">The ID of the Rule of interest</param>
        /// <returns>The RuleReport that describes the execution of a specific Rule</returns>
        /// </summary>
        public WonkaBizRuleReportNode FindRuleReport(int pnRuleSetId, int pnRuleId)
        {
            WonkaBizRuleReportNode RuleReportNode = null;

            WonkaBizRuleSetReportNode RuleSetReportNode = FindRuleSetReport(pnRuleSetId, false);

            if (RuleSetReportNode != null)
            {
                RuleReportNode = RuleSetReportNode.RuleResults.Where(x => x.RuleID == pnRuleId).FirstOrDefault();
            }

            return(RuleReportNode);
        }
Exemple #4
0
        /// <summary>
        ///
        /// This method will score the execution of a RuleSet, setting its status (success, failure, etc.)
        /// on the corresponding RuleSetReport.
        ///
        /// <param name="pnRuleSetId">The ID of the RuleSet whose report we are interested in</param>
        /// <param name="psRuleSetDesc">The description of the RuleSet (that we are passing onto the report)</param>
        /// <param name="psCustomId">The customId of the RuleSet (that we are passing onto the report)</param>
        /// <param name="peRuleSetErrCd">The status code of the target RuleSet's execution</param>
        /// <returns>Indicates whether or not we successfully set the RuleSetReport</returns>
        /// </summary>
        public bool SetRuleSetStatus(int pnRuleSetId, string psRuleSetDesc, string psCustomId, ERR_CD peRuleSetErrCd)
        {
            bool bResult = true;

            WonkaBizRuleSetReportNode RuleSetReport = FindRuleSetReport(pnRuleSetId, true);

            if (RuleSetReport != null)
            {
                RuleSetReport.RuleSetDescription = psRuleSetDesc;
                RuleSetReport.ErrorCode          = peRuleSetErrCd;
                RuleSetReport.CustomId           = psCustomId;
            }

            return(bResult);
        }
Exemple #5
0
        /// <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(WonkaBizRule poRule, ERR_CD peRuleErrCd, string psRuleErrorDesc, string psVerboseError)
        {
            bool bResult = true;

            WonkaBizRuleSetReportNode RuleSetReportNode = FindRuleSetReport(poRule.ParentRuleSetId, true);

            if (RuleSetReportNode != null)
            {
                WonkaBizRuleReportNode RuleReportNode = new WonkaBizRuleReportNode(poRule);

                RuleReportNode.ErrorCode        = peRuleErrCd;
                RuleReportNode.ErrorDescription = psRuleErrorDesc;
                RuleReportNode.VerboseError     = psVerboseError;

                RuleSetReportNode.RuleResults.Add(RuleReportNode);
            }

            return(bResult);
        }
Exemple #6
0
        /// <summary>
        ///
        /// This method will find the RuleSetReport indicated by the RuleSet ID.  If it's not
        /// found and if the caller has flagged it, the function will initialize a new one
        /// (with the provided ID) and add it to our list of RuleSetReports.
        ///
        /// <param name="pnRuleSetId">The ID of the RuleSet whose report we are interested in</param>
        /// <param name="pbCreateNew">Indicator for whether or not we should create a new RuleSetReport if one is not found</param>
        /// <returns>The RuleSetReport that describes the execution of a specific RuleSet</returns>
        /// </summary>
        public WonkaBizRuleSetReportNode FindRuleSetReport(int pnRuleSetId, bool pbCreateNew = false)
        {
            WonkaBizRuleSetReportNode RuleSetReportNode = null;

            if (RuleSetResults.Where(x => x.RuleSetID == pnRuleSetId).Count() > 0)
            {
                RuleSetReportNode = RuleSetResults.Where(x => x.RuleSetID == pnRuleSetId).FirstOrDefault();
            }
            else if (pbCreateNew)
            {
                RuleSetReportNode = new WonkaBizRuleSetReportNode()
                {
                    RuleSetID = pnRuleSetId
                };
                RuleSetResults.Add(RuleSetReportNode);
            }
            else
            {
                throw new WonkaBizRuleException(pnRuleSetId, -1, "ERROR!  This RuleSetReport does not exist!");
            }

            return(RuleSetReportNode);
        }
Exemple #7
0
        /// <summary>
        ///
        /// This method will flag the failure of a particular RuleSet by
        ///
        /// 1.) Setting the error properties on the corresponding RuleSetReport
        /// 2.) Adding the RuleSetReport to the Failures list
        /// 3.) Marking the RuleTree as a failure (since the failure of only one RuleSet flags the whole tree)
        ///
        /// <param name="poTargetRuleSet">The target RuleSet which will be marked as a failure</param>
        /// <param name="peRuleSetErrCd">The type of failure for the RuleSet</param>
        /// <param name="psRuleSetErrMsg">The error message that will provide details about the RuleSet's failure</param>
        /// <returns>The list of RuleReports that describes the execution of a specific RuleSet</returns>
        /// </summary>
        public bool AddResultSetFailure(WonkaBizRuleSet poTargetRuleSet, ERR_CD peRuleSetErrCd, string psRuleSetErrMsg)
        {
            bool bResult = true;

            WonkaBizRuleSetReportNode RuleSetReportNode = FindRuleSetReport(poTargetRuleSet.RuleSetId, false);

            if (RuleSetReportNode != null)
            {
                RuleSetReportNode.ErrorSeverity    = poTargetRuleSet.ErrorSeverity;
                RuleSetReportNode.ErrorCode        = peRuleSetErrCd;
                RuleSetReportNode.ErrorDescription = psRuleSetErrMsg;

                if ((poTargetRuleSet.ErrorSeverity == RULE_SET_ERR_LVL.ERR_LVL_WARNING) ||
                    (poTargetRuleSet.ErrorSeverity == RULE_SET_ERR_LVL.ERR_LVL_SEVERE))
                {
                    RuleSetFailures.Add(RuleSetReportNode);

                    OverallRuleTreeResult = ERR_CD.CD_FAILURE;
                }
            }

            return(bResult);
        }