Exemple #1
0
        private async Task AddInterest(object o)
        {
            var interestAmount = 200;

            var transactions = await _transactionalState.PerformRead(b => b.Transactions);

            if (!transactions
                .Any(t => t.Type == TransactionType.Interest && t.BookingDate.Date.CompareTo(DateTime.Now.Date) == 0))
            {
                await Deposit(interestAmount, "Dailiy interesst", TransactionType.Interest);
            }
        }
Exemple #2
0
        Task IBallGrain.Move()
        {
            uint ball_id = attr.PerformRead(x => x.Id).Result;

            attr.PerformUpdate(x => {
                x.Px += x.Vx;
                x.Py += x.Vy;
            });

            double px = attr.PerformRead(x => x.Px).Result;

            if (px < 0)
            {
                attr.PerformUpdate(x => {
                    x.Px = 0;
                    x.Vx = -x.Vx;
                });
            }
            if (px > Common.x_max)
            {
                attr.PerformUpdate(x => {
                    x.Px = Common.x_max;
                    x.Vx = -x.Vx;
                });
            }
            double py = attr.PerformRead(x => x.Py).Result;

            if (py < 0)
            {
                attr.PerformUpdate(x => {
                    x.Py = 0;
                    x.Vy = -x.Vy;
                });
            }
            if (py > Common.y_max)
            {
                attr.PerformUpdate(x => {
                    x.Py = Common.y_max;
                    x.Vy = -x.Vy;
                });
            }

            Console.WriteLine($"\n\nball {ball_id} move px = {px} py = {py}\n\n");

            return(Task.CompletedTask);
        }
        private Task <Observation[]> Read()
        {
            var txid = TransactionContext.CurrentTransactionId;

            return(data.PerformRead((state) =>
            {
                return new Observation[] {
                    new Observation()
                    {
                        ExecutingTx = txid,
                        WriterTx = state.WriterTx,
                        Grain = MyNumber,
                        SeqNo = state.SeqNo
                    }
                };
            }));
        }
Exemple #4
0
 Task <uint> IAccountGrain.GetBalance()
 {
     return(_balance.PerformRead(x => x.Value));
 }
 List <long> InnerGetBallList()
 {
     long[] balls = ball_arr.PerformRead(x => x.Value).Result;
     return(balls.ToList());
 }
Exemple #6
0
 Task <uint> IAccountGrain.GetBalance()
 {
     return(balance.PerformRead(b => b.Value));
     //return Task.FromResult(this.balance.State.Value);
 }
Exemple #7
0
 public Task <uint> GetBalance() => _balance.PerformRead(x => x.Value);
Exemple #8
0
 public Task <ulong> GetBalance()
 {
     return(_balance.PerformRead(m => m.Value));
 }