mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-30 10:52:55 +08:00
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Data;
|
|||
|
using System.Diagnostics;
|
|||
|
using System.Drawing;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace CodeWalker.ErrorReport
|
|||
|
{
|
|||
|
public partial class ReportForm : Form
|
|||
|
{
|
|||
|
public ReportForm()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
private void ReportForm_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
EventLog myLog = new EventLog();
|
|||
|
myLog.Log = "Application";
|
|||
|
//myLog.Source = ".NET Runtime";
|
|||
|
|
|||
|
var lastEntry = myLog.Entries[myLog.Entries.Count - 1];
|
|||
|
var last_error_Message = lastEntry.Message;
|
|||
|
|
|||
|
bool found = false;
|
|||
|
|
|||
|
for (int index = myLog.Entries.Count - 1; index > 0; index--)
|
|||
|
{
|
|||
|
var errLastEntry = myLog.Entries[index];
|
|||
|
if (errLastEntry.EntryType == EventLogEntryType.Error)
|
|||
|
{
|
|||
|
if (errLastEntry.Source == ".NET Runtime")
|
|||
|
{
|
|||
|
var msg = errLastEntry.Message;
|
|||
|
var lines = msg.Split('\n');
|
|||
|
if ((lines.Length > 0) && (lines[0].Contains("CodeWalker.exe")))
|
|||
|
{
|
|||
|
ErrorTextBox.Text = msg.Replace("\n", "\r\n");
|
|||
|
found = true;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (!found)
|
|||
|
{
|
|||
|
ErrorTextBox.Text = "Event Log entry not found!";
|
|||
|
MessageBox.Show("Unable to find the last CodeWalker.exe error in the Event Log.");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|