File name
Commit message
Commit date
File name
Commit message
Commit date
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace SignusKH
{
public partial class Form1 : Form
{
const int MAX_PROCESS = 10;
private Process[] m_ps = new Process[MAX_PROCESS];
private List<string> m_lstExe = new List<string>();
public Form1()
{
InitializeComponent();
}
private void ToolStripMenuItem_Close_Click(object sender, EventArgs e)
{
Program.PostMessage((IntPtr)0xffff, Program.messageQuit, 0, 0);
for (int i = 0; i < MAX_PROCESS; i++)
{
if (m_ps[i] != null)
{
m_ps[i].Kill();
m_ps[i] = null;
}
}
this.Close();
}
private string m_strUrl = "http://192.168.1.17:8080";
private void Form1_Load(object sender, EventArgs e)
{
string AppPath = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\"));
string strChrome1 = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
string strChrome2 = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
string strChrome3 = "C:\\Users\\CUPC\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe";
if (System.IO.File.Exists(strChrome1))
this.m_lstExe.Add(strChrome1);
else if (System.IO.File.Exists(strChrome2))
this.m_lstExe.Add(strChrome2);
else if (System.IO.File.Exists(strChrome3))
this.m_lstExe.Add(strChrome3);
// 크롬은 한번만 실행하고 재실행 안함
UpdateProgram(0);
this.m_lstExe.Clear();
this.m_lstExe.Add(AppPath + string.Format("\\KHSCALE-1.exe"));
this.m_lstExe.Add(AppPath + string.Format("\\KHSCALE-2.exe"));
this.m_lstExe.Add(AppPath + string.Format("\\KHSCALE.exe"));
//this.m_lstExe.Add(AppPath + string.Format("\\YdtechInTemp.exe"));
//this.m_lstExe.Add(AppPath + string.Format("\\YdtechOutTemp.exe"));
//this.m_lstExe.Add(AppPath + string.Format("\\YdTechGetData.exe"));
timer1.Enabled = true;
timer1.Interval = 500;
this.Visible = false; //창을 보이지 않게 한다.
this.ShowIcon = false; //작업표시줄에서 제거.
}
private int m_nPrevSec = -1;
private void timer1_Tick(object sender, EventArgs e)
{
DateTime dtNow = DateTime.Now;
if (m_nPrevSec == dtNow.Second) return;
m_nPrevSec = dtNow.Second;
UpdateProgram(m_nPrevSec % 10);
//Program.MoveFiles("C:\\EDIM\\Edge Advance 16P\\CSV", "C:\\EDIM\\Edge Advance 16P\\CSV1");
}
public void UpdateProgram(int index)
{
U3Util.ErrorLog(index.ToString() + " Update");
if (index < 0) return;
if (index >= this.m_lstExe.Count()) return;
string AppExe = this.m_lstExe[index];
U3Util.ErrorLog(AppExe);
if (System.IO.File.Exists(AppExe) == false)
{
U3Util.ErrorLog(AppExe + " 찾을 수 없음");
return;
}
string AppPath = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\"));
if (m_ps[index] == null)
{
m_ps[index] = new Process();
}
else
{
try
{
if (m_ps[index].HasExited)
{
m_ps[index].Close();
m_ps[index] = new System.Diagnostics.Process();
}
else
{
return;
}
}
catch
{
return;
}
}
if (AppExe.IndexOf("chrome") > 0)
{
m_ps[index].StartInfo.FileName = AppExe;
m_ps[index].StartInfo.WorkingDirectory = AppPath;
m_ps[index].StartInfo.Arguments = " -kiosk -fullscreen " + m_strUrl;
m_ps[index].StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
m_ps[index].Start();
return;
}
U3Util.ErrorLog(AppExe + " 실행");
m_ps[index].StartInfo.FileName = AppExe;
m_ps[index].StartInfo.WorkingDirectory = AppPath;
m_ps[index].StartInfo.Arguments = "";
m_ps[index].StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
m_ps[index].Start();
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
Program.PostMessage((IntPtr)0xffff, Program.messageQuit, 0, 0);
for (int i = 0; i < MAX_PROCESS; i++)
{
if (m_ps[i] != null)
{
m_ps[i].Kill();
m_ps[i] = null;
}
}
}
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Visible = false; //창을 보이지 않게 한다.
this.ShowIcon = false; //작업표시줄에서 제거.
//m_notify.Visible = true; //트레이 아이콘을 표시한다.
}
}
}
}