Ejemplo n.º 1
0
        //日志监控
        public void threadlog(bool is_first, int exec)
        {
            string db_dir = System.Windows.Forms.Application.StartupPath + "\\db.accdb";
            bool   begin  = tool.execute_or_not("syslog_warn", db_dir, syslog, is_first, exec);

            if (begin == true)
            {
                threadWarnSyslog();
                threadErrorSyslog();
                //Tool_Class.AccessDbClass1 db = new Tool_Class.AccessDbClass1();
                string str5 = System.Windows.Forms.Application.StartupPath;
                string a    = str5 + "\\db.accdb";
                //db.AccessDbClass2(a);
                string error  = "警告日志:" + eventlogWarnNum.ToString() + "个;" + "\n\r" + "错误日志:" + eventlogErrorNum.ToString() + "个;\r\n" + "错误日志详情(最多显示5项):" + "\r\n" + eventlogErrorMessage;
                string error2 = "警告日志:" + eventlogWarnNum.ToString() + "个;" + "\n\r" + "错误日志:" + eventlogErrorNum.ToString() + "个;\r\n";
                string sql3   = "";
                string sql4   = "";
                if (eventlogWarnNum == 0 && eventlogErrorNum == 0 && is_first == true)
                {
                    sql3 = "update Status_Now set para_value='正常',details ='正常',create_date = '" + DateTime.Now + "',flag = 'N' where para_name = 'syslog_warn'";
                    tool.AccessDbclass(sql3);
                }
                if (eventlogWarnNum > 0)
                {
                    sql3 = "update Status_Now set para_value='警告',details ='" + error + "',create_date = '" + DateTime.Now + "',flag = 'W' where para_name = 'syslog_warn'";
                    sql4 = "update Status_Now set para_value='警告',details ='" + error2 + "',create_date = '" + DateTime.Now + "',flag = 'W' where para_name = 'syslog_warn'";
                    bool dd = tool.AccessDbclassdd(sql3);
                    if (dd == false)
                    {
                        tool.AccessDbclass(sql4);
                    }
                }
                if (eventlogErrorNum > 0)
                {
                    sql3 = "update Status_Now set para_value='错误',details ='" + error + "',create_date = '" + DateTime.Now + "',flag = 'E' where para_name = 'syslog_warn'";
                    sql4 = "update Status_Now set para_value='错误',details ='" + error2 + "',create_date = '" + DateTime.Now + "',flag = 'E' where para_name = 'syslog_warn'";
                    bool dd = tool.AccessDbclassdd(sql3);
                    if (dd == false)
                    {
                        tool.AccessDbclass(sql4);
                    }
                }

                eventlogErrorNum     = 0;
                eventlogWarnNum      = 0;
                eventlogErrorMessage = "";
                eventlogWarnMessage  = "";
            }
        }