コード例 #1
0
        public ExecuteCommandImportNewCopyOfFilterIntoContainer(IActivateItems activator, FilterCommand filterCommand, IContainer targetContainer) : base(activator)
        {
            _filterCommand   = filterCommand;
            _targetContainer = targetContainer;

            //if source catalogue is known
            if (_filterCommand.SourceCatalogueIfAny != null)
            {
                var targetCatalogue = targetContainer.GetCatalogueIfAny();

                if (targetCatalogue != null)
                {
                    if (!_filterCommand.SourceCatalogueIfAny.Equals(targetCatalogue))
                    {
                        SetImpossible("Cannot Import Filter from '" + _filterCommand.SourceCatalogueIfAny + "' into '" + targetCatalogue + "'");
                    }
                }
            }
        }
コード例 #2
0
        public static Task Execute(FilterCommand command, ILogger logger)
        {
            if (File.Exists(command.Input) == false)
            {
                logger.Fatal("Input file does not exist!");
                Environment.Exit(0);
            }

            if (File.Exists(command.FiltersConfigurationFile) == false)
            {
                logger.Fatal("Configuration file does not exist!");
                Environment.Exit(0);
            }

            using var reader = new GpdReader(command.Input);
            var slices = reader.ReadPointSlices().Where(s => s != null).ToList();

            foreach (var slice in slices)
            {
                slice.PointSets = slice.PointSets.Where(p => p is { Empty: false }).ToList();
コード例 #3
0
        public ConvolutionFiltrationCorrelationViewModel(SignalViewModel first)
        {
            firstSignalViewModel = first;
            SecondSignalData     = new FunctionData();
            filter = new Filter();

            filters = new Dictionary <FilterType, string>();
            filters.Add(FilterType.LowPassFilter, "LOW-PASS FILTER");
            filters.Add(FilterType.HighPassFilter, "HIGH-PASS FILTER");

            selectedFilter = FilterType.LowPassFilter;
            window         = new RectangularWindow();
            windows        = new List <IWindow>(new IWindow[]
                                                { new RectangularWindow(), new HanningWindow() /*, new HammingWindow(), new BlackmanWindow()*/ });

            filterOrder     = new FunctionAttribute <int>(5, true, 1, 500, "FILTER ORDER");
            cutoffFrequency = new FunctionAttribute <double>(400.0d, true, 10.0d, 25000.0d, "CUTOFF FREQUENCY");

            Attributes = new List <object>(new[] { filterOrder, (object)cutoffFrequency });

            firstSignalViewModel.SignalGenerated += (sender, args) => FilterCommand.RaiseCanExecuteChanged();
        }
コード例 #4
0
 public ViewModel()
 {
     FilterCommand  = new FilterCommand();
     ResetCommand   = new ResetCommand();
     VisibleColumns = new ObservableCollection <ObservableProp <bool> >()
     {
         true, true, true, true, true
     };
     FilterColumns = new List <string>();
     try
     {
         using (var db = new SalesDbModel())
         {
             db.Sales.Load();
             Sales = db.Sales.Local;
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }
コード例 #5
0
        public SearchNavigationBar()
        {
            InitializeComponent();
            gridNav.Margin        = new Thickness(0, App.HeightStatusBar, 0, 0);
            this.HeightRequest    = App.HeightNavigationIOS;
            gridNav.HeightRequest = App.HeightNavigationIOS;
            //
            var gestureRecognizer = new TapGestureRecognizer();

            gestureRecognizer.Tapped += (sender, e) => FilterCommand?.Execute(sender);
            filter.GestureRecognizers.Add(gestureRecognizer);
            //
            var backGR = new TapGestureRecognizer();

            backGR.Tapped += (sender, e) => BackCommand?.Execute(sender);
            back.GestureRecognizers.Add(backGR);
            //
            var searchGR = new TapGestureRecognizer();

            searchBar.GestureRecognizers.Add(searchGR);
            searchBar.BindingContext = this;
        }
コード例 #6
0
 private void BaseContent_Appearing(object sender, EventArgs e)
 {
     if (FilterPage == null)
     {
         FilterCommand.Execute(null);
     }
     else
     {
         Task.Run(async() =>
         {
             var data = await(FilterPage?.BindingContext as PrepareReportViewModel)?.GetFilteredItems();
             if (data != null)
             {
                 Records = new ObservableCollection <InterruptionDbModel>(data);
             }
             else
             {
                 Records = null;
             }
         });
     }
 }
コード例 #7
0
        sealed public override void RetrieveCommands()
        {
            // Add all command and responses needed for configuring the BLE module.
            Command command = new AtCommand("AT");

            _commands.Add(command);

            //command = new NotificationCommand("AT+NOTI1");
            //_commands.Add(command);

            command = new AddressCommand("AT+ADDR?");
            _commands.Add(command);

            command = new NameCommand("AT+NAME?");
            _commands.Add(command);

            command = new FilterCommand("AT+FILT1");
            _commands.Add(command);

            command = new ShowCommand("AT+SHOW1");
            _commands.Add(command);


            command = new RoleCommand("AT+ROLE1");
            _commands.Add(command);

            command = new IMMECommand("AT+IMME1");
            _commands.Add(command);

            command = new DiscoveryCommand("AT+DISC?");
            _commands.Add(command);

            command = new ConnectCommand("AT+CON{0}");
            _commands.Add(command);

            command = new StartCommand("AT+START");
            _commands.Add(command);
        }
コード例 #8
0
        public void ExecuteTest()
        {
            var table  = new Mock <Table>();
            var table2 = new Mock <Table>();

            var cell1 = new Mock <Cell>();
            var cell2 = new Mock <Cell>();

            cell1.Setup(foo => foo.Content).Returns(1.0);
            cell2.Setup(foo => foo.Content).Returns(5.0);
            var cell3 = new Mock <Cell>();
            var cell4 = new Mock <Cell>();
            //var cell5 = new Mock<Cell>();
            //var cell6 = new Mock<Cell>();
            //var cell7 = new Mock<Cell>();
            //var cell8 = new Mock<Cell>();

            List <Cell> list1 = new List <Cell>();
            List <Cell> list2 = new List <Cell>();

            List <Cell> list3 = new List <Cell>();
            List <Cell> list4 = new List <Cell>();

            list1.Add(cell1.Object);
            list1.Add(cell2.Object);
            list2.Add(cell3.Object);
            list2.Add(cell4.Object);
            list3.Add(cell2.Object);
            list4.Add(cell4.Object);

            var column1 = new Mock <Column>();
            var column2 = new Mock <Column>();
            var column3 = new Mock <Column>();
            var column4 = new Mock <Column>();

            column1.Setup(foo => foo.Cells).Returns(list1);
            column2.Setup(foo => foo.Cells).Returns(list2);
            column3.Setup(foo => foo.Cells).Returns(list3);
            column4.Setup(foo => foo.Cells).Returns(list4);

            List <Column> columns1 = new List <Column>();
            List <Column> columns2 = new List <Column>();

            columns1.Add(column1.Object);
            columns1.Add(column2.Object);
            columns2.Add(column3.Object);
            columns2.Add(column4.Object);

            //tabela do filtrowania
            table.Setup(foo => foo.Columns).Returns(columns1);
            table2.Setup(foo => foo.Columns).Returns(columns2);

            FilterCommand.Del del = c => (double)c > 2.0;
            Command           cmd = new FilterCommand(column1.Object, del);
            var result            = cmd.Execute(table.Object);


            int n = table2.Object.Columns.Count;
            int m = result.Columns.Count;

            Assert.AreEqual(n, m);

            for (int i = 0; i < n; i++)
            {
                CollectionAssert.AreEqual(table2.Object.Columns[i].Cells, result.Columns[i].Cells);
            }
        }
コード例 #9
0
        public void FilterLogTabItems(FilterCommand filterIntent = FilterCommand.Filter)
        {
            try
            {
                List <FilterFileItem> filterFileItems = new List <FilterFileItem>(_filterViewModel.FilterList());
                SetStatus(string.Format("filterLogTabItems:enter filterIntent: {0}", filterIntent));
                LogFile logFile;

                // get current log file
                if (_logFileManager.FileManager.Count > 0)
                {
                    logFile = (LogFile)CurrentFile();
                }
                else
                {
                    return;
                }

                LogTabViewModel logTab = (LogTabViewModel)TabItems[SelectedIndex];

                // dont check filter need if intent is to reset list to current filter or to show all
                if (filterIntent == FilterCommand.Filter)
                {
                    FilterNeed filterNeed = _filterViewModel.CompareFilterList(GetPreviousFilter());
                    SetStatus(string.Format("filterLogTabItems: filterNeed: {0}", filterNeed));

                    switch (filterNeed)
                    {
                    case FilterNeed.ApplyColor:
                    {
                        logTab.ContentList = _logFileManager.ApplyColor(logFile.ContentItems, filterFileItems);
                        SaveCurrentFilter(filterFileItems);
                        return;
                    }

                    case FilterNeed.Current:
                    {
                        if (PreviousIndex == SelectedIndex)
                        {
                            SetStatus("filterLogTabItems:no change");
                            return;
                        }

                        break;
                    }

                    case FilterNeed.ShowAll:
                    {
                        filterIntent = FilterCommand.ShowAll;
                        break;
                    }

                    case FilterNeed.Filter:
                        break;

                    case FilterNeed.Unknown:

                    default:
                        SaveCurrentFilter(filterFileItems);
                        return;
                    }
                }

                SetCurrentStatus(CurrentStatusSetting.filtering);

                switch (filterIntent)
                {
                case FilterCommand.Filter:
                {
                    SetStatus(string.Format("switch:Filter: filterIntent:{0}", filterIntent));
                    logTab.ContentList = _logFileManager.ApplyColor(
                        _logFileManager.ApplyFilter(
                            logTab,
                            logFile,
                            filterFileItems,
                            filterIntent),
                        filterFileItems);
                    SetCurrentStatus(CurrentStatusSetting.filtered);
                    break;
                }

                case FilterCommand.Hide:
                {
                    SetStatus(string.Format("switch:Hide: filterIntent:{0}", filterIntent));
                    logTab.ContentList = new ObservableCollection <LogFileItem>(logFile.ContentItems.Where(x => x.FilterIndex > -2));
                    SetCurrentStatus(CurrentStatusSetting.filtered);
                    break;
                }

                case FilterCommand.ShowAll:
                {
                    SetStatus(string.Format("switch:ShowAll: filterIntent:{0}", filterIntent));
                    logTab.ContentList = logFile.ContentItems;
                    break;
                }

                case FilterCommand.Unknown:
                default:
                {
                    break;
                }
                }

                // update line total counts
                LineTotals = string.Format("{0}/{1}", logTab.ContentList.Count, logFile.ContentItems.Count);

                // set current status message
                if (logTab.ContentList.Count == logFile.ContentItems.Count)
                {
                    SetCurrentStatus(CurrentStatusSetting.showing_all);
                }
                else if (_filterViewModel.QuickFindItem.Enabled)
                {
                    SetCurrentStatus(CurrentStatusSetting.quick_filtered);
                }
                else
                {
                    SetCurrentStatus(CurrentStatusSetting.filtered);
                }

                SaveCurrentFilter(filterFileItems);
            }
            catch (Exception e)
            {
                SetStatus("FilterLogTabItems:exception" + e.ToString());
            }
        }
コード例 #10
0
 /// <summary>
 /// Creates a filter query.
 /// </summary>
 /// <param name="filterCommand">The filter command to use.</param>
 /// <param name="query">Optional query to append to.</param>
 /// <returns>A query with the filtering command applied.</returns>
 private IQuery ApplyFilterCommand(FilterCommand filterCommand, IQuery query = null)
 {
     return((query == null) ? firestoreService.Where(CollectionId, filterCommand.FilterKey, filterCommand.Operator, filterCommand.FilterValue)
     : query.Where(filterCommand.FilterKey, filterCommand.Operator, filterCommand.FilterValue));
 }
コード例 #11
0
        public ObservableCollection <LogFileItem> ApplyFilter(LogTabViewModel logTab, LogFile logFile, List <FilterFileItem> filterFileItems, FilterCommand filterCommand)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            DateTime timer = DateTime.Now;

            SetStatus(string.Format("ApplyFilter:start time: {0} log file: {1} ", timer.ToString("hh:mm:ss.fffffff"), logFile.Tag));

            List <FilterFileItem> filterItems = VerifyFilterPatterns(filterFileItems, logTab);

            Debug.Print(string.Format("ApplyFilter: filterItems.Count={0}:{1}", Thread.CurrentThread.ManagedThreadId, filterItems.Count));

            // set regex cache size to number of filter items for better performance
            // https: //msdn.microsoft.com/en-us/library/gg578045(v=vs.110).aspx
            Regex.CacheSize = filterItems.Count;

            int inclusionFilterCount = filterItems.Count(x => x.Include == true);

            ParallelOptions po = new ParallelOptions
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount // / 2
            };

            try
            {
                Parallel.ForEach(logFile.ContentItems, po, logItem =>
                {
                    if (string.IsNullOrEmpty(logItem.Content))
                    {
                        Debug.Print(string.Format("ApplyFilter: logItem.Content empty={0}:{1}", Thread.CurrentThread.ManagedThreadId, logItem.Content));
                        // used for goto line as it needs all line items
                        logItem.FilterIndex = int.MinValue;
                        return;
                    }

                    int filterIndex    = int.MaxValue; // int.MinValue;
                    int includeFilters = inclusionFilterCount;

                    if (Settings.CountMaskedMatches)
                    {
                        logItem.Masked = new int[filterItems.Count, 1];
                    }

                    // clear out groups
                    logItem.Group1 = string.Empty;
                    logItem.Group2 = string.Empty;
                    logItem.Group3 = string.Empty;
                    logItem.Group4 = string.Empty;

                    bool matchSet = false;

                    for (int fItem = 0; fItem < filterItems.Count; fItem++)
                    {
                        int filterItemIndex       = filterFileItems[fItem].Index;
                        bool match                = false;
                        FilterFileItem filterItem = filterItems[fItem];
                        Debug.Print(string.Format("ApplyFilter: loop:{0} filterItem.Pattern={1}:{2} logItem.Content:{3}", filterItemIndex,
                                                  Thread.CurrentThread.ManagedThreadId, filterItem.Filterpattern, logItem.Content));

                        // unnamed and named groups
                        //if (logTab.GroupCount > 0 && filterItem.Regex)
                        if (filterItem.GroupCount > 0 && filterItem.Regex)
                        {
                            MatchCollection mc = Regex.Matches(logItem.Content, filterItem.Filterpattern, RegexOptions.Singleline | (filterItem.CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase));
                            if (mc.Count > 0)
                            {
                                match = true;

                                foreach (Match m in mc)
                                {
                                    if (!string.IsNullOrEmpty(m.Groups[1].Value.ToString()))
                                    {
                                        logItem.Group1 += (string.IsNullOrEmpty(logItem.Group1) ? "" : ";\n") + m.Groups[1].Value.ToString();
                                    }

                                    if (!string.IsNullOrEmpty(m.Groups[2].Value.ToString()))
                                    {
                                        logItem.Group2 += (string.IsNullOrEmpty(logItem.Group2) ? "" : ";\n") + m.Groups[2].Value.ToString();
                                    }

                                    if (!string.IsNullOrEmpty(m.Groups[3].Value.ToString()))
                                    {
                                        logItem.Group3 += (string.IsNullOrEmpty(logItem.Group3) ? "" : ";\n") + m.Groups[3].Value.ToString();
                                    }

                                    if (!string.IsNullOrEmpty(m.Groups[4].Value.ToString()))
                                    {
                                        logItem.Group4 += (string.IsNullOrEmpty(logItem.Group4) ? "" : ";\n") + m.Groups[4].Value.ToString();
                                    }
                                }
                            }
                        }
                        else if (filterItem.Regex && Regex.IsMatch(logItem.Content, filterItem.Filterpattern, RegexOptions.Singleline | (filterItem.CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase)))
                        {
                            match = true;
                        }
                        else if (!filterItem.Regex)
                        {
                            bool andMatch = true;
                            if (filterItem.StringOperators)
                            {
                                Debug.Print(string.Format("ApplyFilter: loop:{0} string with operators "
                                                          + "thread id:{1} filter index:{2} filter string: {3}",
                                                          filterItemIndex,
                                                          Thread.CurrentThread.ManagedThreadId,
                                                          filterIndex,
                                                          filterItem.Filterpattern));
                                // check for ' AND ' and ' OR ' operators
                                foreach (string andPattern in Regex.Split(filterItem.Filterpattern, " AND "))
                                {
                                    Debug.Print(string.Format("ApplyFilter: loop:{0} string andPattern "
                                                              + "thread id:{1} filter index:{2} filter string: {3}",
                                                              filterItemIndex,
                                                              Thread.CurrentThread.ManagedThreadId,
                                                              filterIndex,
                                                              andPattern));

                                    match        = false;
                                    string[] ors = Regex.Split(andPattern, " OR ");
                                    if (ors.Length > 1)
                                    {
                                        foreach (string orPattern in ors)
                                        {
                                            Debug.Print(string.Format("ApplyFilter: loop:{0} string orPattern "
                                                                      + "thread id:{1} filter index:{2} filter string: {3}",
                                                                      filterItemIndex,
                                                                      Thread.CurrentThread.ManagedThreadId,
                                                                      filterIndex,
                                                                      orPattern));
                                            // only match one
                                            if (filterItem.CaseSensitive && logItem.Content.Contains(orPattern))
                                            {
                                                match = true;
                                                Debug.Print(string.Format("ApplyFilter: loop:{0} string orPattern match "
                                                                          + "thread id:{1} filter index:{2} filter string: {3} logItem content: {4}",
                                                                          filterItemIndex,
                                                                          Thread.CurrentThread.ManagedThreadId,
                                                                          filterIndex,
                                                                          orPattern,
                                                                          logItem.Content));
                                                break;
                                            }
                                            else if (logItem.Content.ToLower().Contains(orPattern.ToLower()))
                                            {
                                                match = true;
                                                Debug.Print(string.Format("ApplyFilter: loop:{0} string orPattern match "
                                                                          + "thread id:{1} filter index:{2} filter string: {3} logItem content: {4}",
                                                                          filterItemIndex,
                                                                          Thread.CurrentThread.ManagedThreadId,
                                                                          filterIndex,
                                                                          orPattern,
                                                                          logItem.Content));
                                                break;
                                            }
                                            else
                                            {
                                                Debug.Print(string.Format("ApplyFilter: loop:{0} string orPattern NO match "
                                                                          + "thread id:{1} filter index:{2} filter string: {3} logItem content: {4}",
                                                                          filterItemIndex,
                                                                          Thread.CurrentThread.ManagedThreadId,
                                                                          filterIndex,
                                                                          orPattern,
                                                                          logItem.Content));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        // match all
                                        if (filterItem.CaseSensitive && logItem.Content.Contains(andPattern))
                                        {
                                            match = true;
                                            Debug.Print(string.Format("ApplyFilter: loop:{0} string andPattern all match "
                                                                      + "thread id:{1} filter index:{2} filter string: {3} logItem content: {4}",
                                                                      filterItemIndex,
                                                                      Thread.CurrentThread.ManagedThreadId,
                                                                      filterIndex,
                                                                      andPattern,
                                                                      logItem.Content));
                                        }
                                        else if (logItem.Content.ToLower().Contains(andPattern.ToLower()))
                                        {
                                            match = true;
                                            Debug.Print(string.Format("ApplyFilter: loop:{0} string andPattern all match "
                                                                      + "thread id:{1} filter index:{2} filter string: {3} logItem content: {4}",
                                                                      filterItemIndex,
                                                                      Thread.CurrentThread.ManagedThreadId,
                                                                      filterIndex,
                                                                      andPattern,
                                                                      logItem.Content));
                                        }
                                        else
                                        {
                                            Debug.Print(string.Format("ApplyFilter: loop:{0} string andPattern all NO match "
                                                                      + "thread id:{1} filter index:{2} filter string: {3} logItem content: {4}",
                                                                      filterItemIndex,
                                                                      Thread.CurrentThread.ManagedThreadId,
                                                                      filterIndex,
                                                                      andPattern,
                                                                      logItem.Content));
                                        }
                                    }

                                    andMatch &= match;
                                }

                                match = andMatch;
                            }
                            else
                            {
                                // normal string match
                                if (filterItem.CaseSensitive && logItem.Content.Contains(filterItem.Filterpattern))
                                {
                                    match = true;
                                    Debug.Print(string.Format("ApplyFilter: loop:{0} string andPattern one match "
                                                              + "thread id:{1} filter index:{2} filter string: {3} logItem content: {4}",
                                                              filterItemIndex,
                                                              Thread.CurrentThread.ManagedThreadId,
                                                              filterIndex,
                                                              filterItem.Filterpattern,
                                                              logItem.Content));
                                }
                                else if (logItem.Content.ToLower().Contains(filterItem.Filterpattern.ToLower()))
                                {
                                    match = true;
                                    Debug.Print(string.Format("ApplyFilter: loop:{0} string andPattern one match "
                                                              + "thread id:{1} filter index:{2} filter string: {3} logItem content: {4}",
                                                              filterItemIndex,
                                                              Thread.CurrentThread.ManagedThreadId,
                                                              filterIndex,
                                                              filterItem.Filterpattern,
                                                              logItem.Content));
                                }
                                else
                                {
                                    Debug.Print(string.Format("ApplyFilter: loop:{0} string andPattern one NO match "
                                                              + "thread id:{1} filter index:{2} filter string: {3} logItem content: {4}",
                                                              filterItemIndex,
                                                              Thread.CurrentThread.ManagedThreadId,
                                                              filterIndex,
                                                              filterItem.Filterpattern,
                                                              logItem.Content));
                                }
                            }
                        }

                        Debug.Print(string.Format("ApplyFilter:** loop:{0} filterItem Match={1}:{2} **", filterItemIndex, Thread.CurrentThread.ManagedThreadId, match));

                        if (!matchSet)
                        {
                            if (match && filterItem.Include && !filterItem.Exclude)
                            {
                                filterIndex = filterItemIndex;
                                Debug.Print(string.Format("ApplyFilter: loop:{0} filterItem.Include not exclude setting filterIndex={1}:{2}", filterItemIndex,
                                                          Thread.CurrentThread.ManagedThreadId, filterIndex));
                                matchSet = true;
                                includeFilters--;
                                // break;
                            }
                            else if (!match && filterItem.Include && filterItem.Exclude)
                            {
                                // dynamic filter with and quickfindand but no match so exit
                                filterIndex = int.MinValue;
                                Debug.Print(string.Format("ApplyFilter: loop:{0} no match filterItem.Include and exclude setting filterIndex={1}:{2}", filterItemIndex,
                                                          Thread.CurrentThread.ManagedThreadId, filterIndex));
                                matchSet       = true;
                                includeFilters = 0;
                                // break;
                            }
                            else if (match && filterItem.Include && filterItem.Exclude)
                            {
                                // dynamic filter with and quickfindand but with match
                                filterIndex = int.MinValue;
                                Debug.Print(string.Format("ApplyFilter: loop:{0} match filterItem.Include and exlude setting filterIndex={1}:{2}", filterItemIndex,
                                                          Thread.CurrentThread.ManagedThreadId, filterIndex));
                                matchSet       = false;
                                includeFilters = 0;
                                // break;
                            }
                            else if (match && filterItem.Exclude)
                            {
                                filterIndex = (fItem * -1) - 2;
                                Debug.Print(string.Format("ApplyFilter: loop:{0} filterItem.Exclude and match filterIndex={1}:{2}", filterItemIndex,
                                                          Thread.CurrentThread.ManagedThreadId, filterIndex));

                                matchSet = true;
                                // break;
                            }
                            else if (!match && !filterItem.Exclude)
                            {
                                filterIndex = int.MinValue;
                                Debug.Print(string.Format("ApplyFilter: loop:{0} not filterItem.Exclude and not match filterIndex={1}:{2}",
                                                          filterItemIndex, Thread.CurrentThread.ManagedThreadId, filterIndex));
                            }
                            else if (match)
                            {
                                filterIndex = filterItemIndex;
                                Debug.Print(string.Format("ApplyFilter: loop:{0} setting filterIndex={1}:{2}", filterItemIndex,
                                                          Thread.CurrentThread.ManagedThreadId, filterIndex));
                                matchSet = true;
                                // break;
                            }
                            else if (filterItem.Include)
                            {
                                includeFilters--;
                            }
                        }
                        else if (matchSet && match && Settings.CountMaskedMatches)
                        {
                            logItem.Masked[fItem, 0] = 1;
                            Debug.Print(string.Format("ApplyFilter: loop:{0} masked match filterIndex={1}:{2}", filterItemIndex,
                                                      Thread.CurrentThread.ManagedThreadId, filterItemIndex));
                        }

                        if (matchSet && !Settings.CountMaskedMatches)
                        {
                            Debug.Print(string.Format("ApplyFilter: loop:{0} not filterItem.Exclude CountMaskedMatches={1}:{2}", filterItemIndex,
                                                      Thread.CurrentThread.ManagedThreadId, Settings.CountMaskedMatches));

                            if (includeFilters == 0)
                            {
                                break;
                            }
                        }
                    }

                    Debug.Print(string.Format("ApplyFilter: loop finished set filterIndex={0}:{1}", Thread.CurrentThread.ManagedThreadId, filterIndex));
                    logItem.FilterIndex = filterIndex;
                });

                // write totals negative indexes arent displayed and are only used for counting
                int filterCount = 0;
                for (int i = 0; i < filterFileItems.Count; i++)
                {
                    int filterItemIndex = filterFileItems[i].Index;
                    filterFileItems[i].Count = logFile.ContentItems.Count(x => x.FilterIndex == filterItemIndex | x.FilterIndex == (i * -1) - 2);

                    if (Settings.CountMaskedMatches)
                    {
                        filterFileItems[i].MaskedCount = logFile.ContentItems.Count(x => (x.FilterIndex != int.MaxValue) & (x.FilterIndex != int.MinValue) && x.Masked[i, 0] == 1);
                        SetStatus(string.Format("ApplyFilter:filterItem masked counttotal: {0}", filterFileItems[i].MaskedCount));
                    }

                    SetStatus(string.Format("ApplyFilter:filterItem counttotal: {0}", filterFileItems[i].Count));

                    filterCount += filterFileItems[i].Count;
                }

                double totalSeconds = DateTime.Now.Subtract(timer).TotalSeconds;
                SetStatus(string.Format("ApplyFilter:total time in seconds: {0}\n\tlines per second: {1} "
                                        + "\n\tlogfile total lines count: {2}\n\tlogfile filter lines count: {3}\n\tlog file: {4}"
                                        + "\n\tnumber of filters: {5}\n\tcalculated lines per second for single query: {6}",
                                        totalSeconds,
                                        logFile.ContentItems.Count / totalSeconds,
                                        logFile.ContentItems.Count,
                                        filterCount,
                                        logFile.Tag,
                                        filterItems.Count,
                                        logFile.ContentItems.Count / totalSeconds * filterItems.Count));

                Mouse.OverrideCursor = null;
                return(new ObservableCollection <LogFileItem>(logFile.ContentItems.Where(x => x.FilterIndex > -2)));
            }
            catch (Exception e)
            {
                SetStatus("ApplyFilter:exception" + e.ToString());
                Mouse.OverrideCursor = null;
                return(new ObservableCollection <LogFileItem>());
            }
        }
コード例 #12
0
 void AndGivenInitializeFilterCommand() {
     frCmd = new FilterCommand();
 }