示例#1
0
        private TransactionHistory LoadFromFile(string filename, string ID)
        {
            TransactionHistory history = new TransactionHistory(ID);

            if (File.Exists(filename))
            {
                StreamReader file = new StreamReader(filename);
                history.SetKey(file.ReadLine());
                string entry = file.ReadLine();
                while (String.IsNullOrEmpty(entry) == false)
                {
                    BankTransaction transaction = ParseEntry(entry);
                    if (transaction.IsActive)
                    {
                        history.AddEntry(transaction);
                    }

                    entry = file.ReadLine();
                }
                history.Activate();

                file.Close();

                Console.WriteLine($"Loaded history details for {history.Key} (count:{history.Count})");
            }
            else
            {
                Console.WriteLine("File not found: " + filename);
            }

            return(history);
        }
示例#2
0
 private void RecordToHistory(BankTransaction transaction)
 {
     if (transaction.TransactionType != BankTransactionType.NONE)
     {
         TransactionHistoryDao historyDao = new TransactionHistoryDao();
         TransactionHistory    history    = historyDao.Load(_account.Key);
         history.AddEntry(transaction);
         historyDao.Save(history);
     }
 }