Example #1
0
        private void btOk_Click(object sender, EventArgs e)
        {
            RunProcess run = new RunProcess();

            BI.ReBootingOn                   = cbSetup_Rebooting.Checked;
            BI.Week[0]                       = cbSetup_Mon.Checked;
            BI.Week[1]                       = cbSetup_Tue.Checked;
            BI.Week[2]                       = cbSetup_Wed.Checked;
            BI.Week[3]                       = cbSetup_Thu.Checked;
            BI.Week[4]                       = cbSetup_Fri.Checked;
            BI.Week[5]                       = cbSetup_Sat.Checked;
            BI.Week[6]                       = cbSetup_Sun.Checked;
            dtpSetup_RebootTime.Format       = DateTimePickerFormat.Custom;
            dtpSetup_RebootTime.CustomFormat = "HH:mm";
            BI.ReBootingTime                 = dtpSetup_RebootTime.Text;

            BI.AutoRunOn = cbSetup_AutoRun.Checked;
            if (BI.AutoRunOn)
            {
                run.SetAutoRunProgram(true);
            }
            else
            {
                run.SetAutoRunProgram(false);
            }

            BI.TrayIconOn = cbSetup_TrayIcon.Checked;

            //Launcher.Def.WriteReg();
            this.Close();
        }
Example #2
0
        public void InitializeForm(BaseInfo bi)
        {
            BI = bi;
            RunProcess run = new RunProcess();

            cbSetup_Rebooting.Checked = BI.ReBootingOn;
            cbSetup_Mon.Checked       = BI.Week[0];
            cbSetup_Tue.Checked       = BI.Week[1];
            cbSetup_Wed.Checked       = BI.Week[2];
            cbSetup_Thu.Checked       = BI.Week[3];
            cbSetup_Fri.Checked       = BI.Week[4];
            cbSetup_Sat.Checked       = BI.Week[5];
            cbSetup_Sun.Checked       = BI.Week[6];
            dtpSetup_RebootTime.Text  = BI.ReBootingTime;

            if (run.IsAutoRunProgram())
            {
                cbSetup_AutoRun.Checked = true;
            }
            else
            {
                cbSetup_AutoRun.Checked = false;
            }
            cbSetup_TrayIcon.Checked = BI.TrayIconOn;
        }
Example #3
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);
        }
Example #4
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);
            }
        }