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