Beispiel #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();
                }
            }
        }