Skip to content

Commit

Permalink
2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
peterm30 committed Feb 26, 2019
1 parent 63508c0 commit d1157aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions EventFinder/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.IO;
using CsvHelper;
using System.Security.Principal;
using System.Globalization;

namespace EventFinder
{
Expand Down Expand Up @@ -145,7 +146,6 @@ private void FindEventsButton_Click(object sender, EventArgs e)
{
EventLogQuery eventlogQuery = new EventLogQuery(Log, pathType, query);
EventLogReader eventlogReader = new EventLogReader(eventlogQuery);

for (EventRecord eventRecord = eventlogReader.ReadEvent(); null != eventRecord; eventRecord = eventlogReader.ReadEvent())
{
// Get the SystemTime from the event record XML
Expand Down Expand Up @@ -188,6 +188,22 @@ private void FindEventsButton_Click(object sender, EventArgs e)
try
{
Message = eventRecord.FormatDescription();
if (Message == null)
{
Message += "EventRecord.FormatDescription() returned a null value. This is usually because:\n";
Message += " \"Either the component that raises this event is not installed on your local computer\n" +
" or the installation is corrupted. You can install or repair the component on the local computer.\"\n";
Message += "The event likely originated on another system, below is the XML data associated with this event\n";
Message += "\n";
Message += XDocument.Parse(eventRecord.ToXml()).ToString();
// If the message body is null, it's because the DLL that created it is on another system and it can't be parsed in real time
// The below works, but we can do better!
// foreach (var node in xml.Descendants(ns + "Event"))
// {
// Message += node.Value;
// Message += "\n";
// }
}
}
catch
{
Expand Down Expand Up @@ -437,7 +453,6 @@ private void FindEventsButton_Click(object sender, EventArgs e)
}

}

records = records.OrderBy(x => x.SystemTime).ToList(); // Sort our records in chronological order
// and write them to a CSV
using (var writer = new StreamWriter(DesktopPath + "\\Logs_Runtime_" + RunTime + ".csv", append: true))
Expand Down
Binary file modified EventFinder/bin/Release/EventFinder.exe
Binary file not shown.

0 comments on commit d1157aa

Please # to comment.