private void UpgradeTransActionLog(string input, string output)
 {
     _transCollection = ReadTransactionFileVersion1(input);
     // save transactions into new file
     SaveTransactionLog();
     File.Delete(input);
 }
 public TransactionCollectionPropertyDescriptor(TransactionCollection coll, int idx)
     :
     base("#" + idx.ToString(), null)
 {
     this.collection = coll;
     this.index      = idx;
 }
        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 TransactionCollectionPropertyDescriptor(TransactionCollection coll, int idx)
     : base("#" + idx.ToString(), null)
 {
     this.collection = coll;
     this.index = idx;
 }
 private void UpgradeTransActionLog(string input, string output)
 {
     _transCollection = ReadTransactionFileVersion1(input);
     // save transactions into new file
     SaveTransactionLog();
     File.Delete(input);
 }
        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 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();

            }
        }