private void CastRollBackEvent(TransactionEntry entry)
 {
     if (onRollBack != null)
     {
         onRollBack(this, new RollInformationEventArgs(entry));
     }
 }
 private void CastNoteChangedEvent(TransactionEntry entry)
 {
     if (onNoteChanged != null)
     {
         onNoteChanged(this, new RollInformationEventArgs(entry));
     }
 }
 private void CastRollForwardEvent(TransactionEntry entry)
 {
     if (onRollForward != null)
     {
         onRollForward(this, new RollInformationEventArgs(entry));
     }
 }
Exemple #4
0
 public void AddToTransactionLog(TransactionEntry entry)
 {
     entry.TransactionNumber = _transCollection.Count + 1;
     _transCollection.Add(entry);
     //SaveTransactionLog();
     AddTransactionToFile(entry, true);
     //UpdateNumberOfTransActions();
     //UpdateChecksum();
 }
Exemple #5
0
 public void AddToTransactionLog(TransactionEntry entry)
 {
     entry.TransactionNumber = _transCollection.Count + 1;
     _transCollection.Add(entry);
     //SaveTransactionLog();
     AddTransactionToFile(entry, true);
     //UpdateNumberOfTransActions();
     //UpdateChecksum();
 }
Exemple #6
0
 public void SetEntryNote(TransactionEntry ChangedEntry)
 {
     foreach (TransactionEntry entry in _transCollection)
     {
         if (entry.TransactionNumber == ChangedEntry.TransactionNumber)
         {
             entry.Note = ChangedEntry.Note;
         }
     }
     SaveTransactionLog();
 }
Exemple #7
0
            public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
            {
                if (destType == typeof(string) && value is TransactionEntry)
                {
                    // Cast the value to an Employee type
                    TransactionEntry pp = (TransactionEntry)value;

                    return(pp.EntryDateTime.ToString() + ", " + pp.SymbolAddress + ", " + pp.SymbolLength);
                }
                return(base.ConvertTo(context, culture, value, destType));
            }
Exemple #8
0
        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();
            }
        }
Exemple #9
0
        private void AddTransactionToFile(TransactionEntry entry, bool updateChecksum)
        {
            // append at the end of the file
            //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
            AppendInt32ToFile(entry.TransactionNumber);
            AppendByteToFile(Convert.ToByte(entry.IsRolledBack)); // not rolled back
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Day));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Month));
            AppendInt16ToFile(Convert.ToInt16(entry.EntryDateTime.Year));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Hour));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Minute));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Second));
            AppendInt32ToFile(entry.SymbolAddress);
            AppendInt16ToFile(Convert.ToInt16(entry.Note.Length * 2));
            // now add double hex all characters
            for (int i = 0; i < entry.Note.Length; i++)
            {
                byte   curByte = Convert.ToByte(entry.Note[i]);
                string Hex     = curByte.ToString("X2");
                AppendByteToFile(Convert.ToByte(Hex[0]));
                AppendByteToFile(Convert.ToByte(Hex[1]));
            }
            AppendInt16ToFile(Convert.ToInt16(entry.SymbolLength));
            AppendDataToFile(entry.DataBefore);
            AppendDataToFile(entry.DataAfter);
            // update number of entries
            Int32 _entryCount = readInt32FromFile(m_fileName, 4);

            _entryCount++;

            if (updateChecksum)
            {
                writeInt32ToFile(m_fileName, 4, _entryCount);
                UpdateChecksum();
            }
            // update checksum
        }
Exemple #10
0
        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);
        }
Exemple #11
0
 public TransactionsEventArgs(TransactionEntry entry)
 {
     this._entry = entry;
 }
Exemple #12
0
 public void Remove(TransactionEntry value)
 {
     List.Remove(value);
 }
Exemple #13
0
 public void Insert(int index, TransactionEntry value)
 {
     List.Insert(index, value);
 }
Exemple #14
0
        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();

            }
        }
Exemple #15
0
 public bool Contains(TransactionEntry value)
 {
     // If value is not of type Int16, this will return false.
     return(List.Contains(value));
 }
 public bool Contains(TransactionEntry value)
 {
     // If value is not of type Int16, this will return false.
     return (List.Contains(value));
 }
 public RollInformationEventArgs(TransactionEntry entry)
 {
     this._entry = entry;
 }
 public void Remove(TransactionEntry value)
 {
     List.Remove(value);
 }
 public int Add(TransactionEntry value)
 {
     return (List.Add(value));
 }
Exemple #20
0
 public int IndexOf(TransactionEntry value)
 {
     return(List.IndexOf(value));
 }
Exemple #21
0
        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;
        }
Exemple #22
0
 public void SetEntryNote(TransactionEntry ChangedEntry)
 {
     foreach (TransactionEntry entry in _transCollection)
     {
         if (entry.TransactionNumber == ChangedEntry.TransactionNumber)
         {
             entry.Note = ChangedEntry.Note;
         }
     }
     SaveTransactionLog();
 }
Exemple #23
0
        public void savedatatobinary(int address, int length, byte[] data, string filename, bool DoTransActionEntry, string note)
        {
            FileInfo fi = new FileInfo(filename);
            if (m_currentFiletype == FileType.MOTRONICME7)
            {
                // little endian, reverse bytes
                data = reverseEndian(data);
            }
            if (address > 0 && address < fi.Length)
            {
                try
                {
                    byte[] beforedata = readdatafromfile(filename, address, length, false);
                    FileStream fsi1 = File.OpenWrite(filename);
                    BinaryWriter bw1 = new BinaryWriter(fsi1);
                    fsi1.Position = address;

                    for (int i = 0; i < length; i++)
                    {
                        bw1.Write((byte)data.GetValue(i));
                    }
                    fsi1.Flush();
                    bw1.Close();
                    fsi1.Close();
                    fsi1.Dispose();

                    if (m_ProjectTransactionLog != null && DoTransActionEntry)
                    {
                        TransactionEntry tentry = new TransactionEntry(DateTime.Now, address, length, beforedata, data, 0, 0, note);
                        m_ProjectTransactionLog.AddToTransactionLog(tentry);
                        SignalTransactionLogChanged(tentry.SymbolAddress, tentry.Note);
                    }
                }
                catch (Exception E)
                {
                    frmInfoBox info = new frmInfoBox("Failed to write to binary. Is it read-only? Details: " + E.Message);
                }
            }
        }
Exemple #24
0
        private void AddTransactionToFile(TransactionEntry entry, bool updateChecksum)
        {
            // append at the end of the file
            //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
            AppendInt32ToFile(entry.TransactionNumber);
            AppendByteToFile(Convert.ToByte(entry.IsRolledBack)); // not rolled back
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Day));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Month));
            AppendInt16ToFile(Convert.ToInt16(entry.EntryDateTime.Year));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Hour));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Minute));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Second));
            AppendInt32ToFile(entry.SymbolAddress);
            AppendInt16ToFile(Convert.ToInt16(entry.Note.Length * 2));
            // now add double hex all characters
            for (int i = 0; i < entry.Note.Length; i++)
            {
                byte curByte = Convert.ToByte(entry.Note[i]);
                string Hex = curByte.ToString("X2");
                AppendByteToFile(Convert.ToByte(Hex[0]));
                AppendByteToFile(Convert.ToByte(Hex[1]));
            }
            AppendInt16ToFile(Convert.ToInt16(entry.SymbolLength));
            AppendDataToFile(entry.DataBefore);
            AppendDataToFile(entry.DataAfter);
            // update number of entries
            Int32 _entryCount = readInt32FromFile(m_fileName, 4);
            _entryCount++;

            if (updateChecksum)
            {
                writeInt32ToFile(m_fileName, 4, _entryCount);
                UpdateChecksum();
            }
            // update checksum
        }
 public int IndexOf(TransactionEntry value)
 {
     return (List.IndexOf(value));
 }
 public void Insert(int index, TransactionEntry value)
 {
     List.Insert(index, value);
 }
Exemple #27
0
 private void SignalTransactionLogChanged(TransactionEntry entry)
 {
     if (onTransactionLogChanged != null)
     {
         onTransactionLogChanged(this, new TransactionsEventArgs(entry));
     }
 }
Exemple #28
0
 public int Add(TransactionEntry value)
 {
     return(List.Add(value));
 }