Exemplo n.º 1
0
        public static DataTable dispOnePageLogs(int i_pagenum, int i_pagesize)
        {
            if (LogAPI.i_matchedLogs == 0)
            {
                return(null);
            }
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T1No, new string[0]), typeof(int));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T2DateTime, new string[0]), typeof(string));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T3Category, new string[0]), typeof(string));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T4Severity, new string[0]), typeof(string));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T5Event, new string[0]), typeof(string));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T6LogInfo, new string[0]), typeof(string));
            if (LogAPI.s_myKeyWord != null)
            {
                int num  = (i_pagenum - 1) * i_pagesize;
                int num2 = num + i_pagesize;
                if (num2 > LogAPI.i_matchedLogs)
                {
                    i_pagenum = LogAPI.i_matchedLogs / i_pagesize;
                    num       = i_pagenum * i_pagesize;
                    num2      = LogAPI.i_matchedLogs;
                }
                for (int i = num; i < num2; i++)
                {
                    dataTable.Rows.Add(new object[]
                    {
                        i - num + 1,
                        LogAPI.s_matchedLogs[i][0],
                        LogAPI.s_matchedLogs[i][1],
                        LogAPI.s_matchedLogs[i][2],
                        LogAPI.s_matchedLogs[i][3],
                        LogAPI.s_matchedLogs[i][4]
                    });
                }
            }
            else
            {
                DataTable searchResult = LogInfo.GetSearchResult(LogAPI.i_myRangeType, LogAPI.dt_myStart, LogAPI.dt_myEnd, i_pagenum, i_pagesize, LogAPI.i_foundLogs);
                for (int i = 0; i < searchResult.Rows.Count; i++)
                {
                    string[] oneRow = LogAPI.getOneRow(null, searchResult.Rows[i]);
                    if (oneRow != null)
                    {
                        dataTable.Rows.Add(new object[]
                        {
                            i + 1,
                            oneRow[0],
                            oneRow[1],
                            oneRow[2],
                            oneRow[3],
                            oneRow[4]
                        });
                    }
                }
            }
            return(dataTable);
        }
Exemplo n.º 2
0
        public static DataTable getAllLogs()
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T1No, new string[0]), typeof(int));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T2DateTime, new string[0]), typeof(string));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T3Category, new string[0]), typeof(string));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T4Severity, new string[0]), typeof(string));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T5Event, new string[0]), typeof(string));
            dataTable.Columns.Add(EventLogLang.getMsg(LangRes.T6LogInfo, new string[0]), typeof(string));
            if (LogAPI.i_matchedLogs == 0)
            {
                return(dataTable);
            }
            if (LogAPI.s_myKeyWord != null)
            {
                for (int i = 0; i < LogAPI.i_matchedLogs; i++)
                {
                    dataTable.Rows.Add(new object[]
                    {
                        i + 1,
                        LogAPI.s_matchedLogs[i][0],
                        LogAPI.s_matchedLogs[i][1],
                        LogAPI.s_matchedLogs[i][2],
                        LogAPI.s_matchedLogs[i][3],
                        LogAPI.s_matchedLogs[i][4]
                    });
                }
            }
            else
            {
                DataTable searchResult = LogInfo.GetSearchResult(LogAPI.i_myRangeType, LogAPI.dt_myStart, LogAPI.dt_myEnd, 0, 0, LogAPI.i_foundLogs);
                int       num          = 0;
                foreach (DataRow logData in searchResult.Rows)
                {
                    string[] oneRow = LogAPI.getOneRow(null, logData);
                    if (oneRow != null)
                    {
                        dataTable.Rows.Add(new object[]
                        {
                            num + 1,
                            oneRow[0],
                            oneRow[1],
                            oneRow[2],
                            oneRow[3],
                            oneRow[4]
                        });
                        num++;
                    }
                }
            }
            return(dataTable);
        }
Exemplo n.º 3
0
        private static int emailNewLog(string logKey, params string[] logPrar)
        {
            SMTPSetting sMTPSetting = new SMTPSetting();

            string[] array = sMTPSetting.Receiver.Split(new string[]
            {
                "\r\n",
                ";",
                ",",
                " "
            }, StringSplitOptions.RemoveEmptyEntries);
            List <string> list = new List <string>();

            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string item = array2[i];
                list.Add(item);
            }
            if (sMTPSetting.Status <= 0 || list.Count <= 0)
            {
                return(0);
            }
            string  str     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string  msg     = EventLogLang.getMsg("L" + logKey, logPrar);
            string  msg2    = EventLogLang.getMsg("SL" + logKey, logPrar);
            string  value   = str + "<br/>" + msg;
            MailMsg mailMsg = new MailMsg(sMTPSetting.ServerIP, sMTPSetting.Port, sMTPSetting.Sender, list, sMTPSetting.AuthenticationFlag, sMTPSetting.AccountName, sMTPSetting.AccountPwd);

            mailMsg.Subject  = "eco Sensors Event Notification - " + msg2;
            mailMsg.Body     = new StringBuilder().AppendLine(value).ToString();
            mailMsg.Receiver = sMTPSetting.Receiver;
            if (logKey.Equals("0230002") || logKey.Equals("0110100") || logKey.Equals("0110090") || logKey.Equals("0130001"))
            {
                LogAPI.sendMailThread(mailMsg);
                return(ErrorCode.SUCCESS);
            }
            lock (LogAPI._lockEmail)
            {
                if (LogAPI._mergedMail != null)
                {
                    if (mailMsg.Subject.Equals(LogAPI._mergedMail.Subject, StringComparison.InvariantCultureIgnoreCase) && mailMsg.Receiver.Equals(LogAPI._mergedMail.Receiver, StringComparison.InvariantCultureIgnoreCase))
                    {
                        LogAPI._mergedMail._ItemsInBody++;
                        LogAPI._mergedMail._mergedBody.Append("<br /><br />");
                        LogAPI._mergedMail._mergedBody.Append(mailMsg.Body);
                        LogAPI._lastEmailMerge = DateTime.Now;
                    }
                    else
                    {
                        LogAPI._emailQueue.Enqueue(LogAPI._mergedMail);
                        LogAPI._emailEvent.Set();
                        LogAPI._mergedMail = null;
                    }
                }
                if (LogAPI._mergedMail == null)
                {
                    LogAPI._mergedMail           = mailMsg;
                    LogAPI._mergedMail._SerialNo = LogAPI._NextEmailSerialNo++;
                    LogAPI._mergedMail._ItemsInBody++;
                    LogAPI._mergedMail._mergedBody.Append(mailMsg.Body);
                    LogAPI._lastEmailMerge = DateTime.Now;
                }
            }
            if (LogAPI._threadEmail == null)
            {
                LogAPI._waitEmailHandles[0]        = LogAPI._stopMailEvent;
                LogAPI._waitEmailHandles[1]        = LogAPI._emailEvent;
                LogAPI._threadEmail                = new Thread(new ParameterizedThreadStart(LogAPI.MailThreadScheduler));
                LogAPI._threadEmail.Name           = "Email Scheduler Thread";
                LogAPI._threadEmail.CurrentCulture = CultureInfo.InvariantCulture;
                LogAPI._threadEmail.IsBackground   = true;
                LogAPI._threadEmail.Start();
            }
            return(ErrorCode.SUCCESS);
        }
Exemplo n.º 4
0
        private static string[] getOneRow(string keyword, DataRow logData)
        {
            string[] array = new string[5];
            string   text  = "L" + logData["eventid"].ToString();
            string   text2 = logData["insert_time"].ToString();

            string[] separator = new string[]
            {
                "^|^"
            };
            string[] argv  = logData["parametervalue"].ToString().Split(separator, StringSplitOptions.None);
            int      num   = Convert.ToInt32(text.Substring(1));
            int      num2  = num / 10000 % 10;
            int      num3  = num / 100000;
            string   text3 = "";

            switch (num2)
            {
            case 1:
                text3 = LangRes.Sev1Critical;
                break;

            case 2:
                text3 = LangRes.Sev2Warning;
                break;

            case 3:
                text3 = LangRes.Sev3Information;
                break;
            }
            string text4 = "";

            switch (num3)
            {
            case 1:
                text4 = LangRes.Cat1System;
                break;

            case 2:
                text4 = LangRes.Cat2Authentication;
                break;

            case 3:
                text4 = LangRes.Cat3Usermanagement;
                break;

            case 4:
                text4 = LangRes.Cat4Devicemanagement;
                break;

            case 5:
                text4 = LangRes.Cat5Systemtask;
                break;

            case 6:
                text4 = LangRes.Cat6Device;
                break;

            case 7:
                text4 = LangRes.Cat7DevTrap;
                break;
            }
            string msg  = EventLogLang.getMsg("S" + text, new string[0]);
            string msg2 = EventLogLang.getMsg(text, argv);

            array[0] = text2;
            array[1] = text4;
            array[2] = text3;
            array[3] = msg;
            array[4] = msg2;
            if (keyword != null && !text2.Contains(keyword) && !text4.Contains(keyword) && !text3.Contains(keyword) && !msg.Contains(keyword) && !msg2.Contains(keyword))
            {
                return(null);
            }
            return(array);
        }
Exemplo n.º 5
0
 public static string strEvent(string strLogKey)
 {
     return(EventLogLang.getMsg("SL" + strLogKey, new string[0]));
 }