public void AddToTransactionLog(TransactionEntry entry) { entry.TransactionNumber = _transCollection.Count + 1; _transCollection.Add(entry); //SaveTransactionLog(); AddTransactionToFile(entry, true); //UpdateNumberOfTransActions(); //UpdateChecksum(); }
public void ReadTransactionFile() { _transCollection = new TransactionCollection(); if (VerifyChecksum()) { FileInfo fi = new FileInfo(m_fileName); Int32 _entryCount = readInt32FromFile(m_fileName, 4); FileStream fs = new FileStream(m_fileName, FileMode.Open); fs.Seek(8, SeekOrigin.Begin); using (BinaryReader br = new BinaryReader(fs)) { // byte[] allBytes = br.ReadBytes((int)fi.Length - 8); //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after for (int t = 0; t < _entryCount; t++) { Int32 transActionNumber = br.ReadInt32(); byte isRolledBack = br.ReadByte(); byte day = br.ReadByte(); byte month = br.ReadByte(); Int16 year = br.ReadInt16(); byte hour = br.ReadByte(); byte minute = br.ReadByte(); byte second = br.ReadByte(); DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second)); Int32 address = br.ReadInt32(); Int16 NoteLength = br.ReadInt16(); byte[] notedata = br.ReadBytes(NoteLength); string note = string.Empty; for (int i = 0; i < notedata.Length; i += 2) { string Hex = string.Empty; Hex += Convert.ToChar(notedata[i]); Hex += Convert.ToChar(notedata[i + 1]); int value = Convert.ToInt32(Hex, 16); note += Convert.ToChar(value); } Int16 length = br.ReadInt16(); byte[] beforeData = br.ReadBytes(length); byte[] afterData = br.ReadBytes(length); // read day TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, note); _transCollection.Add(entry); } } fs.Close(); } }
public TransactionCollection ReadTransactionFileVersion1(string filename) { TransactionCollection m_transCollection = new TransactionCollection(); Int32 _entryCount = readInt32FromFile(filename, 4); FileStream fs = new FileStream(filename, FileMode.Open); fs.Seek(8, SeekOrigin.Begin); using (BinaryReader br = new BinaryReader(fs)) { //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after for (int t = 0; t < _entryCount; t++) { Int32 transActionNumber = br.ReadInt32(); byte isRolledBack = br.ReadByte(); byte day = br.ReadByte(); byte month = br.ReadByte(); Int16 year = br.ReadInt16(); byte hour = br.ReadByte(); byte minute = br.ReadByte(); byte second = br.ReadByte(); DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second)); Int32 address = br.ReadInt32(); Int16 length = br.ReadInt16(); byte[] beforeData = br.ReadBytes(length); byte[] afterData = br.ReadBytes(length); // read day TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, ""); m_transCollection.Add(entry); } } fs.Close(); return(m_transCollection); }
public TransactionCollection ReadTransactionFileVersion1(string filename) { TransactionCollection m_transCollection = new TransactionCollection(); Int32 _entryCount = readInt32FromFile(filename, 4); FileStream fs = new FileStream(filename, FileMode.Open); fs.Seek(8, SeekOrigin.Begin); using (BinaryReader br = new BinaryReader(fs)) { //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after for (int t = 0; t < _entryCount; t++) { Int32 transActionNumber = br.ReadInt32(); byte isRolledBack = br.ReadByte(); byte day = br.ReadByte(); byte month = br.ReadByte(); Int16 year = br.ReadInt16(); byte hour = br.ReadByte(); byte minute = br.ReadByte(); byte second = br.ReadByte(); DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second)); Int32 address = br.ReadInt32(); Int16 length = br.ReadInt16(); byte[] beforeData = br.ReadBytes(length); byte[] afterData = br.ReadBytes(length); // read day TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, ""); m_transCollection.Add(entry); } } fs.Close(); return m_transCollection; }