예제 #1
0
        public void HandleEvents(WonkaBreRulesEngine poRulesEngine, RuleTreeReport poRuleTreeReport)
        {
            var ruleTreeLog   = RuleTreeEvents.GetFilterChanges <CallRuleTreeEvent>(RuleTreeEventFilter).Result;
            var ruleSetLog    = RuleSetEvents.GetFilterChanges <CallRuleSetEvent>(RuleSetEventFilter).Result;
            var ruleLog       = RuleEvents.GetFilterChanges <CallRuleEvent>(RuleEventFilter).Result;
            var ruleSetErrLog = RuleSetErrorEvents.GetFilterChanges <RuleSetErrorEvent>(RuleSetErrorEventFilter).Result;

            /**
             * if (ruleTreeLog.Count > 0)
             *  System.Console.WriteLine("RuleTree Called that Belongs to : (" + ruleTreeLog[0].Event.TreeOwner + ")");
             **/

            if (ruleSetLog.Count > 0)
            {
                foreach (EventLog <CallRuleSetEvent> TmpRuleSetEvent in ruleSetLog)
                {
                    if (TmpRuleSetEvent.Event != null)
                    {
                        poRuleTreeReport.RuleSetIds.Add(TmpRuleSetEvent.Event.RuleSetId);
                    }
                }
            }

            if (ruleLog.Count > 0)
            {
                foreach (EventLog <CallRuleEvent> TmpRuleEvent in ruleLog)
                {
                    if (TmpRuleEvent.Event != null)
                    {
                        poRuleTreeReport.RuleIds.Add(TmpRuleEvent.Event.RuleId); // TmpRuleEvent.Event.RuleType
                    }
                }
            }

            if (ruleSetErrLog.Count > 0)
            {
                foreach (EventLog <RuleSetErrorEvent> TmpRuleSetError in ruleSetErrLog)
                {
                    if (TmpRuleSetError.Event != null)
                    {
                        if (TmpRuleSetError.Event.SevereFailure)
                        {
                            poRuleTreeReport.RuleSetFailures.Add(TmpRuleSetError.Event.RuleSetId);
                        }
                        else
                        {
                            poRuleTreeReport.RuleSetWarnings.Add(TmpRuleSetError.Event.RuleSetId);
                        }
                    }
                }
            }
        }
예제 #2
0
        public void Copy(RuleTreeReport poOriginal)
        {
            NumberOfRuleFailures = poOriginal.NumberOfRuleFailures;
            TransactionHash      = poOriginal.TransactionHash;
            InvokeTrxBlockNumber = poOriginal.InvokeTrxBlockNumber;

            RuleSetIds = poOriginal.RuleSetIds;
            RuleIds    = poOriginal.RuleIds;

            RuleSetWarnings = poOriginal.RuleSetWarnings;
            RuleSetFailures = poOriginal.RuleSetFailures;

            RuleSetFailMessages = poOriginal.RuleSetFailMessages;
        }
        public async Task <RuleTreeReport> ExecuteWithReportAsync(WonkaBreRulesEngine poRulesEngine, bool pbValidateWithinTransaction)
        {
            WonkaRefEnvironment RefEnv = WonkaRefEnvironment.GetInstance();

            WonkaRefAttr CurrValueAttr  = RefEnv.GetAttributeByAttrName("AccountCurrValue");
            WonkaRefAttr ReviewFlagAttr = RefEnv.GetAttributeByAttrName("AuditReviewFlag");

            var contract      = GetContract();
            var senderAddress = moEthEngineInit.EthSenderAddress;

            var executeWithReportFunction = contract.GetFunction(CONST_CONTRACT_FUNCTION_EXEC_RPT);

            RuleTreeReport ruleTreeReport = null;

            if (pbValidateWithinTransaction)
            {
                var FlagSource    = poRulesEngine.SourceMap[ReviewFlagAttr.AttrName];
                var CurrValSource = poRulesEngine.SourceMap[CurrValueAttr.AttrName];

                var executeGetLastReportFunction = contract.GetFunction(CONST_CONTRACT_FUNCTION_GET_LAST_RPT);

                string sFlagBeforeOrchestrationAssignment = await RetrieveValueMethodAsync(FlagSource, ReviewFlagAttr.AttrName).ConfigureAwait(false);

                string sValueBeforeOrchestrationAssignment = await RetrieveValueMethodAsync(CurrValSource, CurrValueAttr.AttrName).ConfigureAwait(false);

                var EthRuleTreeReport = new WonkaEth.Extensions.RuleTreeReport();
                await poRulesEngine.ExecuteOnChainAsync(moEthEngineInit, EthRuleTreeReport).ConfigureAwait(false);

                string sFlagAfterOrchestrationAssignment = await RetrieveValueMethodAsync(FlagSource, ReviewFlagAttr.AttrName).ConfigureAwait(false);

                string sValueAfterOrchestrationAssignment = await RetrieveValueMethodAsync(CurrValSource, CurrValueAttr.AttrName).ConfigureAwait(false);

                ruleTreeReport =
                    await executeGetLastReportFunction.CallDeserializingToObjectAsync <RuleTreeReport>().ConfigureAwait(false);
            }
            else
            {
                ruleTreeReport =
                    await executeWithReportFunction.CallDeserializingToObjectAsync <RuleTreeReport>(senderAddress).ConfigureAwait(false);
            }

            return(ruleTreeReport);
        }
예제 #4
0
        public RuleTreeReport ExecuteWithReport(WonkaBreRulesEngine poRulesEngine, bool pbValidateWithinTransaction)
        {
            WonkaRefEnvironment RefEnv = WonkaRefEnvironment.GetInstance();

            WonkaRefAttr CurrValueAttr  = RefEnv.GetAttributeByAttrName("AccountCurrValue");
            WonkaRefAttr ReviewFlagAttr = RefEnv.GetAttributeByAttrName("AuditReviewFlag");

            Dictionary <string, string> PrdKeys = new Dictionary <string, string>();

            var contract      = GetContract();
            var senderAddress = moEthEngineInit.EthSenderAddress;

            var executeWithReportFunction = contract.GetFunction(CONST_CONTRACT_FUNCTION_EXEC_RPT);

            RuleTreeReport ruleTreeReport = null;

            if (pbValidateWithinTransaction)
            {
                var FlagSource    = poRulesEngine.SourceMap[ReviewFlagAttr.AttrName];
                var CurrValSource = poRulesEngine.SourceMap[CurrValueAttr.AttrName];

                var executeGetLastReportFunction = contract.GetFunction(CONST_CONTRACT_FUNCTION_GET_LAST_RPT);

                WonkaProduct OrchContractCurrValues = poRulesEngine.AssembleCurrentProduct(new Dictionary <string, string>());

                string sFlagBeforeOrchestrationAssignment  = RetrieveValueMethod(FlagSource, ReviewFlagAttr.AttrName);
                string sValueBeforeOrchestrationAssignment = RetrieveValueMethod(CurrValSource, CurrValueAttr.AttrName);

                var EthRuleTreeReport = new WonkaEth.Extensions.RuleTreeReport();
                poRulesEngine.ExecuteOnChain(moEthEngineInit, EthRuleTreeReport);

                string sFlagAfterOrchestrationAssignment  = RetrieveValueMethod(FlagSource, ReviewFlagAttr.AttrName);
                string sValueAfterOrchestrationAssignment = RetrieveValueMethod(CurrValSource, CurrValueAttr.AttrName);

                ruleTreeReport = executeGetLastReportFunction.CallDeserializingToObjectAsync <RuleTreeReport>().Result;
            }
            else
            {
                ruleTreeReport = executeWithReportFunction.CallDeserializingToObjectAsync <RuleTreeReport>(senderAddress).Result;
            }

            return(ruleTreeReport);
        }
예제 #5
0
 public RuleTreeReport(RuleTreeReport poOriginal)
 {
     Copy(poOriginal);
 }