Пример #1
0
        static async Task <bool> ChangeOrderStatus(string orderid, int status)
        {
            var web3 = new Web3("http://127.0.0.1:7545");

            //testing with the ethereum /truffle example from the petshop tutorial
            var json     = JObject.Load(new JsonTextReader(new StreamReader(System.IO.File.OpenRead(orderSystemJson))));
            var abi      = json["abi"].ToString();
            var bytecode = json["bytecode"].ToString();
            var ganacheOrderSystemContractAddress = json["networks"]["5777"]["address"].ToString();

            var unlockAccountResult = await web3.Personal.UnlockAccount.SendRequestAsync(DataController.senderAddress, DataController.senderPassword, 1200).ConfigureAwait(false);

            ChangeStatusFunction statusChange = new ChangeStatusFunction();

            statusChange.Orderid     = orderid;
            statusChange.Newstatus   = status;
            statusChange.FromAddress = senderAddress;


            OrderSystemService service = new OrderSystemService(web3, ganacheOrderSystemContractAddress);

            var theresult = await service.ChangeStatusRequestAsync(statusChange);

            return(theresult.Length > 0);
        }
Пример #2
0
        static async Task <GetOrdersOutputDTOBase> GetOrdersEth(BigInteger timespan)
        {
            var web3 = new Web3("http://127.0.0.1:7545");

            //testing with the ethereum /truffle example from the petshop tutorial
            var json     = JObject.Load(new JsonTextReader(new StreamReader(System.IO.File.OpenRead(orderSystemJson))));
            var abi      = json["abi"].ToString();
            var bytecode = json["bytecode"].ToString();
            var ganacheOrderSystemContractAddress = json["networks"]["5777"]["address"].ToString();

            var unlockAccountResult = await web3.Personal.UnlockAccount.SendRequestAsync(senderAddress, senderPassword, 1200).ConfigureAwait(false);

            var unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds - timespan;

            //get the contract we deployed
            GetOrdersFunction getOrders = new GetOrdersFunction();

            getOrders.TimeGreaterThan = unixTimestamp;
            getOrders.FromAddress     = senderAddress;

            OrderSystemService service2 = new OrderSystemService(web3, ganacheOrderSystemContractAddress);
            var theresult = await service2.GetOrdersQueryAsync(getOrders);

            return(theresult);
        }
Пример #3
0
        static async Task <decimal> CreateOrderEth(string orderinfo)
        {
            var web3 = new Web3("http://127.0.0.1:7545");

            //testing with the ethereum /truffle example from the petshop tutorial
            var json     = JObject.Load(new JsonTextReader(new StreamReader(System.IO.File.OpenRead(orderSystemJson))));
            var abi      = json["abi"].ToString();
            var bytecode = json["bytecode"].ToString();
            var ganacheOrderSystemContractAddress = json["networks"]["5777"]["address"].ToString();

            var unlockAccountResult = await web3.Personal.UnlockAccount.SendRequestAsync(DataController.senderAddress, DataController.senderPassword, 1200).ConfigureAwait(false);

            var orderinfoObj = JObject.Parse(orderinfo);
            var asdf         = orderinfoObj.GetValue("customer");
            var thename      = asdf["name"];
            CreateOrderFunction createOrder = new CreateOrderFunction();

            createOrder.Orderid     = Guid.NewGuid().ToString();
            createOrder.Orderinfo   = orderinfo;
            createOrder.Submitter   = thename.Value <string>();
            createOrder.FromAddress = senderAddress;


            OrderSystemService service = new OrderSystemService(web3, ganacheOrderSystemContractAddress);

            var theresult = await service.CreateOrderRequestAndWaitForReceiptAsync(createOrder);

            return(new decimal(1));
        }