示例#1
0
 public ISearchTaskResult GetErrorResult(Exception ex)
 {
     if ((this.type & SearchType.Statistics) == SearchType.Statistics)
     {
         List <IKeywordHit> list  = new List <IKeywordHit>(1);
         List <string>      list2 = new List <string>(1);
         list2.Add(this.criteria.QueryString);
         if (this.criteria.SubFilters != null)
         {
             list2.AddRange(this.criteria.SubFilters.Keys);
         }
         foreach (string phrase in list2)
         {
             IKeywordHit keywordHit = null;
             foreach (MailboxInfo mailbox in this.MailboxInfoList)
             {
                 if (keywordHit == null)
                 {
                     keywordHit = new KeywordHit(phrase, mailbox, ex);
                 }
                 else
                 {
                     keywordHit.Merge(new KeywordHit(phrase, mailbox, ex));
                 }
             }
             list.Add(keywordHit);
         }
         return(new AggregatedSearchTaskResult(this.MailboxInfoList, list));
     }
     return(new AggregatedSearchTaskResult(this.MailboxInfoList, ex));
 }
        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));
        }
 internal AggregatedSearchTaskResult(MailboxInfoList mailboxInfoList, List <string> keywords, Exception exception) : this(SearchType.Statistics, false, mailboxInfoList, null, null, null, null, 0UL, ByteQuantifiedSize.Zero, null, null, exception)
 {
     Util.ThrowOnNull(keywords, "keywords");
     Util.ThrowOnNull(exception, "exception");
     this.keywordStatisticsResult = new Dictionary <string, IKeywordHit>(keywords.Count, StringComparer.InvariantCultureIgnoreCase);
     foreach (string text in keywords)
     {
         IKeywordHit keywordHit = new KeywordHit(text, this.totalResultCount, this.totalResultSize);
         foreach (MailboxInfo first in this.mailboxInfoList)
         {
             keywordHit.Errors.Add(new Pair <MailboxInfo, Exception>(first, exception));
         }
         this.keywordStatisticsResult.Add(text, keywordHit);
     }
 }