20250202_1 jhlim

This commit is contained in:
t001310
2025-02-28 08:40:40 +09:00
parent 402df7997b
commit 5cf740318e
9 changed files with 681 additions and 84 deletions

View File

@@ -17,6 +17,12 @@ using JWH;
using JWH.CONTROL;
using JWH.DATA;
using Telerik.WinControls.UI;
//jhlim 20250202 start
using FluentFTP;
using JWH.NETWORK;
using Renci.SshNet;
using Renci.SshNet.Sftp;
//jhlim 20250202 end
namespace DDUtilityApp.LOGPARSER
{
@@ -40,7 +46,7 @@ namespace DDUtilityApp.LOGPARSER
public string EquipmentID { get; set; } = string.Empty;
public SECSDefine SECSDefine { get; set; } = null;
public SECSDefine SECSDefine { get; set; } = null;
#endregion
@@ -49,7 +55,6 @@ namespace DDUtilityApp.LOGPARSER
public FrmEqSelector()
{
InitializeComponent();
this.SetLayout();
this.SetEventHandler();
}
@@ -73,7 +78,9 @@ namespace DDUtilityApp.LOGPARSER
this.tboxModelDescription.Font = font;
this.GridEquipments_Setting();
this.GridLogFiles_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();
}
@@ -99,6 +106,13 @@ 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 void FrmEqSelector_Disposed(object sender, EventArgs e)
@@ -188,6 +202,37 @@ namespace DDUtilityApp.LOGPARSER
}
}
/// <summary>
/// jhlim 20250202
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex >= 2)
{
int selectIdx = tabControl1.SelectedIndex;
string subPath = tabControl1.SelectedTab.Text.Contains("Workflow") ? "Workflow" : "THiRA_SECSGEM/HSMS";
var equipment = this.Equipment;
//StpClientWrap.Connect();
FtpsClient.Connect();
// SFTP 파일 목록 가져오기
// var rtnObj = StpClientWrap.GetSftpList($"/{equipment.EquipmentID}/{subPath}");
var rtnObj = FtpsClient.GetFtpsList($"/EISLog/{equipment.EquipmentID}/{subPath}");
if (rtnObj == null) return;
GridViewEx grid = tabControl1.SelectedTab.Controls.OfType<GridViewEx>().FirstOrDefault();
if (grid != null)
{
//grid.AutoBinding(GetSftplogFiles(rtnObj));
grid.AutoBinding(GetFtpslogFiles(rtnObj));
}
}
}
/// <summary>
/// [CheckPoint] 로그파일 목록을 반환한다
/// </summary>
@@ -362,16 +407,11 @@ namespace DDUtilityApp.LOGPARSER
if (modelInfo?.Length > 0)
{
this.tboxModelDescription.Text = modelInfo[0].Description;
//Console.WriteLine(modelInfo[0].Description);
//foreach(string splitValue in modelInfo[0].Description.Split(new char[] { (char)0x0D }, StringSplitOptions.RemoveEmptyEntries))
//{
// splitValue.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
//}
}
#endregion
#region [ LogFiles ]
if (logServer.NetworkAccount.ContainsKey(equipment.LogServerIP))
if (logServer.NetworkAccount.ContainsKey(equipment.LogServerIP)) //jhlim 20250202 jj
{
// Checking Local IP-Address
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
@@ -390,12 +430,69 @@ namespace DDUtilityApp.LOGPARSER
}
// SMB (Server Message Block)
if (string.IsNullOrEmpty(path) && this.chkUseSMB.Checked)
//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];
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);
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(tabPage4))
{
tabControl1.TabPages.Remove(tabPage4);
}
}
else
{
if (!tabControl1.TabPages.Contains(tabPage4))
{
tabControl1.TabPages.Add(tabPage4);
}
}
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
@@ -406,15 +503,15 @@ namespace DDUtilityApp.LOGPARSER
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);
//// 로그 파일 목록
//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)
{
@@ -505,9 +602,9 @@ namespace DDUtilityApp.LOGPARSER
#region [ GridLogFiles ] ----------------------------------------------
private void GridLogFiles_Setting()
private void GridLogFiles_Setting(GridViewEx grid)
{
GridViewEx grid = this.gridLogFiles;
//GridViewEx grid = this.gridLogFiles; jhlim 20250202
grid.TableElement.RowHeight = 20;
grid.MultiSelect = true;
@@ -571,7 +668,38 @@ namespace DDUtilityApp.LOGPARSER
XLogger.Instance.Fatal(ex);
}
}
private void Grid_KeyDown(object sender, KeyEventArgs e) //jhlim 20250202
{
if (e.KeyCode == Keys.Enter)
{
Grid_CellDoubleClick((GridViewEx)sender, null);
}
}
private void Grid_CellDoubleClick(object sender, GridViewCellEventArgs e) //jhlim 20250202
{
RadGridView gd = sender.GetType().Name.Contains("GridDataCellElement") ?
((GridDataCellElement)sender)?.RowElement?.GridControl : (GridViewEx)sender;
try
{
foreach (GridViewRowInfo row in gd.SelectedRows)
{
LogFile item = row.DataBoundItem as LogFile;
var fullPath = item.FullName;
string destPath = GlobalVariable.Instance.DownloadPath;
if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath);
string destFileName = $@"{destPath}{System.IO.Path.GetFileName(fullPath)}";
FtpsClient.DownloadFtpsFile(fullPath, destFileName);
}
MessageBox.Show($"{gd.SelectedRows.Count}개의 파일을 저장하였습니다.");
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex, true);
}
}
#endregion
#region [ GridModelDetail ] -------------------------------------------
@@ -642,6 +770,53 @@ namespace DDUtilityApp.LOGPARSER
}
}
/// <summary>
/// Sftp Log Files jhlim 20250202
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
private LogFile[] GetlogFiles(object obj)
{
LogFile[] logFiles = ((List<ISftpFile>)obj).Where(item => !item.IsDirectory && item.Name != "." && item.Name != "..") //
.Select(item => new LogFile
{
Name = Path.GetFileNameWithoutExtension(item.Name),
FullName = item.FullName,
Extension = Path.GetExtension(item.Name),
Length = item.Length,
CreationTime = item.LastAccessTime,
LastAccessTime = item.LastAccessTime,
LastWriteTime = item.LastWriteTime
})
.OrderByDescending(x => x.Name)
.ToArray();
return logFiles;
}
/// <summary>
/// Ftps Log Files jhlim 20250202
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
private LogFile[] GetFtpslogFiles(object obj)
{
LogFile[] logFiles = ((FtpListItem[])obj).Where(item => item.Type == FtpFileSystemObjectType.File)
.Select(item => new LogFile
{
Name = Path.GetFileNameWithoutExtension(item.Name),
FullName = item.FullName,
Extension = Path.GetExtension(item.Name),
Length = item.Size,
CreationTime = item.Modified,
LastAccessTime = item.Modified,
LastWriteTime = item.Modified
})
.OrderByDescending(x => x.Name)
.ToArray();
return logFiles;
}
#endregion
#region [ Method ] ----------------------------------------------------
@@ -715,37 +890,38 @@ namespace DDUtilityApp.LOGPARSER
logServer.DBGetModelDetails = sbModelDetails.ToString();
logServer.DBGetModelInfo = sbModelInfo.ToString();
logServer.NetworkAccount.Add("192.168.7.214", new Account("192.168.7.214", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.7.215", new Account("192.168.7.215", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.7.216", new Account("192.168.7.216", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.7.217", new Account("192.168.7.217", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.7.218", new Account("192.168.7.218", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.7.219", new Account("192.168.7.219", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.235.214", new Account("192.168.7.214", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.235.215", new Account("192.168.7.215", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.235.216", new Account("192.168.7.216", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.235.217", new Account("192.168.7.217", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.235.218", new Account("192.168.7.218", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.235.219", new Account("192.168.7.219", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.115.214", new Account("192.168.7.214", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.115.215", new Account("192.168.7.215", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.115.216", new Account("192.168.7.216", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.115.217", new Account("192.168.7.217", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.115.218", new Account("192.168.7.218", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.115.219", new Account("192.168.7.219", "DDECAdmin", "kL5QLMRxMXzrV#", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.7.150", new Account("192.168.7.150", "T001084@DAEDUCK.COM", "daeduck!1", @"Vol2\EIS서버\"));
logServer.NetworkAccount.Add("192.168.7.214", new Account("192.168.7.214", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.7.215", new Account("192.168.7.215", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.7.216", new Account("192.168.7.216", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.7.217", new Account("192.168.7.217", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.7.218", new Account("192.168.7.218", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.7.219", new Account("192.168.7.219", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.235.214", new Account("192.168.7.214", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.235.215", new Account("192.168.7.215", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.235.216", new Account("192.168.7.216", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.235.217", new Account("192.168.7.217", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.235.218", new Account("192.168.7.218", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.235.219", new Account("192.168.7.219", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.115.214", new Account("192.168.7.214", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.115.215", new Account("192.168.7.215", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.115.216", new Account("192.168.7.216", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.115.217", new Account("192.168.7.217", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.115.218", new Account("192.168.7.218", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.115.219", new Account("192.168.7.219", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.7.150", new Account("192.168.7.150", "test", "daeduck!1", @"EIS서버"));
logServer.NetworkAccount.Add("192.168.113.231", new Account("192.168.113.231", "serviceadmin", "daeduck!1", @"d\EISLog\"));
logServer.NetworkAccount.Add("192.168.113.232", new Account("192.168.113.232", "serviceadmin", "daeduck!1", @"d\EISLog\"));
logServer.NetworkAccount.Add("192.168.113.233", new Account("192.168.113.233", "serviceadmin", "daeduck!1", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.113.236", new Account("192.168.113.236", "serviceadmin", "daeduck!1", @"d\EISLog\"));
logServer.NetworkAccount.Add("192.168.143.231", new Account("192.168.143.231", "serviceadmin", "daeduck!1", @"d\EISLog\"));
logServer.NetworkAccount.Add("192.168.143.232", new Account("192.168.143.232", "serviceadmin", "daeduck!1", @"d\EISLog\"));
logServer.NetworkAccount.Add("192.168.143.233", new Account("192.168.143.233", "serviceadmin", "daeduck!1", @"d\EISLog\"));
logServer.NetworkAccount.Add("192.168.143.235", new Account("192.168.143.235", "serviceadmin", "daeduck!1", @"d\EISLog\"));
logServer.NetworkAccount.Add("192.168.233.231", new Account("192.168.233.231", "serviceadmin", "daeduck!1", @"d\EISLog\"));
logServer.NetworkAccount.Add("192.168.233.232", new Account("192.168.233.232", "serviceadmin", "daeduck!1", @"e\EISLog\"));
logServer.NetworkAccount.Add("192.168.233.233", new Account("192.168.233.233", "serviceadmin", "daeduck!1", @"d\EISLog\"));
logServer.NetworkAccount.Add("192.168.113.231", new Account("192.168.113.231", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.113.232", new Account("192.168.113.232", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.113.233", new Account("192.168.113.233", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.113.236", new Account("192.168.113.236", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.143.231", new Account("192.168.143.231", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.143.232", new Account("192.168.143.232", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.143.233", new Account("192.168.143.233", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.143.235", new Account("192.168.143.235", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.233.231", new Account("192.168.233.231", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.233.232", new Account("192.168.233.232", "test", "daeduck!1", @"EISLog"));
logServer.NetworkAccount.Add("192.168.233.233", new Account("192.168.233.233", "test", "daeduck!1", @"EISLog"));
logServer.FTPAddress = "192.168.7.208";
logServer.FTPPort = 7000;
@@ -762,9 +938,9 @@ namespace DDUtilityApp.LOGPARSER
logServer.DBGetEquipments = sbEquipments.ToString();
logServer.DBGetModelDetails = sbModelDetails.ToString();
logServer.DBGetModelInfo = sbModelInfo.ToString();
logServer.NetworkAccount.Add("192.168.8.215", new Account("192.168.8.215", "DDB2EISLOG", "SJwmseYUExFAP%^", @"eisap01_eislog\log\"));
logServer.NetworkAccount.Add("192.168.8.216", new Account("192.168.8.216", "DDB2EISLOG", "SJwmseYUExFAP%^", @"eisap02_eislog\"));
logServer.NetworkAccount.Add("192.168.8.217", new Account("192.168.8.217", "DDB2EISLOG", "SJwmseYUExFAP%^", @"eisap03_eislog\"));
logServer.NetworkAccount.Add("192.168.8.215", new Account("192.168.8.215", "test", "daeduck!1", @"eisap01_eislog\log"));
logServer.NetworkAccount.Add("192.168.8.216", new Account("192.168.8.216", "test", "daeduck!1", "eisap02_eislog"));
logServer.NetworkAccount.Add("192.168.8.217", new Account("192.168.8.217", "test", "daeduck!1", "eisap03_eislog"));
logServer.FTPAddress = "192.168.8.217";
logServer.FTPPort = 21;
logServer.FTPUserID = "anonymous";
@@ -947,6 +1123,11 @@ namespace DDUtilityApp.LOGPARSER
}
}
private object GetNetworkAccount(string logserverIP) //jhim 20250202
{
return ((LogServer) this.cboxServer.SelectedItem)?.NetworkAccount[logserverIP];
}
private void GetGEMSetting()
{
try
@@ -1058,6 +1239,8 @@ namespace DDUtilityApp.LOGPARSER
}
}
#endregion
}