|
@@ -2,6 +2,7 @@
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data;
|
|
|
|
+using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
@@ -17,8 +18,26 @@ namespace Scada.Page
|
|
public PageLogManage()
|
|
public PageLogManage()
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
|
|
+ InitCbData();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void InitCbData()
|
|
|
|
+ {
|
|
|
|
+ string logpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs");
|
|
|
|
+ if (!Directory.Exists(logpath))
|
|
|
|
+ {
|
|
|
|
+ Directory.CreateDirectory(logpath);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ string[] dirNames = Directory.GetDirectories(logpath);
|
|
|
|
+ dirNames.ForEach(dir =>
|
|
|
|
+ {
|
|
|
|
+ this.cb_Date.Items.Add(Path.GetFileName(dir));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
private void PageLogManage_Load(object sender, EventArgs e)
|
|
private void PageLogManage_Load(object sender, EventArgs e)
|
|
{
|
|
{
|
|
|
|
|
|
@@ -28,5 +47,100 @@ namespace Scada.Page
|
|
{
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private void cb_Date_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
+ {
|
|
|
|
+ string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs", this.cb_Date.SelectedItem.ToString());
|
|
|
|
+ string[] dirNames = Directory.GetDirectories(logPath);
|
|
|
|
+ this.cb_LogLev.Items.Clear();
|
|
|
|
+ dirNames.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ this.cb_LogLev.Items.Add(Path.GetFileName(x));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void cb_LogLev_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
+ {
|
|
|
|
+ if (this.cb_Date.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ UIMessageTip.ShowError("请先选择日期");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.cb_LogLev.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ UIMessageTip.ShowError("请先选择日志级别");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ string logPath = Path.Combine(Application.StartupPath, "Logs", cb_Date.SelectedItem.ToString(), cb_LogLev.SelectedItem.ToString());
|
|
|
|
+ this.lb_Files.Items.Clear();
|
|
|
|
+
|
|
|
|
+ string[] fileNames = Directory.GetFiles(logPath, "*.log");
|
|
|
|
+
|
|
|
|
+ fileNames.OrderBy(x => x).ToList().ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ this.lb_Files.Items.Add(Path.GetFileName(x));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private async void lb_Files_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
+ {
|
|
|
|
+ if (this.cb_Date.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ UIMessageTip.ShowError("请先选择日期");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.cb_LogLev.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ UIMessageTip.ShowError("请先选择日志级别");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.lb_Files.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ UIMessageTip.ShowError("请先选择日志文件");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ string logPath = Path.Combine(Application.StartupPath, "Logs", cb_Date.SelectedItem.ToString()
|
|
|
|
+ , cb_LogLev.SelectedItem.ToString(), lb_Files.SelectedItem.ToString());
|
|
|
|
+ string content = string.Empty;
|
|
|
|
+
|
|
|
|
+ this.txt_ShowLog.Text = "";
|
|
|
|
+
|
|
|
|
+ using (StreamReader sr = new StreamReader(logPath, Encoding.UTF8))
|
|
|
|
+ {
|
|
|
|
+ content = await sr.ReadToEndAsync();
|
|
|
|
+ }
|
|
|
|
+ this.txt_ShowLog.Text = content;
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ LogExtension.ShowMessage(ex.Message, Microsoft.Extensions.Logging.LogLevel.Error);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void btn_OpenDire_Click(object sender, EventArgs e)
|
|
|
|
+ {
|
|
|
|
+ string logPath = Path.Combine(Application.StartupPath, "Logs");
|
|
|
|
+
|
|
|
|
+ ProcessStartInfo startInfo = new ProcessStartInfo()
|
|
|
|
+ {
|
|
|
|
+ FileName = logPath,
|
|
|
|
+ UseShellExecute = true,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Process process = new Process
|
|
|
|
+ {
|
|
|
|
+ StartInfo = startInfo
|
|
|
|
+ };
|
|
|
|
+ process.Start();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void btn_ShowToDgv_Click(object sender, EventArgs e)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|