Beispiel #1
0
        static void Main(string[] args)
        {
            if (!onlyOneMutex())
            {
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (args.Length >= 4)
            {
                applicationInfo = new Applications()
                {
                    Name      = args[0],
                    Path      = args[1],
                    StartArgs = obainExtraArgs(args),
                    Cycle     = args[args.Length - 1]
                };
                MessageBox.Show(applicationInfo.StartArgs);
            }

            if (!File.Exists($@"{applicationInfo.Path}\{applicationInfo.Name}.exe"))
            {
                MessageBox.Show($"程序{applicationInfo.Name}.exe 不存在,守护进程失败!");
                return;
            }

            QuartzManager.AddJob <AutoRestart>("AutoRestart", int.Parse(applicationInfo.Cycle) == 0 ? 10000 : int.Parse(applicationInfo.Cycle));
            Application.Run(new frmProtect());
        }
Beispiel #2
0
        /// <summary>
        /// 开启守护
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnStartProtect_Click(object sender, EventArgs e)
        {
            int cycleTime = 0;

            if (applicationInfos.Count > 0)
            {
                cycleTime = int.Parse(applicationInfos[0].Cycle);
                foreach (var applicationInfo in applicationInfos)
                {
                    if (!File.Exists($@"{applicationInfo.Path}\{applicationInfo.Name}.exe"))
                    {
                        MessageBox.Show($"程序{applicationInfo.Name}.exe 不存在,开始守护进程失败,请检查配置文件模板!"
                                        , "络町软件");
                        return;
                    }
                }
            }
            QuartzManager.AddJob <AutoRestart>("AutoRestart", cycleTime == 0 ? 10000 : cycleTime);
            btnStartProtect.Enabled = false;
        }
Beispiel #3
0
        /// <summary>
        /// 每半小时检测是否有更新
        /// </summary>
        public static void TimingCheckUpdate()
        {
            string timingCheckUpdate = System.Configuration.ConfigurationManager.AppSettings["TimingCheckUpdate"];

            QuartzManager.AddJob <Updater>("TimingCheckUpdate", timingCheckUpdate);
        }