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