forked from dexyfex/CodeWalker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportForm.cs
More file actions
66 lines (59 loc) · 2.1 KB
/
ReportForm.cs
File metadata and controls
66 lines (59 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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)
{
var l = lines[0];
if (l.Contains("CodeWalker.exe") ||
l.Contains("CodeWalker RPF Explorer.exe") ||
l.Contains("CodeWalker Ped Viewer.exe") ||
l.Contains("CodeWalker Vehicle Viewer.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.");
}
}
}
}