EquipmentList.OrderBy
This commit is contained in:
@@ -19,6 +19,9 @@ namespace DDUtilityApp.LOGPARSER.DATA
|
|||||||
/// <summary>MES.FacilityName</summary>
|
/// <summary>MES.FacilityName</summary>
|
||||||
public string Facility { get; set; }
|
public string Facility { get; set; }
|
||||||
|
|
||||||
|
/// <summary>MES.FacilityName</summary>
|
||||||
|
public string OrderByKey { get { return string.IsNullOrEmpty(this.Facility) ? "" : this.Facility.Substring(0, 2); } }
|
||||||
|
|
||||||
/// <summary>EIS.Line</summary>
|
/// <summary>EIS.Line</summary>
|
||||||
public string Line { get; set; }
|
public string Line { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using DDUtilityApp.DATA;
|
||||||
using JWH.DATA;
|
using JWH.DATA;
|
||||||
|
|
||||||
namespace DDUtilityApp.LOGPARSER.DATA
|
namespace DDUtilityApp.LOGPARSER.DATA
|
||||||
@@ -10,7 +11,7 @@ namespace DDUtilityApp.LOGPARSER.DATA
|
|||||||
public class LogFile : DataTableBase
|
public class LogFile : DataTableBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public AccessType Access { get; set; } = AccessType.FTPS;
|
public Account Account { get; set; } = null;
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1143,7 +1143,7 @@ namespace DDUtilityApp.LOGPARSER
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return equipments.OrderBy(x => x.Line).ThenBy(x => x.ProcessSegmentID).ThenBy(x => x.MesName).ToArray();
|
return equipments.OrderBy(x => x.OrderByKey).ThenBy(x => x.Line).ThenBy(x => x.ProcessSegmentID).ThenBy(x => x.MesName).ToArray();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1293,6 +1293,8 @@ namespace DDUtilityApp.LOGPARSER
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string connectionString = string.Empty;
|
string connectionString = string.Empty;
|
||||||
|
connectionString = $@"server=192.168.8.232;database=ddmes;uid=DDB2MESAdmin;pwd=Yhqe4csJXJ4W5$%;";
|
||||||
|
|
||||||
StringBuilder query = new StringBuilder();
|
StringBuilder query = new StringBuilder();
|
||||||
query.AppendLine($" SELECT A.SITEID, ");
|
query.AppendLine($" SELECT A.SITEID, ");
|
||||||
query.AppendLine($" A.FACILITYID, ");
|
query.AppendLine($" A.FACILITYID, ");
|
||||||
@@ -1312,9 +1314,6 @@ namespace DDUtilityApp.LOGPARSER
|
|||||||
query.AppendLine($" A.MAKER, ");
|
query.AppendLine($" A.MAKER, ");
|
||||||
query.AppendLine($" A.EQPSTATE, ");
|
query.AppendLine($" A.EQPSTATE, ");
|
||||||
query.AppendLine($" A.LOCATION ");
|
query.AppendLine($" A.LOCATION ");
|
||||||
|
|
||||||
connectionString = $@"server=192.168.8.232;database=ddmes;uid=DDB2MESAdmin;pwd=Yhqe4csJXJ4W5$%;";
|
|
||||||
|
|
||||||
query.AppendLine($" , E.PLANDATE ");
|
query.AppendLine($" , E.PLANDATE ");
|
||||||
query.AppendLine($" FROM CIM_EQUIPMENT A (nolock) ");
|
query.AppendLine($" FROM CIM_EQUIPMENT A (nolock) ");
|
||||||
query.AppendLine($" LEFT JOIN CIM_PROCESSSEGMENT B (nolock) ON A.PROCESSSEGMENTID = B.PROCESSSEGMENTID AND A.SITEID = B.SITEID ");
|
query.AppendLine($" LEFT JOIN CIM_PROCESSSEGMENT B (nolock) ON A.PROCESSSEGMENTID = B.PROCESSSEGMENTID AND A.SITEID = B.SITEID ");
|
||||||
@@ -1365,7 +1364,7 @@ namespace DDUtilityApp.LOGPARSER
|
|||||||
LogFile[] logFiles = fileItems
|
LogFile[] logFiles = fileItems
|
||||||
.Select(item => new LogFile
|
.Select(item => new LogFile
|
||||||
{
|
{
|
||||||
Access = AccessType.SMB,
|
Account = this.Account,
|
||||||
Name = Path.GetFileNameWithoutExtension(item.Name),
|
Name = Path.GetFileNameWithoutExtension(item.Name),
|
||||||
FullName = item.FullName,
|
FullName = item.FullName,
|
||||||
Extension = Path.GetExtension(item.Name),
|
Extension = Path.GetExtension(item.Name),
|
||||||
@@ -1390,7 +1389,7 @@ namespace DDUtilityApp.LOGPARSER
|
|||||||
LogFile[] logFiles = fileItems.Where(item => item.Type == FtpFileSystemObjectType.File)
|
LogFile[] logFiles = fileItems.Where(item => item.Type == FtpFileSystemObjectType.File)
|
||||||
.Select(item => new LogFile
|
.Select(item => new LogFile
|
||||||
{
|
{
|
||||||
Access = AccessType.FTPS,
|
Account = this.Account,
|
||||||
Name = Path.GetFileNameWithoutExtension(item.Name),
|
Name = Path.GetFileNameWithoutExtension(item.Name),
|
||||||
FullName = item.FullName,
|
FullName = item.FullName,
|
||||||
Extension = Path.GetExtension(item.Name),
|
Extension = Path.GetExtension(item.Name),
|
||||||
@@ -1415,7 +1414,7 @@ namespace DDUtilityApp.LOGPARSER
|
|||||||
LogFile[] logFiles = fileItems.Where(item => !item.IsDirectory && item.Name != "." && item.Name != "..")
|
LogFile[] logFiles = fileItems.Where(item => !item.IsDirectory && item.Name != "." && item.Name != "..")
|
||||||
.Select(item => new LogFile
|
.Select(item => new LogFile
|
||||||
{
|
{
|
||||||
Access = AccessType.SFTP,
|
Account = this.Account,
|
||||||
Name = Path.GetFileNameWithoutExtension(item.Name),
|
Name = Path.GetFileNameWithoutExtension(item.Name),
|
||||||
FullName = item.FullName,
|
FullName = item.FullName,
|
||||||
Extension = Path.GetExtension(item.Name),
|
Extension = Path.GetExtension(item.Name),
|
||||||
@@ -1440,6 +1439,7 @@ namespace DDUtilityApp.LOGPARSER
|
|||||||
LogFile[] logFiles = ((FtpListItem[])fileItems).Where(item => item.Type == FtpFileSystemObjectType.File)
|
LogFile[] logFiles = ((FtpListItem[])fileItems).Where(item => item.Type == FtpFileSystemObjectType.File)
|
||||||
.Select(item => new LogFile
|
.Select(item => new LogFile
|
||||||
{
|
{
|
||||||
|
Account = this.Account,
|
||||||
Name = Path.GetFileNameWithoutExtension(item.Name),
|
Name = Path.GetFileNameWithoutExtension(item.Name),
|
||||||
FullName = item.FullName,
|
FullName = item.FullName,
|
||||||
Extension = Path.GetExtension(item.Name),
|
Extension = Path.GetExtension(item.Name),
|
||||||
|
|||||||
@@ -473,6 +473,7 @@ namespace DDUtilityApp.LOGPARSER
|
|||||||
string path = Path.GetDirectoryName(src.FullName);
|
string path = Path.GetDirectoryName(src.FullName);
|
||||||
string fullName = Path.Combine(path, fileName);
|
string fullName = Path.Combine(path, fileName);
|
||||||
logFile = new LogFile(fullName);
|
logFile = new LogFile(fullName);
|
||||||
|
logFile.Account = src.Account;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1317,7 +1318,7 @@ 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(logFile.Access)
|
switch(logFile.Account.Access)
|
||||||
{
|
{
|
||||||
case AccessType.SMB:
|
case AccessType.SMB:
|
||||||
{
|
{
|
||||||
@@ -1342,6 +1343,7 @@ namespace DDUtilityApp.LOGPARSER
|
|||||||
break;
|
break;
|
||||||
case AccessType.FTPS:
|
case AccessType.FTPS:
|
||||||
{
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
|||||||
@@ -14,102 +14,163 @@ namespace JWH.NETWORK
|
|||||||
|
|
||||||
public static void Initialize(string host, string userId, string password, int port = 990)
|
public static void Initialize(string host, string userId, string password, int port = 990)
|
||||||
{
|
{
|
||||||
_host = host;
|
try
|
||||||
_userId = userId;
|
|
||||||
_password = password;
|
|
||||||
_port = port;
|
|
||||||
|
|
||||||
_ftpClient = new FluentFTP.FtpClient(_host, _port, new NetworkCredential(_userId, _password))
|
|
||||||
{
|
{
|
||||||
//EncryptionMode = FtpEncryptionMode.Explicit,
|
_host = host;
|
||||||
EncryptionMode = FtpEncryptionMode.Implicit,
|
_userId = userId;
|
||||||
SslProtocols = System.Security.Authentication.SslProtocols.Tls12,
|
_password = password;
|
||||||
ConnectTimeout = 500 // 타임아웃 설정 (0.5초)
|
_port = port;
|
||||||
};
|
|
||||||
_ftpClient.ValidateCertificate += (control, args) => args.Accept = true; // 인증서 검증 비활성화 (운영 확인 필요!)
|
_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; // 인증서 검증 비활성화 (운영 확인 필요!)
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Connect()
|
public static void Connect()
|
||||||
{
|
{
|
||||||
if (_ftpClient == null)
|
try
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("FTPS client is not initialized. Call Initialize() first.");
|
if (_ftpClient == null)
|
||||||
}
|
throw new InvalidOperationException("FTPS client is not initialized. Call Initialize() first.");
|
||||||
|
|
||||||
if (!_ftpClient.IsConnected)
|
if (!_ftpClient.IsConnected)
|
||||||
|
_ftpClient.Connect();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
_ftpClient.Connect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Disconnect()
|
public static void Disconnect()
|
||||||
{
|
{
|
||||||
if (_ftpClient != null && _ftpClient.IsConnected)
|
try
|
||||||
|
{
|
||||||
|
if (_ftpClient != null && _ftpClient.IsConnected)
|
||||||
|
_ftpClient.Disconnect();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
_ftpClient.Disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsFileExists(string path)
|
public static bool IsFileExists(string path)
|
||||||
{
|
{
|
||||||
Connect();
|
try
|
||||||
return _ftpClient.FileExists(path);
|
{
|
||||||
|
Connect();
|
||||||
|
return _ftpClient.FileExists(path);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsDirExists(string path)
|
public static bool IsDirExists(string path)
|
||||||
{
|
{
|
||||||
Connect();
|
try
|
||||||
return _ftpClient.DirectoryExists(path);
|
{
|
||||||
|
Connect();
|
||||||
|
return _ftpClient.DirectoryExists(path);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FtpListItem[] GetFtpsList(string path)
|
public static FtpListItem[] GetFtpsList(string path)
|
||||||
{
|
{
|
||||||
Connect();
|
try
|
||||||
return _ftpClient.GetListing(path);
|
{
|
||||||
|
Connect();
|
||||||
|
return _ftpClient.GetListing(path);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static object GetObjectInfo(string filePath)
|
public static object GetObjectInfo(string filePath)
|
||||||
{
|
{
|
||||||
Connect();
|
try
|
||||||
return _ftpClient.GetObjectInfo(filePath);
|
{
|
||||||
|
Connect();
|
||||||
|
return _ftpClient.GetObjectInfo(filePath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FtpListItem GetFileInfo(string remoteFilePath)
|
public static FtpListItem GetFileInfo(string remoteFilePath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FtpsClient.Connect();
|
Connect();
|
||||||
|
|
||||||
if (!_ftpClient.IsConnected)
|
if (!_ftpClient.IsConnected)
|
||||||
{
|
throw new InvalidOperationException("FTPS 서버에 연결되지 않았습니다.");
|
||||||
Console.WriteLine("FTPS 서버에 연결되지 않았습니다.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Passive Mode 설정 (필요한 경우)
|
// Passive Mode 설정 (필요한 경우)
|
||||||
// _ftpClient.SetPassiveMode(true);
|
// _ftpClient.SetPassiveMode(true);
|
||||||
|
|
||||||
if (!FtpsClient.IsFileExists(remoteFilePath))
|
if (!FtpsClient.IsFileExists(remoteFilePath))
|
||||||
{
|
throw new InvalidOperationException("파일이 존재하지 않습니다.");
|
||||||
Console.WriteLine("파일이 존재하지 않습니다.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var fileInfo = FtpsClient.GetObjectInfo(remoteFilePath) ;
|
var fileInfo = FtpsClient.GetObjectInfo(remoteFilePath);
|
||||||
if (fileInfo == null)
|
if (fileInfo == null)
|
||||||
{
|
throw new InvalidOperationException("파일 정보를 가져오는 데 실패했습니다.");
|
||||||
Console.WriteLine("파일 정보를 가져오는 데 실패했습니다.");
|
|
||||||
}
|
|
||||||
return (FtpListItem)fileInfo;
|
return (FtpListItem)fileInfo;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"파일 정보 조회 오류: {ex.Message}");
|
throw ex;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
FtpsClient.Disconnect();
|
Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +184,11 @@ namespace JWH.NETWORK
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Download error: {ex.Message}");
|
throw ex;
|
||||||
return false;
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,8 +202,11 @@ namespace JWH.NETWORK
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Upload error: {ex.Message}");
|
throw ex;
|
||||||
return false;
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,19 @@ namespace JWH.NETWORK
|
|||||||
|
|
||||||
public static bool IsFileExists(string path)
|
public static bool IsFileExists(string path)
|
||||||
{
|
{
|
||||||
Connect();
|
try
|
||||||
return _sftpClient.Exists(path);
|
{
|
||||||
|
Connect();
|
||||||
|
return _sftpClient.Exists(path);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Renci.SshNet.Sftp.SftpFileAttributes GetFileInfo(string remoteFilePath)
|
public static Renci.SshNet.Sftp.SftpFileAttributes GetFileInfo(string remoteFilePath)
|
||||||
@@ -74,12 +85,27 @@ namespace JWH.NETWORK
|
|||||||
Console.WriteLine($"파일 정보 조회 오류: {ex.Message}");
|
Console.WriteLine($"파일 정보 조회 오류: {ex.Message}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static object GetSftpList(string path)
|
public static object GetSftpList(string path)
|
||||||
{
|
{
|
||||||
Connect();
|
try
|
||||||
return _sftpClient.ListDirectory(path);
|
{
|
||||||
|
Connect();
|
||||||
|
return _sftpClient.ListDirectory(path);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool DownloadSftpFile(string remotePath, string localPath)
|
public static bool DownloadSftpFile(string remotePath, string localPath)
|
||||||
@@ -98,6 +124,10 @@ namespace JWH.NETWORK
|
|||||||
Console.WriteLine($"Download error: {ex.Message}");
|
Console.WriteLine($"Download error: {ex.Message}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool UploadSftpFile(string localPath, string remotePath)
|
public static bool UploadSftpFile(string localPath, string remotePath)
|
||||||
@@ -116,6 +146,10 @@ namespace JWH.NETWORK
|
|||||||
Console.WriteLine($"Upload error: {ex.Message}");
|
Console.WriteLine($"Upload error: {ex.Message}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user