From 9be4b773a5cbc00b414b995f939033f22e4622e9 Mon Sep 17 00:00:00 2001 From: T001084 Date: Fri, 7 Mar 2025 11:57:24 +0900 Subject: [PATCH] F1 Change --- DDUtilityApp/LOGPARSER/DATA/LogFile.cs | 57 +++++++++++-- DDUtilityApp/LOGPARSER/FrmEqSelector.cs | 20 ++--- DDUtilityApp/LOGPARSER/FrmLogParser.cs | 92 ++++++++++----------- DDUtilityApp/LOGPARSER/PARSER/EisParser0.cs | 8 +- DDUtilityApp/LOGPARSER/PARSER/LogParser.cs | 4 +- JWH/NETWORK/FtpsClient.cs | 3 +- 6 files changed, 107 insertions(+), 77 deletions(-) diff --git a/DDUtilityApp/LOGPARSER/DATA/LogFile.cs b/DDUtilityApp/LOGPARSER/DATA/LogFile.cs index edfdfa2..0c0f637 100644 --- a/DDUtilityApp/LOGPARSER/DATA/LogFile.cs +++ b/DDUtilityApp/LOGPARSER/DATA/LogFile.cs @@ -1,4 +1,6 @@ using System; +using System.IO; +using System.Windows.Forms.DataVisualization.Charting; using DDUtilityApp.DATA; using JWH.DATA; @@ -11,33 +13,74 @@ namespace DDUtilityApp.LOGPARSER.DATA public class LogFile : DataTableBase { + private string m_FullName = string.Empty; + public Account Account { get; set; } = null; - public string Name { get; set; } + public string FullName + { + get { return this.m_FullName; } + set + { + this.m_FullName = value; + this.DirectoryName = Path.GetDirectoryName(value); + this.FileName = Path.GetFileName(value); + this.Name = Path.GetFileNameWithoutExtension(value); + this.Extension = Path.GetExtension(value); + } + } + + public string DirectoryName { get; private set; } + + public string FileName { get; private set; } + + public string Name { get; private set; } + + public string Extension { get; private set; } public long Length { get; set; } - public string Extension { get; set; } - - public string FullName { get; set; } - public DateTime CreationTime { get; set; } public DateTime LastAccessTime { get; set; } public DateTime LastWriteTime { get; set; } + public string DestFullName { get; set; } + public LogFile() { } public LogFile(string fullName) { - this.Name = System.IO.Path.GetFileNameWithoutExtension(fullName); this.FullName = fullName; - this.Extension = System.IO.Path.GetExtension(fullName); + } + + public string GetFileSize(FileSizeType format = FileSizeType.Auto) + { + int index = 0; + int nFormat = (int)format; + double value = this.Length; + for (index = 0; index < nFormat; index++) + { + if (format == FileSizeType.Auto && value < 1024) break; + value /= 1024; + } + + return $"{value.ToString("N2")} {(FileSizeType)index}"; } } + public enum FileSizeType + { + Bt = 0, + KB = 1, + MB = 2, + GB = 3, + TB = 4, + Auto = 9, + } + } diff --git a/DDUtilityApp/LOGPARSER/FrmEqSelector.cs b/DDUtilityApp/LOGPARSER/FrmEqSelector.cs index cd7845f..678f2f7 100644 --- a/DDUtilityApp/LOGPARSER/FrmEqSelector.cs +++ b/DDUtilityApp/LOGPARSER/FrmEqSelector.cs @@ -53,8 +53,6 @@ namespace DDUtilityApp.LOGPARSER public string ServerName { get; set; } = string.Empty; - //public string EquipmentID { get; set; } = string.Empty; - public SECSDefine SECSDefine { get; set; } = null; #endregion @@ -80,7 +78,7 @@ namespace DDUtilityApp.LOGPARSER this.tboxName.ImeMode = ImeMode.Hangul; this.tboxEquipmentID.ImeMode = ImeMode.Alpha; this.chkAllEquipment.Checked = GlobalVariable.Instance.FrmEqSelector_AllEquipment; - this.chkUseSMB.Checked = true; // GlobalVariable.Instance.FrmEqSelector_UseSMB + this.chkUseSMB.Checked = true; // = GlobalVariable.Instance.FrmEqSelector_UseSMB this.chkUseSMB.Visible = false; this.tabControl1.SelectedIndex = 0; this.tboxModelDescription.Font = font; @@ -142,7 +140,7 @@ namespace DDUtilityApp.LOGPARSER switch (keyData) { case Keys.F1: - Process.Start($"http://jungwoois.dothome.co.kr"); + Process.Start("IEXPLORE.EXE", "http://pms.e1soft.co.kr:8090/Deploy/eqview/"); break; case Keys.F6: this.gridEquipments.BestFitColumns(BestFitColumnMode.DisplayedCells); @@ -886,7 +884,7 @@ namespace DDUtilityApp.LOGPARSER foreach (GridViewRowInfo row in grid.SelectedRows) { LogFile logFile = row.DataBoundItem as LogFile; - string destFileName = Path.Combine(destPath, Path.GetFileName(logFile.FullName)); + string destFileName = Path.Combine(destPath, logFile.FileName); switch (this.Account.Access) { @@ -897,12 +895,14 @@ namespace DDUtilityApp.LOGPARSER { FtpsClient.DownloadFtpsFile(logFile.FullName, destFileName); downfiles.Add(destFileName); + logFile.DestFullName = destFileName; } break; case AccessType.SFTP: { StpClientWrap.DownloadSftpFile(logFile.FullName, destFileName); downfiles.Add(destFileName); + logFile.DestFullName = destFileName; } break; case AccessType.FTP: @@ -1311,7 +1311,7 @@ namespace DDUtilityApp.LOGPARSER foreach (LogFile logFile in logFiles) { - if (string.Compare(item.FullName, logFile.FullName, true) == 0) + if (string.Compare(item.FileName, logFile.FileName, true) == 0) { if (current == null) { @@ -1444,9 +1444,7 @@ namespace DDUtilityApp.LOGPARSER .Select(item => new LogFile { Account = this.Account, - Name = Path.GetFileNameWithoutExtension(item.Name), FullName = item.FullName, - Extension = Path.GetExtension(item.Name), Length = item.Length, CreationTime = item.CreationTime, LastAccessTime = item.LastAccessTime, @@ -1469,9 +1467,7 @@ namespace DDUtilityApp.LOGPARSER .Select(item => new LogFile { Account = this.Account, - Name = Path.GetFileNameWithoutExtension(item.Name), FullName = item.FullName, - Extension = Path.GetExtension(item.Name), Length = item.Size, CreationTime = item.Modified, LastAccessTime = item.Modified, @@ -1494,9 +1490,7 @@ namespace DDUtilityApp.LOGPARSER .Select(item => new LogFile { Account = this.Account, - Name = Path.GetFileNameWithoutExtension(item.Name), FullName = item.FullName, - Extension = Path.GetExtension(item.Name), Length = item.Length, CreationTime = item.LastAccessTime, LastAccessTime = item.LastAccessTime, @@ -1519,9 +1513,7 @@ namespace DDUtilityApp.LOGPARSER .Select(item => new LogFile { Account = this.Account, - Name = Path.GetFileNameWithoutExtension(item.Name), FullName = item.FullName, - Extension = Path.GetExtension(item.Name), Length = item.Size, CreationTime = item.Modified, LastAccessTime = item.Modified, diff --git a/DDUtilityApp/LOGPARSER/FrmLogParser.cs b/DDUtilityApp/LOGPARSER/FrmLogParser.cs index 73b37a5..fee25ac 100644 --- a/DDUtilityApp/LOGPARSER/FrmLogParser.cs +++ b/DDUtilityApp/LOGPARSER/FrmLogParser.cs @@ -40,8 +40,6 @@ namespace DDUtilityApp.LOGPARSER private bool RadGridControlKey { get; set; } = false; - private Account Account { get; set; } = null; - private StandardCollection StandardCollection { get; set; } = new StandardCollection(); public LogParser LogParser @@ -254,7 +252,7 @@ namespace DDUtilityApp.LOGPARSER switch (keyData) { case Keys.F1: - Process.Start($"http://192.168.7.221:8081/"); + Process.Start("IEXPLORE.EXE", "http://pms.e1soft.co.kr:8090/Deploy/eqview/"); break; case Keys.F2: this.Location = new Point(0, 0); @@ -359,8 +357,10 @@ namespace DDUtilityApp.LOGPARSER int index = -1; index = this.lviewFiles.SelectedItems[0].Index; LogFile logFile = this.lviewFiles.Items[index].Tag as LogFile; + if (logFile == null) return; - this.tboxFilename.Text = Path.GetFileName(logFile.FullName); + this.tboxFilename.Text = logFile.FileName; + this.tboxFilename.Tag = logFile; if (string.IsNullOrEmpty(this.tboxFilename.Text) == false && this.tboxFilename.Text.Length > 6) { this.tboxFilename.SelectionStart = this.tboxFilename.Text.Length - 6; @@ -457,28 +457,25 @@ namespace DDUtilityApp.LOGPARSER { try { - LogFile logFile = this.tboxFilename.Tag as LogFile; string fileName = this.tboxFilename.Text; if (string.IsNullOrEmpty(fileName)) return; foreach (ListViewItem item in this.lviewFiles.Items) if (string.Compare(item.Text, fileName, true) == 0) return; - if (logFile == null) + LogFile srcLogFile = this.tboxFilename.Tag as LogFile; + if (srcLogFile == null) { if (this.lviewFiles.Items.Count < 1) return; - LogFile src = this.lviewFiles.Items[0].Tag as LogFile; - if (src != null) - { - string path = Path.GetDirectoryName(src.FullName); - string fullName = Path.Combine(path, fileName); - logFile = new LogFile(fullName); - logFile.Account = src.Account; - } + srcLogFile = this.lviewFiles.Items[0].Tag as LogFile; + if (srcLogFile == null) return; } - ListViewItem lviewItem = this.lviewFiles.Items.Add(fileName); - lviewItem.Tag = logFile; + string fullName = Path.Combine(srcLogFile.DirectoryName, fileName); + LogFile newLogFile = new LogFile(fullName) { Account = srcLogFile.Account }; + + ListViewItem lviewItem = this.lviewFiles.Items.Add(newLogFile.FileName); + lviewItem.Tag = newLogFile; lviewItem.Checked = true; } catch (Exception ex) @@ -570,14 +567,15 @@ namespace DDUtilityApp.LOGPARSER { if (this.LogParser == null) return; - List lstFileNames = new List(); + List lstLogFile = new List(); foreach (ListViewItem item in this.lviewFiles.Items) { if (item.Tag != null && item.Tag.GetType() == typeof(LogFile)) - lstFileNames.Add((LogFile)item.Tag); + lstLogFile.Add((LogFile)item.Tag); } - LogFile[] logfiles = this.LogParser.FileSelector(this, lstFileNames.ToArray()); - this.Account = this.LogParser.Account; + + // LogPaser > FrmEqSelector + LogFile[] logfiles = this.LogParser.FileSelector(this, lstLogFile.ToArray()); if (logfiles == null || logfiles.Length < 1) return; if (this.chkAutoClear.Checked) this.BtnFileClear_Click(this.btnFileClear, new EventArgs()); @@ -599,7 +597,7 @@ namespace DDUtilityApp.LOGPARSER foreach (LogFile logfile in logfiles) { this.tboxFilename.Tag = logfile; - this.tboxFilename.Text = Path.GetFileName(logfile.FullName); + this.tboxFilename.Text = logfile.FileName; this.BtnFileAdd_Click(this.btnFileAdd, new EventArgs()); } this.tboxFilename.Tag = null; @@ -810,25 +808,20 @@ namespace DDUtilityApp.LOGPARSER { try { - List lstFileName = new List(); + List lstFullName = new List(); foreach (ListViewItem lviewItem in this.lviewFiles.Items) { if (lviewItem.Checked == false) continue; XLogger.Instance.Info(lviewItem.Text); - string sourceFileName = lviewItem.Tag as string; - string destPath = GlobalVariable.Instance.DownloadPath; - if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath); + LogFile logFile = lviewItem.Tag as LogFile; + if (logFile == null) continue; - string destFileName = $@"{destPath}{System.IO.Path.GetFileName(sourceFileName)}"; - if (this.chkDownload.Checked == false) System.IO.File.Copy(sourceFileName, destFileName, true); - sourceFileName = destFileName; - - lstFileName.Add(sourceFileName); + lstFullName.Add(logFile.DestFullName); } - foreach (string filename in lstFileName) - Process.Start(filename); + foreach (string fullName in lstFullName) + Process.Start(fullName); } catch (Exception ex) { @@ -1309,7 +1302,6 @@ namespace DDUtilityApp.LOGPARSER List lstFileName = new List(); string strTitle = string.Empty; string destPath = string.Empty; - string destFileName = string.Empty; // Process Unit: File foreach (ListViewItem lviewItem in this.lviewFiles.Items) //jhlim 20250202 @@ -1318,47 +1310,49 @@ namespace DDUtilityApp.LOGPARSER XLogger.Instance.Info(lviewItem.Text); LogFile logFile = lviewItem.Tag as LogFile; - switch(this.Account.Access) + switch(logFile.Account.Access) { case AccessType.SMB: { FileInfo fileInfo = new FileInfo(logFile.FullName); 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"; + logFile.Length = fileInfo.Length; + if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add(logFile.GetFileSize()); + else lviewItem.SubItems[1].Text = logFile.GetFileSize(); if (this.chkDownload.Checked) { destPath = Path.Combine(GlobalVariable.Instance.DownloadPath, this.Equipment.EquipmentID); - if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath); + if (Directory.Exists(destPath) == false) Directory.CreateDirectory(destPath); - if (string.IsNullOrEmpty(strTitle)) strTitle = logFile.Name; - destFileName = $@"{destPath}{System.IO.Path.GetFileName(logFile.FullName)}"; + if (string.IsNullOrEmpty(strTitle)) strTitle = this.Equipment.MesName; + logFile.DestFullName = Path.Combine(destPath, logFile.FileName); - if (logFile.FullName != destFileName) - System.IO.File.Copy(logFile.FullName, destFileName, true); + File.Copy(logFile.FullName, logFile.DestFullName, true); } } break; case AccessType.FTPS: { - FtpsClient.Initialize(logFile.Account.IPAddress, logFile.Account.UserID, logFile.Account.Password); + if (FtpsClient._host != logFile.Account.IPAddress) + FtpsClient.Initialize(logFile.Account.IPAddress, logFile.Account.UserID, logFile.Account.Password); FtpListItem ftpsFileInfo = FtpsClient.GetFileInfo(logFile.FullName); if (ftpsFileInfo == null) continue; - 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"; + logFile.Length = ftpsFileInfo.Size; + if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add(logFile.GetFileSize()); + else lviewItem.SubItems[1].Text = logFile.GetFileSize(); if (this.chkDownload.Checked) { destPath = Path.Combine(GlobalVariable.Instance.DownloadPath, this.Equipment.EquipmentID); - if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath); + if (Directory.Exists(destPath) == false) Directory.CreateDirectory(destPath); - if (string.IsNullOrEmpty(strTitle)) strTitle = logFile.Name; - destFileName = Path.Combine(destPath, $"{logFile.Name}{logFile.Extension}"); + if (string.IsNullOrEmpty(strTitle)) strTitle = this.Equipment.MesName; + logFile.DestFullName = Path.Combine(destPath, logFile.FileName); - FtpsClient.DownloadFtpsFile(logFile.FullName, destFileName); + FtpsClient.DownloadFtpsFile(logFile.FullName, logFile.DestFullName); } } break; @@ -1368,7 +1362,7 @@ namespace DDUtilityApp.LOGPARSER break; } - lstFileName.Add(destFileName); + lstFileName.Add(logFile.DestFullName); } if (!string.IsNullOrEmpty(this.tboxEISInfo04.Text)) this.LogParser.ModelID = this.tboxEISInfo04.Text; diff --git a/DDUtilityApp/LOGPARSER/PARSER/EisParser0.cs b/DDUtilityApp/LOGPARSER/PARSER/EisParser0.cs index 62afdce..a0d71e0 100644 --- a/DDUtilityApp/LOGPARSER/PARSER/EisParser0.cs +++ b/DDUtilityApp/LOGPARSER/PARSER/EisParser0.cs @@ -373,16 +373,16 @@ namespace DDUtilityApp.LOGPARSER.PARSER FrmEqSelector dlg = null; try { - List logFiles = new List(); - logFiles.AddRange(args); + List lstLogFile = new List(); + lstLogFile.AddRange(args); dlg = new FrmEqSelector(); dlg.Owner = sender; - dlg.Size = sender.Size; + dlg.Size = new System.Drawing.Size(sender.Width - 60, sender.Height - 60); dlg.StartPosition = FormStartPosition.CenterParent; dlg.ServerName = this.ServerName; dlg.Equipment = sender.Equipment == null ? new EisEquipment() { EquipmentID = this.EquipmentID, Server = new LogServer(this.ServerName)} : sender.Equipment; - dlg.SelectedLogFiles = logFiles.ToArray(); + dlg.SelectedLogFiles = lstLogFile.ToArray(); DialogResult dlgResult = dlg.ShowDialog(); if (dlgResult != DialogResult.OK) return null; diff --git a/DDUtilityApp/LOGPARSER/PARSER/LogParser.cs b/DDUtilityApp/LOGPARSER/PARSER/LogParser.cs index d9075dc..8af6ab4 100644 --- a/DDUtilityApp/LOGPARSER/PARSER/LogParser.cs +++ b/DDUtilityApp/LOGPARSER/PARSER/LogParser.cs @@ -112,8 +112,8 @@ namespace DDUtilityApp.LOGPARSER.PARSER string fileName = string.Empty; if (args != null && args.Length > 0) { - directoryName = Path.GetDirectoryName(args[0].Name); - fileName = Path.GetFileName(args[0].Name); + directoryName = args[0].DirectoryName; + fileName = args[0].FileName; } OpenFileDialog dlg = new OpenFileDialog(); diff --git a/JWH/NETWORK/FtpsClient.cs b/JWH/NETWORK/FtpsClient.cs index 686ecaf..a3b1855 100644 --- a/JWH/NETWORK/FtpsClient.cs +++ b/JWH/NETWORK/FtpsClient.cs @@ -1,13 +1,14 @@ using System; using System.Net; using FluentFTP; +using Org.BouncyCastle.Crypto.Agreement.JPake; namespace JWH.NETWORK { public static class FtpsClient { private static FluentFTP.FtpClient _ftpClient; - private static string _host; + public static string _host { get; private set; } private static int _port = 990; // FTPS 기본 포트 private static string _userId; private static string _password;