Пример #1
0
 /// <summary>
 /// reads the filter UI components and creates a LogFilter object
 /// </summary>
 /// <returns></returns>
 private LogFilter CreateLogFilter()
 {
     LogFilter filter = new LogFilter();
     if (_dateFilterActive)
     {
         filter.From = dtpFrom.Value;
         filter.To = dtpTo.Value;
     }
     filter.Thread = txtThread.Text;
     filter.User = txtUser.Text;
     filter.TextFilter = txtFilter.Text;
     filter.Level = cmbLevel.Text;
     return filter;
 }
Пример #2
0
        //move to engine
        private List<LogEntry> ApplyFilterToEntryList(List<LogEntry> entries, LogFilter filter)
        {
            IEnumerable<LogEntry> dvMainView = entries;
            string strFilter = "";
            if (!string.IsNullOrEmpty(cmbLevel.Text) && cmbLevel.Text != "ALL")
                dvMainView = dvMainView.Where(r => r.LogLevel.Equals(cmbLevel.Text, StringComparison.InvariantCultureIgnoreCase));

            if (!string.IsNullOrEmpty(txtFilter.Text))
                dvMainView = dvMainView.Where(r => r.ErrorInfo.Contains(txtFilter.Text) || r.Info.Contains(txtFilter.Text));

            if (!string.IsNullOrEmpty(txtUser.Text))
                dvMainView = dvMainView.Where(r => r.UserName.Contains(txtUser.Text));

            if (!string.IsNullOrEmpty(txtThread.Text))
                dvMainView = dvMainView.Where(r => r.ThreadName.Contains(txtThread.Text));

            if (!string.IsNullOrEmpty(txtThread.Text))
                dvMainView = dvMainView.Where(r => r.EntryTime >= dtpFrom.Value && r.EntryTime <= dtpTo.Value);

            _dvMainView = dvMainView.ToList();

            foreach (DataGridViewRow dgRow in dataGridView1.Rows)
            {
                LogEntry drRow = (LogEntry)dgRow.DataBoundItem;
                if (drRow.Key == _intUserSelectionKey)
                {
                    dgRow.Selected = true;
                    if (!dgRow.Displayed && chkPinTrack.Checked)
                        dataGridView1.FirstDisplayedCell = dgRow.Cells[0];
                    break;
                }
            }
            return dvMainView.ToList();
        }
Пример #3
0
        /// <summary>
        /// returns the new lines added to the file since last read, filters lines by the given filter
        /// </summary>
        /// <param name="file"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        internal List<LogEntry> GetNewLinesForFile(string file, LogFilter filter)
        {
            List<LogEntry> filteredNewLines = new List<LogEntry>();
            long lngPrevLength = _colWatchedFiles[file];

            if (File.Exists(file))
            {
                long lngFileLength = (long)new FileInfo(file).Length;

                //file was swapped, and a new file was created => smaller filesize
                if (lngPrevLength > lngFileLength)
                {
                    //we will adjust our counters to keep track with the file.
                    //(the following code will take care of the rest as ususal)
                    if (_colWatchedFiles.ContainsKey(file))
                        _colWatchedFiles[file] = 0;

                    lngPrevLength = 0;
                }

                //file changed (more entries were added)
                if (lngPrevLength < lngFileLength)
                {
                    LogBehavior behavior = ChosenBehavior;
                    if (IsAutoDetectMode)
                        behavior = FindCorrectBehaviorForFile(file);

                    var newLines = ParseLogFileRegExp(file, lngPrevLength, behavior);

                    filteredNewLines = ApplyFilterToEntryList(newLines, filter);
                    MainView.AddRange(filteredNewLines);
                }

            }
            return filteredNewLines;
        }
Пример #4
0
 /// <summary>
 /// filters the main view according to the given filter
 /// </summary>
 /// <param name="filter"></param>
 internal void RefreshFilter(LogFilter filter)
 {
     _dvMainView.Clear();
     _dvMainView.AddRange(ApplyFilterToEntryList(_dtlogEntries, filter));
 }
Пример #5
0
        //move to engine
        //move to engine
        internal List<LogEntry> ApplyFilterToEntryList(List<LogEntry> entries, LogFilter filter)
        {
            IEnumerable<LogEntry> dvMainView = entries;
            string strFilter = "";
            if (!string.IsNullOrEmpty(filter.Level) && filter.Level != "ALL")
                dvMainView = dvMainView.Where(r => r.LogLevel.Equals(filter.Level, StringComparison.InvariantCultureIgnoreCase));

            if (!string.IsNullOrEmpty(filter.TextFilter))
                dvMainView = dvMainView.Where(r => r.ErrorInfo.Contains(filter.TextFilter) || r.Info.Contains(filter.TextFilter));

            if (!string.IsNullOrEmpty(filter.User))
                dvMainView = dvMainView.Where(r => r.UserName.Contains(filter.User));

            if (!string.IsNullOrEmpty(filter.Thread))
                dvMainView = dvMainView.Where(r => r.ThreadName.Contains(filter.Thread));

            if (filter.From != null && filter.To != null)
                dvMainView = dvMainView.Where(r => r.EntryTime >= filter.From && r.EntryTime <= filter.To);

            return dvMainView.ToList();
        }