-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
196 lines (153 loc) · 6.25 KB
/
Copy pathForm1.cs
File metadata and controls
196 lines (153 loc) · 6.25 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SphereLogViewer
{
public partial class Form1 : Form
{
DataTable table;
public static string baselogspath = Path.Combine(Application.StartupPath, "logs");
public static int contentheight = 840;
public static int saatheight = 55;
public Form1()
{
InitializeComponent();
table = new DataTable();
table.Columns.Add("Saat", typeof(string));
table.Columns.Add("Content", typeof(string));
}
private bool IsBlank(string inString)
{
if (!string.IsNullOrEmpty(inString)) inString = inString.Trim();
return string.IsNullOrEmpty(inString);
}
private void Form1_Load(object sender, EventArgs e)
{
if (!Directory.Exists(baselogspath))
{
MessageBox.Show("Logs klasörü bulunamadı!" + baselogspath);
Close();
return;
}
getAllLogFiles();
}
public void getLogContent(string filename)
{
string logfile = filename;
if (!File.Exists(filename))
{
MessageBox.Show("Log dosyası bulunamadı!");
return;
}
using (var streamReader = new StreamReader(filename))
{
while (!streamReader.EndOfStream)
{
var line = streamReader.ReadLine();
if (!IsBlank(line))
{
var values = line.Split('\t');
int len = 0;
string value = string.Empty;
string content = string.Empty;
for (int i = 0; i < values.Length; i++)
{
content = values[i];
len = content.Length;
if (content.Length > 0)
value = content.Substring(6);
string saat = content.Substring(0, 5);
if (!content.Contains("Indexing the client files...") && value != "WARNING:" && !content.Contains("contain errors, might be unstable or even destroy your shard as they are mostly untested!") && !content.Contains("Nightly builds are automatically made at every commit to the source code repository and might") && !content.Contains("DO NOT run this build on a live shard unless you know what you are doing!") && !content.Contains("-----------------------------------------------------------------") && !content.Contains("This is a nightly build of SphereServer.") && !string.IsNullOrEmpty(value))
table.Rows.Add(saat, value);
}
}
}
}
dataGridView1.DataSource = table;
dataGridView1.Columns[1].Width = contentheight;
dataGridView1.Columns[0].Width = saatheight;
}
public void getAllLogFiles()
{
//checkedListBox1.Items.Clear();
dataGridView2.Rows.Clear();
DirectoryInfo d = new DirectoryInfo(baselogspath);
FileInfo[] Files = d.GetFiles("*.log");
foreach (FileInfo file in Files)
{
dataGridView2.Rows.Add(false, file.Name);
//checkedListBox1.Items.Add(file.Name);
}
}
private void buttonLogFilesRefresh_Click(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
dataGridView1.Rows.Clear();
dataGridView1.Refresh();
dataGridView1.Columns[1].Width = contentheight;
dataGridView1.Columns[0].Width = saatheight;
getAllLogFiles();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
DataView dv = table.DefaultView;
dv.RowFilter = "Content LIKE '%" + textBox1.Text + "%'";
dataGridView1.DataSource = dv;
dataGridView1.Columns[1].Width = contentheight;
dataGridView1.Columns[0].Width = saatheight;
}
private void textBox1_MouseClick(object sender, MouseEventArgs e)
{
if (textBox1.Text == "Anahtar kelime giriniz.")
{
textBox1.Text = "";
}
dataGridView1.Columns[1].Width = contentheight;
dataGridView1.Columns[0].Width = saatheight;
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://arcaneuo.com");
}
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int rowindex = dataGridView2.CurrentCell.RowIndex;
int columnindex = dataGridView2.CurrentCell.ColumnIndex;
//if (dataGridView2.SelectedRows.Count <= 0)
//{
dataGridView1.DataSource = null;
dataGridView1.Rows.Clear();
dataGridView1.Refresh();
//}
//else
//{
// dataGridView1.Refresh();
// dataGridView1.DataSource = table;
// dataGridView1.Columns[1].Width = contentheight;
// dataGridView1.Columns[0].Width = saatheight;
//}
//if (e.ColumnIndex == Select.Index && e.RowIndex != -1)
if (columnindex == 0)
{
textBox1.Text = "Anahtar kelime giriniz.";
string filedir = "";
for (int i = 0; i < dataGridView2.SelectedCells.Count; i++)
{
filedir = Path.Combine(baselogspath, dataGridView2.Rows[rowindex].Cells[1].Value.ToString());
getLogContent(filedir);
//Console.WriteLine(filedir);
}
//MessageBox.Show(filedir);
}
}
}
}