Esempio n. 1
0
        private bool ProgramUpdate(string copy_name)
        {
            try
            {
                if (lvRun_Msg.InvokeRequired)
                {
                    lvRun_Msg.Invoke(new UpdateFile(ProgramUpdate), new object[] { copy_name });
                }
                else
                {
                    string exe_name = Path.GetFileName(copy_name);

                    foreach (ListViewItem item in lvRun_Msg.CheckedItems)
                    {
                        string run_name = item.SubItems[0].Text;
                        string run_path = item.SubItems[1].Text;

                        if (String.Compare(run_name, exe_name, true) == 0)
                        {
                            RunProcess run      = new RunProcess();
                            string     sou_name = Path.GetDirectoryName(run_path) + copy_name;

                            if (File.Exists(sou_name))
                            {
                                UpdateOn = true;
                                // 프로그램이 실행 중이면
                                if (run.IsRun(run_name))
                                {
                                    AddLog(Log.Type.LOG_RUN, "Kill {0} Program", run_name);
                                    run.Kill(Path.GetFileNameWithoutExtension(run_name));
                                    Delay(100);
                                }
                                AddLog(Log.Type.LOG_RUN, "Copy {0} -> {1}", sou_name, run_path);
                                File.Copy(sou_name, run_path, true);
                                Delay(100);
                                AddLog(Log.Type.LOG_RUN, "{0} Program Copy Ok!", run_name);

                                UpdateOn = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AddLog(Log.Type.LOG_ERR, "Error ProgramUpdate Name {0}:{1}", copy_name, ex.Message);
            }
            return(true);
        }
Esempio n. 2
0
        private void timer_RunCheck_Tick(object sender, EventArgs e)
        {
            try
            {
                if (UpdateOn)
                {
                    return;
                }
                if (BI.ReBootingOn)
                {
                    // Test 용
                    //Def.ReBootingTime = DateTime.Now.ToString("HH:mm");
                    if (BI.Week[(Byte)DateTime.Now.DayOfWeek])
                    {
                        string cur_time = DateTime.Now.ToString("HH:mm");
                        if (cur_time == BI.ReBootingTime)
                        {
                            RunProcess.ComputerRestart();
                            ExitOn = true;
                            Application.Exit();
                        }
                    }
                }

                if (lvRun_Msg.Items.Count > 0)
                {
                    RunProcess run = new RunProcess();

                    if (run.IsRun("WerFault"))
                    {
                        run.Kill("WerFault");
                        // 에러 메시지 창이 뜨면 뭐가 에러 난건지 구분을 못한다. 그래서 다 죽인다.
                        foreach (ListViewItem item in lvRun_Msg.CheckedItems)
                        {
                            string exe_name = item.SubItems[0].Text;
                            run.Kill(Path.GetFileNameWithoutExtension(exe_name));
                        }
                    }

                    for (int i = 0; i < lvRun_Msg.Items.Count; i++)
                    {
                        ListViewItem item         = lvRun_Msg.CheckedItems[i];
                        string       exe_name     = item.SubItems[0].Text;
                        string       exe_path     = item.SubItems[1].Text;
                        int          ReStart_Time = Convert.ToInt32(item.SubItems[2].Text);
                        int          ReStart_Co   = Convert.ToInt32(item.SubItems[3].Text);

                        if (run.IsRunClass(exe_path))
                        {
                            run.Kill(Path.GetFileNameWithoutExtension(exe_name));
                        }

                        if (run.IsRun(exe_path))
                        {
                            // 실행 중 일때
                            if (ReStart_Time >= 0)
                            {
                                ReStart_Time--;
                                if (ReStart_Time <= 0)
                                {
                                    run.Kill(Path.GetFileNameWithoutExtension(exe_name));
                                    ReStart_Time = BI.CheckExe[i].ReStart_MaxTime;
                                    AddLog(Log.Type.LOG_RUN, "Kill Process : {0}", exe_name);
                                }
                                item.SubItems[2].Text = ReStart_Time.ToString();
                            }
                        }
                        else
                        {
                            // 실행중이 아닐때
                            if (run.Start(exe_path))        // 에러가 아닐때
                            {
                                item.SubItems[2].Text = BI.CheckExe[i].ReStart_MaxTime.ToString();
                                ReStart_Co++;
                                item.SubItems[3].Text = ReStart_Co.ToString();
                                AddLog(Log.Type.LOG_RUN, "Run Process : {0}", exe_name);
                            }
                            else
                            {
                                AddLog(Log.Type.LOG_ERR, "해당파일이 없거나 실행하지 못했습니다.");
                                item.BackColor = Color.Gray;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AddLog(Log.Type.LOG_ERR, "Error timer_RunCheck_Tick:{0}", ex.Message);
            }
        }