/// <summary>
        /// Initializes a new instance of the <see cref="Filter"/> class.
        /// </summary>
        /// <param name="entries">The entries.</param>
        /// <param name="logFilter">The log filter.</param>
        public Filter(IEnumerable <LogEntry> entries, LogFilter logFilter)
        {
            Opacity = 0d;
            InitializeComponent();
            populateDropDown(entries);
            this.logFilter       = logFilter;
            MainGrid.DataContext = this.logFilter;

            try { this.ApplyTheme("ExpressionDark"); }
            catch (Exception ex) { }
        }
示例#2
0
        private void doMenuFilter()
        {
            log.Info("Cloning the log filter");
            var tempFilter = logFilter.Clone();
            var filter     = new Filter(Entries, tempFilter)
            {
                Owner = this
            };

            log.Info("Showing the filter dialog");

            filter.ShowDialog();

            if (filter.DialogResult != true)
            {
                return;
            }

            log.Info("Cloning the log filter again after loading new filters");
            logFilter = tempFilter.Clone();
            logFilter.TrimAll();

            log.Info("Initializing the query object");
            var query = (from e in Entries select e);

            if (!string.IsNullOrEmpty(logFilter.App))
            {
                query = query.Where(e => e.App.ToUpperInvariant().Contains(logFilter.App.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.Level))
            {
                query = query.Where(e => e.Level == logFilter.Level);
            }
            if (!string.IsNullOrEmpty(logFilter.Thread))
            {
                query = query.Where(e => e.Thread == logFilter.Thread);
            }
            if (!string.IsNullOrEmpty(logFilter.Message))
            {
                query = query.Where(e => e.Message.ToUpperInvariant().Contains(logFilter.Message.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.MachineName))
            {
                query = query.Where(e => e.MachineName.ToUpperInvariant().Contains(logFilter.MachineName.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.UserName))
            {
                query = query.Where(e => e.UserName.ToUpperInvariant().Contains(logFilter.UserName.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.HostName))
            {
                query = query.Where(e => e.HostName.ToUpperInvariant().Contains(logFilter.HostName.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.Throwable))
            {
                query = query.Where(e => e.Throwable.ToUpperInvariant().Contains(logFilter.Throwable.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.Class))
            {
                query = query.Where(e => e.Class.ToUpperInvariant().Contains(logFilter.Class.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.Method))
            {
                query = query.Where(e => e.Method.ToUpperInvariant().Contains(logFilter.Method.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.File))
            {
                query = query.Where(e => e.File.ToUpperInvariant().Contains(logFilter.File.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.LogName))
            {
                query = query.Where(e => e.LogFile.ToUpperInvariant().Contains(logFilter.LogName.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.Identity))
            {
                query = query.Where(e => e.Identity.ToUpperInvariant().Contains(logFilter.Identity.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.NDC))
            {
                query = query.Where(e => e.NDC.ToUpperInvariant().Contains(logFilter.NDC.ToUpperInvariant()));
            }
            if (!string.IsNullOrEmpty(logFilter.Logger))
            {
                query = query.Where(e => e.Logger.ToUpperInvariant().Contains(logFilter.Logger.ToUpperInvariant()));
            }

            // TODO: shouldn't we be showing 0 results if the filter matched 0 results?
            var c = query.Count();

            log.Info("Received queries " + query.Count());

            FilterIndicator.IsFiltered = query.Any() && (c != Entries.Count());

            logFilter.IsFiltered = FilterIndicator.IsFiltered;
            log.Info("Log Filter status " + logFilter.IsFiltered);

            LogFilter.FilteredEntries = FilterIndicator.IsFiltered ? query.ToList() : Entries;
            listView1.ItemsSource     = logFilter.IsFiltered ? LogFilter.FilteredEntries : Entries;
            tbFiltered.Text           = FilterIndicator.IsFiltered ? c + "/" + Entries.Count() : Entries.Count().ToString();
        }