Пример #1
0
        public static string ToXml(this WonkaBizRulesEngine poEngine)
        {
            var RulesWriter =
                new Wonka.BizRulesEngine.Writers.WonkaBizRulesXmlWriter(poEngine);

            return(RulesWriter.ExportXmlString());
        }
        public async Task <bool> Init()
        {
            bool bResult = true;

            using (var client = new System.Net.Http.HttpClient())
            {
                string sIpfsUrl = String.Format("{0}/{1}", CONST_INFURA_IPFS_GATEWAY_URL, "QmXcsGDQthxbGW8C3Sx9r4tV9PGSj4MxJmtXF7dnXN5XUT");

                msRulesContents = await client.GetStringAsync(sIpfsUrl).ConfigureAwait(false);
            }

            // By setting the addresses to NULL, we indicates that we want the API to deploy the contracts for us
            if (msContractAddress == null)
            {
                msEngineContractAddress   = null;
                msRegistryContractAddress = null;
                msTestContractAddress     = null;
            }
            // By using the indicator "DEPLOY" here, we will manually deploy the contracts ourselves
            else if (msContractAddress == "DEPLOY")
            {
                msEngineContractAddress = await DeployWonka().ConfigureAwait(false);
            }
            // Else, we will use existing contracts on the test chain
            else
            {
                if (msContractAddress == "")
                {
                    msEngineContractAddress = "0xfB419DEA1f28283edAD89103fc1f1272f7573E6A";
                }
                else
                {
                    msEngineContractAddress = msContractAddress;
                }

                msRegistryContractAddress = "0x7E618a3948F6a5D2EA6b92D8Ce6723a468540CaA";
                msTestContractAddress     = "0x4092bc250ef6c384804af2f871Af9c679b672d0B";
            }

            if (String.IsNullOrEmpty(msChronoLogAddress))
            {
                var web3 = GetWeb3();
                var ChronoLogDeployment = new Wonka.Eth.Autogen.ChronoLog.ChronoLogDeployment();

                Nethereum.Hex.HexTypes.HexBigInteger nDefaultGas = new Nethereum.Hex.HexTypes.HexBigInteger(1000000);

                msChronoLogAddress =
                    await ChronoLogDeployment.DeployContractAsync(web3, msAbiChronoLog, msSenderAddress, nDefaultGas, CONST_ONLINE_TEST_CHAIN_URL).ConfigureAwait(false);
            }

            await InitEngineAsync(mbInitChainEnv).ConfigureAwait(false);


            Wonka.BizRulesEngine.Writers.WonkaBizRulesXmlWriter Writer =
                new Wonka.BizRulesEngine.Writers.WonkaBizRulesXmlWriter(moEthEngineInit.Engine.RulesEngine);

            string sOutputRules = Writer.ExportXmlString();

            return(bResult);
        }