コード例 #1
0
        internal void CreateSuccessResult(SearchMailboxesResult ewsResult)
        {
            SortedResultPage sortedResultPage = null;
            List <Pair <MailboxInfo, Exception> >       previewErrors = null;
            Dictionary <string, List <IRefinerResult> > dictionary    = null;
            List <MailboxStatistics>         mailboxStatistics        = null;
            Dictionary <string, IKeywordHit> dictionary2 = null;

            if (base.SearchCriteria.SearchType == SearchType.Preview || base.SearchCriteria.SearchType == SearchType.NonIndexedItemPreview || base.SearchCriteria.SearchType == SearchType.NonIndexedItemStatistics)
            {
                sortedResultPage = this.ConvertToPreviewItems(ewsResult.PreviewItems);
                if (ewsResult.FailedMailboxes != null && ewsResult.FailedMailboxes.Length != 0)
                {
                    previewErrors = this.ConvertToPreviewErrors(ewsResult.FailedMailboxes);
                }
                bool emptyResults = sortedResultPage != null && sortedResultPage.ResultCount == 0;
                dictionary        = null;
                mailboxStatistics = this.ConvertMailboxStatistics(ewsResult.MailboxStats, emptyResults);
                if (sortedResultPage == null && (ewsResult.ItemCount > 0L || dictionary != null || ewsResult.Size > 0UL))
                {
                    throw new WebServiceProxyInvalidResponseException(Strings.InvalidPreviewSearchResults(this.Uri.AbsoluteUri));
                }
            }
            if (base.SearchCriteria.SearchType == SearchType.Statistics)
            {
                dictionary2 = new Dictionary <string, IKeywordHit>();
                foreach (KeywordStatisticsSearchResult keywordStatisticsSearchResult in ewsResult.KeywordStats)
                {
                    KeywordHit value = new KeywordHit(keywordStatisticsSearchResult.Keyword, (ulong)((long)keywordStatisticsSearchResult.ItemHits), new ByteQuantifiedSize(keywordStatisticsSearchResult.Size));
                    dictionary2.Add(keywordStatisticsSearchResult.Keyword, value);
                }
            }
            base.ResultAggregator.MergeSearchResult(new ResultAggregator(sortedResultPage, dictionary, (ulong)ewsResult.ItemCount, new ByteQuantifiedSize(ewsResult.Size), previewErrors, dictionary2, mailboxStatistics));
        }
コード例 #2
0
 public ResultAggregator(SortedResultPage resultPage, Dictionary <string, List <IRefinerResult> > refinerResults, ulong totalResultCount, ByteQuantifiedSize totalResultSize, List <Pair <MailboxInfo, Exception> > previewErrors, Dictionary <string, IKeywordHit> keywordStatistics, List <MailboxStatistics> mailboxStatistics)
 {
     this.keywordStatistics = keywordStatistics;
     this.previewResult     = resultPage;
     this.refinerResults    = refinerResults;
     this.previewErrors     = previewErrors;
     this.totalResultCount  = totalResultCount;
     this.totalResultSize   = totalResultSize;
     this.mailboxStatistics = mailboxStatistics;
 }
コード例 #3
0
 public ResultAggregator(SortedResultPage resultPage, Dictionary <string, List <IRefinerResult> > refinerResults, ulong totalResultCount, ByteQuantifiedSize totalResultSize, List <Pair <MailboxInfo, Exception> > previewErrors) : this(resultPage, refinerResults, totalResultCount, totalResultSize, previewErrors, new Dictionary <string, IKeywordHit>(0), new List <MailboxStatistics>(4))
 {
     if (resultPage != null)
     {
         int resultCount = resultPage.ResultCount;
     }
     if (resultPage != null)
     {
         int resultCount2 = resultPage.ResultCount;
     }
 }
コード例 #4
0
        public SearchMailboxResult(MailboxInfo mailbox, SortedResultPage result, ulong totalResultCount)
        {
            Util.ThrowOnNull(mailbox, "mailbox");
            Util.ThrowOnNull(result, "result");
            int resultCount = result.ResultCount;

            this.resultType       = SearchType.Preview;
            this.mailbox          = mailbox;
            this.result           = result;
            this.totalResultCount = totalResultCount;
            this.mailboxStats     = new List <MailboxStatistics>
            {
                new MailboxStatistics(mailbox, this.totalResultCount, this.TotalResultSize)
            };
            this.success = true;
        }
コード例 #5
0
        public void Merge(SortedResultPage newPage)
        {
            if (newPage == null)
            {
                return;
            }
            if (this.pagingInfo == null)
            {
                throw new ArgumentException(Strings.SortedResultNullParameters);
            }
            if (!this.pagingInfo.Equals(newPage.pagingInfo))
            {
                throw new ArgumentException(Strings.InvalidResultMerge);
            }
            int num  = 0;
            int num2 = 0;
            int i    = 0;
            int num3 = this.ResultCount + newPage.ResultCount;

            PreviewItem[] array = new PreviewItem[num3];
            while (i < num3)
            {
                bool flag = false;
                if (num == this.ResultCount)
                {
                    flag = false;
                }
                else if (num2 == newPage.ResultCount)
                {
                    flag = true;
                }
                else if (this.resultRows[num].CompareTo(newPage.resultRows[num2]) <= 0)
                {
                    if (this.pagingInfo.AscendingSort)
                    {
                        flag = true;
                    }
                }
                else if (this.resultRows[num].CompareTo(newPage.resultRows[num2]) > 0 && !this.pagingInfo.AscendingSort)
                {
                    flag = true;
                }
                if (flag)
                {
                    array[i] = this.resultRows[num];
                    num++;
                }
                else
                {
                    array[i] = newPage.resultRows[num2];
                    num2++;
                }
                i++;
            }
            if (this.pagingInfo.ExcludeDuplicates)
            {
                array = Util.ExcludeDuplicateItems(array);
                num3  = array.Length;
            }
            this.resultRows = new PreviewItem[Math.Min(this.pagingInfo.PageSize, num3)];
            if (this.pagingInfo.Direction == PageDirection.Next || num3 < this.pagingInfo.PageSize)
            {
                num = 0;
            }
            else
            {
                num = num3 - this.pagingInfo.PageSize;
            }
            i = 0;
            while (i < Math.Min(this.pagingInfo.PageSize, num3))
            {
                this.resultRows[i] = array[num];
                i++;
                num++;
            }
        }
コード例 #6
0
 internal AggregatedSearchTaskResult(MailboxInfoList mailboxInfoList, SortedResultPage resultPage, Dictionary <string, List <IRefinerResult> > refinerResults, ulong totalResultCount, ByteQuantifiedSize totalResultSize, List <Pair <MailboxInfo, Exception> > previewFailures, List <MailboxStatistics> mailboxStatistics, IProtocolLog protocolLog) : this(SearchType.Preview, true, mailboxInfoList, resultPage, refinerResults, mailboxStatistics, protocolLog, totalResultCount, totalResultSize, previewFailures, null, null)
 {
 }
コード例 #7
0
 private AggregatedSearchTaskResult(SearchType searchType, bool isSuccess, MailboxInfoList mailboxInfoList, SortedResultPage previewResultPage, Dictionary <string, List <IRefinerResult> > refinerResult, List <MailboxStatistics> mailboxStatistics, IProtocolLog protocolLog, ulong totalResultCount, ByteQuantifiedSize totalResultSize, List <Pair <MailboxInfo, Exception> > previewFailures, List <IKeywordHit> keywordStatsResults, Exception error)
 {
     Util.ThrowOnNull(mailboxInfoList, "mailboxInfoList");
     if (mailboxInfoList.Count == 0)
     {
         throw new ArgumentException("Invalid or empty mailboxInfoList");
     }
     this.resultType       = searchType;
     this.mailboxInfoList  = mailboxInfoList;
     this.success          = isSuccess;
     this.exception        = error;
     this.totalResultCount = totalResultCount;
     this.totalResultSize  = totalResultSize;
     this.protocolLog      = protocolLog;
     if (searchType == SearchType.Preview)
     {
         if (this.success)
         {
             if (totalResultCount > 0UL)
             {
                 Util.ThrowOnNull(previewResultPage, "resultPage");
             }
             if (previewResultPage != null && previewResultPage.ResultCount > 0)
             {
                 if (totalResultCount < (ulong)((long)previewResultPage.ResultCount))
                 {
                     Factory.Current.LocalTaskTracer.TraceError <string, Guid>((long)this.GetHashCode(), "The total result count was less than the current page result count for the mailbox:{0} on database:{1}", this.mailboxInfoList[0].MailboxGuid.ToString(), this.mailboxInfoList[0].MdbGuid);
                     throw new ArgumentException("The totalResultCount must be greater than or equal to the current page result count");
                 }
                 if (totalResultSize == ByteQuantifiedSize.Zero)
                 {
                     Factory.Current.LocalTaskTracer.TraceError <string, string>((long)this.GetHashCode(), "There are results from FAST but the size information was not returned from FAST for the mailbox:{0} on database:{1}", this.mailboxInfoList[0].MailboxGuid.ToString(), this.mailboxInfoList[0].MdbGuid.ToString());
                     Factory.Current.EventLog.LogEvent(InfoWorkerEventLogConstants.Tuple_DiscoveryFailedToFetchSizeInformation, null, new object[]
                     {
                         this.mailboxInfoList[0].MailboxGuid.ToString(),
                         this.mailboxInfoList[0].MdbGuid.ToString()
                     });
                 }
             }
             this.previewSearchResultPage = previewResultPage;
             this.refinersResults         = refinerResult;
             Util.ThrowOnNull(mailboxStatistics, "mailboxStatistics");
             if (this.previewSearchResultPage != null && this.previewSearchResultPage.ResultCount > 0 && mailboxStatistics.Count == 0)
             {
                 throw new ArgumentException("The MailboxStats cannot be an empty list when the results are present.");
             }
             this.mailboxStatistics = mailboxStatistics;
         }
         this.previewErrors = new List <Pair <MailboxInfo, Exception> >(this.mailboxInfoList.Count);
         if (this.exception != null)
         {
             foreach (MailboxInfo first in this.mailboxInfoList)
             {
                 this.previewErrors.Add(new Pair <MailboxInfo, Exception>(first, this.exception));
             }
         }
         if (previewFailures != null)
         {
             this.previewErrors.AddRange(previewFailures);
             return;
         }
     }
     else if (searchType == SearchType.Statistics && isSuccess)
     {
         Util.ThrowOnNull(keywordStatsResults, null);
         this.keywordStatisticsResult = new Dictionary <string, IKeywordHit>(keywordStatsResults.Count, StringComparer.InvariantCultureIgnoreCase);
         foreach (IKeywordHit keywordHit in keywordStatsResults)
         {
             IKeywordHit keywordHit2 = null;
             if (!this.keywordStatisticsResult.TryGetValue(keywordHit.Phrase, out keywordHit2))
             {
                 this.keywordStatisticsResult.Add(keywordHit.Phrase, keywordHit);
             }
         }
     }
 }