Beispiel #1
0
 protected override void StopSearch()
 {
     Factory.Current.LocalTaskTracer.TraceDebug <Guid>((long)this.GetHashCode(), "Correlation Id:{0}. Search was cancelled", base.ExecutingUser.QueryCorrelationId);
     lock (this.locker)
     {
         if (this.completed != this.totalTasks)
         {
             this.cancelled = true;
             foreach (ISearchMailboxTask searchMailboxTask in this.queue)
             {
                 Factory.Current.LocalTaskTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. Removing {1} Search task on {2} mailboxes on {3} database from the queue", new object[]
                 {
                     base.ExecutingUser.QueryCorrelationId,
                     (searchMailboxTask.Type == SearchType.Preview) ? "Preview" : "Statistics",
                     ((AggregatedMailboxSearchTask)searchMailboxTask).MailboxInfoList.Count,
                     ((AggregatedMailboxSearchTask)searchMailboxTask).MailboxDatabaseGuid
                 });
                 AggregatedMailboxSearchTask aggregatedMailboxSearchTask = searchMailboxTask as AggregatedMailboxSearchTask;
                 base.ResultAggregator.MergeSearchResult((AggregatedSearchTaskResult)searchMailboxTask.GetErrorResult(new DiscoverySearchTaskCancelled(aggregatedMailboxSearchTask.MailboxInfoList, aggregatedMailboxSearchTask.MailboxDatabaseGuid)));
                 this.completed++;
             }
             foreach (ISearchMailboxTask searchMailboxTask2 in this.scheduledTasks)
             {
                 Factory.Current.LocalTaskTracer.TraceDebug <Guid, string, int>((long)this.GetHashCode(), "Correlation Id:{0}. Cancelling {1} Search task on {2} mailboxes. Merging error with the result.", base.ExecutingUser.QueryCorrelationId, (searchMailboxTask2.Type == SearchType.Preview) ? "Preview" : "Statistics", ((AggregatedMailboxSearchTask)searchMailboxTask2).MailboxInfoList.Count);
                 AggregatedMailboxSearchTask aggregatedMailboxSearchTask2 = searchMailboxTask2 as AggregatedMailboxSearchTask;
                 aggregatedMailboxSearchTask2.Abort();
                 base.ResultAggregator.MergeSearchResult((AggregatedSearchTaskResult)searchMailboxTask2.GetErrorResult(new DiscoverySearchTaskCancelled(aggregatedMailboxSearchTask2.MailboxInfoList, aggregatedMailboxSearchTask2.MailboxDatabaseGuid)));
                 this.completed++;
             }
             this.ReportCompletion();
         }
     }
 }