public TransactionGenerator(UIHelper uiHelper, CancellationToken cancelToken, BankQueue bankQueue, CustomerList customerList, int maxTransAmount, int timeOutThrottle,
                                    /*List<Teller> tellers,*/ BlockingCollection <Teller> tellers, Bank bank)
        {
            this.cancelToken     = cancelToken;
            this.customerList    = customerList;
            this.maxTransAmount  = maxTransAmount;
            this.uiHelper        = uiHelper;
            this.timeOutThrottle = timeOutThrottle;
            this.bankQueue       = bankQueue;
            this.bank            = bank;

            currentTranAmount = 0;
            rand               = new Random();
            this.tellers       = tellers;
            availTellerQueue   = new BlockingCollection <Teller>();
            unAvailTellerQueue = new BlockingCollection <Teller>();

            foreach (Teller tel in tellers)
            {
                availTellerQueue.Add(tel);
            }


            task = new Task(Generate);
            task.Start();
        }
        public TransactionGenerator(UIHelper uiHelper, CancellationToken ct, BankQueue bq, CustomerList cl, decimal maxTransactionAmount, int timeoutThrottle)
        {
            try
            {
                this.uiHelper = uiHelper;
                this.cancelToken = ct;
                this.maxTransAmount = maxTransactionAmount;
                if (cl == null)
                {
                    uiHelper.GeneralMessage("DEBUG: The 'cl' (CustomerList) IS NULL!!!!");
                }
                this.customerList = cl;

                if (timeoutThrottle < 1) timeoutThrottle = 1;
                this.timeoutThrottle = timeoutThrottle;

                this.bankQueue = bq;

                this.task = Task.Factory.StartNew(TransactionGeneratorProc, cancelToken);
            }
            catch(Exception ex)
            {
                uiHelper.GeneralMessage("Exception in the Transaction Generator().  Message=" + ex.Message);
            }
        }
示例#3
0
 public Bank(UIHelper uiHelper, CancellationToken ct, int numTellers, int numCustomers, decimal custInitialAmount, decimal initialBankVaultBalance)
 {
     BankQueue = new BankQueue(ct);
     Customers = new CustomerList(numCustomers, custInitialAmount, uiHelper);
     Vault = new BankVault(initialBankVaultBalance);
     tellerList = new List<Teller>();
     for (int i = 0; i < numTellers; i++)
     {
         tellerList.Add(new Teller(uiHelper, ct, this));
     }
 }
示例#4
0
        public Bank(UIHelper uiHelper, CancellationToken ct, int numberTellers, int numberCustomers, decimal bankVaultAmount, decimal maxTransactionAmount, decimal customersGoal, decimal customersInitAmount)
        {
            this.uiHelper    = uiHelper;
            this.cancelToken = ct;

            this.custList             = new CustomerList();
            this.numberCustomers      = numberCustomers;
            this.numberTellers        = numberTellers;
            this.bankVaultAmount      = bankVaultAmount;
            this.maxTransactionAmount = maxTransactionAmount;
            this.customerGoal         = customersGoal;
            this.customersInitAmount  = customersInitAmount;

            tellers   = new BlockingCollection <Teller>(); // List<Teller>();
            bankQueue = new BankQueue(cancelToken);

            InitBank();
        }