Exemple #1
0
        private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
        {
            Logger.logInfo("Started Filter worker [" + Thread.CurrentThread.ManagedThreadId + "] for line " +
                           startLine);

            // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering
            FilterParams threadFilterParams = filterParams.CreateCopy2();

            LogExpert.LogWindow.ColumnizerCallback threadColumnizerCallback = this.callback.createCopy();

            Filter filter = new Filter(threadColumnizerCallback);

            lock (this.filterWorkerList)
            {
                this.filterWorkerList.Add(filter);
            }
            if (this.shouldStop)
            {
                return(filter);
            }
            int realCount = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback);

            Logger.logInfo("Filter worker [" + Thread.CurrentThread.ManagedThreadId + "] for line " + startLine +
                           " has completed.");
            lock (this.filterReadyList)
            {
                this.filterReadyList.Add(filter);
            }
            return(filter);
        }
 public RangeFinder(FilterParams filterParams, LogExpert.LogWindow.ColumnizerCallback callback)
 {
     this.filterParams = filterParams.CreateCopy2();
     this.callback     = callback;
 }
Exemple #3
0
		private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
		{
			Logger.logInfo(string.Format("Started Filter worker [{0}] for line {1}", Thread.CurrentThread.ManagedThreadId, startLine));
			
			// Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering
			FilterParams threadFilterParams = filterParams.CreateCopy2();
			LogExpert.ColumnizerCallback threadColumnizerCallback = _callback.createCopy();
			
			Filter filter = new Filter(threadColumnizerCallback);
			lock (_filterWorkerList)
			{
				_filterWorkerList.Add(filter);
			}
			if (_shouldStop)
			{
				return filter;
			}
			int realCount = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback);
			Logger.logInfo(string.Format("Filter worker [{0}] for line {1} has completed.", Thread.CurrentThread.ManagedThreadId, startLine));
			lock (_filterReadyList)
			{
				_filterReadyList.Add(filter);
			}
			return filter;
		}
Exemple #4
0
		public RangeFinder(FilterParams filterParams, LogExpert.ColumnizerCallback callback)
		{
			_filterParams = filterParams.CreateCopy2();
			_callback = callback;
		}
Exemple #5
0
        public Range FindRange(int startLine)
        {
            Logger.logInfo("Starting range search for " + _filterParams.searchText + " ... " + _filterParams.rangeSearchText);
            if (_filterParams.rangeSearchText == null || _filterParams.rangeSearchText.Trim().Length == 0)
            {
                Logger.logInfo("Range search text not set. Cancelling range search.");
                return(null);
            }
            if (_filterParams.searchText == null || _filterParams.searchText.Trim().Length == 0)
            {
                Logger.logInfo("Search text not set. Cancelling range search.");
                return(null);
            }

            _filterParams.isRangeSearch = false;
            _filterParams.isInRange     = false;
            string       line;
            int          lineCount      = _callback.GetLineCount();
            int          lineNum        = startLine;
            bool         foundStartLine = false;
            Range        range          = new Range();
            FilterParams tmpParam       = _filterParams.CreateCopy2();

            tmpParam.searchText = _filterParams.rangeSearchText;

            // search backward for starting keyword
            line = _callback.GetLogLine(lineNum);
            while (lineNum >= 0)
            {
                _callback.LineNum = lineNum;
                if (Classes.DamerauLevenshtein.TestFilterCondition(_filterParams, line, _callback))
                {
                    foundStartLine = true;
                    break;
                }
                lineNum--;
                line = _callback.GetLogLine(lineNum);
                if (lineNum < 0 || Classes.DamerauLevenshtein.TestFilterCondition(tmpParam, line, _callback))                 // do not crash on Ctrl+R when there is not start line found
                {
                    // lower range bound found --> we are not in between a valid range
                    break;
                }
            }
            if (!foundStartLine)
            {
                Logger.logInfo("Range start not found");
                return(null);
            }
            range.StartLine             = lineNum;
            _filterParams.isRangeSearch = true;
            _filterParams.isInRange     = true;
            lineNum++;
            while (lineNum < lineCount)
            {
                line = _callback.GetLogLine(lineNum);
                _callback.LineNum = lineNum;
                if (!Classes.DamerauLevenshtein.TestFilterCondition(_filterParams, line, _callback))
                {
                    break;
                }
                lineNum++;
            }
            lineNum--;
            range.EndLine = lineNum;
                        #if DEBUG
            Logger.logInfo("Range search finished. Found " + (range.EndLine - range.StartLine) + " lines");
                        #endif
            return(range);
        }
Exemple #6
0
 public RangeFinder(FilterParams filterParams, LogExpert.ColumnizerCallback callback)
 {
     _filterParams = filterParams.CreateCopy2();
     _callback     = callback;
 }