public Account GetAccountFromFile(string CustID) { StreamReader file = new StreamReader(Path.Combine(BANK.BANKDATA, BANK.ACCOUNTINFO)); string line; while ((line = file.ReadLine()) != null) { string[] CharArray = line.Split(';').ToArray<string>(); if(CharArray.Contains(CustID)) { Account cust = new Account(); cust.ID = CharArray[0]; cust.AccountName = CharArray[1]; cust.Balance =Decimal.Parse(CharArray[2].Replace("$", "")); return cust; } } return null; }
public Account GetAccount(String CustID) { //Retrieve from database SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); SqlCommand cmd = new SqlCommand(); //SqlDataReader reader; string queryString = "SELECT * FROM ACCOUNT where Account_Number=" + CustID; SqlDataAdapter adapter = new SqlDataAdapter(queryString, conn); DataSet ds = new DataSet(); conn.Open(); adapter.Fill(ds); conn.Close(); //cmd.CommandText = "SELECT * FROM ACCOUNT where id=" +CustID; //cmd.CommandType = CommandType.Text; //cmd.Connection = conn; //reader = cmd.ExecuteReader(); Account retrievedAccount = new Account(); retrievedAccount.AccountName = ds.Tables[0].Rows[0][1].ToString(); retrievedAccount.ID = ds.Tables[0].Rows[0][3].ToString(); retrievedAccount.Balance = decimal.Parse(ds.Tables[0].Rows[0][2].ToString()); return retrievedAccount; }
public bool Add(string transindex,Account PayerAccount ,Account PayeeAccount,string details,decimal amount) { BnkQueue.Add(new Transaction(transindex,PayerAccount,PayeeAccount,details,amount)); return true; }
public void Start(TransactionQueue tsacs) { WaitCallback callBack; System.Diagnostics.Debug.WriteLine("Setting minimum threads for pool"); System.Threading.ThreadPool.SetMinThreads(10, 10); TransactionQueue splitchunk = new TransactionQueue(); callBack = new WaitCallback(ProcessBatch); MasterAccount = tsacs.Queue[0].AccountFrom; for (int i = 1; i <= tsacs.Queue.Count; i++) { splitchunk.Add(tsacs.Queue[i - 1]); if(i % 500 == 0 || i == tsacs.Queue.Count) { splitchunk.BatchID = tsacs.BatchID; System.Threading.ThreadPool.QueueUserWorkItem(callBack,(object)splitchunk); splitchunk = null; splitchunk = new TransactionQueue(); } } }