Ejemplo n.º 1
0
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        internal 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Search result object</returns>
        internal 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);
        }
 /// <summary>
 /// Load from xml
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 internal 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;
 }