Example #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));
        }
Example #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));
        }
Example #3
0
 public WithdrawEvent(Transaction transaction, Boolean multiples)
     : base()
 {
     this.Transaction = transaction;
     this.Multiples = multiples;
 }
Example #4
0
 public UnlockEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Example #5
0
 public DepositEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Example #6
0
 public BalanceInquiryEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Example #7
0
 private void Send(Transaction trans, Response resp)
 {
     this.Send(trans.GetMachine(), Activator.CreateInstance(trans.GetCallback(), resp) as Event);
 }
Example #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)));
        }
Example #9
0
 public WithdrawEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Example #10
0
 public CreateAccountEvent(Transaction transaction)
     : base()
 {
     this.Transaction = transaction;
 }
Example #11
0
        void InitOnEntry()
        {
            this.Driver = (this.ReceivedEvent as Config).Driver;
            this.Accounts = new Dictionary<Integer, MachineId>();
            this.TransBeingProcessed = null;

            this.Goto(typeof(Active));
        }