diff --git a/DDUtilityApp/App.config b/DDUtilityApp/App.config index 013eddd..f339ce0 100644 --- a/DDUtilityApp/App.config +++ b/DDUtilityApp/App.config @@ -1,37 +1,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DDUtilityApp/DDUtilityApp.csproj b/DDUtilityApp/DDUtilityApp.csproj index 0e8e6c6..93ad132 100644 --- a/DDUtilityApp/DDUtilityApp.csproj +++ b/DDUtilityApp/DDUtilityApp.csproj @@ -397,6 +397,20 @@ FrmEqSelector.cs + + Form + + + ProgressForm.cs + + + Form + + + ServerLog.cs + + + Form diff --git a/DDUtilityApp/GlobalVariable.cs b/DDUtilityApp/GlobalVariable.cs index 3d320d2..ae58f39 100644 --- a/DDUtilityApp/GlobalVariable.cs +++ b/DDUtilityApp/GlobalVariable.cs @@ -28,6 +28,11 @@ namespace DDUtilityApp /// public string DownloadPath { get; set; } + /// + /// 로그파일 다운로드 경로 jhlim 20250202 + /// + public string MesDownloadPath { get; set; } + /// /// Workflow 다운로드 경로 /// @@ -109,6 +114,7 @@ namespace DDUtilityApp this.DefaultPath = defaultPath.Replace("%MyDocuments%", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); this.DownloadPath = $@"{this.DefaultPath}Download\"; this.WorkflowPath = $@"{this.DefaultPath}Workflow\"; + this.MesDownloadPath = $@"{this.DefaultPath}MesDownload\"; //jhlim 20250202 } public void LoadSetting() diff --git a/DDUtilityApp/MESDOWNLOADER/MESDOWNLOADER.7z b/DDUtilityApp/MESDOWNLOADER/MESDOWNLOADER.7z new file mode 100644 index 0000000..9ff87a1 Binary files /dev/null and b/DDUtilityApp/MESDOWNLOADER/MESDOWNLOADER.7z differ diff --git a/DDUtilityApp/MESDOWNLOADER/ProgressForm.Designer.cs b/DDUtilityApp/MESDOWNLOADER/ProgressForm.Designer.cs new file mode 100644 index 0000000..13f69c8 --- /dev/null +++ b/DDUtilityApp/MESDOWNLOADER/ProgressForm.Designer.cs @@ -0,0 +1,75 @@ + +namespace DDUtilityApp.MESDOWNLOADER +{ + partial class ProgressForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.progressBar = new System.Windows.Forms.ProgressBar(); + this.lblStatus = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // progressBar + // + this.progressBar.Location = new System.Drawing.Point(20, 20); + this.progressBar.Name = "progressBar"; + this.progressBar.Size = new System.Drawing.Size(250, 20); + this.progressBar.TabIndex = 0; + // + // lblStatus + // + this.lblStatus.AutoSize = true; + this.lblStatus.Location = new System.Drawing.Point(28, 54); + this.lblStatus.Name = "lblStatus"; + this.lblStatus.Size = new System.Drawing.Size(38, 12); + this.lblStatus.TabIndex = 1; + this.lblStatus.Text = "label1"; + this.lblStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // ProgressForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 93); + this.ControlBox = false; + this.Controls.Add(this.lblStatus); + this.Controls.Add(this.progressBar); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "ProgressForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "다운로드 진행 중"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ProgressBar progressBar; + private System.Windows.Forms.Label lblStatus; + } +} \ No newline at end of file diff --git a/DDUtilityApp/MESDOWNLOADER/ProgressForm.cs b/DDUtilityApp/MESDOWNLOADER/ProgressForm.cs new file mode 100644 index 0000000..afef5c7 --- /dev/null +++ b/DDUtilityApp/MESDOWNLOADER/ProgressForm.cs @@ -0,0 +1,28 @@ +using System; +using System.Windows.Forms; + +namespace DDUtilityApp.MESDOWNLOADER +{ + public partial class ProgressForm : Form + { + public ProgressForm(int maxFiles) + { + InitializeComponent(); + progressBar.Maximum = maxFiles + 1; + lblStatus.Text = string.Empty; + } + + public void UpdateProgress(string fileName, int current) + { + if (this.InvokeRequired) + { + this.Invoke(new Action(() => UpdateProgress(fileName, current))); + } + else + { + lblStatus.Text = $"{fileName}\r\n{current} / {progressBar.Maximum - 1}"; + progressBar.Value = current; + } + } + } +} diff --git a/DDUtilityApp/MESDOWNLOADER/ServerLog.Designer.cs b/DDUtilityApp/MESDOWNLOADER/ServerLog.Designer.cs new file mode 100644 index 0000000..241309f --- /dev/null +++ b/DDUtilityApp/MESDOWNLOADER/ServerLog.Designer.cs @@ -0,0 +1,376 @@ + +namespace DDUtilityApp.MESDOWNLOADER +{ + partial class ServerLog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + Telerik.WinControls.UI.TableViewDefinition tableViewDefinition1 = new Telerik.WinControls.UI.TableViewDefinition(); + Telerik.WinControls.UI.TableViewDefinition tableViewDefinition2 = new Telerik.WinControls.UI.TableViewDefinition(); + this.cboxServer = new System.Windows.Forms.ComboBox(); + this.btnConnect = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.btnFoder = new System.Windows.Forms.Button(); + this.panel4 = new System.Windows.Forms.FlowLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.txtPath = new System.Windows.Forms.TextBox(); + this.panel2 = new System.Windows.Forms.Panel(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.panel3 = new System.Windows.Forms.Panel(); + this.panel6 = new System.Windows.Forms.Panel(); + this.gridServer = new JWH.CONTROL.GridViewEx(); + this.panel5 = new System.Windows.Forms.Panel(); + this.panel7 = new System.Windows.Forms.Panel(); + this.gridLogFiles = new JWH.CONTROL.GridViewEx(); + this.panel1 = new System.Windows.Forms.Panel(); + this.panel8 = new System.Windows.Forms.Panel(); + this.plSubPart = new System.Windows.Forms.FlowLayoutPanel(); + this.btnPath = new System.Windows.Forms.Button(); + this.panel4.SuspendLayout(); + this.panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); + this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.Panel2.SuspendLayout(); + this.splitContainer2.SuspendLayout(); + this.panel3.SuspendLayout(); + this.panel6.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.gridServer)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.gridServer.MasterTemplate)).BeginInit(); + this.panel5.SuspendLayout(); + this.panel7.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.gridLogFiles)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.gridLogFiles.MasterTemplate)).BeginInit(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // cboxServer + // + this.cboxServer.FormattingEnabled = true; + this.cboxServer.Location = new System.Drawing.Point(100, 4); + this.cboxServer.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.cboxServer.Name = "cboxServer"; + this.cboxServer.Size = new System.Drawing.Size(215, 20); + this.cboxServer.TabIndex = 1; + this.cboxServer.SelectedIndexChanged += new System.EventHandler(this.cboxServer_SelectedIndexChanged); + // + // btnConnect + // + this.btnConnect.Location = new System.Drawing.Point(321, 4); + this.btnConnect.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnConnect.Name = "btnConnect"; + this.btnConnect.Size = new System.Drawing.Size(87, 23); + this.btnConnect.TabIndex = 1; + this.btnConnect.Text = "연결"; + this.btnConnect.UseVisualStyleBackColor = true; + this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click); + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Left; + this.label2.Location = new System.Drawing.Point(414, 2); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(88, 27); + this.label2.TabIndex = 5; + this.label2.Text = "로컬디렉토리 :"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // btnFoder + // + this.btnFoder.Location = new System.Drawing.Point(855, 4); + this.btnFoder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnFoder.Name = "btnFoder"; + this.btnFoder.Size = new System.Drawing.Size(66, 23); + this.btnFoder.TabIndex = 4; + this.btnFoder.Text = "폴더"; + this.btnFoder.UseVisualStyleBackColor = true; + this.btnFoder.Click += new System.EventHandler(this.btnFoder_Click); + // + // panel4 + // + this.panel4.Controls.Add(this.label1); + this.panel4.Controls.Add(this.cboxServer); + this.panel4.Controls.Add(this.btnConnect); + this.panel4.Controls.Add(this.label2); + this.panel4.Controls.Add(this.txtPath); + this.panel4.Controls.Add(this.btnFoder); + this.panel4.Controls.Add(this.btnPath); + this.panel4.Dock = System.Windows.Forms.DockStyle.Top; + this.panel4.Location = new System.Drawing.Point(0, 0); + this.panel4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel4.MinimumSize = new System.Drawing.Size(0, 19); + this.panel4.Name = "panel4"; + this.panel4.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel4.Size = new System.Drawing.Size(1007, 31); + this.panel4.TabIndex = 0; + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Left; + this.label1.Location = new System.Drawing.Point(6, 2); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(88, 27); + this.label1.TabIndex = 0; + this.label1.Text = "Server : "; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // txtPath + // + this.txtPath.Location = new System.Drawing.Point(508, 5); + this.txtPath.Name = "txtPath"; + this.txtPath.Size = new System.Drawing.Size(341, 21); + this.txtPath.TabIndex = 2; + // + // panel2 + // + this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel2.Controls.Add(this.plSubPart); + this.panel2.Controls.Add(this.panel8); + this.panel2.Controls.Add(this.panel4); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(0, 0); + this.panel2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(1009, 73); + this.panel2.TabIndex = 2; + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer1.Location = new System.Drawing.Point(3, 2); + this.splitContainer1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.panel2); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); + this.splitContainer1.Size = new System.Drawing.Size(1009, 622); + this.splitContainer1.SplitterDistance = 73; + this.splitContainer1.SplitterWidth = 2; + this.splitContainer1.TabIndex = 1; + // + // splitContainer2 + // + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.panel3); + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.panel5); + this.splitContainer2.Size = new System.Drawing.Size(1009, 547); + this.splitContainer2.SplitterDistance = 570; + this.splitContainer2.TabIndex = 1; + // + // panel3 + // + this.panel3.Controls.Add(this.panel6); + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel3.Location = new System.Drawing.Point(0, 0); + this.panel3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel3.Name = "panel3"; + this.panel3.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel3.Size = new System.Drawing.Size(570, 547); + this.panel3.TabIndex = 1; + // + // panel6 + // + this.panel6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel6.Controls.Add(this.gridServer); + this.panel6.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel6.Location = new System.Drawing.Point(3, 2); + this.panel6.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel6.Name = "panel6"; + this.panel6.Size = new System.Drawing.Size(564, 543); + this.panel6.TabIndex = 3; + // + // gridServer + // + this.gridServer.ColumnResizeKey = System.Windows.Forms.Keys.F6; + this.gridServer.Dock = System.Windows.Forms.DockStyle.Fill; + this.gridServer.Location = new System.Drawing.Point(0, 0); + this.gridServer.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + // + // + // + this.gridServer.MasterTemplate.ViewDefinition = tableViewDefinition1; + this.gridServer.Name = "gridServer"; + this.gridServer.Size = new System.Drawing.Size(562, 541); + this.gridServer.TabIndex = 0; + // + // panel5 + // + this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel5.Controls.Add(this.panel7); + this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel5.Location = new System.Drawing.Point(0, 0); + this.panel5.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(435, 547); + this.panel5.TabIndex = 3; + // + // panel7 + // + this.panel7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel7.Controls.Add(this.gridLogFiles); + this.panel7.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel7.Location = new System.Drawing.Point(0, 0); + this.panel7.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel7.Name = "panel7"; + this.panel7.Size = new System.Drawing.Size(433, 545); + this.panel7.TabIndex = 4; + // + // gridLogFiles + // + this.gridLogFiles.ColumnResizeKey = System.Windows.Forms.Keys.F6; + this.gridLogFiles.Dock = System.Windows.Forms.DockStyle.Fill; + this.gridLogFiles.Location = new System.Drawing.Point(0, 0); + this.gridLogFiles.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + // + // + // + this.gridLogFiles.MasterTemplate.ViewDefinition = tableViewDefinition2; + this.gridLogFiles.Name = "gridLogFiles"; + this.gridLogFiles.Size = new System.Drawing.Size(431, 543); + this.gridLogFiles.TabIndex = 1; + // + // panel1 + // + this.panel1.Controls.Add(this.splitContainer1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel1.Name = "panel1"; + this.panel1.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel1.Size = new System.Drawing.Size(1015, 626); + this.panel1.TabIndex = 2; + // + // panel8 + // + this.panel8.Dock = System.Windows.Forms.DockStyle.Left; + this.panel8.Location = new System.Drawing.Point(0, 31); + this.panel8.Name = "panel8"; + this.panel8.Size = new System.Drawing.Size(46, 40); + this.panel8.TabIndex = 1; + // + // plSubPart + // + this.plSubPart.Dock = System.Windows.Forms.DockStyle.Fill; + this.plSubPart.Location = new System.Drawing.Point(46, 31); + this.plSubPart.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.plSubPart.MinimumSize = new System.Drawing.Size(0, 19); + this.plSubPart.Name = "plSubPart"; + this.plSubPart.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.plSubPart.Size = new System.Drawing.Size(961, 40); + this.plSubPart.TabIndex = 2; + // + // btnPath + // + this.btnPath.Location = new System.Drawing.Point(927, 4); + this.btnPath.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnPath.Name = "btnPath"; + this.btnPath.Size = new System.Drawing.Size(66, 23); + this.btnPath.TabIndex = 6; + this.btnPath.Text = "경로열기"; + this.btnPath.UseVisualStyleBackColor = true; + this.btnPath.Click += new System.EventHandler(this.btnPath_Click); + // + // ServerLog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1015, 626); + this.Controls.Add(this.panel1); + this.Name = "ServerLog"; + this.Text = "ServerLog"; + this.WindowState = System.Windows.Forms.FormWindowState.Minimized; + this.Shown += new System.EventHandler(this.ServerLog_Shown); + this.Resize += new System.EventHandler(this.ServerLog_Resize); + this.panel4.ResumeLayout(false); + this.panel4.PerformLayout(); + this.panel2.ResumeLayout(false); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); + this.splitContainer2.ResumeLayout(false); + this.panel3.ResumeLayout(false); + this.panel6.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.gridServer.MasterTemplate)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.gridServer)).EndInit(); + this.panel5.ResumeLayout(false); + this.panel7.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.gridLogFiles.MasterTemplate)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.gridLogFiles)).EndInit(); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ComboBox cboxServer; + private System.Windows.Forms.Button btnConnect; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnFoder; + private System.Windows.Forms.FlowLayoutPanel panel4; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtPath; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.SplitContainer splitContainer2; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.Panel panel6; + private JWH.CONTROL.GridViewEx gridServer; + private System.Windows.Forms.Panel panel5; + private System.Windows.Forms.Panel panel7; + private JWH.CONTROL.GridViewEx gridLogFiles; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.FlowLayoutPanel plSubPart; + private System.Windows.Forms.Panel panel8; + private System.Windows.Forms.Button btnPath; + } +} \ No newline at end of file diff --git a/DDUtilityApp/MESDOWNLOADER/ServerLog.cs b/DDUtilityApp/MESDOWNLOADER/ServerLog.cs new file mode 100644 index 0000000..1016ea9 --- /dev/null +++ b/DDUtilityApp/MESDOWNLOADER/ServerLog.cs @@ -0,0 +1,374 @@ +using JWH.CONTROL; +using JWH.NETWORK; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; +using Telerik.WinControls.Data; +using Telerik.WinControls.UI; + +namespace DDUtilityApp.MESDOWNLOADER +{ + public partial class ServerLog : Form + { + DataSet dsXml; + DataTable dtFiles; + public ServerLog() + { + InitializeComponent(); + SetDataTable(); + GetXmlFile(); + gridLogFiles.CellDoubleClick += Grid_CellDoubleClick; + gridLogFiles.KeyDown += Grid_KeyDown; + } + + + private void ServerLog_Shown(object sender, EventArgs e) + { + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + txtPath.Text = GlobalVariable.Instance.MesDownloadPath; //Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + SetGridView(); + } + private void ServerLog_Resize(object sender, EventArgs e) + { + splitContainer2.SplitterDistance = splitContainer2.ClientSize.Width / 2; + } + private void btnConnect_Click(object sender, EventArgs e) + { + gridLogFiles.DataSource = null; + dtFiles.Rows.Clear(); + LoadFiles(gridServer.ChildRows); + } + private void btnFoder_Click(object sender, EventArgs e) + { + // 폴더 선택 대화 상자를 생성 + using (FolderBrowserDialog folderDialog = new FolderBrowserDialog()) + { + // txtPath.Text에 값이 있으면 해당 경로로 설정, 없으면 문서 폴더로 설정 + if (!string.IsNullOrEmpty(txtPath.Text)) + { + folderDialog.SelectedPath = txtPath.Text; + } + else + { + // 초기값이 없으면 문서 폴더를 기본 경로로 설정 + folderDialog.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + } + + // 폴더 선택 대화 상자가 "확인" 버튼을 클릭했을 경우 + if (folderDialog.ShowDialog() == DialogResult.OK) + { + // 선택한 경로를 텍스트 박스에 표시 + txtPath.Text = folderDialog.SelectedPath; + GlobalVariable.Instance.MesDownloadPath = folderDialog.SelectedPath; + } + } + } + private void btnPath_Click(object sender, EventArgs e) + { + System.Diagnostics.Process.Start("explorer.exe", txtPath.Text); + } + private void cboxServer_SelectedIndexChanged(object sender, EventArgs e) + { + gridServer.DataSource = null; + if (dsXml == null || !dsXml.Tables.Contains("Item")) return; + + int serverId = 0; + if (cboxServer.SelectedValue == null) return; + if (cboxServer.SelectedValue is DataRowView dataRowView) + { + serverId = Convert.ToInt32(dataRowView["Server_Id"]); // Replace "ColumnName" with the actual column name + } + else + { + serverId = Convert.ToInt32(cboxServer.SelectedValue); + } + + DataTable filteredTable = dsXml.Tables["Item"].Clone(); + + + + // LINQ를 사용하여 Server Item Server_Id 기준으로 조인 + var query = from table1 in dsXml.Tables["Server"].AsEnumerable() + join table2 in dsXml.Tables["Item"].AsEnumerable() + on table1.Field("Server_Id") equals table2.Field("Server_Id") + where table2.Field("Server_Id") == serverId // 필터 조건을 추가 + select new + { + name = table1.Field("name"), + nameap = table2.Field("name"), + url = table2.Field("url"), + dir = table2.Field("dir"), + conkey = table2.Field("conkey"), + Server_Id = table2.Field("Server_Id") + }; + + gridServer.DataSource = query; + var uniqueNames = query.Select(x => x.nameap).Distinct(); + UpdateCheckBoxes(uniqueNames); + SetGridView(); + } + private void Grid_KeyDown(object sender, KeyEventArgs e) //jhlim 20250202 + { + if (e.KeyCode == Keys.Enter) + { + Grid_CellDoubleClick((GridViewEx)sender, null); + } + } + private bool isProcessing = false; // 중복 실행 방지 플래그 + + private async void Grid_CellDoubleClick(object sender, GridViewCellEventArgs e) // jhlim 20250202 + { + if (isProcessing) return; // 이미 실행 중이면 종료 + + isProcessing = true; // 실행 상태 설정 + + RadGridView gd = sender.GetType().Name.Contains("GridDataCellElement") ? + ((GridDataCellElement)sender)?.RowElement?.GridControl : (GridViewEx)sender; + + try + { + List mergefileList = new List(); + bool rtnBool = false; + int totalFiles = gd.SelectedRows.Count; + + if (totalFiles == 0) + { + MessageBox.Show("선택된 파일이 없습니다."); + isProcessing = false; + return; + } + + // 프로그래스 바 폼 생성 및 표시 + using (ProgressForm progressForm = new ProgressForm(totalFiles)) + { + progressForm.Show(); + progressForm.UpdateProgress(string.Empty, 0); // 초기 상태 업데이트 + + int processedCount = 0; + + // 파일 다운로드 비동기 처리 + foreach (GridViewRowInfo row in gd.SelectedRows) + { + var host = Util.GetStr(row.Cells["url"].Value); + var dir = row.Cells["dir"].Value; + var fileName = row.Cells["FileName"].Value; + var userId = Util.GetStr(row.Cells["userId"].Value); + var password = Util.GetStr(row.Cells["password"].Value); + + // 진행 상태 업데이트 + processedCount++; + progressForm.UpdateProgress(fileName?.ToString(), processedCount); + + FtpsClient.Disconnect(); + FtpsClient.Initialize(host, userId, password); + + rtnBool = await Task.Run(() => + FtpsClient.DownloadFtpsFile($"{dir}/{fileName}", $"{txtPath.Text}\\{fileName}") + ); + + if (!rtnBool) + { + MessageBox.Show($"{fileName} 다운로드에 실패했습니다."); + break; + } + + mergefileList.Add($"{txtPath.Text}\\{fileName}"); + } + + progressForm.Close(); // 프로그래스 바 폼 닫기 + } + + // 다운로드 완료 후 병합 처리 + if (rtnBool) + { + if (totalFiles > 1) + { + Util.GetFileMerge(mergefileList); + MessageBox.Show($"{totalFiles}개의 파일을 머지 하였습니다."); + } + else + { + MessageBox.Show($"{gd.SelectedRows[0].Cells["Name"].Value} 파일을 저장 하였습니다."); + } + } + } + catch (Exception ex) + { + MessageBox.Show($"에러 발생: {ex.Message}"); + } + finally + { + isProcessing = false; // 실행 완료 후 플래그 해제 + } + } + + private void GetXmlFile() + { + string xmlPath = ConfigurationManager.AppSettings["BULK_VIEWER"]; + dsXml = XmlToDsConverter.ConvertXmlToDataSet(xmlPath); + + if (dsXml == null || dsXml.Tables.Count == 0) + { + MessageBox.Show("XML 데이터를 불러올 수 없습니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + PopulateComboBox(); + } + private void PopulateComboBox() + { + if (dsXml == null || !dsXml.Tables.Contains("Server")) return; + + cboxServer.DataSource = dsXml.Tables["Server"]; + cboxServer.DisplayMember = "name"; // 사용자가 볼 값 (서버 이름) + cboxServer.ValueMember = "Server_Id"; // 내부적으로 사용할 값 (서버 ID) + cboxServer.SelectedIndex = 0; + } + private void SetDataTable() + { + dtFiles = new DataTable(); + dtFiles.Columns.Add("Name", typeof(string)); + dtFiles.Columns.Add("nameap", typeof(string)); + dtFiles.Columns.Add("FileName", typeof(string)); + dtFiles.Columns.Add("Size", typeof(string)); + dtFiles.Columns.Add("Modified", typeof(string)); + dtFiles.Columns.Add("Type", typeof(string)); + dtFiles.Columns.Add("url", typeof(string)); + dtFiles.Columns.Add("dir", typeof(string)); + dtFiles.Columns.Add("userId", typeof(string)); + dtFiles.Columns.Add("password", typeof(string)); + } + private void SetGridView() + { + gridServer.Columns.Clear(); + gridLogFiles.Columns.Clear(); + + gridLogFiles.MultiSelect = true; + gridLogFiles.SelectionMode = GridViewSelectionMode.FullRowSelect; + + gridServer.AutoGenerateColumns = false; + gridServer.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None; // 컬럼 크기 자동 조정 끄기 + // 컬럼 추가 + gridServer.Columns.Add(new GridViewTextBoxColumn("name") { HeaderText = "시스템명", Width = 100, ReadOnly = true }); + gridServer.Columns.Add(new GridViewTextBoxColumn("nameap") { HeaderText = "서버명", Width = 100, ReadOnly = true }); + gridServer.Columns.Add(new GridViewTextBoxColumn("url") { HeaderText = "FTP 서버", Width = 300, ReadOnly = true }); + gridServer.Columns.Add(new GridViewTextBoxColumn("dir") { HeaderText = "FTP 폴더", Width = 300, ReadOnly = true }); + gridServer.Columns.Add(new GridViewTextBoxColumn("conkey") { IsVisible = false }); + + gridLogFiles.AutoGenerateColumns = false; + gridLogFiles.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None; // 컬럼 크기 자동 조정 끄기 + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("name") { HeaderText = "시스템", Width = 100, ReadOnly = true }); + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("nameap") { HeaderText = "서버", Width = 100, ReadOnly = true }); + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("FileName") { HeaderText = "파일명", Width = 300, ReadOnly = true }); + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("Size") { HeaderText = "파일 크기", Width = 100, TextAlignment = ContentAlignment.MiddleRight, ReadOnly = true }); + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("Modified") { HeaderText = "수정 날짜", Width = 150, TextAlignment = ContentAlignment.MiddleCenter, ReadOnly = true }); + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("Type") { HeaderText = "파일 유형", Width = 100, ReadOnly = true }); + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("url") { IsVisible = false }); + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("dir") { IsVisible = false }); + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("userId") { IsVisible = false }); + gridLogFiles.Columns.Add(new GridViewTextBoxColumn("password") { IsVisible = false }); + + FilterGridByNameap(); + } + private void FilterGridByNameap() + { + + var checkedNames = plSubPart.Controls.OfType() + .Where(c => c.Checked) + .Select(c => c.Text) + .ToList(); + + // 기존 필터 제거 + gridServer.FilterDescriptors.Clear(); + gridLogFiles.FilterDescriptors.Clear(); + // 체크된 항목이 없으면 전체 표시 + if (checkedNames == null || checkedNames.Count == 0) + return; + + // 필터 생성 + CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor(); + compositeFilter.LogicalOperator = FilterLogicalOperator.Or; + + foreach (var name in checkedNames) + { + compositeFilter.FilterDescriptors.Add(new FilterDescriptor("nameap", FilterOperator.IsEqualTo, name)); + } + + // 필터 적용 + gridServer.FilterDescriptors.Add(compositeFilter); + gridLogFiles.FilterDescriptors.Add(compositeFilter); + } + private void UpdateCheckBoxes(IEnumerable uniqueNames) + { + // 기존 체크박스 삭제 + plSubPart.Controls.Clear(); + + // 이름을 정렬 + var sortedNames = uniqueNames.OrderBy(name => name); + + // 체크박스 동적 생성 + foreach (var name in sortedNames) + { + CheckBox checkBox = new CheckBox(); + checkBox.Text = name; + checkBox.AutoSize = true; + checkBox.Checked = true; // 기본값 체크 상태 + + // 체크박스 이벤트 + checkBox.CheckedChanged += (s, ev) => + { + FilterGridByNameap(); + }; + + // 패널에 추가 + plSubPart.Controls.Add(checkBox); + } + } + private void LoadFiles(GridViewChildRowCollection rows) + { + try + { + foreach (GridViewRowInfo row in gridServer.ChildRows) // 필터된 행 제외 + { + if (row.IsVisible && row.Cells.Count > 1) // 표시된 행만 처리 + { + var path = Util.GetStr(row.Cells[3].Value); + string[] userInfo = Util.GetUser(Util.GetStr(row.Cells[4].Value)); + + if (userInfo != null) + { + FtpsClient.Initialize(Util.GetStr(row.Cells[2].Value), userInfo[0], userInfo[1]); + + // FTPS 서버에서 파일 목록 가져오기 + var fileList = FtpsClient.GetFtpsList(path); + + if (fileList == null || fileList.Length == 0) + { + MessageBox.Show("파일 목록을 가져올 수 없습니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + // 데이터 테이블 생성 후 바인딩 + foreach (var item in fileList) + { + dtFiles.Rows.Add(row.Cells["name"].Value, row.Cells["nameap"].Value, item.Name, item.Size.ToString("N0") + , item.Modified.ToString("yyyy-MM-dd HH:mm:ss"), item.Type, row.Cells["url"].Value, row.Cells["dir"].Value, userInfo[0], userInfo[1]); + } + + } + } + } + gridLogFiles.DataSource = dtFiles; + SetGridView(); + } + catch (Exception ex) + { + MessageBox.Show($"파일 목록 로드 오류: {ex.Message}", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/DDUtilityApp/MESDOWNLOADER/Utili.cs b/DDUtilityApp/MESDOWNLOADER/Utili.cs new file mode 100644 index 0000000..b82d3a6 --- /dev/null +++ b/DDUtilityApp/MESDOWNLOADER/Utili.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; + +namespace DDUtilityApp.MESDOWNLOADER +{ + public static class Util + { + public static int GetFileMerge(List filePaths) + { + int rtnBint = 9; // 기본 실패 코드 + + if (filePaths.Count == 0) + { + Console.WriteLine("병합할 파일이 없습니다."); + return 1; + } + + // 실행 시간 측정을 위한 Stopwatch 시작 + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); + + // 첫 번째 파일명에서 경로 제외 + string firstFileName = Path.GetFileName(filePaths.First()); + string mergedFileName = "merge_" + firstFileName; + + // 병합된 파일을 저장할 경로 (첫 번째 파일과 동일한 폴더) + string mergedFilePath = Path.Combine(Path.GetDirectoryName(filePaths.First()), mergedFileName); + + try + { + using (StreamWriter writer = new StreamWriter(mergedFilePath, false)) // false: 새 파일 생성 + { + foreach (string file in filePaths) + { + if (File.Exists(file)) + { + using (StreamReader reader = new StreamReader(file)) + { + writer.Write(reader.ReadToEnd()); + } + Console.WriteLine($"{file} -> 병합 완료"); + } + else + { + Console.WriteLine($"파일 없음: {file}"); + } + } + } + + // 실행 시간 측정 종료 + stopwatch.Stop(); + Console.WriteLine($"모든 파일이 {mergedFileName}로 병합되었습니다."); + Console.WriteLine($"병합 실행 시간: {stopwatch.ElapsedMilliseconds} ms"); + + rtnBint = 0; // 성공 코드 + } + catch (Exception ex) + { + Console.WriteLine($"오류 발생: {ex.Message}"); + } + + return rtnBint; + } + + public static string GetStr(object str ) + { + return string.IsNullOrEmpty(str.ToString())?"": str.ToString(); + } + + public static string GetBase64(string base64, string type = "decoded") + { + string rtnStr = string.Empty; + if (string.IsNullOrEmpty(base64) == false) + { + if (type == "decoded") + // Base64 디코딩 + rtnStr = Encoding.UTF8.GetString(Convert.FromBase64String(base64)); + else + // Base64 디코딩 + rtnStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(base64)); + } + return rtnStr; + } + + public static string[] GetUser(string userInfo) + { + string[] rtnArry = null; + if (string.IsNullOrEmpty(userInfo) == false) + { + rtnArry = GetBase64(userInfo).Split(':'); + } + return rtnArry; + } + } +} \ No newline at end of file diff --git a/DDUtilityApp/MESDOWNLOADER/XmlToDsConverter.cs b/DDUtilityApp/MESDOWNLOADER/XmlToDsConverter.cs new file mode 100644 index 0000000..e665e52 --- /dev/null +++ b/DDUtilityApp/MESDOWNLOADER/XmlToDsConverter.cs @@ -0,0 +1,55 @@ +using System; +using System.Data; +using System.IO; +using System.Xml; + +namespace DDUtilityApp.MESDOWNLOADER +{ + + public static class XmlToDsConverter + { + public static DataSet ConvertXmlToDataSet(string xmlFilePath) + { + try + { + DataSet dataSet = new DataSet(); + using (StreamReader reader = new StreamReader(xmlFilePath, System.Text.Encoding.UTF8)) + { + dataSet.ReadXml(reader); + } + return dataSet; + } + catch (Exception ex) + { + Console.WriteLine($"XML 변환 오류: {ex.Message}"); + return null; + } + } + + + public static void PrintDataSet(DataSet dataSet) + { + if (dataSet == null) + { + Console.WriteLine("데이터셋이 비어 있습니다."); + return; + } + + foreach (DataTable table in dataSet.Tables) + { + Console.WriteLine($"테이블: {table.TableName}"); + foreach (DataRow row in table.Rows) + { + foreach (DataColumn column in table.Columns) + { + Console.WriteLine($"{column.ColumnName}: {row[column]}"); + } + } + } + } + } +} +// 사용 예제 +// string xmlPath = "ViewList.xml"; +// DataSet ds = XmlToDataSetConverter.ConvertXmlToDataSet(xmlPath); +// XmlToDataSetConverter.PrintDataSet(ds); diff --git a/DDUtilityApp/Program.cs b/DDUtilityApp/Program.cs index b5d46b0..d994dd3 100644 --- a/DDUtilityApp/Program.cs +++ b/DDUtilityApp/Program.cs @@ -70,15 +70,15 @@ namespace DDUtilityApp #region [ 버튼 생성 정보 ] frmMain.Buttons.Add("EIS Log Viewer", new EisParser0()); - //frmMain.Buttons.Add("MES Log Download", typeof(SPECDOCUMENT.FrmSpecDocument)); // 위치 - //frmMain.Buttons.Add("MIS Log Viewer", new AgvParser()); // 제거 + frmMain.Buttons.Add("MES Log Download", typeof(MESDOWNLOADER.ServerLog)); // 위치 + 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)); +// frmMain.Buttons.Add("MES Log Download", typeof(MESDOWNLOADER.ServerLog)); #endif #endregion