Exemple #1
0
        public void AddLogEntry(Logger.EventLogEntry entry)
        {
            if ((entry != null) && (entry.Text != null))
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new Action <Logger.EventLogEntry>(AddLogEntry), entry);
                }
                else
                {
                    ListViewItem item = new ListViewItem(entry.Timestamp.ToString());
                    item.SubItems.Add(entry.EntryType.ToString());
                    item.SubItems.Add(entry.SourceName ?? "Unknown");

                    string[] s = entry.Text.Split('\r', '\n');
                    if (s.Length > 0)
                    {
                        item.SubItems.Add(s[0]);
                    }
                    else
                    {
                        item.SubItems.Add(entry.Text);
                    }

                    if (entry.ExceptionObject != null)
                    {
                        item.ToolTipText = entry.ExceptionObject.ToString();
                    }

                    item.Tag = entry;
                    listViewLog.AddItem(item);
                }
            }
        }
Exemple #2
0
        private void listViewLog_DoubleClick(object sender, EventArgs e)
        {
            if (listViewLog.SelectedItems.Count > 0)
            {
                Logger.EventLogEntry entry = listViewLog.SelectedItems[0].Tag as Logger.EventLogEntry;

                if (entry != null)
                {
                    EventLogViewerForm frm = new EventLogViewerForm(entry);
                    frm.Show(this);
                }
            }
        }
Exemple #3
0
 public EventLogViewerForm(Logger.EventLogEntry entry)
 {
     InitializeComponent();
     lblSourceName.Text    = entry.SourceName ?? "";
     lblTimestampName.Text = entry.Timestamp.ToString();
     lblTypeName.Text      = entry.EntryType.ToString();
     if (entry.ExceptionObject != null)
     {
         richTextBoxDetails.Text = entry.ExceptionObject.ToString();
     }
     else
     {
         richTextBoxDetails.Text = entry.Text;
     }
 }
Exemple #4
0
        private string ItemsToText(IEnumerable items)
        {
            StringBuilder builder = new StringBuilder();

            foreach (ListViewItem item in items)
            {
                Logger.EventLogEntry entry = item.Tag as Logger.EventLogEntry;

                builder.AppendFormat("{0} - {1} - {2}", entry.Timestamp, entry.EntryType, entry.SourceName);
                builder.AppendLine(entry.Text);
                builder.AppendLine();
                if (entry.ExceptionObject != null)
                {
                    builder.AppendLine(entry.ExceptionObject.ToString());
                    builder.AppendLine();
                }
            }

            return(builder.ToString());
        }