Exemplo n.º 1
0
        void DoCloseAccount()
        {
            var transaction = (this.ReceivedEvent as CloseAccountEvent).Transaction;

            if (!this.Accounts.ContainsKey(transaction.GetAccountNumber()))
            {
                this.Send(transaction, new FailureResponse("No such account."));
                return;
            }

            var acccount = this.Accounts[transaction.GetAccountNumber()];

            this.Send(acccount, new Account.Close(this.Id));
            this.TransBeingProcessed = transaction;

            this.Goto(typeof(WaitingAccountToClose));
        }
Exemplo n.º 2
0
        void DoCloseAccountAck()
        {
            var result = (this.ReceivedEvent as Account.CloseAck).Result;

            if (result.BooleanValue())
            {
                this.Accounts.Remove(this.TransBeingProcessed.GetAccountNumber());
                this.Send(this.TransBeingProcessed, new SuccessResponse("Account closed."));
                this.TransBeingProcessed = null;
            }
            else
            {
                this.Send(this.TransBeingProcessed, new FailureResponse("Account not closed: nonzero balance."));
                this.TransBeingProcessed = null;
            }

            this.Goto(typeof(Active));
        }
Exemplo n.º 3
0
 public WithdrawEvent(Transaction transaction, Boolean multiples)
     : base()
 {
     this.Transaction = transaction;
     this.Multiples = multiples;
 }
Exemplo n.º 4
0
 public UnlockEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Exemplo n.º 5
0
 public DepositEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Exemplo n.º 6
0
 public BalanceInquiryEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Exemplo n.º 7
0
 private void Send(Transaction trans, Response resp)
 {
     this.Send(trans.GetMachine(), Activator.CreateInstance(trans.GetCallback(), resp) as Event);
 }
Exemplo n.º 8
0
        void DoTransfer()
        {
            var fromAccount = (this.ReceivedEvent as Account.TransferEvent).Account;
            var transfer = (this.ReceivedEvent as Account.TransferEvent).Transfer;

            if (this.IsLocked)
            {
                this.Send(transfer, new FailureResponse("Destination account is locked."));
                return;
            }

            if (this.TransferTransaction != null)
            {
                this.Send(transfer, new FailureResponse("Transaction cannot be completed at this time."));
                return;
            }

            this.TransferTransaction = transfer;
            var wTrans = new Transaction(this.Id, typeof(TransferComplete), new Integer(0),
                transfer.GetAmount(), transfer.GetPin(), 0, 0.0);

            this.Send(fromAccount, new Account.WithdrawEvent(wTrans, new Boolean(false)));
        }
Exemplo n.º 9
0
 public WithdrawEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Exemplo n.º 10
0
 public CreateAccountEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Exemplo n.º 11
0
        void InitOnEntry()
        {
            this.Driver = (this.ReceivedEvent as Config).Driver;
            this.Accounts = new Dictionary<Integer, MachineId>();
            this.TransBeingProcessed = null;

            this.Goto(typeof(Active));
        }