Esempio n. 1
0
        private void SerializeRulesEngineToBlockchain()
        {
            WonkaRefEnvironment RefEnv = WonkaRefEnvironment.GetInstance();

            // Creating an instance of the rules engine using our rules and the metadata
            moRulesEngine =
                new WonkaBizRulesEngine(new StringBuilder(msRulesContents), moMetadataSource);

            moRulesEngine.SetDefaultStdOps(this.msPassword);

            var contract = GetContract();

            var hasRuleTreeFunction = contract.GetFunction(CONST_CONTRACT_FUNCTION_HAS_RT);

            // Out of gas exception
            // var gas = new Nethereum.Hex.HexTypes.HexBigInteger(1000000);

            var gas = hasRuleTreeFunction.EstimateGasAsync(this.msSenderAddress).Result;

            bool bTreeAlreadyExists =
                hasRuleTreeFunction.CallAsync <bool>(this.msSenderAddress, gas, null, this.msSenderAddress).Result;

            if (!bTreeAlreadyExists)
            {
                moRulesEngine.Serialize(msSenderAddress, msPassword, msSenderAddress, msContractAddress, msAbiWonka);
            }
        }
        private void SerializeRulesEngineToBlockchain(WonkaBizRulesEngine poEngine)
        {
            var contract = GetContract();

            var hasRuleTreeFunction = contract.GetFunction(CONST_CONTRACT_FUNCTION_HAS_RT);

            var gas = hasRuleTreeFunction.EstimateGasAsync(this.msSenderAddress).Result;

            bool bTreeAlreadyExists =
                hasRuleTreeFunction.CallAsync <bool>(this.msSenderAddress, gas, null, this.msSenderAddress).Result;

            if (!bTreeAlreadyExists)
            {
                poEngine.Serialize(msSenderAddress, msPassword, msSenderAddress, msContractAddress, msAbiWonka);
            }
        }
        protected virtual void SerializeRulesEngineToBlockchain()
        {
            var contract = GetContract();

            var hasRuleTreeFunction = contract.GetFunction(CONST_CONTRACT_FUNCTION_HAS_RT);

            // Out of gas exception
            var gas = hasRuleTreeFunction.EstimateGasAsync(BlockchainEngineOwner).Result;
            // var gas = new Nethereum.Hex.HexTypes.HexBigInteger(1000000);

            bool bTreeAlreadyExists =
                hasRuleTreeFunction.CallAsync <bool>(BlockchainEngineOwner, gas, null, BlockchainEngine.SenderAddress).Result;

            if (!bTreeAlreadyExists)
            {
                moRulesEngine.Serialize(BlockchainEngineOwner,
                                        BlockchainEngine.Password,
                                        BlockchainEngine.SenderAddress,
                                        BlockchainEngine.ContractAddress,
                                        BlockchainEngine.ContractABI,
                                        null,
                                        msWeb3HttpUrl);
            }
        }