예제 #1
0
        IUserDefinedSearch IUserDefinedSearches.AddNew()
        {
            string name;

            for (int num = 1;; ++num)
            {
                name = string.Format("New filter {0}", num);
                if (!items.ContainsKey(name))
                {
                    break;
                }
            }
            var search = new UserDefinedSearch(
                this, name,
                filtersFactory.CreateFiltersList(FilterAction.Exclude, FiltersListPurpose.Search)
                );

            items[name] = search;
            changeHandlerInvoker.Invoke();
            return(search);
        }
예제 #2
0
        internal SearchManager(
            ILogSourcesManager sources,
            ISynchronizationContext modelSynchronization,
            IHeartBeatTimer heartBeat,
            ISearchObjectsFactory factory,
            IChangeNotification changeNotification
            )
        {
            this.sources            = sources;
            this.factory            = factory;
            this.changeNotification = changeNotification;

            this.combinedSearchResult        = factory.CreateCombinedSearchResult(this);
            this.combinedResultUpdateInvoker = new AsyncInvokeHelper(
                modelSynchronization, UpdateCombinedResult);
            this.combinedResultNeedsLazyUpdateFlag = new LazyUpdateFlag();

            sources.OnLogSourceAdded += (s, e) =>
            {
                results.ForEach(r => r.FireChangeEventIfContainsSourceResults(s as ILogSource));
            };
            sources.OnLogSourceRemoved += (s, e) =>
            {
                results.ForEach(r => r.FireChangeEventIfContainsSourceResults(s as ILogSource));

                // Search result is fully disposed if it contains messages
                // only from disposed log sources.
                // Fully disposed results are automatically dropped.
                var toBeDropped = results.Where(
                    r => r.Results.All(sr => sr.Source.IsDisposed)).ToHashSet();
                var nrOfFullyDisposedResults = DisposeResults(toBeDropped);
                if (nrOfFullyDisposedResults > 0 && SearchResultsChanged != null)
                {
                    SearchResultsChanged(this, EventArgs.Empty);
                }
                if (nrOfFullyDisposedResults > 0)
                {
                    changeNotification.Post();
                    combinedResultNeedsLazyUpdateFlag.Invalidate();
                }
            };
            heartBeat.OnTimer += (s, e) =>
            {
                if (e.IsNormalUpdate && combinedResultNeedsLazyUpdateFlag.Validate())
                {
                    combinedResultUpdateInvoker.Invoke();
                }
            };
        }
예제 #3
0
 public BookmarkController(
     IBookmarks bookmarks,
     IModelThreads threads,
     IHeartBeatTimer heartbeat,
     ISynchronizationContext synchronization
     )
 {
     tracer         = LJTraceSource.EmptyTracer;
     bookmarksPurge = new AsyncInvokeHelper(synchronization, bookmarks.PurgeBookmarksForDisposedThreads);
     threads.OnThreadListChanged += (s, e) =>
     {
         bookmarksPurge.Invoke();
     };
     bookmarks.OnBookmarksChanged += (sender, e) =>
     {
         if (e.Type == BookmarksChangedEventArgs.ChangeType.Added || e.Type == BookmarksChangedEventArgs.ChangeType.Removed ||
             e.Type == BookmarksChangedEventArgs.ChangeType.RemovedAll || e.Type == BookmarksChangedEventArgs.ChangeType.Purged)
         {
             foreach (var affectedSource in
                      e.AffectedBookmarks
                      .Select(b => b.GetLogSource())
                      .Where(s => s.LogSourceStateIsOkToChangePersistentState())
                      .Distinct())
             {
                 try
                 {
                     affectedSource.StoreBookmarks();
                 }
                 catch (Persistence.StorageException storageException)
                 {
                     tracer.Error(storageException, "Failed to store bookmarks for log {0}",
                                  affectedSource.GetSafeConnectionId());
                 }
             }
         }
     };
 }
예제 #4
0
 void ISearchResultInternal.OnResultCompleted(ISourceSearchResultInternal rslt)
 {
     updateInvokationHelper.Invoke();
 }