Пример #1
0
        //针对事件模糊查询
        private void btn_Select_Click(object sender, EventArgs e)
        {
            string whereclause = "";

            whereclause += (txt_select.Text == "") ? "" : "logEVENT like '%" + txt_select.Text + "%' AND ";
            if (whereclause.EndsWith(" AND "))
            {
                whereclause = whereclause.Substring(0, whereclause.Length - 5);
            }
            if (whereclause != "")
            {
                whereclause = whereclause + " order by logTime desc ";                    //让日志按照时间顺序 升序排列
            }
            listView.Items.Clear();
            List <string[]> list = LogTable.SeachLog(whereclause);

            if (list.Count == 0)
            {
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                string[] strRow = list[i];
                listView.Items.Add(strRow[0]);
                listView.Items[i].SubItems.Add(strRow[1]);
                listView.Items[i].SubItems.Add(strRow[2]);
                listView.Items[i].SubItems.Add(strRow[3]);
            }
        }
Пример #2
0
        public void RefreshLog()
        {
            //log = new LogFile(null, m_strLogFilePath);
            string whereclause = "";

            whereclause += (dateTimePickerStart.Text == "") ? "" : "logTime > '" + Convert.ToDateTime(dateTimePickerStart.Text).ToString("yyyy-MM-dd HH:mm:ss") + "' AND ";
            whereclause += (dateTimePickerEnd.Text == "") ? "" : "logTime < '" + Convert.ToDateTime(dateTimePickerEnd.Text + " 23:59:59").ToString("yyyy-MM-dd HH:mm:ss") + "' AND ";
            whereclause += (cBoxUser.Text == "所有用户" || cBoxUser.Text == "") ? "" : "logUser = '******' AND ";
            whereclause += (cBoxAccessIP.Text == "" || cBoxAccessIP.Text == "所有IP") ? "" : "logIP = '" + cBoxAccessIP.Text + "'";
            if (whereclause.EndsWith(" AND "))
            {
                whereclause = whereclause.Substring(0, whereclause.Length - 5);
            }
            if (whereclause != "")
            {
                whereclause = whereclause + " order by logTime desc ";                //让日志按照时间顺序 升序排列
            }
            listView.Items.Clear();
            List <string[]> list = LogTable.SeachLog(whereclause);

            if (list.Count == 0)
            {
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                string[] strRow = list[i];
                listView.Items.Add(strRow[0]);
                listView.Items[i].SubItems.Add(strRow[1]);
                listView.Items[i].SubItems.Add(strRow[2]);
                listView.Items[i].SubItems.Add(strRow[3]);
            }
        }
Пример #3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //log = new LogFile(null, m_strLogFilePath);
            List <string> listUsers = new List <string> ();
            string        groupUser = "";

            if (CBGroupUser.Checked == true && ComBoxGroupUsers.Text != "")
            {
                listUsers = LogTable.GetUsersByGroupUsers(ComBoxGroupUsers.Text);
                if (listUsers.Count > 0)
                {
                    for (int i = 0; i < listUsers.Count; i++)
                    {
                        groupUser += "'" + listUsers[i] + "',";
                    }
                    groupUser = groupUser.Substring(0, groupUser.Length - 1);
                }
                else
                {
                    MessageBox.Show("该用户组不存在用户!", "错误", MessageBoxButtons.OK);
                    return;
                }
            }
            string whereclause = "";

            whereclause += (dateTimePickerStart.Text == "") ? "" : "logTime > '" + Convert.ToDateTime(dateTimePickerStart.Text).ToString("yyyy-MM-dd HH:mm:ss") + "' AND ";
            whereclause += (dateTimePickerEnd.Text == "") ? "" : "logTime < '" + Convert.ToDateTime(dateTimePickerEnd.Text + " 23:59:59").ToString("yyyy-MM-dd HH:mm:ss") + "' AND ";
            whereclause += (CBAllUsers.Checked == true) ? "" : "";
            whereclause += (CBSingleUser.Checked == true) ? "logUser ='******' AND " : "";
            whereclause += (CBGroupUser.Checked == true) ? "logUser in (" + groupUser + ") AND " : "";
            whereclause += (cBoxAccessIP.Text == "" || cBoxAccessIP.Text == "所有IP") ? "" : "logIP = '" + cBoxAccessIP.Text + "' AND ";
            whereclause += (comBoxOperation.Text == "" || comBoxOperation.Text == "所有操作") ? "" : "logEVENT = '" + comBoxOperation.Text + "' AND ";
            if (whereclause.EndsWith(" AND "))
            {
                whereclause = whereclause.Substring(0, whereclause.Length - 5);
            }
            listView.Items.Clear();
            whereclause = whereclause + " order by logTime desc ";//让日志按照时间顺序 升序排列
            List <string[]> list = LogTable.SeachLog(whereclause);

            if (list.Count == 0)
            {
                MessageBox.Show("没有符合条件的日志", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                string[] strRow = list[i];
                listView.Items.Add(strRow[0]);
                listView.Items[i].SubItems.Add(strRow[1]);
                listView.Items[i].SubItems.Add(strRow[2]);
                listView.Items[i].SubItems.Add(strRow[3]);
            }
        }