프로젝트 구조 개선 및 README.md 추가
- UIControl 프로젝트 구조 변경 (CapCleaningControl → Sub/UIControl) - arAjinextek 라이브러리 통합 및 구조 개선 - 새로운 arAjinextek_Union 프로젝트 추가 - 솔루션 파일에 README.md 추가 - QR 모드에서 WMS RCV 태그 인식 기능 강화 - 데이터베이스 스키마 업데이트 및 관련 클래스 수정 - 프린터 및 바코드 장치 연동 로직 개선 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -20,50 +20,12 @@ namespace Project
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
//중복실행방지
|
||||
var guidAttr = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), true);
|
||||
if (guidAttr != null)
|
||||
{
|
||||
var guida = (GuidAttribute)guidAttr[0];
|
||||
var guidstr = guida.Value;
|
||||
Mutex mtx = new Mutex(true, guidstr);
|
||||
var success = mtx.WaitOne(new TimeSpan(0, 0, 1));
|
||||
if (success == false)
|
||||
{
|
||||
//MessageBox.Show("중복실행 불가\n\n프로그램이 실행 중 입니다");
|
||||
|
||||
//"※ Amkor Standard Label Attach"
|
||||
var list = System.Diagnostics.Process.GetProcesses();
|
||||
var prc = list.Where(t => t.ProcessName == "Amkor" && t.MainModule.FileVersionInfo.FileDescription.Contains("Amkor Standard Label")).FirstOrDefault();
|
||||
if (prc != null)
|
||||
{
|
||||
var dlg = MessageBox.Show(
|
||||
"중복 실행이 감지 되었습니다.\r\n" +
|
||||
"현재 실행중인 프로그램을 종료 할까요?\r\n" +
|
||||
"프로그램은 다시 실행하세요", "중복실행", MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question);
|
||||
|
||||
if (dlg == DialogResult.Yes)
|
||||
{
|
||||
prc.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//if(IsAdmin()==false)
|
||||
//{
|
||||
// var dlg = MessageBox.Show(
|
||||
// "이 프로그램은 관리자 모드로 실행해야 합니다", "중복실행", MessageBoxButtons.YesNo,
|
||||
// MessageBoxIcon.Question);
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
if (CheckSingleInstance() == false) return;
|
||||
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
Application.Run(new FMain());
|
||||
@@ -72,7 +34,7 @@ namespace Project
|
||||
static bool IsAdmin()
|
||||
{
|
||||
var identy = WindowsIdentity.GetCurrent();
|
||||
if(identy != null)
|
||||
if (identy != null)
|
||||
{
|
||||
var princ = new WindowsPrincipal(identy);
|
||||
return princ.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
@@ -80,20 +42,81 @@ namespace Project
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 중복실행 방지 체크
|
||||
/// </summary>
|
||||
/// <returns>단일 인스턴스인 경우 true, 중복실행인 경우 false</returns>
|
||||
static bool CheckSingleInstance()
|
||||
{
|
||||
string processName = Process.GetCurrentProcess().ProcessName;
|
||||
Process[] processes = Process.GetProcessesByName(processName);
|
||||
|
||||
if (processes.Length > 1)
|
||||
{
|
||||
// 중복실행 감지
|
||||
string message = $"⚠️ {Application.ProductName} 프로그램이 이미 실행 중입니다!\n\n" +
|
||||
"동시에 여러 개의 프로그램을 실행할 수 없습니다.\n\n" +
|
||||
"해결방법을 선택하세요:";
|
||||
|
||||
var result = MessageBox.Show(message + "\n\n예(Y): 기존 프로그램을 종료하고 새로 시작\n아니오(N): 현재 실행을 취소",
|
||||
"중복실행 감지",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Warning);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
// 기존 프로세스들을 종료
|
||||
try
|
||||
{
|
||||
int currentProcessId = Process.GetCurrentProcess().Id;
|
||||
foreach (Process process in processes)
|
||||
{
|
||||
if (process.Id != currentProcessId)
|
||||
{
|
||||
process.Kill();
|
||||
process.WaitForExit(3000); // 3초 대기
|
||||
}
|
||||
}
|
||||
|
||||
// 잠시 대기 후 계속 진행
|
||||
Thread.Sleep(1000);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"기존 프로그램 종료 중 오류가 발생했습니다:\n{ex.Message}\n\n" +
|
||||
"작업관리자에서 수동으로 종료해주세요.",
|
||||
"오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 현재 실행을 취소
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true; // 단일 인스턴스
|
||||
}
|
||||
|
||||
|
||||
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
|
||||
string emsg = "Fatal Error(UHE)\n\n" + e.ExceptionObject.ToString();
|
||||
PUB.log.AddE(emsg);
|
||||
PUB.log.Flush();
|
||||
if (PUB.log != null)
|
||||
{
|
||||
PUB.log.AddE(emsg);
|
||||
PUB.log.Flush();
|
||||
}
|
||||
|
||||
|
||||
UTIL.SaveBugReport(emsg);
|
||||
Shutdown();
|
||||
|
||||
var f = new AR.Dialog.fErrorException(emsg);
|
||||
f.ShowDialog();
|
||||
|
||||
using (var f = new AR.Dialog.fErrorException(emsg))
|
||||
f.ShowDialog();
|
||||
Application.ExitThread();
|
||||
}
|
||||
|
||||
@@ -114,13 +137,15 @@ namespace Project
|
||||
{
|
||||
|
||||
string emsg = "Fatal Error(ATE)\n\n" + e.Exception.ToString();
|
||||
//emsg += "stack:" + e.Exception.StackTrace;
|
||||
PUB.log.AddE(emsg);
|
||||
PUB.log.Flush();
|
||||
if(PUB.log != null)
|
||||
{
|
||||
PUB.log.AddE(emsg);
|
||||
PUB.log.Flush();
|
||||
}
|
||||
UTIL.SaveBugReport(emsg);
|
||||
Shutdown();
|
||||
var f = new AR.Dialog.fErrorException(emsg);
|
||||
f.ShowDialog();
|
||||
using (var f = new AR.Dialog.fErrorException(emsg))
|
||||
f.ShowDialog();
|
||||
Application.ExitThread();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user