Ver 2025.03.19.0
FrmEqSelector 로그파일 목록수집 개선(2회 to 1회) FrmServerLog 파일명 중복에 따른 다운로드 파일명 수정
This commit is contained in:
@@ -20,6 +20,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
using Telerik.WinControls.UI;
|
||||
@@ -55,6 +56,8 @@ namespace DDUtilityApp.LOGPARSER
|
||||
|
||||
public SECSDefine SECSDefine { get; set; } = null;
|
||||
|
||||
private int InitializeStatus { get; set; } = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region [ FrmEqSelector ] ---------------------------------------------
|
||||
@@ -82,17 +85,11 @@ namespace DDUtilityApp.LOGPARSER
|
||||
this.chkUseSMB.Visible = false;
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tboxModelDescription.Font = font;
|
||||
|
||||
this.GridEquipments_Setting();
|
||||
this.GridLogFiles_Setting(this.gridLogFiles); //jhlim 20250202
|
||||
this.GridLogFiles_Setting(this.gridHsms); //jhlim 20250202
|
||||
this.GridLogFiles_Setting(this.gridWorkflow); //jhlim 20250202
|
||||
this.GridModelDetail_Setting();
|
||||
}
|
||||
|
||||
protected void SetEventHandler()
|
||||
{
|
||||
this.Load += FrmEquipments_Load;
|
||||
this.Shown += this.FrmEqSelector_Shown;
|
||||
this.FormClosing += FrmEqSelector_FormClosing;
|
||||
this.FormClosed += this.FrmEqSelector_FormClosed;
|
||||
this.Disposed += this.FrmEqSelector_Disposed;
|
||||
@@ -113,12 +110,44 @@ namespace DDUtilityApp.LOGPARSER
|
||||
this.gridLogFiles.CellDoubleClick += GridLogFiles_CellDoubleClick;
|
||||
this.gridLogFiles.KeyDown += GridLogFiles_KeyDown;
|
||||
|
||||
//jhlim 20250202 start
|
||||
this.gridWorkflow.CellDoubleClick += Grid_CellDoubleClick;
|
||||
this.gridWorkflow.KeyDown += Grid_KeyDown;
|
||||
this.gridHsms.CellDoubleClick += Grid_CellDoubleClick;
|
||||
this.gridHsms.KeyDown += Grid_KeyDown;
|
||||
//jhlim 20250202 end
|
||||
}
|
||||
|
||||
private async void FrmEqSelector_Shown(object sender, EventArgs e)
|
||||
{
|
||||
await Task.Delay(500);
|
||||
|
||||
try
|
||||
{
|
||||
this.SuspendLayout();
|
||||
|
||||
this.GridEquipments_Setting();
|
||||
this.GridLogFiles_Setting(this.gridLogFiles);
|
||||
this.GridLogFiles_Setting(this.gridHsms);
|
||||
this.GridLogFiles_Setting(this.gridWorkflow);
|
||||
this.GridModelDetail_Setting();
|
||||
|
||||
this.InitializeStatus = 1;
|
||||
this.SetLogServer();
|
||||
if (this.Equipment != null) this.SetEquipment(this.Equipment);
|
||||
else this.SetEquipment(this.ServerName, this.Equipment?.EquipmentID);
|
||||
this.InitializeStatus = 0;
|
||||
|
||||
this.GridEquipments_SelectionChanged(this.gridEquipments, null);
|
||||
this.SetSelectedLogFiles(this.SelectedLogFiles);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
XLogger.Instance.Fatal(ex, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.InitializeStatus = 0;
|
||||
this.ResumeLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private void FrmEqSelector_Disposed(object sender, EventArgs e)
|
||||
@@ -157,14 +186,6 @@ namespace DDUtilityApp.LOGPARSER
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
|
||||
private void FrmEquipments_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.SetLogServer();
|
||||
if (this.Equipment != null) this.SetEquipment(this.Equipment);
|
||||
else this.SetEquipment(this.ServerName, this.Equipment?.EquipmentID);
|
||||
this.SetSelectedLogFiles(this.SelectedLogFiles);
|
||||
}
|
||||
|
||||
private void FrmEqSelector_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
}
|
||||
@@ -356,7 +377,7 @@ namespace DDUtilityApp.LOGPARSER
|
||||
{
|
||||
GridViewEx grid = this.gridEquipments;
|
||||
grid.TableElement.RowHeight = 20;
|
||||
grid.MultiSelect = true;
|
||||
grid.MultiSelect = false;
|
||||
|
||||
Dictionary<string, string> dicColumnText = new Dictionary<string, string>();
|
||||
dicColumnText.Add("Facility", "");
|
||||
@@ -424,12 +445,13 @@ namespace DDUtilityApp.LOGPARSER
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.InitializeStatus > 0) return;
|
||||
if (this.gridEquipments.SelectedRows.Count < 1) return;
|
||||
|
||||
this.gridLogFiles.DataSource = null;
|
||||
this.gridModelDetail.DataSource = null;
|
||||
this.gridWorkflow.DataSource = null;
|
||||
this.gridHsms.DataSource = null;
|
||||
//if (this.tabControl1.TabPages.Contains(this.tabHSMS)) this.tabControl1.TabPages.Remove(this.tabHSMS);
|
||||
|
||||
EisEquipment equipment = this.gridEquipments.SelectedRows[0].DataBoundItem as EisEquipment;
|
||||
if (equipment == null) return;
|
||||
@@ -570,165 +592,6 @@ namespace DDUtilityApp.LOGPARSER
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// [CheckPoint] 선택된 설비의 로그파일 목록을 표시한다.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void xGridEquipments_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.gridEquipments.SelectedRows.Count < 1) return;
|
||||
this.gridLogFiles.DataSource = null;
|
||||
this.gridModelDetail.DataSource = null;
|
||||
|
||||
EisEquipment equipment = this.gridEquipments.SelectedRows[0].DataBoundItem as EisEquipment;
|
||||
if (equipment == null) return;
|
||||
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
this.Equipment = equipment;
|
||||
LogServer logServer = this.cboxServer.SelectedItem as LogServer;
|
||||
string path = string.Empty;
|
||||
|
||||
#region [ Model Details ]
|
||||
// 모델 버전 정보
|
||||
EisModelDetails[] modelDetails = this.GetModelDetails(equipment);
|
||||
this.gridModelDetail.AutoBinding(modelDetails);
|
||||
this.gridModelDetail.SetRowForeColor("LockState", $"LockState = 'BLOCKED'", Color.LightGray);
|
||||
foreach (GridViewRowInfo row in this.gridModelDetail.Rows)
|
||||
{
|
||||
EisModelDetails item = row.DataBoundItem as EisModelDetails;
|
||||
if (item == null) continue;
|
||||
if (item.Version == equipment.Version)
|
||||
{
|
||||
row.IsSelected = true;
|
||||
row.IsCurrent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 모델 정보
|
||||
EisModelInfo[] modelInfo = this.GetModelInfo(equipment);
|
||||
if (modelInfo?.Length > 0)
|
||||
{
|
||||
this.tboxModelDescription.Text = modelInfo[0].Description;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region [ LogFiles ]
|
||||
if (logServer.NetworkAccount.ContainsKey(equipment.LogServerIP)) //jhlim 20250202 jj
|
||||
{
|
||||
// Checking Local IP-Address
|
||||
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
foreach (UnicastIPAddressInformation ip in nic.GetIPProperties().UnicastAddresses)
|
||||
{
|
||||
if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
||||
{
|
||||
if (ip.Address.ToString() == equipment.LogServerIP)
|
||||
{
|
||||
path = $@"{equipment.LogPath}\{equipment.EquipmentID}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SMB (Server Message Block)
|
||||
//if (string.IsNullOrEmpty(path) && this.chkUseSMB.Checked)
|
||||
//{
|
||||
// Account account = logServer.NetworkAccount[equipment.LogServerIP];
|
||||
// int result = ExtensionAPI.ConnectRemoteServer(account.IPAddress, account.UserID, account.Password);
|
||||
// if (result != 0 && result != 1219) { MessageBox.Show($@"네트워크 접근에 실패하였습니다. (Code:{result})"); return; }
|
||||
// path = logServer.GetLogPath(equipment.LogServerIP, equipment.EquipmentID);
|
||||
//}
|
||||
|
||||
if (string.IsNullOrEmpty(path) && this.chkUseSMB.Checked) //jhlim 20250202
|
||||
{
|
||||
Account account = logServer.NetworkAccount[equipment.LogServerIP];
|
||||
object rtnObj = null;
|
||||
|
||||
// StpClientWrap 사용
|
||||
//StpClientWrap.Initialize(equipment?.LogServerIP, "test", "daeduck!1");
|
||||
//StpClientWrap.Connect();
|
||||
var svrInfo = (DDUtilityApp.DATA.Account)GetNetworkAccount(equipment?.LogServerIP);
|
||||
FtpsClient.Initialize(equipment?.LogServerIP, svrInfo.UserID, svrInfo.Password);
|
||||
FtpsClient.Connect();
|
||||
|
||||
var remotePath = $"/{svrInfo.DefaultPath}/{equipment.EquipmentID}";
|
||||
//var remotePath = $"{equipment.EquipmentID}";
|
||||
// SFTP 파일 목록 가져오기
|
||||
//rtnObj = StpClientWrap.GetSftpList(remotePath);
|
||||
rtnObj = FtpsClient.GetFtpsList(remotePath);
|
||||
|
||||
if (rtnObj == null) return;
|
||||
//StpClientWrap.IsDirectory( "/302304/THiRA_SECSGEM/HSMS")
|
||||
//var hsmsEnabled = (StpClientWrap.IsDirExists( $"{remotePath}/THiRA_SECSGEM/HSMS"));
|
||||
var hsmsEnabled = (FtpsClient.IsDirExists($"{remotePath}/THiRA_SECSGEM/HSMS"));
|
||||
|
||||
if (hsmsEnabled == false)
|
||||
{
|
||||
if (tabControl1.TabPages.Contains(tabHSMS))
|
||||
{
|
||||
tabControl1.TabPages.Remove(tabHSMS);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!tabControl1.TabPages.Contains(tabHSMS))
|
||||
{
|
||||
tabControl1.TabPages.Add(tabHSMS);
|
||||
}
|
||||
}
|
||||
|
||||
this.gridLogFiles.AutoBinding(GetFtpslogFiles(rtnObj));
|
||||
|
||||
// 연결 종료 //jhlim 20250202
|
||||
//StpClientWrap.Disconnect();
|
||||
FtpsClient.Disconnect();
|
||||
}
|
||||
else if (string.IsNullOrEmpty(path) == false)
|
||||
{
|
||||
// 로그 파일 목록
|
||||
DirectoryInfo directory = new DirectoryInfo(path);
|
||||
if (directory.Exists == false)
|
||||
{
|
||||
MessageBox.Show($@"폴더가 존재하지 않습니다" + Environment.NewLine + Environment.NewLine + $@"Path: {path}");
|
||||
return;
|
||||
}
|
||||
LogFile[] logFiles = directory.GetFiles().ToClass<LogFile>().OrderByDescending(x => x.Name).ToArray();
|
||||
this.gridLogFiles.AutoBinding(logFiles);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = $@"{equipment.LogPath}\{equipment.EquipmentID}";
|
||||
}
|
||||
this.rstatus1.Text = path;
|
||||
if (string.IsNullOrEmpty(path)) return;
|
||||
#endregion
|
||||
|
||||
//// 로그 파일 목록
|
||||
//DirectoryInfo directory = new DirectoryInfo(path);
|
||||
//if (directory.Exists == false)
|
||||
//{
|
||||
// MessageBox.Show($@"폴더가 존재하지 않습니다" + Environment.NewLine + Environment.NewLine + $@"Path: {path}");
|
||||
// return;
|
||||
//}
|
||||
//LogFile[] logFiles = directory.GetFiles().ToClass<LogFile>().OrderByDescending(x => x.Name).ToArray();
|
||||
//this.gridLogFiles.AutoBinding(logFiles);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
XLogger.Instance.Fatal(ex, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
}
|
||||
|
||||
private void GridEquipments_CellDoubleClick(object sender, GridViewCellEventArgs e)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user