示例#1
0
        public static ErrorIndexModel PayClients(List <ArkClientModel> arkClientModels, string passPhrase, string paymentDescription)
        {
            var returnModel = new ErrorIndexModel();
            var accCtnrl    = new AccountController(passPhrase);

            foreach (var voter in arkClientModels)
            {
                var voterAccount = AccountService.GetByAddress(voter.Address);

                _log.Info(String.Format("Paying {0}({1}) to address {2}", (voter.AmountToBePaid / StaticProperties.ARK_DIVISOR), (long)voter.AmountToBePaid, voter.Address));
                var response = accCtnrl.SendArk((long)voter.AmountToBePaid, voterAccount.Address, string.IsNullOrWhiteSpace(paymentDescription) ? string.Empty : paymentDescription, passPhrase);

                if (response.Item1 == false)
                {
                    _log.Error(String.Format("Error paying {0}({1}) to address {2}", (voter.AmountToBePaid / StaticProperties.ARK_DIVISOR), (long)voter.AmountToBePaid, voter.Address));
                    returnModel.ErrorClients.Add(new ErrorModel(voter.Address, (long)voter.AmountToBePaid, response.Item3));
                }
                else
                {
                    _log.Info(String.Format("Finished paying {0}({1}) to addres {2}", (voter.AmountToBePaid / StaticProperties.ARK_DIVISOR), (long)voter.AmountToBePaid, voter.Address));
                }
            }

            return(returnModel);
        }
        public static async Task <ErrorIndexModel> PayClients(List <ArkClientModel> arkClientModels, string passPhrase, string paymentDescription)
        {
            var returnModel = new ErrorIndexModel();
            var accCtnrl    = new AccountController(passPhrase);

            foreach (var voter in arkClientModels)
            {
                var voterAccount = await AccountService.GetByAddressAsync(voter.Address);

                _log.Info(String.Format("Paying {0}({1}) to address {2}", (voter.AmountToBePaid / StaticProperties.ARK_DIVISOR), (long)voter.AmountToBePaid, voter.Address));
                var response = await accCtnrl.SendArkUsingMultiBroadCastAsync((long)voter.AmountToBePaid, voterAccount.Account.Address, string.IsNullOrWhiteSpace(paymentDescription)?string.Empty : paymentDescription);

                if (response <= 0)
                {
                    _log.Error(String.Format("Error paying {0}({1}) to address {2}", (voter.AmountToBePaid / StaticProperties.ARK_DIVISOR), (long)voter.AmountToBePaid, voter.Address));
                    returnModel.ErrorClients.Add(new ErrorModel(voter.Address, (long)voter.AmountToBePaid, "transaction failed"));
                }
                else
                {
                    _log.Info(String.Format("Finished paying {0}({1}) to addres {2}", (voter.AmountToBePaid / StaticProperties.ARK_DIVISOR), (long)voter.AmountToBePaid, voter.Address));
                }
            }

            return(returnModel);
        }