MES Log Download

This commit is contained in:
2025-02-28 16:47:40 +09:00
parent f6d430550f
commit 8b39c28efb
7 changed files with 54 additions and 13 deletions

View File

@@ -1,10 +1,12 @@
using JWH.CONTROL;
using JWH.NETWORK;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -188,12 +190,21 @@ namespace DDUtilityApp.MESDOWNLOADER
{
if (totalFiles > 1)
{
Util.GetFileMerge(mergefileList);
string filename = Util.GetFileMerge(mergefileList);
MessageBox.Show($"{totalFiles}개의 파일을 머지 하였습니다.");
System.Diagnostics.Process.Start(filename);
}
else
{
MessageBox.Show($"{gd.SelectedRows[0].Cells["Name"].Value} 파일을 저장 하였습니다.");
string fileName = mergefileList[0];
string extension = Path.GetExtension(fileName);
if (string.Compare(extension, ".Log", true) != 0)
{
fileName += ".Log";
File.Move(mergefileList[0], fileName);
}
System.Diagnostics.Process.Start(fileName);
}
}
}

View File

@@ -9,14 +9,14 @@ namespace DDUtilityApp.MESDOWNLOADER
{
public static class Util
{
public static int GetFileMerge(List<string> filePaths)
public static string GetFileMerge(List<string> filePaths)
{
int rtnBint = 9; // 기본 실패 코드
string mergedFilePath = string.Empty;
if (filePaths.Count == 0)
{
Console.WriteLine("병합할 파일이 없습니다.");
return 1;
return mergedFilePath;
}
// 실행 시간 측정을 위한 Stopwatch 시작
@@ -26,9 +26,10 @@ namespace DDUtilityApp.MESDOWNLOADER
// 첫 번째 파일명에서 경로 제외
string firstFileName = Path.GetFileName(filePaths.First());
string mergedFileName = "merge_" + firstFileName;
// 병합된 파일을 저장할 경로 (첫 번째 파일과 동일한 폴더)
string mergedFilePath = Path.Combine(Path.GetDirectoryName(filePaths.First()), mergedFileName);
mergedFilePath = Path.Combine(Path.GetDirectoryName(filePaths.First()), mergedFileName);
string extension = Path.GetExtension(mergedFilePath);
if (string.Compare(extension, ".Log", true) != 0) mergedFilePath = mergedFilePath + ".Log";
try
{
@@ -56,14 +57,14 @@ namespace DDUtilityApp.MESDOWNLOADER
Console.WriteLine($"모든 파일이 {mergedFileName}로 병합되었습니다.");
Console.WriteLine($"병합 실행 시간: {stopwatch.ElapsedMilliseconds} ms");
rtnBint = 0; // 성공 코드
return mergedFilePath;
}
catch (Exception ex)
{
Console.WriteLine($"오류 발생: {ex.Message}");
}
return rtnBint;
return mergedFilePath;
}
public static string GetStr(object str )