Пример #1
0
        private void HandleSearchCompletion(ISearchMailboxTask task, ISearchTaskResult result)
        {
            AggregatedMailboxSearchTask aggregatedMailboxSearchTask = task as AggregatedMailboxSearchTask;

            lock (this.locker)
            {
                Factory.Current.LocalTaskTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. {1} Search completed on {2} mailboxes, with query of length {3} with {4} keywords.The result was {5}", new object[]
                {
                    base.ExecutingUser.QueryCorrelationId,
                    (task.Type == SearchType.Preview) ? "Preview" : "Statistics",
                    aggregatedMailboxSearchTask.MailboxInfoList.Count,
                    string.IsNullOrEmpty(aggregatedMailboxSearchTask.SearchCriteria.QueryString) ? 0 : aggregatedMailboxSearchTask.SearchCriteria.QueryString.Trim().Length,
                    (aggregatedMailboxSearchTask.SearchCriteria.SubFilters != null && aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count > 0) ? aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count : 0,
                    (result != null && result.Success) ? "Success" : "Failure"
                });
                this.tasksInProgress--;
                this.scheduledTasks.Remove(task);
                if (result != null && task.ShouldRetry(result))
                {
                    Factory.Current.LocalTaskTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. Retrying {1} Search completed on {2} mailboxes, with query of length {3} with {4} keywords.", new object[]
                    {
                        base.ExecutingUser.QueryCorrelationId,
                        (task.Type == SearchType.Preview) ? "Preview" : "Statistics",
                        aggregatedMailboxSearchTask.MailboxInfoList.Count,
                        string.IsNullOrEmpty(aggregatedMailboxSearchTask.SearchCriteria.QueryString) ? 0 : aggregatedMailboxSearchTask.SearchCriteria.QueryString.Trim().Length,
                        (aggregatedMailboxSearchTask.SearchCriteria.SubFilters != null && aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count > 0) ? aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count : 0
                    });
                    this.queue.Enqueue(task);
                }
                else
                {
                    this.completed++;
                    if (result != null)
                    {
                        base.ResultAggregator.MergeSearchResult(result);
                    }
                    aggregatedMailboxSearchTask.Dispose();
                    if (this.completed == this.totalTasks)
                    {
                        this.ReportCompletion();
                    }
                }
                if (!this.cancelled)
                {
                    this.Dispatch();
                }
            }
        }
Пример #2
0
        private void SearchCompletedCallback(ISearchMailboxTask task, ISearchTaskResult result)
        {
            AggregatedMailboxSearchTask aggregatedMailboxSearchTask = task as AggregatedMailboxSearchTask;

            lock (this.locker)
            {
                if (!this.cancelled)
                {
                    this.HandleSearchCompletion(task, result);
                }
                else
                {
                    Factory.Current.LocalTaskTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. {1} Search completed on {2} mailboxes, with query of length {3} with {4} keywords. But not merging the results because search was cancelled.", new object[]
                    {
                        base.ExecutingUser.QueryCorrelationId,
                        (task.Type == SearchType.Preview) ? "Preview" : "Statistics",
                        aggregatedMailboxSearchTask.MailboxInfoList.Count,
                        string.IsNullOrEmpty(aggregatedMailboxSearchTask.SearchCriteria.QueryString) ? 0 : aggregatedMailboxSearchTask.SearchCriteria.QueryString.Trim().Length,
                        (aggregatedMailboxSearchTask.SearchCriteria.SubFilters != null && aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count > 0) ? aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count : 0
                    });
                }
            }
        }
Пример #3
0
 private void Dispatch()
 {
     while (this.tasksInProgress < this.maxNumberOfTasks)
     {
         if (this.queue.Count == 0)
         {
             return;
         }
         ISearchMailboxTask          searchMailboxTask           = this.queue.Dequeue();
         AggregatedMailboxSearchTask aggregatedMailboxSearchTask = searchMailboxTask as AggregatedMailboxSearchTask;
         this.tasksInProgress++;
         this.scheduledTasks.Add(searchMailboxTask);
         Factory.Current.LocalTaskTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. Queuing {1} Search on {2} mailboxes for query of length {3} with {4} keywords.", new object[]
         {
             base.ExecutingUser.QueryCorrelationId,
             (searchMailboxTask.Type == SearchType.Preview) ? "Preview" : "Statistics",
             aggregatedMailboxSearchTask.MailboxInfoList.Count,
             string.IsNullOrEmpty(aggregatedMailboxSearchTask.SearchCriteria.QueryString) ? 0 : aggregatedMailboxSearchTask.SearchCriteria.QueryString.Trim().Length,
             (aggregatedMailboxSearchTask.SearchCriteria.SubFilters != null && aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count > 0) ? aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count : 0
         });
         ThreadPool.QueueUserWorkItem(new WaitCallback(this.Worker), aggregatedMailboxSearchTask);
     }
 }