Example #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //timer1.Enabled = false;
            //DirectoryInfo TheFolder = new DirectoryInfo(path);
            //foreach (FileInfo NextFile in TheFolder.GetFiles("L2CommError*"))
            //{
            //    if (NextFile.LastWriteTime > lasttime)
            //    {
            //        lasttime = NextFile.LastWriteTime;
            //    }
            //}
            //label2.Text = lasttime.ToString("hh:mm:ss");

            //if ((DateTime.Now - lasttime).TotalSeconds > 100)
            //{
            //    CleanMainExe("L2Comm");
            //    Thread.Sleep(1000);
            //    ReStartExe("L2Comm.bat");
            //    //重启通讯后,上次修改时间改为当前时间
            //    lasttime = DateTime.Now;
            //    Thread.Sleep(5000);
            //}
            //timer1.Enabled = true;
            CleanMainExe("w3wp");
            remark rmk = new remark();

            rmk.id   = (++id).ToString();
            rmk.des  = "自动重启";
            rmk.time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            remarkList.Add(rmk);
            dataGridView1.DataSource = null;
            dataGridView1.DataSource = remarkList;
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            remarkList = new List <remark>();
            path       = @"D:\" + ConfigurationManager.AppSettings["path"];
            DirectoryInfo TheFolder = new DirectoryInfo(path);

            label1.Text = path + "开始监控(100秒不动,重启通讯)";
            remark rmk = new remark();

            rmk.id   = (++id).ToString();
            rmk.des  = "监控启动";
            rmk.time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            remarkList.Add(rmk);
            dataGridView1.DataSource = remarkList;
        }
Example #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            remarkList = new List <remark>();
            //设置了通讯监控路径,才开始监控
            if (ConfigurationManager.AppSettings["path"] != null && ConfigurationManager.AppSettings["path"].ToString() != "")
            {
                autotx = true;
            }
            if (autotx)
            {
                path = @"D:\" + ConfigurationManager.AppSettings["path"];
                DirectoryInfo TheFolder = new DirectoryInfo(path);
                label1.Text = path + "开始监控(100秒不动,重启通讯)";
                remark rmk = new remark();
                rmk.id   = (++id).ToString();
                rmk.des  = "监控启动";
                rmk.time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                remarkList.Add(rmk);
            }
            else
            {
                dataGridView1.Visible = false;
                label2.Text           = "";
                label1.Text           = "";
            }

            if (GetLocalIP() == "192.168.48.163")
            {
                autocomm = true;
            }
            else
            {
                timer2.Enabled = false;
            }

            dataGridView1.DataSource = remarkList;
        }
Example #4
0
        /// <summary>
        /// 重启主程序 (bat 与exe程序是不一样的)
        /// </summary>
        private void ReStartExe(string mainExe)
        {
            Process proc = null;

            try
            {
                proc = new Process();
                proc.StartInfo.WorkingDirectory = path + @"\";
                proc.StartInfo.FileName         = mainExe;
                proc.StartInfo.Arguments        = string.Format("10");//this is argument
                proc.Start();
                // proc.WaitForExit();
                remark rmk = new remark();
                rmk.id   = (++id).ToString();
                rmk.des  = "自动重启";
                rmk.time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                remarkList.Add(rmk);
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = remarkList;
            }
            catch (Exception ex)
            {
            }
        }