diff --git a/DDUtilityApp/DDUtilityApp.csproj b/DDUtilityApp/DDUtilityApp.csproj
index 820e8dd..0e8e6c6 100644
--- a/DDUtilityApp/DDUtilityApp.csproj
+++ b/DDUtilityApp/DDUtilityApp.csproj
@@ -145,12 +145,17 @@
..\packages\AWSSDK.SecurityToken.3.7.100.14\lib\net45\AWSSDK.SecurityToken.dll
+
+ False
+ ..\..\SftpTest\WindowsFormsApp1\bin\Debug\BouncyCastle.Cryptography.dll
+
..\packages\DnsClient.1.6.1\lib\net471\DnsClient.dll
..\Library\EIS.Framework.dll
+
False
..\Library\JWH.SECS.dll
@@ -179,6 +184,10 @@
..\packages\MongoDB.Libmongocrypt.1.8.2\lib\netstandard2.0\MongoDB.Libmongocrypt.dll
+
+ False
+ ..\..\SftpTest\packages\SSH.NET.2024.2.0\lib\net462\Renci.SshNet.dll
+
..\packages\SharpCompress.0.30.1\lib\net461\SharpCompress.dll
diff --git a/DDUtilityApp/LOGPARSER/FrmEqSelector.Designer.cs b/DDUtilityApp/LOGPARSER/FrmEqSelector.Designer.cs
index 343482f..4f3c2f2 100644
--- a/DDUtilityApp/LOGPARSER/FrmEqSelector.Designer.cs
+++ b/DDUtilityApp/LOGPARSER/FrmEqSelector.Designer.cs
@@ -31,6 +31,8 @@
Telerik.WinControls.UI.TableViewDefinition tableViewDefinition1 = new Telerik.WinControls.UI.TableViewDefinition();
Telerik.WinControls.UI.TableViewDefinition tableViewDefinition2 = new Telerik.WinControls.UI.TableViewDefinition();
Telerik.WinControls.UI.TableViewDefinition tableViewDefinition3 = new Telerik.WinControls.UI.TableViewDefinition();
+ Telerik.WinControls.UI.TableViewDefinition tableViewDefinition4 = new Telerik.WinControls.UI.TableViewDefinition();
+ Telerik.WinControls.UI.TableViewDefinition tableViewDefinition5 = new Telerik.WinControls.UI.TableViewDefinition();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmEqSelector));
this.panel1 = new System.Windows.Forms.Panel();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
@@ -44,6 +46,7 @@
this.label4 = new System.Windows.Forms.Label();
this.chkAllEquipment = new System.Windows.Forms.CheckBox();
this.chkUseMesDB = new System.Windows.Forms.CheckBox();
+ this.chkUseSMB = new System.Windows.Forms.CheckBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.panel4 = new System.Windows.Forms.Panel();
this.cboxServer = new System.Windows.Forms.ComboBox();
@@ -62,9 +65,12 @@
this.gridModelDetail = new JWH.CONTROL.GridViewEx();
this.panel10 = new System.Windows.Forms.Panel();
this.tboxModelDescription = new System.Windows.Forms.TextBox();
+ this.tabPage3 = new System.Windows.Forms.TabPage();
+ this.gridWorkflow = new JWH.CONTROL.GridViewEx();
+ this.tabPage4 = new System.Windows.Forms.TabPage();
+ this.gridHsms = new JWH.CONTROL.GridViewEx();
this.radStatusStrip1 = new Telerik.WinControls.UI.RadStatusStrip();
this.rstatus1 = new Telerik.WinControls.UI.RadLabelElement();
- this.chkUseSMB = new System.Windows.Forms.CheckBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@@ -94,6 +100,12 @@
((System.ComponentModel.ISupportInitialize)(this.gridModelDetail)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gridModelDetail.MasterTemplate)).BeginInit();
this.panel10.SuspendLayout();
+ this.tabPage3.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.gridWorkflow)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.gridWorkflow.MasterTemplate)).BeginInit();
+ this.tabPage4.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.gridHsms)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.gridHsms.MasterTemplate)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.radStatusStrip1)).BeginInit();
this.SuspendLayout();
//
@@ -235,6 +247,16 @@
this.chkUseMesDB.Text = "MES DB";
this.chkUseMesDB.UseVisualStyleBackColor = true;
//
+ // chkUseSMB
+ //
+ this.chkUseSMB.AutoSize = true;
+ this.chkUseSMB.Location = new System.Drawing.Point(879, 6);
+ this.chkUseSMB.Name = "chkUseSMB";
+ this.chkUseSMB.Size = new System.Drawing.Size(77, 16);
+ this.chkUseSMB.TabIndex = 5;
+ this.chkUseSMB.Text = "Use SMB";
+ this.chkUseSMB.UseVisualStyleBackColor = true;
+ //
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
@@ -376,6 +398,8 @@
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
+ this.tabControl1.Controls.Add(this.tabPage3);
+ this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
@@ -383,6 +407,7 @@
this.tabControl1.Size = new System.Drawing.Size(547, 489);
this.tabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
this.tabControl1.TabIndex = 6;
+ this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
//
// tabPage1
//
@@ -465,6 +490,66 @@
this.tboxModelDescription.Size = new System.Drawing.Size(533, 96);
this.tboxModelDescription.TabIndex = 0;
//
+ // tabPage3
+ //
+ this.tabPage3.Controls.Add(this.gridWorkflow);
+ this.tabPage3.Location = new System.Drawing.Point(4, 22);
+ this.tabPage3.Name = "tabPage3";
+ this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage3.Size = new System.Drawing.Size(539, 463);
+ this.tabPage3.TabIndex = 3;
+ this.tabPage3.Text = "Workflow";
+ this.tabPage3.UseVisualStyleBackColor = true;
+ //
+ // gridWorkflow
+ //
+ this.gridWorkflow.BackColor = System.Drawing.SystemColors.ControlLightLight;
+ this.gridWorkflow.ColumnResizeKey = System.Windows.Forms.Keys.F6;
+ this.gridWorkflow.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.gridWorkflow.Location = new System.Drawing.Point(3, 3);
+ this.gridWorkflow.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ //
+ //
+ //
+ this.gridWorkflow.MasterTemplate.ViewDefinition = tableViewDefinition4;
+ this.gridWorkflow.Name = "gridWorkflow";
+ //
+ //
+ //
+ this.gridWorkflow.RootElement.ControlBounds = new System.Drawing.Rectangle(3, 3, 240, 150);
+ this.gridWorkflow.Size = new System.Drawing.Size(533, 457);
+ this.gridWorkflow.TabIndex = 4;
+ //
+ // tabPage4
+ //
+ this.tabPage4.Controls.Add(this.gridHsms);
+ this.tabPage4.Location = new System.Drawing.Point(4, 22);
+ this.tabPage4.Name = "tabPage4";
+ this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage4.Size = new System.Drawing.Size(539, 463);
+ this.tabPage4.TabIndex = 2;
+ this.tabPage4.Text = "HSMS";
+ this.tabPage4.UseVisualStyleBackColor = true;
+ //
+ // gridHsms
+ //
+ this.gridHsms.BackColor = System.Drawing.SystemColors.ControlLightLight;
+ this.gridHsms.ColumnResizeKey = System.Windows.Forms.Keys.F6;
+ this.gridHsms.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.gridHsms.Location = new System.Drawing.Point(3, 3);
+ this.gridHsms.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ //
+ //
+ //
+ this.gridHsms.MasterTemplate.ViewDefinition = tableViewDefinition5;
+ this.gridHsms.Name = "gridHsms";
+ //
+ //
+ //
+ this.gridHsms.RootElement.ControlBounds = new System.Drawing.Rectangle(3, 3, 240, 150);
+ this.gridHsms.Size = new System.Drawing.Size(533, 457);
+ this.gridHsms.TabIndex = 4;
+ //
// radStatusStrip1
//
this.radStatusStrip1.Items.AddRange(new Telerik.WinControls.RadItem[] {
@@ -481,16 +566,6 @@
this.rstatus1.Text = "";
this.rstatus1.TextWrap = true;
//
- // chkSMB
- //
- this.chkUseSMB.AutoSize = true;
- this.chkUseSMB.Location = new System.Drawing.Point(879, 6);
- this.chkUseSMB.Name = "chkSMB";
- this.chkUseSMB.Size = new System.Drawing.Size(77, 16);
- this.chkUseSMB.TabIndex = 5;
- this.chkUseSMB.Text = "Use SMB";
- this.chkUseSMB.UseVisualStyleBackColor = true;
- //
// FrmEqSelector
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -537,6 +612,12 @@
((System.ComponentModel.ISupportInitialize)(this.gridModelDetail)).EndInit();
this.panel10.ResumeLayout(false);
this.panel10.PerformLayout();
+ this.tabPage3.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.gridWorkflow.MasterTemplate)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.gridWorkflow)).EndInit();
+ this.tabPage4.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.gridHsms.MasterTemplate)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.gridHsms)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.radStatusStrip1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -578,5 +659,9 @@
private Telerik.WinControls.UI.RadStatusStrip radStatusStrip1;
private Telerik.WinControls.UI.RadLabelElement rstatus1;
private System.Windows.Forms.CheckBox chkUseSMB;
+ private System.Windows.Forms.TabPage tabPage4;
+ private System.Windows.Forms.TabPage tabPage3;
+ private JWH.CONTROL.GridViewEx gridHsms;
+ private JWH.CONTROL.GridViewEx gridWorkflow;
}
}
\ No newline at end of file
diff --git a/DDUtilityApp/LOGPARSER/FrmEqSelector.cs b/DDUtilityApp/LOGPARSER/FrmEqSelector.cs
index 62df6bd..2d6f9ff 100644
--- a/DDUtilityApp/LOGPARSER/FrmEqSelector.cs
+++ b/DDUtilityApp/LOGPARSER/FrmEqSelector.cs
@@ -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
}
}
+ ///
+ /// jhlim 20250202
+ ///
+ ///
+ ///
+ 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().FirstOrDefault();
+ if (grid != null)
+ {
+ //grid.AutoBinding(GetSftplogFiles(rtnObj));
+ grid.AutoBinding(GetFtpslogFiles(rtnObj));
+ }
+ }
+ }
+
///
/// [CheckPoint] 로그파일 목록을 반환한다
///
@@ -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().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().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().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
}
}
+ ///
+ /// Sftp Log Files jhlim 20250202
+ ///
+ ///
+ ///
+ private LogFile[] GetlogFiles(object obj)
+ {
+ LogFile[] logFiles = ((List)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;
+ }
+
+ ///
+ /// Ftps Log Files jhlim 20250202
+ ///
+ ///
+ ///
+ 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
}
diff --git a/DDUtilityApp/LOGPARSER/FrmLogParser.cs b/DDUtilityApp/LOGPARSER/FrmLogParser.cs
index c135ffd..a9bac40 100644
--- a/DDUtilityApp/LOGPARSER/FrmLogParser.cs
+++ b/DDUtilityApp/LOGPARSER/FrmLogParser.cs
@@ -14,6 +14,7 @@ using DDUtilityApp.MONGO;
using DDUtilityApp.SECS;
using JWH;
using JWH.CONTROL;
+using JWH.NETWORK;
using Telerik.WinControls.UI;
using ContentAlignment = System.Drawing.ContentAlignment;
@@ -1289,29 +1290,59 @@ namespace DDUtilityApp.LOGPARSER
string strTitle = string.Empty;
// Process Unit: File
- foreach (ListViewItem lviewItem in this.lviewFiles.Items)
+ foreach (ListViewItem lviewItem in this.lviewFiles.Items) //jhlim 20250202
{
if (lviewItem.Checked == false) continue;
XLogger.Instance.Info(lviewItem.Text);
-
+
string fullPath = lviewItem.Tag as string;
- FileInfo fileInfo = new FileInfo(fullPath);
- if (fileInfo.Exists == false) continue;
- if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add($"{((float)fileInfo.Length / 1024 / 1024).ToString("F2")} MB");
- else lviewItem.SubItems[1].Text = $"{((float)fileInfo.Length / 1024 / 1024).ToString("F2")} MB";
-
- if (this.chkDownload.Checked)
+ //var sftpFileInfo = SftpClientWrapper.GetFileInfo(fullPath);
+ var ftpsFileInfo = FtpsClient.GetFileInfo(fullPath);
+ //if (sftpFileInfo != null)
+ if (ftpsFileInfo != null)
{
- string destPath = GlobalVariable.Instance.DownloadPath;
- if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath);
- if (string.IsNullOrEmpty(strTitle)) strTitle = System.IO.Path.GetFileNameWithoutExtension(fullPath);
- string destFileName = $@"{destPath}{System.IO.Path.GetFileName(fullPath)}";
- System.IO.File.Copy(fullPath, destFileName, true);
- fullPath = destFileName;
+ //if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add($"{((float)sftpFileInfo.Size / 1024 / 1024).ToString("F2")} MB");
+ //else lviewItem.SubItems[1].Text = $"{((float)sftpFileInfo.Size / 1024 / 1024).ToString("F2")} MB";
+ if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add($"{((float)ftpsFileInfo.Size / 1024 / 1024).ToString("F2")} MB");
+ else lviewItem.SubItems[1].Text = $"{((float)ftpsFileInfo.Size / 1024 / 1024).ToString("F2")} MB";
+
+ if (this.chkDownload.Checked)
+ {
+ string destPath = GlobalVariable.Instance.DownloadPath;
+ if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath);
+
+ if (string.IsNullOrEmpty(strTitle)) strTitle = System.IO.Path.GetFileNameWithoutExtension(fullPath);
+ string destFileName = $@"{destPath}{System.IO.Path.GetFileName(fullPath)}";
+ //SftpClientWrapper.DownloadSftpFile(fullPath, destFileName);
+ FtpsClient.DownloadFtpsFile(fullPath, destFileName);
+ fullPath = destFileName;
+ }
}
+ else
+ {
+ FileInfo fileInfo = new FileInfo(fullPath); //
+ if (fileInfo.Exists == false) continue;
+ if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add($"{((float)fileInfo.Length / 1024 / 1024).ToString("F2")} MB");
+ else lviewItem.SubItems[1].Text = $"{((float)fileInfo.Length / 1024 / 1024).ToString("F2")} MB";
+
+ if (this.chkDownload.Checked)
+ {
+ string destPath = GlobalVariable.Instance.DownloadPath;
+ if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath);
+
+ if (string.IsNullOrEmpty(strTitle)) strTitle = System.IO.Path.GetFileNameWithoutExtension(fullPath);
+ string destFileName = $@"{destPath}{System.IO.Path.GetFileName(fullPath)}";
+
+ if (fullPath != destFileName)
+ {
+ System.IO.File.Copy(fullPath, destFileName, true);
+ }
+ fullPath = destFileName;
+ }
+ }
lstFileName.Add(fullPath);
} // Process Unit: File
diff --git a/DDUtilityApp/LOGPARSER/LogServer.cs b/DDUtilityApp/LOGPARSER/LogServer.cs
index 1e0909d..9840a6b 100644
--- a/DDUtilityApp/LOGPARSER/LogServer.cs
+++ b/DDUtilityApp/LOGPARSER/LogServer.cs
@@ -252,6 +252,10 @@ namespace DDUtilityApp.DATA
public class Account
{
+ public enum AccessType { SMB, FTP ,FTPS, SFTP };
+
+ public AccessType Access { get; set; } = Account.AccessType.FTPS;
+
public string IPAddress { get; set; }
public string UserID { get; set; }
@@ -264,12 +268,13 @@ namespace DDUtilityApp.DATA
{
}
- public Account(string ipAddress, string uid, string pwd, string defaultPath = "")
+ public Account(string ipAddress, string uid, string pwd, string defaultPath = "", AccessType access = AccessType.FTPS)
{
this.IPAddress = ipAddress;
this.UserID = uid;
this.Password = pwd;
this.DefaultPath = defaultPath;
+ this.Access = access;
}
}
diff --git a/DDUtilityApp/Program.cs b/DDUtilityApp/Program.cs
index 3f4d834..b5d46b0 100644
--- a/DDUtilityApp/Program.cs
+++ b/DDUtilityApp/Program.cs
@@ -70,13 +70,15 @@ namespace DDUtilityApp
#region [ 버튼 생성 정보 ]
frmMain.Buttons.Add("EIS Log Viewer", new EisParser0());
- frmMain.Buttons.Add("MIS Log Viewer", new AgvParser());
+ //frmMain.Buttons.Add("MES Log Download", typeof(SPECDOCUMENT.FrmSpecDocument)); // 위치
+ //frmMain.Buttons.Add("MIS Log Viewer", new AgvParser()); // 제거
frmMain.Buttons.Add("FDC Mongo Viewer", typeof(MONGO.FrmFDCMongo));
frmMain.Buttons.Add("TIB Simulator", typeof(TIBRENDEZVOUS.FrmSimulator01));
frmMain.Buttons.Add("HSMS Converter", typeof(LOGPARSER.FrmHsmsViewer));
frmMain.Buttons.Add("TibcoConfig.Xml", typeof(ETC.FrmTIbcoConfig));
#if DEBUG
frmMain.Buttons.Add("FTP Test", typeof(SPECDOCUMENT.FrmSpecDocument));
+ frmMain.Buttons.Add("MES Log Download", typeof(SPECDOCUMENT.FrmSpecDocument));
#endif
#endregion
diff --git a/JWH/JWH.csproj b/JWH/JWH.csproj
index 9521fa6..bdfa43a 100644
--- a/JWH/JWH.csproj
+++ b/JWH/JWH.csproj
@@ -86,12 +86,25 @@
prompt
+
+ ..\..\SftpTest\WindowsFormsApp1\bin\Debug\BouncyCastle.Cryptography.dll
+
+
+ ..\DDUtilityApp\bin\Debug\FluentFTP.dll
+
..\Library\JWH.SECS.dll
..\packages\log4net.2.0.12\lib\net45\log4net.dll
+
+ False
+ ..\..\SftpTest\WindowsFormsApp1\bin\Debug\Microsoft.Bcl.AsyncInterfaces.dll
+
+
+ ..\..\SftpTest\packages\SSH.NET.2024.2.0\lib\net462\Renci.SshNet.dll
+
@@ -129,7 +142,9 @@
+
+
diff --git a/JWH/NETWORK/FtpsClient.cs b/JWH/NETWORK/FtpsClient.cs
new file mode 100644
index 0000000..6bd9377
--- /dev/null
+++ b/JWH/NETWORK/FtpsClient.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Net;
+using FluentFTP;
+
+namespace JWH.NETWORK
+{
+ public static class FtpsClient
+ {
+ private static FluentFTP.FtpClient _ftpClient;
+ private static string _host;
+ private static int _port = 990; // FTPS 기본 포트
+ private static string _userId;
+ private static string _password;
+
+ public static void Initialize(string host, string userId, string password, int port = 990)
+ {
+ _host = host;
+ _userId = userId;
+ _password = password;
+ _port = port;
+
+ _ftpClient = new FluentFTP.FtpClient(_host, _port, new NetworkCredential(_userId, _password))
+ {
+ //EncryptionMode = FtpEncryptionMode.Explicit,
+ EncryptionMode = FtpEncryptionMode.Implicit,
+ SslProtocols = System.Security.Authentication.SslProtocols.Tls12,
+ ConnectTimeout = 500 // 타임아웃 설정 (0.5초)
+ };
+ _ftpClient.ValidateCertificate += (control, args) => args.Accept = true; // 인증서 검증 비활성화 (운영 확인 필요!)
+ }
+
+ public static void Connect()
+ {
+ if (_ftpClient == null)
+ {
+ throw new InvalidOperationException("FTPS client is not initialized. Call Initialize() first.");
+ }
+
+ if (!_ftpClient.IsConnected)
+ {
+ _ftpClient.Connect();
+ }
+ }
+
+ public static void Disconnect()
+ {
+ if (_ftpClient != null && _ftpClient.IsConnected)
+ {
+ _ftpClient.Disconnect();
+ }
+ }
+
+ public static bool IsFileExists(string path)
+ {
+ Connect();
+ return _ftpClient.FileExists(path);
+ }
+
+ public static bool IsDirExists(string path)
+ {
+ Connect();
+ return _ftpClient.DirectoryExists(path);
+ }
+
+ public static FtpListItem[] GetFtpsList(string path)
+ {
+ Connect();
+ return _ftpClient.GetListing(path);
+ }
+
+ public static object GetObjectInfo(string filePath)
+ {
+ Connect();
+ return _ftpClient.GetObjectInfo(filePath);
+ }
+
+ public static FtpListItem GetFileInfo(string remoteFilePath)
+ {
+ try
+ {
+ FtpsClient.Connect();
+
+ if (!_ftpClient.IsConnected)
+ {
+ Console.WriteLine("FTPS 서버에 연결되지 않았습니다.");
+ return null;
+ }
+
+ // Passive Mode 설정 (필요한 경우)
+ // _ftpClient.SetPassiveMode(true);
+
+ if (!FtpsClient.IsFileExists(remoteFilePath))
+ {
+ Console.WriteLine("파일이 존재하지 않습니다.");
+ return null;
+ }
+
+ var fileInfo = FtpsClient.GetObjectInfo(remoteFilePath) ;
+ if (fileInfo == null)
+ {
+ Console.WriteLine("파일 정보를 가져오는 데 실패했습니다.");
+ }
+ return (FtpListItem)fileInfo;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"파일 정보 조회 오류: {ex.Message}");
+ return null;
+ }
+ finally
+ {
+ FtpsClient.Disconnect();
+ }
+ }
+
+ public static bool DownloadFtpsFile(string remotePath, string localPath)
+ {
+ try
+ {
+ Connect();
+ _ftpClient.DownloadFile(localPath, remotePath);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Download error: {ex.Message}");
+ return false;
+ }
+ }
+
+ public static bool UploadFtpsFile(string localPath, string remotePath)
+ {
+ try
+ {
+ Connect();
+ _ftpClient.UploadFile(localPath, remotePath);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Upload error: {ex.Message}");
+ return false;
+ }
+ }
+ }
+}
diff --git a/JWH/NETWORK/SFtpClient.cs b/JWH/NETWORK/SFtpClient.cs
new file mode 100644
index 0000000..3be480c
--- /dev/null
+++ b/JWH/NETWORK/SFtpClient.cs
@@ -0,0 +1,121 @@
+using Renci.SshNet;
+using System;
+using File = System.IO.File;
+
+namespace JWH.NETWORK
+{
+ public static class StpClientWrap
+ {
+ private static SftpClient _sftpClient;
+ private static string _host;
+ private static int _port = 22;
+ private static string _userId;
+ private static string _password;
+
+ public static void Initialize(string host, string userId, string password, int port = 22)
+ {
+ _host = host;
+ _userId = userId;
+ _password = password;
+ _port = port;
+ _sftpClient = new SftpClient(_host, _port, _userId, _password);
+ }
+
+ public static void Connect()
+ {
+ if (_sftpClient == null)
+ {
+ throw new InvalidOperationException("SFTP client is not initialized. Call Initialize() first.");
+ }
+
+ if (!_sftpClient.IsConnected)
+ {
+ _sftpClient.Connect();
+ }
+ }
+
+ public static void Disconnect()
+ {
+ if (_sftpClient != null && _sftpClient.IsConnected)
+ {
+ _sftpClient.Disconnect();
+ }
+ }
+
+ public static bool IsDirExists(string path)
+ {
+ return IsFileExists(path) && _sftpClient.GetAttributes(path).IsDirectory;
+ }
+
+
+ public static bool IsFileExists(string path)
+ {
+ Connect();
+ return _sftpClient.Exists(path);
+ }
+
+ public static Renci.SshNet.Sftp.SftpFileAttributes GetFileInfo(string remoteFilePath)
+ {
+ try
+ {
+ Connect();
+ if (_sftpClient.Exists(remoteFilePath))
+ {
+ return _sftpClient.GetAttributes(remoteFilePath);
+ }
+ else
+ {
+ Console.WriteLine("파일이 존재하지 않습니다.");
+ return null;
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"파일 정보 조회 오류: {ex.Message}");
+ return null;
+ }
+ }
+
+ public static object GetSftpList(string path)
+ {
+ Connect();
+ return _sftpClient.ListDirectory(path);
+ }
+
+ public static bool DownloadSftpFile(string remotePath, string localPath)
+ {
+ try
+ {
+ Connect();
+ using (var fileStream = File.OpenWrite(localPath))
+ {
+ _sftpClient.DownloadFile(remotePath, fileStream);
+ }
+ return true;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Download error: {ex.Message}");
+ return false;
+ }
+ }
+
+ public static bool UploadSftpFile(string localPath, string remotePath)
+ {
+ try
+ {
+ Connect();
+ using (var fileStream = File.OpenRead(localPath))
+ {
+ _sftpClient.UploadFile(fileStream, remotePath);
+ }
+ return true;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Upload error: {ex.Message}");
+ return false;
+ }
+ }
+ }
+}