HSMS, Workflow Download

This commit is contained in:
2025-03-05 17:08:54 +09:00
parent 933519164e
commit 0b7f4ba366
4 changed files with 191 additions and 112 deletions

View File

@@ -8,6 +8,7 @@ using JWH.CONTROL;
using JWH.DATA;
using JWH.NETWORK;
using Org.BouncyCastle.Tls.Crypto;
using Renci.SshNet;
using Renci.SshNet.Sftp;
using System;
using System.Collections.Generic;
@@ -214,27 +215,71 @@ namespace DDUtilityApp.LOGPARSER
/// <param name="e"></param>
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex >= 2)
try
{
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)
if (this.tabControl1.SelectedTab == this.tabHSMS)
{
//grid.AutoBinding(GetSftplogFiles(rtnObj));
grid.AutoBinding(GetLogFiles(rtnObj));
if (this.gridHsms.DataSource == null) return;
string remotePath = $"/{this.Account.DefaultPath}/{this.Equipment.EquipmentID}/THiRA_SECSGEM/HSMS";
switch (this.Account.Access)
{
case AccessType.SMB:
break;
case AccessType.FTPS:
{
FtpsClient.Connect();
FtpListItem[] items = FtpsClient.GetFtpsList(remotePath);
this.gridHsms.AutoBinding(this.GetLogFiles(items));
FtpsClient.Disconnect();
}
break;
case AccessType.SFTP:
{
StpClientWrap.Connect();
ISftpFile[] items = (ISftpFile[])StpClientWrap.GetSftpList(remotePath);
this.gridHsms.AutoBinding(this.GetLogFiles(items));
StpClientWrap.Disconnect();
}
break;
case AccessType.FTP:
break;
}
}
else if (this.tabControl1.SelectedTab == this.tabWorkflow)
{
if (this.gridWorkflow.DataSource != null) return;
string remotePath = $"/{this.Account.DefaultPath}/{this.Equipment.EquipmentID}/Workflow";
switch (this.Account.Access)
{
case AccessType.SMB:
break;
case AccessType.FTPS:
{
FtpsClient.Connect();
FtpListItem[] items = FtpsClient.GetFtpsList(remotePath);
LogFile[] logFiles = this.GetLogFiles(items);
this.gridWorkflow.AutoBinding(logFiles);
FtpsClient.Disconnect();
}
break;
case AccessType.SFTP:
{
StpClientWrap.Connect();
ISftpFile[] items = (ISftpFile[])StpClientWrap.GetSftpList(remotePath);
this.gridWorkflow.AutoBinding(this.GetLogFiles(items));
StpClientWrap.Disconnect();
}
break;
case AccessType.FTP:
break;
}
}
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex, true);
}
}
@@ -383,6 +428,9 @@ namespace DDUtilityApp.LOGPARSER
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;
@@ -393,6 +441,7 @@ namespace DDUtilityApp.LOGPARSER
string path = string.Empty;
#region [ Model Details ]
// 모델 버전 정보
EisModelDetails[] modelDetails = this.GetModelDetails(equipment);
this.gridModelDetail.AutoBinding(modelDetails);
@@ -415,6 +464,7 @@ namespace DDUtilityApp.LOGPARSER
{
this.tboxModelDescription.Text = modelInfo[0].Description;
}
#endregion
#region [ LogFiles ]
@@ -464,10 +514,8 @@ namespace DDUtilityApp.LOGPARSER
if (ftpFiles != null) this.gridLogFiles.AutoBinding(this.GetLogFiles(ftpFiles));
this.rstatus1.Text = $"Path={this.Account.IPAddress}{path}";
if (FtpsClient.IsDirExists($"{path}/THiRA_SECSGEM/HSMS"))
{ if (!tabControl1.TabPages.Contains(tabPage4)) tabControl1.TabPages.Add(tabPage4); }
else
{ if (tabControl1.TabPages.Contains(tabPage4)) tabControl1.TabPages.Remove(tabPage4); }
//if (FtpsClient.IsDirExists($"{path}/THiRA_SECSGEM/HSMS") && !this.tabControl1.TabPages.Contains(tabHSMS))
// this.tabControl1.TabPages.Add(this.tabHSMS);
FtpsClient.Disconnect();
}
@@ -482,10 +530,8 @@ namespace DDUtilityApp.LOGPARSER
if (ftpFiles != null) this.gridLogFiles.AutoBinding(this.GetLogFiles(ftpFiles));
this.rstatus1.Text = $"Path={this.Account.IPAddress}{path}";
if (StpClientWrap.IsDirExists($"{path}/THiRA_SECSGEM/HSMS"))
{ if (!tabControl1.TabPages.Contains(tabPage4)) tabControl1.TabPages.Add(tabPage4); }
else
{ if (tabControl1.TabPages.Contains(tabPage4)) tabControl1.TabPages.Remove(tabPage4); }
//if (StpClientWrap.IsDirExists($"{path}/THiRA_SECSGEM/HSMS") && !this.tabControl1.TabPages.Contains(tabHSMS))
// this.tabControl1.TabPages.Add(this.tabHSMS);
StpClientWrap.Disconnect();
}
@@ -500,6 +546,12 @@ namespace DDUtilityApp.LOGPARSER
#endregion
#region [ Workflow & HSMS ]
this.tabControl1_SelectedIndexChanged(this.tabControl1, new EventArgs());
#endregion
}
catch (Exception ex)
{
@@ -618,16 +670,16 @@ namespace DDUtilityApp.LOGPARSER
if (hsmsEnabled == false)
{
if (tabControl1.TabPages.Contains(tabPage4))
if (tabControl1.TabPages.Contains(tabHSMS))
{
tabControl1.TabPages.Remove(tabPage4);
tabControl1.TabPages.Remove(tabHSMS);
}
}
else
{
if (!tabControl1.TabPages.Contains(tabPage4))
if (!tabControl1.TabPages.Contains(tabHSMS))
{
tabControl1.TabPages.Add(tabPage4);
tabControl1.TabPages.Add(tabHSMS);
}
}
@@ -768,7 +820,7 @@ namespace DDUtilityApp.LOGPARSER
grid.AddColumn("Length");
grid.AddColumn("LastWriteTime");
grid.AddContextMenu("");
//grid.AddContextMenu("");
//grid.AddContextMenu("Open Log", GridEquipments_OpenWindows);
}
@@ -813,28 +865,54 @@ namespace DDUtilityApp.LOGPARSER
/// <param name="e"></param>
private void Grid_CellDoubleClick(object sender, GridViewCellEventArgs e)
{
RadGridView gd = sender.GetType().Name.Contains("GridDataCellElement") ?
((GridDataCellElement)sender)?.RowElement?.GridControl : (GridViewEx)sender;
try
{
List<string> downfiles = new List<string>();
foreach (GridViewRowInfo row in gd.SelectedRows)
{
LogFile item = row.DataBoundItem as LogFile;
var fullPath = item.FullName;
string destPath = GlobalVariable.Instance.DownloadPath;
string destPath = Path.Combine(GlobalVariable.Instance.DownloadPath, this.Equipment.EquipmentID);
if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath);
string destFileName = $@"{destPath}{System.IO.Path.GetFileName(fullPath)}";
FtpsClient.DownloadFtpsFile(fullPath, destFileName);
downfiles.Add(destFileName);
RadGridView grid = sender as RadGridView;
if (grid == null && sender.GetType() == typeof(GridDataCellElement))
{
GridDataCellElement element = sender as GridDataCellElement;
grid = element.RowElement.GridControl;
}
if (grid == null) return;
if (grid == this.gridHsms) destPath = Path.Combine(destPath, "HSMS");
else if (grid == this.gridWorkflow) destPath = Path.Combine(destPath, "Workflow");
if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath);
List<string> downfiles = new List<string>();
foreach (GridViewRowInfo row in grid.SelectedRows)
{
LogFile logFile = row.DataBoundItem as LogFile;
string destFileName = Path.Combine(destPath, Path.GetFileName(logFile.FullName));
switch (this.Account.Access)
{
case AccessType.SMB:
{ }
break;
case AccessType.FTPS:
{
FtpsClient.DownloadFtpsFile(logFile.FullName, destFileName);
downfiles.Add(destFileName);
}
break;
case AccessType.SFTP:
{
StpClientWrap.DownloadSftpFile(logFile.FullName, destFileName);
downfiles.Add(destFileName);
}
break;
case AccessType.FTP:
{ }
break;
}
}
MessageBox.Show($"{gd.SelectedRows.Count}개의 파일을 저장하였습니다.");
//System.Diagnostics.Process.Start($"explorer.exe", $"/select,{argument}");
foreach(string command in downfiles)
System.Diagnostics.Process.Start(command);
MessageBox.Show($"{grid.SelectedRows.Count}개의 파일을 저장하였습니다.");
foreach (string file in downfiles)
System.Diagnostics.Process.Start(file);
}
catch (Exception ex)
{