Exemplo n.º 1
0
        static void Main()
        {
            try
            {
                bool createNew;
                //处理未捕获的异常
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                //处理UI线程异常
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                //处理非UI线程异常
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);


                using (System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out createNew))
                {
                    if (createNew)
                    {
                        Splash.Show();

                        Application.Run(new MainApp());

                        Splash.Close();
                    }
                    else
                    {
                        MessageBox.Show("抱歉,已经有一个实例在运行,您可以关闭之后再运行!", "提示");
                    }
                }
            }
            catch (Exception ex)
            {
                string str         = "";
                string strDateInfo = "出现应用程序未处理的异常:" + DateTime.Now.ToString() + "\r\n";

                if (ex != null)
                {
                    str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{1}\r\n异常信息:{2}\r\n",
                                        ex.GetType().Name, ex.Message, ex.StackTrace);
                }
                else
                {
                    str = string.Format("应用程序线程错误:{0}", ex);
                }


                //writeLog(str);
                MessageBox.Show("发生致命错误,请及时联系作者!" + str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        public MainApp()
        {
            InitializeComponent();
            //this.TopMost = true;

            this.StartPosition = FormStartPosition.CenterScreen;
            Splash.Status      = "状态:载入初始化数据";

            this.FormClosing += MainApp_FormClosing;

            ThreadPoolManager.Init(1);

            timerEmailSend.Interval = 5000;//10秒检测一次
            timerEmailSend.Tick    += ToSendReport;
            timerEmailSend.Start();

            #region 初始


            dtpStart.Width = 110;
            dtpEnd.Width   = 110;



            lstbFileList.View          = View.Details; //只有设置为这个HeaderStyle才有用
            lstbFileList.HeaderStyle   = ColumnHeaderStyle.Nonclickable;
            lstbFileList.GridLines     = true;         //显示网格线
            lstbFileList.FullRowSelect = true;         //选择时选择是行,而不是某列
            lstbFileList.Columns.Add("文件目录", 600, HorizontalAlignment.Center);
            lstbFileList.Columns.Add("状态", 100, HorizontalAlignment.Center);

            lstWatchList.View          = View.Details; //只有设置为这个HeaderStyle才有用
            lstWatchList.HeaderStyle   = ColumnHeaderStyle.Nonclickable;
            lstWatchList.GridLines     = true;         //显示网格线
            lstWatchList.FullRowSelect = true;         //选择时选择是行,而不是某列
            lstWatchList.Columns.Add("文件路径", 600, HorizontalAlignment.Center);
            lstWatchList.Columns.Add("操作", 100, HorizontalAlignment.Center);
            lstWatchList.Columns.Add("备注", 100, HorizontalAlignment.Center);

            lvErrSiteList.View          = View.Details; //只有设置为这个HeaderStyle才有用
            lvErrSiteList.HeaderStyle   = ColumnHeaderStyle.Nonclickable;
            lvErrSiteList.GridLines     = true;         //显示网格线
            lvErrSiteList.FullRowSelect = true;         //选择时选择是行,而不是某列
            lvErrSiteList.Columns.Add("网站名称", 100, HorizontalAlignment.Center);
            lvErrSiteList.Columns.Add("应用池", 100, HorizontalAlignment.Center);
            lvErrSiteList.Columns.Add("检测网址", 250, HorizontalAlignment.Left);
            lvErrSiteList.Columns.Add("间隔", 50, HorizontalAlignment.Center);
            lvErrSiteList.Columns.Add("错误数", 50, HorizontalAlignment.Center);
            lvErrSiteList.Columns.Add("报告数", 50, HorizontalAlignment.Center);
            lvErrSiteList.Columns.Add("最后错误时间", 100, HorizontalAlignment.Center);
            lvErrSiteList.Columns.Add("ID", 0);


            //winform中,listview是没有办法设置行高的,没行之间排得密密麻麻的,很不好!

            //可以加入一个imagelist来 撑大 行,实现行高的设置!

            //   设置行高   20
            ImageList imgList = new ImageList();
            imgList.ImageSize = new Size(1, 20);     //分别是宽和高

            lv404links.View          = View.Details; //只有设置为这个HeaderStyle才有用
            lv404links.HeaderStyle   = ColumnHeaderStyle.Nonclickable;
            lv404links.GridLines     = true;         //显示网格线
            lv404links.FullRowSelect = true;         //选择时选择是行,而不是某列
            lv404links.Columns.Add("检测目标地址", 350, HorizontalAlignment.Left);
            lv404links.Columns.Add("时间间隔", 80, HorizontalAlignment.Center);
            lv404links.Columns.Add("死链数", 80, HorizontalAlignment.Center);
            lv404links.Columns.Add("状态", 120, HorizontalAlignment.Center);
            lv404links.Columns.Add("最后汇报时间", 120, HorizontalAlignment.Center);
            lv404links.Columns.Add("最后汇报结果", 500, HorizontalAlignment.Center);
            lv404links.Columns.Add("ID", 0);
            lv404links.Columns.Add("页面名称", 80);
            lv404links.SmallImageList = imgList;   //这里设置listView的SmallImageList ,用imgList将其撑大


            lvBadWords.View          = View.Details; //只有设置为这个HeaderStyle才有用
            lvBadWords.HeaderStyle   = ColumnHeaderStyle.Nonclickable;
            lvBadWords.GridLines     = true;         //显示网格线
            lvBadWords.FullRowSelect = true;         //选择时选择是行,而不是某列
            lvBadWords.Columns.Add("检测目标地址", 350, HorizontalAlignment.Left);
            lvBadWords.Columns.Add("内容获取方式", 100, HorizontalAlignment.Center);
            lvBadWords.Columns.Add("状态", 120, HorizontalAlignment.Center);
            lvBadWords.Columns.Add("最后汇报时间", 120, HorizontalAlignment.Center);
            lvBadWords.Columns.Add("最后汇报结果", 500, HorizontalAlignment.Center);
            lvBadWords.SmallImageList = imgList;       //这里设置listView的SmallImageList ,用imgList将其撑大

            lvPageUpdate.View          = View.Details; //只有设置为这个HeaderStyle才有用
            lvPageUpdate.HeaderStyle   = ColumnHeaderStyle.Nonclickable;
            lvPageUpdate.GridLines     = true;         //显示网格线
            lvPageUpdate.FullRowSelect = true;         //选择时选择是行,而不是某列
            lvPageUpdate.Columns.Add("检测目标地址", 350, HorizontalAlignment.Left);
            lvPageUpdate.Columns.Add("时间间隔", 180, HorizontalAlignment.Center);
            lvPageUpdate.Columns.Add("状态", 120, HorizontalAlignment.Center);
            lvPageUpdate.Columns.Add("最后汇报时间", 120, HorizontalAlignment.Center);
            lvPageUpdate.Columns.Add("最后汇报结果", 500, HorizontalAlignment.Center);
            lvPageUpdate.Columns.Add("最近一次md5", 120, HorizontalAlignment.Center);
            lvPageUpdate.Columns.Add("ID", 0);

            lvPageUpdate.SmallImageList = imgList;   //这里设置listView的SmallImageList ,用imgList将其撑大


            lvWebLinkUrl.View          = View.Details; //只有设置为这个HeaderStyle才有用
            lvWebLinkUrl.HeaderStyle   = ColumnHeaderStyle.Nonclickable;
            lvWebLinkUrl.GridLines     = true;         //显示网格线
            lvWebLinkUrl.FullRowSelect = true;         //选择时选择是行,而不是某列
            lvWebLinkUrl.Columns.Add("检测目标地址", 350, HorizontalAlignment.Left);
            lvWebLinkUrl.Columns.Add("时间间隔", 180, HorizontalAlignment.Center);
            lvWebLinkUrl.Columns.Add("状态", 120, HorizontalAlignment.Center);
            lvWebLinkUrl.Columns.Add("友链数量", 100, HorizontalAlignment.Center);
            lvWebLinkUrl.Columns.Add("最后汇报时间", 120, HorizontalAlignment.Center);
            lvWebLinkUrl.Columns.Add("ID", 0);
            lvWebLinkUrl.SmallImageList = imgList;   //这里设置listView的SmallImageList ,用imgList将其撑大

            //WindowState = FormWindowState.Maximized;


            //MyHttpListener _MyHttpListener = new MyHttpListener("http://+:8089/");
            //_MyHttpListener.RequestEvent += OnHttpRequest;
            //_MyHttpListener.Start();
            //dglUpdateHttpWatch = OnUpdateHttpWatch;



            #endregion


            Splash.Status = "状态:启用监听事件";

            //监视cpu与内存
            GetCpuInfo();
            siMemoryInfo         = new SystemInfo();
            timerMemory.Interval = 3000;
            timerMemory.Tick    += new EventHandler(OntimerMemory);
            //timerMemory.Tick += new EventHandler(NetInfo);
            timerMemory.Start();
            Splash.Status       = "状态:获取网卡信息";
            cbNetCar.DataSource = GetNicList();
            if (!string.IsNullOrEmpty(Core.Configs.ConfigsControl.Instance.SelNetCar))
            {
                cbNetCar.Text = Core.Configs.ConfigsControl.Instance.SelNetCar;
                //StarShowNetInfo();
            }

            Splash.Status    = "状态:加载站点信息";
            drpTimeSpan.Text = "检测时间间隔(分钟)";
            BindErrSites();
            LoadPlugins();

            Splash.Close();
            this.Show();
            this.Activate();

            urlNoChecks = BLL.BadLinkNoCheck.Instance.GetList();

            //Log.ErrorLog.Error("fsdfsdfsd{0}");
        }