SCLS/SSWCS_JXDL(2019)/ControlSystem/FrmBrowseDarkCasket.cs

198 lines
7.0 KiB
C#
Raw Permalink Normal View History

2025-05-19 09:45:29 +08:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ControlSystem
{
public partial class FrmBrowseDarkCasket : Form
{
private static FrmBrowseDarkCasket _formInstance;
private static string strCurrentLog = string.Empty;
private static string strFormTitle = string.Empty;
private static int iCurrentDayLogs = 0;
private static int iEcho = 0;
public static FrmBrowseDarkCasket FormInstance
{
get
{
if (_formInstance == null)
{
_formInstance = new FrmBrowseDarkCasket();
}
return _formInstance;
}
set { _formInstance = value; }
}
public FrmBrowseDarkCasket()
{
InitializeComponent();
_formInstance = this;
}
private void button1_Click(object sender, EventArgs e)
{
string filePath = System.IO.Path.GetFullPath(System.Reflection.Assembly.GetExecutingAssembly().GetName().ToString());
filePath = System.IO.Path.GetDirectoryName(filePath);
filePath = System.IO.Path.Combine(filePath, "DarkCasket");
if (Directory.Exists(filePath) == false)
{
return;
}
string[] files=Directory.GetFiles(filePath,"*.log",SearchOption.TopDirectoryOnly);//20101220<32><30>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>LOG<4F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5>ļ<EFBFBD>
if (files != null)
{
Array.Sort(files);//20100726
if (files.Length < 1) return;
}
else
{
return;
}
bool bExist = false;
string tempStr = string.Empty;
string str = string.Empty;
//Get Selected Date's log file count
if (0 >= iEcho)
{
foreach (string strTemp in files)
{
if (strTemp.IndexOf(this.dateTimePicker1.Value.ToString("yyyy-MM-dd")) != -1)
{
iCurrentDayLogs++;
}
iEcho++;
}
this.label_TotalNo.Text = iCurrentDayLogs.ToString().Trim();
if (iCurrentDayLogs > 0)
{
this.numericUpDown1.Maximum = iCurrentDayLogs;
this.numericUpDown1.Minimum = 1;
}
else
{
this.numericUpDown1.Minimum = iCurrentDayLogs;
this.numericUpDown1.Maximum = iCurrentDayLogs;
}
}
iCurrentDayLogs = 0;
iEcho = 0;
for (int j = files.Length - 1; j > -1; j--)
{
str = files[j];
tempStr = str.Substring(str.LastIndexOf('\\') + 1);
tempStr = tempStr.Substring(0, tempStr.LastIndexOf('.'));
if (tempStr == (this.dateTimePicker1.Value.ToString("yyyy-MM-dd") + "0" + this.numericUpDown1.Value.ToString().Trim()))
{
//string opf=files[files.Length - 1];
string[] cc = new string[1] { "**" };
string[] sp = null;
using (StreamReader sr = new StreamReader(str))
{
this.listView1.Items.Clear();
sr.ReadLine();
while (!sr.EndOfStream)
{
sp = sr.ReadLine().Split(cc, StringSplitOptions.RemoveEmptyEntries);
if (sp.GetLength(0) > 0)
{
ListViewItem lvi = new ListViewItem();
lvi.Text = sp[0];
for (int i = 1; i < sp.GetLength(0); i++)
{
lvi.SubItems.Add(sp[i]);
}
listView1.Items.Add(lvi);
lvi = null;
}
}
}
strCurrentLog = str;
strFormTitle = tempStr;
bExist = true;
break;
}
}
if (!bExist)
{
listView1.Items.Clear();
strCurrentLog = string.Empty;
strFormTitle = this.dateTimePicker1.Value.ToString("yyyy-MM-dd");
//MessageBox.Show("ָ<><D6B8><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>");
}
}
private void button2_Click(object sender, EventArgs e)
{
//string filePath = System.IO.Path.GetFullPath(System.Reflection.Assembly.GetExecutingAssembly().GetName().ToString());
//filePath = System.IO.Path.GetDirectoryName(filePath);
//filePath = System.IO.Path.Combine(filePath, "DarkCasket");
//if (Directory.Exists(filePath) == false)
//{
// return;
//}
//string[] files = Directory.GetFiles(filePath);
//if (files.Length < 1) return;
if (MessageBox.Show(this,"<22><>ȷ<EFBFBD><C8B7>Ҫɾ<D2AA><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><C4BC>𣿸ò<F0A3BFB8><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>", "ϵͳ<CFB5><CDB3>ʾ<EFBFBD><CABE>", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
if (File.Exists(strCurrentLog))
{
File.Delete(strCurrentLog);
}
else
{
MessageBox.Show("ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ں<EFBFBD>ϻ<EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>");
}
this.listView1.Items.Clear();
button1_Click(sender, e);
this.Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ӣ<EFBFBD>" + strFormTitle;
}
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void FrmBrowseDarkCasket_Load(object sender, EventArgs e)
{
SetColumnTitle();
this.numericUpDown1.Value = this.numericUpDown1.Minimum;
button1_Click(sender, e);
this.Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ӣ<EFBFBD>" + strFormTitle;
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
this.numericUpDown1.Value = this.numericUpDown1.Minimum;
button1_Click(sender, e);
this.Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ӣ<EFBFBD>" + strFormTitle;
}
private void SetColumnTitle()
{
listView1.Columns[0].Text = "ͨѶʱ<D1B6><CAB1>";
listView1.Columns[1].Text = "<22>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>";
listView1.Columns[2].Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ";
listView1.Columns[3].Text = "<22><>ַ/<2F>˿<EFBFBD>";
listView1.Columns[4].Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
button1_Click(sender, e);
this.Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ӣ<EFBFBD>" + strFormTitle;
}
}
}