Beispiel #1
0
 private MailboxInfo FindMailboxInfo(object state)
 {
     Recorder.Trace(4L, TraceType.InfoTrace, "SearchMailboxesResults.FindMailboxInfo State:", state);
     if (this.sources != null && this.sources.Count > 0)
     {
         Recorder.Trace(4L, TraceType.InfoTrace, "SearchMailboxesResults.FindMailboxInfo Count:", this.sources.Count);
         SearchSource      searchSource = null;
         SearchPreviewItem previewItem  = state as SearchPreviewItem;
         if (previewItem != null)
         {
             searchSource = this.Sources.FirstOrDefault((SearchSource t) => string.Equals(t.OriginalReferenceId, previewItem.Mailbox.MailboxId, StringComparison.InvariantCultureIgnoreCase) || string.Equals(t.ReferenceId, previewItem.Mailbox.MailboxId, StringComparison.InvariantCultureIgnoreCase));
         }
         FailedSearchMailbox failedItem = state as FailedSearchMailbox;
         if (failedItem != null)
         {
             searchSource = this.Sources.FirstOrDefault((SearchSource t) => string.Equals(t.OriginalReferenceId, failedItem.Mailbox, StringComparison.InvariantCultureIgnoreCase) || string.Equals(t.ReferenceId, failedItem.Mailbox, StringComparison.InvariantCultureIgnoreCase));
         }
         MailboxStatisticsItem statisticsItem = state as MailboxStatisticsItem;
         if (statisticsItem != null)
         {
             searchSource = this.Sources.FirstOrDefault((SearchSource t) => string.Equals(t.OriginalReferenceId, statisticsItem.MailboxId, StringComparison.InvariantCultureIgnoreCase) || string.Equals(t.ReferenceId, statisticsItem.MailboxId, StringComparison.InvariantCultureIgnoreCase));
         }
         if (searchSource != null)
         {
             return(searchSource.MailboxInfo);
         }
     }
     Recorder.Trace(4L, TraceType.WarningTrace, "SearchMailboxesResults.FindMailboxInfo Source Not Found State:", state);
     return(null);
 }
Beispiel #2
0
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader"></param>
    /// <returns></returns>
    static MailboxStatisticsItem LoadFromXml(EwsServiceXmlReader reader)
    {
        MailboxStatisticsItem msi = new MailboxStatisticsItem();

        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.MailboxStat);
        msi.MailboxId   = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.MailboxId);
        msi.DisplayName = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.DisplayName);
        msi.ItemCount   = reader.ReadElementValue <long>(XmlNamespace.Types, XmlElementNames.ItemCount);
        msi.Size        = reader.ReadElementValue <ulong>(XmlNamespace.Types, XmlElementNames.Size);
        return(msi);
    }
Beispiel #3
0
    /// <summary>
    /// Load from xml
    /// </summary>
    /// <param name="reader">The reader</param>
    /// <returns>Search result object</returns>
    static SearchMailboxesResult LoadFromXml(EwsServiceXmlReader reader)
    {
        SearchMailboxesResult searchResult = new SearchMailboxesResult();

        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.SearchMailboxesResult);

        List <MailboxQuery> searchQueries = new List <MailboxQuery>();

        do
        {
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SearchQueries))
            {
                reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.MailboxQuery);
                String query = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Query);
                reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScopes);
                List <MailboxSearchScope> mailboxSearchScopes = new List <MailboxSearchScope>();
                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScope))
                    {
                        String mailbox = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Mailbox);
                        reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.SearchScope);
                        String searchScope = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SearchScope);
                        reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScope);
                        mailboxSearchScopes.Add(new MailboxSearchScope(mailbox, (MailboxSearchLocation)Enum.Parse(typeof(MailboxSearchLocation), searchScope)));
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.MailboxSearchScopes));
                reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.MailboxSearchScopes);
                searchQueries.Add(new MailboxQuery(query, mailboxSearchScopes.ToArray()));
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.SearchQueries));
        reader.ReadEndElementIfNecessary(XmlNamespace.Types, XmlElementNames.SearchQueries);
        searchResult.SearchQueries = searchQueries.ToArray();

        searchResult.ResultType    = (SearchResultType)Enum.Parse(typeof(SearchResultType), reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ResultType));
        searchResult.ItemCount     = int.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ItemCount));
        searchResult.Size          = ulong.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Size));
        searchResult.PageItemCount = int.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.PageItemCount));
        searchResult.PageItemSize  = ulong.Parse(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.PageItemSize));

        do
        {
            reader.Read();
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.KeywordStats))
            {
                searchResult.KeywordStats = LoadKeywordStatsXml(reader);
            }

            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Items))
            {
                searchResult.PreviewItems = LoadPreviewItemsXml(reader);
            }

            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.FailedMailboxes))
            {
                searchResult.FailedMailboxes = FailedSearchMailbox.LoadFailedMailboxesXml(XmlNamespace.Types, reader);
            }

            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Refiners))
            {
                List <SearchRefinerItem> refiners = new List <SearchRefinerItem>();
                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Refiner))
                    {
                        refiners.Add(SearchRefinerItem.LoadFromXml(reader));
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Refiners));
                if (refiners.Count > 0)
                {
                    searchResult.Refiners = refiners.ToArray();
                }
            }

            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxStats))
            {
                List <MailboxStatisticsItem> mailboxStats = new List <MailboxStatisticsItem>();
                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxStat))
                    {
                        mailboxStats.Add(MailboxStatisticsItem.LoadFromXml(reader));
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.MailboxStats));
                if (mailboxStats.Count > 0)
                {
                    searchResult.MailboxStats = mailboxStats.ToArray();
                }
            }
        }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.SearchMailboxesResult));

        return(searchResult);
    }