示例#1
0
        public ListViewItem[] getCurrentLogList(Boolean wantFilter, String serverity, String facility, String fromDate, String toDate, Boolean wantSearch, String searchTerm, String searchField)
        {
            if (serverity.Contains("none"))
            {
                serverity = "";
            }
            if (facility.Contains("none"))
            {
                facility = "";
            }
            activeList = new List<SysLogMessageVO>(logList);
            resetMsg(activeList);
            if (wantFilter)
            {
                Filter filter = new Filter(activeList, serverity, facility, fromDate, toDate);
                activeList = filter.getActiveList();
            }
            if (wantSearch)
            {
                if (searchTerm.ToLower().Equals("instantkharma"))
                {

                }
                Search search = new Search(activeList, searchTerm, searchField);
                activeList = search.getActiveList();
            }

            List<ListViewItem> activeListViewItemList = new List<ListViewItem>();
            foreach (SysLogMessageVO vo in activeList)
            {
                if (vo.visible)
                {
                    ListViewItem item1 = new ListViewItem(vo.date);
                    item1.SubItems.Add(vo.time);
                    item1.SubItems.Add(vo.source);
                    item1.SubItems.Add(vo.severity);
                    item1.SubItems.Add(vo.facility);
                    item1.SubItems.Add(vo.message);
                    activeListViewItemList.Add(item1);
                }
            }

            return activeListViewItemList.ToArray();
        }
示例#2
0
        private void MenuFilter_Click(object sender, RoutedEventArgs e)
        {
            Filter filter = new Filter(Entries);
            filter.ShowDialog();
            if (filter.DialogResult == true)
            {
                string level = filter.Level;
                string message = filter.Message;
                string username = filter.UserName;

                List<LogEntry> query = new List<LogEntry>();

                if (level.Length > 0)
                {
                    var q =
                    (
                        from entry in Entries
                        where entry.Level == level
                        select entry
                    ).ToList<LogEntry>();

                    query.AddRange(q);
                }

                if (message.Length > 0)
                {
                    var q =
                    (
                        from entry in Entries
                        where entry.Message.Contains(message)
                        select entry
                    ).ToList<LogEntry>();
                    query.AddRange(q);
                }

                if (username.Length > 0)
                {
                    var q =
                    (
                        from entry in Entries
                        where entry.UserName.Contains(username)
                        select entry
                    ).ToList<LogEntry>();
                    query.AddRange(q);
                }

                this.listView1.ItemsSource = query.Count > 0 ? query : Entries;
            }
        }