2023-02-13 00:43:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
2023-03-23 05:12:16 +00:00
|
|
|
|
using System.IO;
|
2023-04-04 08:29:19 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2023-02-13 00:43:01 +00:00
|
|
|
|
|
|
|
|
|
using INT_PT002.Forms;
|
2023-03-23 05:12:16 +00:00
|
|
|
|
using INT_PT002.DataStore;
|
2023-03-27 02:29:31 +00:00
|
|
|
|
using INT_PT002.DialogForms;
|
2023-02-13 00:43:01 +00:00
|
|
|
|
|
|
|
|
|
namespace INT_PT002.Controls
|
|
|
|
|
{
|
2023-03-06 04:52:55 +00:00
|
|
|
|
public partial class ControlMenuLogAlarm : UserControl
|
2023-02-13 00:43:01 +00:00
|
|
|
|
{
|
|
|
|
|
#region Field
|
2023-04-05 11:13:22 +00:00
|
|
|
|
private string SelectedNodeFullPath;
|
|
|
|
|
private int ListBoxCount;
|
|
|
|
|
|
2023-02-13 00:43:01 +00:00
|
|
|
|
private FormMenu m_ParentForm;
|
2023-03-23 05:12:16 +00:00
|
|
|
|
|
2023-04-04 08:29:19 +00:00
|
|
|
|
private Define.E_DataType CurrentDataType;
|
2023-03-23 05:12:16 +00:00
|
|
|
|
private List<DataBackupYear> ListAlarmFile;
|
2023-04-04 08:29:19 +00:00
|
|
|
|
private Collection<SmartX.SmartListBox> CollectionListBox;
|
2023-02-13 00:43:01 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructor
|
2023-03-06 04:52:55 +00:00
|
|
|
|
public ControlMenuLogAlarm(FormMenu parent)
|
2023-02-13 00:43:01 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.ParentForm = parent;
|
2023-03-23 05:12:16 +00:00
|
|
|
|
|
2023-02-13 00:43:01 +00:00
|
|
|
|
this.Initialize();
|
2023-03-23 05:12:16 +00:00
|
|
|
|
this.DefaultSetting();
|
2023-02-13 00:43:01 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Property
|
|
|
|
|
public FormMenu ParentForm
|
|
|
|
|
{
|
|
|
|
|
get { return this.m_ParentForm; }
|
|
|
|
|
private set { this.m_ParentForm = value; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Method
|
|
|
|
|
private void Initialize()
|
|
|
|
|
{
|
2023-03-06 04:52:55 +00:00
|
|
|
|
this.smartGroupBox1.Text = "Log > Alarm";
|
2023-02-13 00:43:01 +00:00
|
|
|
|
}
|
2023-03-23 05:12:16 +00:00
|
|
|
|
private void DefaultSetting()
|
|
|
|
|
{
|
2023-04-04 08:29:19 +00:00
|
|
|
|
this.CurrentDataType = Define.E_DataType.Alarm;
|
2023-04-05 11:13:22 +00:00
|
|
|
|
this.ListBoxCount = 0;
|
2023-03-23 05:12:16 +00:00
|
|
|
|
|
|
|
|
|
this.ListAlarmFile = new List<DataBackupYear>();
|
2023-04-04 08:29:19 +00:00
|
|
|
|
|
|
|
|
|
this.CollectionListBox = new Collection<SmartX.SmartListBox>();
|
|
|
|
|
this.CollectionListBox.Clear();
|
|
|
|
|
this.CollectionListBox.Add(this.listBoxTime);
|
|
|
|
|
this.CollectionListBox.Add(this.listBoxLoginID);
|
|
|
|
|
this.CollectionListBox.Add(this.listBoxEvent);
|
|
|
|
|
this.CollectionListBox.Add(this.listBoxDetail);
|
2023-03-23 05:12:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-04 00:09:48 +00:00
|
|
|
|
public void LoadFile(string fullFilePath)
|
|
|
|
|
{
|
|
|
|
|
if (fullFilePath.Contains("_Alarm") == false)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this.smartFile1.FilePathName = fullFilePath;
|
|
|
|
|
this.smartFile1.Open();
|
|
|
|
|
this.smartFile1.StringType.EncodingType = SmartX.SmartFile.Encodings.ANSI;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.smartFile1.StringType.FillBuffer();
|
|
|
|
|
|
|
|
|
|
long lineNum = this.smartFile1.StringType.GetCount();
|
2023-04-05 11:13:22 +00:00
|
|
|
|
this.ListBoxCount = (int)lineNum;
|
2023-04-04 00:09:48 +00:00
|
|
|
|
for (int i = 1; i < lineNum; i++)
|
|
|
|
|
{
|
2023-04-04 08:29:19 +00:00
|
|
|
|
this.UpdateListBoxDataDisplay(this.smartFile1.StringType.ReadBuffer(i));
|
2023-04-04 00:09:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
DialogFormMessage myMsg = new DialogFormMessage(16, this.ParentForm.ParentForm.SystemConfig.LANGUAGE);
|
|
|
|
|
myMsg.ShowDialog();
|
|
|
|
|
|
|
|
|
|
this.smartFile1.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.smartFile1.Close();
|
|
|
|
|
}
|
2023-04-05 11:13:22 +00:00
|
|
|
|
private void UpdateListBoxCount()
|
|
|
|
|
{
|
2023-04-14 02:03:30 +00:00
|
|
|
|
this.labelTotalIndex.Text = (this.ListBoxCount - 1).ToString();
|
|
|
|
|
if (this.ListBoxCount - 1 - this.listBoxTime.ViewRemainCount < 0)
|
|
|
|
|
this.labelRemainIndex.Text = "0";
|
|
|
|
|
else
|
|
|
|
|
this.labelRemainIndex.Text = (this.ListBoxCount - 1 - this.listBoxTime.ViewRemainCount).ToString();
|
2023-04-05 11:13:22 +00:00
|
|
|
|
}
|
2023-04-04 08:29:19 +00:00
|
|
|
|
private void UpdateListBoxDataDisplay(string data)
|
|
|
|
|
{
|
|
|
|
|
if (data.Contains(",") == false)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string[] sb = data.Split(',');
|
|
|
|
|
|
|
|
|
|
// Date-생략, Time, LoginID, Event, Detail
|
|
|
|
|
for (int i = 0; i < this.CollectionListBox.Count; i++)
|
|
|
|
|
this.CollectionListBox[i].AddItem(sb[i + 1]);
|
|
|
|
|
}
|
2023-03-23 05:12:16 +00:00
|
|
|
|
private void UpdateDisplayFile()
|
|
|
|
|
{
|
|
|
|
|
int fileCount = 0;
|
|
|
|
|
//TreeNode node;
|
|
|
|
|
List<string> years = new List<string>();
|
|
|
|
|
List<string> months = new List<string>();
|
|
|
|
|
List<string> days = new List<string>();
|
|
|
|
|
|
2023-03-30 10:56:06 +00:00
|
|
|
|
this.treeView.Nodes.Clear();
|
2023-03-23 05:12:16 +00:00
|
|
|
|
this.ListAlarmFile.Clear();
|
|
|
|
|
|
2023-03-27 09:00:47 +00:00
|
|
|
|
DirectoryInfo dir = new DirectoryInfo(this.ParentForm.ParentForm.PathDataAlarmFolder);
|
2023-03-23 05:12:16 +00:00
|
|
|
|
List<string> fileNames = new List<string>();
|
|
|
|
|
|
|
|
|
|
// 폴더 체크
|
|
|
|
|
if (dir.Exists == false)
|
|
|
|
|
dir.Create();
|
|
|
|
|
|
|
|
|
|
// year 폴더 가져오기
|
|
|
|
|
DirectoryInfo[] yearDirectorys = dir.GetDirectories();
|
|
|
|
|
// year 폴더 정렬
|
|
|
|
|
years = this.ParentForm.DirectorySort(yearDirectorys);
|
|
|
|
|
|
2023-03-27 09:00:47 +00:00
|
|
|
|
// Alarm File 리스트 생성
|
2023-03-23 05:12:16 +00:00
|
|
|
|
if (years.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
// Year
|
|
|
|
|
foreach (string year in years)
|
|
|
|
|
{
|
|
|
|
|
DataBackupYear y = new DataBackupYear(year);
|
|
|
|
|
DirectoryInfo monthDir = new DirectoryInfo(string.Format("{0}{1}", this.ParentForm.ParentForm.PathDataAlarmFolder, year));
|
|
|
|
|
DirectoryInfo[] monthDirectorys = monthDir.GetDirectories();
|
|
|
|
|
|
|
|
|
|
months = this.ParentForm.DirectorySort(monthDirectorys);
|
|
|
|
|
|
|
|
|
|
if (months.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
// Month
|
|
|
|
|
foreach (string month in months)
|
|
|
|
|
{
|
|
|
|
|
DirectoryInfo dayDir = new DirectoryInfo(string.Format("{0}{1}\\{2}", this.ParentForm.ParentForm.PathDataAlarmFolder, year, month));
|
|
|
|
|
FileInfo[] dayFiles = dayDir.GetFiles();
|
|
|
|
|
|
2023-03-27 09:00:47 +00:00
|
|
|
|
days = this.DayAlarmDirectorySort(dayFiles);
|
2023-03-23 05:12:16 +00:00
|
|
|
|
|
|
|
|
|
DataBackupMonth m = new DataBackupMonth(month);
|
|
|
|
|
m.Days = days;
|
|
|
|
|
|
|
|
|
|
y.Months.Add(m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ListAlarmFile.Add(y);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.ListAlarmFile.Add(y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// node 생성
|
|
|
|
|
for (int i = 0; i < this.ListAlarmFile.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
TreeNode node = new TreeNode(this.ListAlarmFile[i].Year);
|
|
|
|
|
for (int j = 0; j < this.ListAlarmFile[i].Months.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
TreeNode nodeMonth = new TreeNode(this.ListAlarmFile[i].Months[j].Month);
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < this.ListAlarmFile[i].Months[j].Days.Count; k++)
|
|
|
|
|
{
|
|
|
|
|
nodeMonth.Nodes.Add(this.ListAlarmFile[i].Months[j].Days[k]);
|
|
|
|
|
fileCount++;
|
|
|
|
|
}
|
|
|
|
|
node.Nodes.Add(nodeMonth);
|
|
|
|
|
}
|
2023-03-30 10:56:06 +00:00
|
|
|
|
this.treeView.Nodes.Add(node);
|
2023-03-23 05:12:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-11 09:01:18 +00:00
|
|
|
|
this.labelCount.Text = fileCount.ToString();
|
2023-03-23 05:12:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-27 09:00:47 +00:00
|
|
|
|
private List<string> DayAlarmDirectorySort(FileInfo[] files)
|
2023-03-23 05:12:16 +00:00
|
|
|
|
{
|
|
|
|
|
List<string> listFile = new List<string>();
|
|
|
|
|
Dictionary<string, int> dirNames = new Dictionary<string, int>();
|
2023-03-31 01:47:21 +00:00
|
|
|
|
Dictionary<string, int> dirNamesSort = new Dictionary<string, int>();
|
2023-03-23 05:12:16 +00:00
|
|
|
|
|
2023-03-31 01:47:21 +00:00
|
|
|
|
#region File List 날짜 순서대로 정렬
|
2023-03-23 05:12:16 +00:00
|
|
|
|
foreach (FileInfo file in files)
|
2023-03-31 01:47:21 +00:00
|
|
|
|
dirNames.Add(file.Name, int.Parse(file.Name.Substring(0, 8)));
|
2023-03-23 05:12:16 +00:00
|
|
|
|
|
2023-03-31 01:47:21 +00:00
|
|
|
|
var vrList = dirNames.Keys.ToList();
|
|
|
|
|
vrList.Sort();
|
2023-03-23 05:12:16 +00:00
|
|
|
|
|
|
|
|
|
foreach (var v in vrList)
|
2023-03-31 01:47:21 +00:00
|
|
|
|
dirNamesSort.Add(v, dirNames[v]);
|
|
|
|
|
|
|
|
|
|
foreach (var v in dirNamesSort)
|
2023-03-23 05:12:16 +00:00
|
|
|
|
listFile.Add(v.Key);
|
2023-03-31 01:47:21 +00:00
|
|
|
|
|
2023-03-23 05:12:16 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
return listFile;
|
|
|
|
|
}
|
2023-02-13 00:43:01 +00:00
|
|
|
|
|
|
|
|
|
public void DisplayRefresh()
|
|
|
|
|
{
|
2023-04-04 00:09:48 +00:00
|
|
|
|
this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplayMode = Define.E_DisplayModeStore.LogAlarm;
|
2023-03-31 01:47:21 +00:00
|
|
|
|
this.ParentForm.ParentForm.SetDisplayMode(Define.E_EquipmentMode.Menu);
|
2023-03-27 09:00:47 +00:00
|
|
|
|
|
2023-03-27 02:29:31 +00:00
|
|
|
|
this.UpdateDisplayFile();
|
2023-03-30 10:56:06 +00:00
|
|
|
|
this.treeView.ExpandAll();
|
2023-02-13 00:43:01 +00:00
|
|
|
|
|
2023-04-06 02:24:42 +00:00
|
|
|
|
this.labelRemainIndex.Text = "0";
|
|
|
|
|
this.labelTotalIndex.Text = "0";
|
2025-02-14 00:09:42 +00:00
|
|
|
|
|
|
|
|
|
// User
|
|
|
|
|
switch (this.ParentForm.ParentForm.CurrentSystemStatus.CurrentUser.Group)
|
|
|
|
|
{
|
|
|
|
|
case Define.E_UserGroup.None:
|
|
|
|
|
this.Enabled = false;
|
|
|
|
|
break;
|
|
|
|
|
case Define.E_UserGroup.Level1:
|
|
|
|
|
this.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuAlarmLog;
|
|
|
|
|
break;
|
|
|
|
|
case Define.E_UserGroup.Level2:
|
|
|
|
|
this.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuAlarmLog;
|
|
|
|
|
break;
|
|
|
|
|
case Define.E_UserGroup.Level3:
|
|
|
|
|
this.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuAlarmLog;
|
|
|
|
|
break;
|
|
|
|
|
case Define.E_UserGroup.Admin:
|
|
|
|
|
this.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuAlarmLog;
|
|
|
|
|
break;
|
|
|
|
|
case Define.E_UserGroup.Developer:
|
|
|
|
|
this.Enabled = true;
|
|
|
|
|
break;
|
|
|
|
|
case Define.E_UserGroup.NotLogin:
|
|
|
|
|
this.Enabled = false;
|
|
|
|
|
break;
|
|
|
|
|
case Define.E_UserGroup.LogOut:
|
|
|
|
|
this.Enabled = false;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-02-13 00:43:01 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2023-04-04 00:09:48 +00:00
|
|
|
|
#region Event Handler
|
2023-03-31 01:47:21 +00:00
|
|
|
|
private void treeViewLogAlarm_AfterSelect(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
2023-04-04 00:09:48 +00:00
|
|
|
|
this.labelFileName.Text = e.Node.Text;
|
2023-04-05 11:13:22 +00:00
|
|
|
|
this.SelectedNodeFullPath = this.treeView.SelectedNode.FullPath;
|
2023-04-04 08:29:19 +00:00
|
|
|
|
for (int i = 0; i < this.CollectionListBox.Count; i++)
|
|
|
|
|
this.CollectionListBox[i].ClearAll();
|
2023-04-05 11:13:22 +00:00
|
|
|
|
|
2023-04-04 08:29:19 +00:00
|
|
|
|
this.LoadFile(this.ParentForm.ParentForm.PathDataAlarmFolder + this.treeView.SelectedNode.FullPath);
|
2023-04-05 11:13:22 +00:00
|
|
|
|
this.UpdateListBoxCount();
|
|
|
|
|
}
|
|
|
|
|
private void buttonBackup_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.labelFileName.Text == "")
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this.ParentForm.FileCopy(Define.E_DataType.Alarm, this.SelectedNodeFullPath);
|
2023-04-04 08:29:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonUp_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < this.CollectionListBox.Count; i++)
|
|
|
|
|
this.CollectionListBox[i].ScrollUp();
|
2023-04-05 11:13:22 +00:00
|
|
|
|
|
|
|
|
|
this.UpdateListBoxCount();
|
2023-04-04 08:29:19 +00:00
|
|
|
|
}
|
|
|
|
|
private void buttonDown_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < this.CollectionListBox.Count; i++)
|
|
|
|
|
this.CollectionListBox[i].ScrollDown();
|
|
|
|
|
|
2023-04-05 11:13:22 +00:00
|
|
|
|
this.UpdateListBoxCount();
|
2023-04-04 08:29:19 +00:00
|
|
|
|
}
|
2023-04-05 11:13:22 +00:00
|
|
|
|
#endregion
|
2023-02-13 00:43:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|