F1 Change

This commit is contained in:
2025-03-07 11:57:24 +09:00
parent 0790ae42f9
commit 9be4b773a5
6 changed files with 107 additions and 77 deletions

View File

@@ -1,4 +1,6 @@
using System; using System;
using System.IO;
using System.Windows.Forms.DataVisualization.Charting;
using DDUtilityApp.DATA; using DDUtilityApp.DATA;
using JWH.DATA; using JWH.DATA;
@@ -11,33 +13,74 @@ namespace DDUtilityApp.LOGPARSER.DATA
public class LogFile : DataTableBase public class LogFile : DataTableBase
{ {
private string m_FullName = string.Empty;
public Account Account { get; set; } = null; 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 long Length { get; set; }
public string Extension { get; set; }
public string FullName { get; set; }
public DateTime CreationTime { get; set; } public DateTime CreationTime { get; set; }
public DateTime LastAccessTime { get; set; } public DateTime LastAccessTime { get; set; }
public DateTime LastWriteTime { get; set; } public DateTime LastWriteTime { get; set; }
public string DestFullName { get; set; }
public LogFile() public LogFile()
{ {
} }
public LogFile(string fullName) public LogFile(string fullName)
{ {
this.Name = System.IO.Path.GetFileNameWithoutExtension(fullName);
this.FullName = 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,
}
} }

View File

@@ -53,8 +53,6 @@ namespace DDUtilityApp.LOGPARSER
public string ServerName { get; set; } = string.Empty; public string ServerName { get; set; } = string.Empty;
//public string EquipmentID { get; set; } = string.Empty;
public SECSDefine SECSDefine { get; set; } = null; public SECSDefine SECSDefine { get; set; } = null;
#endregion #endregion
@@ -80,7 +78,7 @@ namespace DDUtilityApp.LOGPARSER
this.tboxName.ImeMode = ImeMode.Hangul; this.tboxName.ImeMode = ImeMode.Hangul;
this.tboxEquipmentID.ImeMode = ImeMode.Alpha; this.tboxEquipmentID.ImeMode = ImeMode.Alpha;
this.chkAllEquipment.Checked = GlobalVariable.Instance.FrmEqSelector_AllEquipment; 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.chkUseSMB.Visible = false;
this.tabControl1.SelectedIndex = 0; this.tabControl1.SelectedIndex = 0;
this.tboxModelDescription.Font = font; this.tboxModelDescription.Font = font;
@@ -142,7 +140,7 @@ namespace DDUtilityApp.LOGPARSER
switch (keyData) switch (keyData)
{ {
case Keys.F1: case Keys.F1:
Process.Start($"http://jungwoois.dothome.co.kr"); Process.Start("IEXPLORE.EXE", "http://pms.e1soft.co.kr:8090/Deploy/eqview/");
break; break;
case Keys.F6: case Keys.F6:
this.gridEquipments.BestFitColumns(BestFitColumnMode.DisplayedCells); this.gridEquipments.BestFitColumns(BestFitColumnMode.DisplayedCells);
@@ -886,7 +884,7 @@ namespace DDUtilityApp.LOGPARSER
foreach (GridViewRowInfo row in grid.SelectedRows) foreach (GridViewRowInfo row in grid.SelectedRows)
{ {
LogFile logFile = row.DataBoundItem as LogFile; 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) switch (this.Account.Access)
{ {
@@ -897,12 +895,14 @@ namespace DDUtilityApp.LOGPARSER
{ {
FtpsClient.DownloadFtpsFile(logFile.FullName, destFileName); FtpsClient.DownloadFtpsFile(logFile.FullName, destFileName);
downfiles.Add(destFileName); downfiles.Add(destFileName);
logFile.DestFullName = destFileName;
} }
break; break;
case AccessType.SFTP: case AccessType.SFTP:
{ {
StpClientWrap.DownloadSftpFile(logFile.FullName, destFileName); StpClientWrap.DownloadSftpFile(logFile.FullName, destFileName);
downfiles.Add(destFileName); downfiles.Add(destFileName);
logFile.DestFullName = destFileName;
} }
break; break;
case AccessType.FTP: case AccessType.FTP:
@@ -1311,7 +1311,7 @@ namespace DDUtilityApp.LOGPARSER
foreach (LogFile logFile in logFiles) 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) if (current == null)
{ {
@@ -1444,9 +1444,7 @@ namespace DDUtilityApp.LOGPARSER
.Select(item => new LogFile .Select(item => new LogFile
{ {
Account = this.Account, Account = this.Account,
Name = Path.GetFileNameWithoutExtension(item.Name),
FullName = item.FullName, FullName = item.FullName,
Extension = Path.GetExtension(item.Name),
Length = item.Length, Length = item.Length,
CreationTime = item.CreationTime, CreationTime = item.CreationTime,
LastAccessTime = item.LastAccessTime, LastAccessTime = item.LastAccessTime,
@@ -1469,9 +1467,7 @@ namespace DDUtilityApp.LOGPARSER
.Select(item => new LogFile .Select(item => new LogFile
{ {
Account = this.Account, Account = this.Account,
Name = Path.GetFileNameWithoutExtension(item.Name),
FullName = item.FullName, FullName = item.FullName,
Extension = Path.GetExtension(item.Name),
Length = item.Size, Length = item.Size,
CreationTime = item.Modified, CreationTime = item.Modified,
LastAccessTime = item.Modified, LastAccessTime = item.Modified,
@@ -1494,9 +1490,7 @@ namespace DDUtilityApp.LOGPARSER
.Select(item => new LogFile .Select(item => new LogFile
{ {
Account = this.Account, Account = this.Account,
Name = Path.GetFileNameWithoutExtension(item.Name),
FullName = item.FullName, FullName = item.FullName,
Extension = Path.GetExtension(item.Name),
Length = item.Length, Length = item.Length,
CreationTime = item.LastAccessTime, CreationTime = item.LastAccessTime,
LastAccessTime = item.LastAccessTime, LastAccessTime = item.LastAccessTime,
@@ -1519,9 +1513,7 @@ namespace DDUtilityApp.LOGPARSER
.Select(item => new LogFile .Select(item => new LogFile
{ {
Account = this.Account, Account = this.Account,
Name = Path.GetFileNameWithoutExtension(item.Name),
FullName = item.FullName, FullName = item.FullName,
Extension = Path.GetExtension(item.Name),
Length = item.Size, Length = item.Size,
CreationTime = item.Modified, CreationTime = item.Modified,
LastAccessTime = item.Modified, LastAccessTime = item.Modified,

View File

@@ -40,8 +40,6 @@ namespace DDUtilityApp.LOGPARSER
private bool RadGridControlKey { get; set; } = false; private bool RadGridControlKey { get; set; } = false;
private Account Account { get; set; } = null;
private StandardCollection StandardCollection { get; set; } = new StandardCollection(); private StandardCollection StandardCollection { get; set; } = new StandardCollection();
public LogParser LogParser public LogParser LogParser
@@ -254,7 +252,7 @@ namespace DDUtilityApp.LOGPARSER
switch (keyData) switch (keyData)
{ {
case Keys.F1: case Keys.F1:
Process.Start($"http://192.168.7.221:8081/"); Process.Start("IEXPLORE.EXE", "http://pms.e1soft.co.kr:8090/Deploy/eqview/");
break; break;
case Keys.F2: case Keys.F2:
this.Location = new Point(0, 0); this.Location = new Point(0, 0);
@@ -359,8 +357,10 @@ namespace DDUtilityApp.LOGPARSER
int index = -1; int index = -1;
index = this.lviewFiles.SelectedItems[0].Index; index = this.lviewFiles.SelectedItems[0].Index;
LogFile logFile = this.lviewFiles.Items[index].Tag as LogFile; 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) if (string.IsNullOrEmpty(this.tboxFilename.Text) == false && this.tboxFilename.Text.Length > 6)
{ {
this.tboxFilename.SelectionStart = this.tboxFilename.Text.Length - 6; this.tboxFilename.SelectionStart = this.tboxFilename.Text.Length - 6;
@@ -457,28 +457,25 @@ namespace DDUtilityApp.LOGPARSER
{ {
try try
{ {
LogFile logFile = this.tboxFilename.Tag as LogFile;
string fileName = this.tboxFilename.Text; string fileName = this.tboxFilename.Text;
if (string.IsNullOrEmpty(fileName)) return; if (string.IsNullOrEmpty(fileName)) return;
foreach (ListViewItem item in this.lviewFiles.Items) foreach (ListViewItem item in this.lviewFiles.Items)
if (string.Compare(item.Text, fileName, true) == 0) return; 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; if (this.lviewFiles.Items.Count < 1) return;
LogFile src = this.lviewFiles.Items[0].Tag as LogFile; srcLogFile = this.lviewFiles.Items[0].Tag as LogFile;
if (src != null) if (srcLogFile == null) return;
{
string path = Path.GetDirectoryName(src.FullName);
string fullName = Path.Combine(path, fileName);
logFile = new LogFile(fullName);
logFile.Account = src.Account;
}
} }
ListViewItem lviewItem = this.lviewFiles.Items.Add(fileName); string fullName = Path.Combine(srcLogFile.DirectoryName, fileName);
lviewItem.Tag = logFile; LogFile newLogFile = new LogFile(fullName) { Account = srcLogFile.Account };
ListViewItem lviewItem = this.lviewFiles.Items.Add(newLogFile.FileName);
lviewItem.Tag = newLogFile;
lviewItem.Checked = true; lviewItem.Checked = true;
} }
catch (Exception ex) catch (Exception ex)
@@ -570,14 +567,15 @@ namespace DDUtilityApp.LOGPARSER
{ {
if (this.LogParser == null) return; if (this.LogParser == null) return;
List<LogFile> lstFileNames = new List<LogFile>(); List<LogFile> lstLogFile = new List<LogFile>();
foreach (ListViewItem item in this.lviewFiles.Items) foreach (ListViewItem item in this.lviewFiles.Items)
{ {
if (item.Tag != null && item.Tag.GetType() == typeof(LogFile)) 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 (logfiles == null || logfiles.Length < 1) return;
if (this.chkAutoClear.Checked) this.BtnFileClear_Click(this.btnFileClear, new EventArgs()); if (this.chkAutoClear.Checked) this.BtnFileClear_Click(this.btnFileClear, new EventArgs());
@@ -599,7 +597,7 @@ namespace DDUtilityApp.LOGPARSER
foreach (LogFile logfile in logfiles) foreach (LogFile logfile in logfiles)
{ {
this.tboxFilename.Tag = logfile; this.tboxFilename.Tag = logfile;
this.tboxFilename.Text = Path.GetFileName(logfile.FullName); this.tboxFilename.Text = logfile.FileName;
this.BtnFileAdd_Click(this.btnFileAdd, new EventArgs()); this.BtnFileAdd_Click(this.btnFileAdd, new EventArgs());
} }
this.tboxFilename.Tag = null; this.tboxFilename.Tag = null;
@@ -810,25 +808,20 @@ namespace DDUtilityApp.LOGPARSER
{ {
try try
{ {
List<string> lstFileName = new List<string>(); List<string> lstFullName = new List<string>();
foreach (ListViewItem lviewItem in this.lviewFiles.Items) foreach (ListViewItem lviewItem in this.lviewFiles.Items)
{ {
if (lviewItem.Checked == false) continue; if (lviewItem.Checked == false) continue;
XLogger.Instance.Info(lviewItem.Text); XLogger.Instance.Info(lviewItem.Text);
string sourceFileName = lviewItem.Tag as string; LogFile logFile = lviewItem.Tag as LogFile;
string destPath = GlobalVariable.Instance.DownloadPath; if (logFile == null) continue;
if (System.IO.Directory.Exists(destPath) == false) System.IO.Directory.CreateDirectory(destPath);
string destFileName = $@"{destPath}{System.IO.Path.GetFileName(sourceFileName)}"; lstFullName.Add(logFile.DestFullName);
if (this.chkDownload.Checked == false) System.IO.File.Copy(sourceFileName, destFileName, true);
sourceFileName = destFileName;
lstFileName.Add(sourceFileName);
} }
foreach (string filename in lstFileName) foreach (string fullName in lstFullName)
Process.Start(filename); Process.Start(fullName);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1309,7 +1302,6 @@ namespace DDUtilityApp.LOGPARSER
List<string> lstFileName = new List<string>(); List<string> lstFileName = new List<string>();
string strTitle = string.Empty; string strTitle = string.Empty;
string destPath = string.Empty; string destPath = string.Empty;
string destFileName = string.Empty;
// Process Unit: File // Process Unit: File
foreach (ListViewItem lviewItem in this.lviewFiles.Items) //jhlim 20250202 foreach (ListViewItem lviewItem in this.lviewFiles.Items) //jhlim 20250202
@@ -1318,47 +1310,49 @@ namespace DDUtilityApp.LOGPARSER
XLogger.Instance.Info(lviewItem.Text); XLogger.Instance.Info(lviewItem.Text);
LogFile logFile = lviewItem.Tag as LogFile; LogFile logFile = lviewItem.Tag as LogFile;
switch(this.Account.Access) switch(logFile.Account.Access)
{ {
case AccessType.SMB: case AccessType.SMB:
{ {
FileInfo fileInfo = new FileInfo(logFile.FullName); FileInfo fileInfo = new FileInfo(logFile.FullName);
if (fileInfo.Exists == false) continue; if (fileInfo.Exists == false) continue;
if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add($"{((float)fileInfo.Length / 1024 / 1024).ToString("F2")} MB"); logFile.Length = fileInfo.Length;
else lviewItem.SubItems[1].Text = $"{((float)fileInfo.Length / 1024 / 1024).ToString("F2")} MB"; if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add(logFile.GetFileSize());
else lviewItem.SubItems[1].Text = logFile.GetFileSize();
if (this.chkDownload.Checked) if (this.chkDownload.Checked)
{ {
destPath = Path.Combine(GlobalVariable.Instance.DownloadPath, this.Equipment.EquipmentID); 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; if (string.IsNullOrEmpty(strTitle)) strTitle = this.Equipment.MesName;
destFileName = $@"{destPath}{System.IO.Path.GetFileName(logFile.FullName)}"; logFile.DestFullName = Path.Combine(destPath, logFile.FileName);
if (logFile.FullName != destFileName) File.Copy(logFile.FullName, logFile.DestFullName, true);
System.IO.File.Copy(logFile.FullName, destFileName, true);
} }
} }
break; break;
case AccessType.FTPS: 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); FtpListItem ftpsFileInfo = FtpsClient.GetFileInfo(logFile.FullName);
if (ftpsFileInfo == null) continue; if (ftpsFileInfo == null) continue;
if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add($"{((float)ftpsFileInfo.Size / 1024 / 1024).ToString("F2")} MB"); logFile.Length = ftpsFileInfo.Size;
else lviewItem.SubItems[1].Text = $"{((float)ftpsFileInfo.Size / 1024 / 1024).ToString("F2")} MB"; if (lviewItem.SubItems.Count < 2) lviewItem.SubItems.Add(logFile.GetFileSize());
else lviewItem.SubItems[1].Text = logFile.GetFileSize();
if (this.chkDownload.Checked) if (this.chkDownload.Checked)
{ {
destPath = Path.Combine(GlobalVariable.Instance.DownloadPath, this.Equipment.EquipmentID); 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; if (string.IsNullOrEmpty(strTitle)) strTitle = this.Equipment.MesName;
destFileName = Path.Combine(destPath, $"{logFile.Name}{logFile.Extension}"); logFile.DestFullName = Path.Combine(destPath, logFile.FileName);
FtpsClient.DownloadFtpsFile(logFile.FullName, destFileName); FtpsClient.DownloadFtpsFile(logFile.FullName, logFile.DestFullName);
} }
} }
break; break;
@@ -1368,7 +1362,7 @@ namespace DDUtilityApp.LOGPARSER
break; break;
} }
lstFileName.Add(destFileName); lstFileName.Add(logFile.DestFullName);
} }
if (!string.IsNullOrEmpty(this.tboxEISInfo04.Text)) this.LogParser.ModelID = this.tboxEISInfo04.Text; if (!string.IsNullOrEmpty(this.tboxEISInfo04.Text)) this.LogParser.ModelID = this.tboxEISInfo04.Text;

View File

@@ -373,16 +373,16 @@ namespace DDUtilityApp.LOGPARSER.PARSER
FrmEqSelector dlg = null; FrmEqSelector dlg = null;
try try
{ {
List<LogFile> logFiles = new List<LogFile>(); List<LogFile> lstLogFile = new List<LogFile>();
logFiles.AddRange(args); lstLogFile.AddRange(args);
dlg = new FrmEqSelector(); dlg = new FrmEqSelector();
dlg.Owner = sender; dlg.Owner = sender;
dlg.Size = sender.Size; dlg.Size = new System.Drawing.Size(sender.Width - 60, sender.Height - 60);
dlg.StartPosition = FormStartPosition.CenterParent; dlg.StartPosition = FormStartPosition.CenterParent;
dlg.ServerName = this.ServerName; dlg.ServerName = this.ServerName;
dlg.Equipment = sender.Equipment == null ? new EisEquipment() { EquipmentID = this.EquipmentID, Server = new LogServer(this.ServerName)} : sender.Equipment; 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(); DialogResult dlgResult = dlg.ShowDialog();
if (dlgResult != DialogResult.OK) return null; if (dlgResult != DialogResult.OK) return null;

View File

@@ -112,8 +112,8 @@ namespace DDUtilityApp.LOGPARSER.PARSER
string fileName = string.Empty; string fileName = string.Empty;
if (args != null && args.Length > 0) if (args != null && args.Length > 0)
{ {
directoryName = Path.GetDirectoryName(args[0].Name); directoryName = args[0].DirectoryName;
fileName = Path.GetFileName(args[0].Name); fileName = args[0].FileName;
} }
OpenFileDialog dlg = new OpenFileDialog(); OpenFileDialog dlg = new OpenFileDialog();

View File

@@ -1,13 +1,14 @@
using System; using System;
using System.Net; using System.Net;
using FluentFTP; using FluentFTP;
using Org.BouncyCastle.Crypto.Agreement.JPake;
namespace JWH.NETWORK namespace JWH.NETWORK
{ {
public static class FtpsClient public static class FtpsClient
{ {
private static FluentFTP.FtpClient _ftpClient; private static FluentFTP.FtpClient _ftpClient;
private static string _host; public static string _host { get; private set; }
private static int _port = 990; // FTPS 기본 포트 private static int _port = 990; // FTPS 기본 포트
private static string _userId; private static string _userId;
private static string _password; private static string _password;