Ejemplo n.º 1
0
        public WonkaBreRuleSetReportNode GetRuleSetFailure(int pnIndex = 0)
        {
            WonkaBreRuleSetReportNode FailureReportNode = null;

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

            return(FailureReportNode);
        }
Ejemplo n.º 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 <WonkaBreRuleReportNode> FindRuleReports(int pnRuleSetId, bool pbCreateNew)
        {
            List <WonkaBreRuleReportNode> RuleReportNodes = null;

            WonkaBreRuleSetReportNode SoughtRuleSetReport = FindRuleSetReport(pnRuleSetId, pbCreateNew);

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

            return(RuleReportNodes);
        }
Ejemplo n.º 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 WonkaBreRuleReportNode FindRuleReport(int pnRuleSetId, int pnRuleId)
        {
            WonkaBreRuleReportNode RuleReportNode = null;

            WonkaBreRuleSetReportNode RuleSetReportNode = FindRuleSetReport(pnRuleSetId, false);

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

            return(RuleReportNode);
        }
Ejemplo n.º 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;

            WonkaBreRuleSetReportNode RuleSetReport = FindRuleSetReport(pnRuleSetId, true);

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

            return(bResult);
        }
Ejemplo n.º 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(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);
        }
Ejemplo n.º 6
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(WonkaBreRuleSet poTargetRuleSet, ERR_CD peRuleSetErrCd, string psRuleSetErrMsg)
        {
            bool bResult = true;

            WonkaBreRuleSetReportNode 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);
        }
Ejemplo n.º 7
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 WonkaBreRuleSetReportNode FindRuleSetReport(int pnRuleSetId, bool pbCreateNew = false)
        {
            WonkaBreRuleSetReportNode RuleSetReportNode = null;

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

            return(RuleSetReportNode);
        }