示例#1
0
        private static async Task Run1()
        {
            IATMGrain atm  = _client.GetGrain <IATMGrain>(0);
            Guid      from = Guid.Parse("{aaaf5c35-c257-4ac1-96eb-796a5a84ba06}");
            Guid      to   = Guid.Parse("{a57239f5-3bfc-4065-b4b2-b10e90a36b84}");
            await atm.Transfer(from, to, 100);

            uint fromBalance = await _client.GetGrain <IAccountGrain>(from).GetBalance();

            uint toBalance = await _client.GetGrain <IAccountGrain>(to).GetBalance();

            _logger.LogInformation("fromBalance:{0},toBalance{1}", fromBalance, toBalance);
        }
示例#2
0
        private static async Task DoClientWork(IClusterClient client)
        {
            IATMGrain atm  = client.GetGrain <IATMGrain>(0);
            Guid      from = Guid.NewGuid();
            Guid      to   = Guid.NewGuid();
            await atm.Transfer(from, to, 100);

            uint fromBalance = await client.GetGrain <IAccountGrain>(from).GetBalance();

            uint toBalance = await client.GetGrain <IAccountGrain>(to).GetBalance();

            Console.WriteLine($"\n\nWe transfered 100 credits from {from} to {to}.\n{from} balance: {fromBalance}\n{to} balance: {toBalance}\n\n");
        }
示例#3
0
        public async Task <IActionResult> Tranfer(int fromAccount, int toAccount, uint amount)
        {
            IATMGrain atm  = client.GetGrain <IATMGrain>(0);
            Account   from = Account.Accounts[fromAccount];
            Account   to   = Account.Accounts[toAccount];
            await atm.Transfer(from.Id, to.Id, amount);

            uint fromBalance = await client.GetGrain <IAccountGrain>(from.Id).GetBalance();

            uint toBalance = await client.GetGrain <IAccountGrain>(to.Id).GetBalance();

            BaseResult baseResult = new BaseResult();

            baseResult.ResultValue = $"账户{from.Name} 转账 {amount} 到 {to.Name},最新余额:{from.Name}:{fromBalance},{to.Name}:{toBalance}";
            return(Ok(baseResult.ResultValue));
        }