Пример #1
0
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Non indexable item details result object</returns>
        internal static NonIndexableItemDetailsResult LoadFromXml(EwsServiceXmlReader reader)
        {
            NonIndexableItemDetailsResult nonIndexableItemDetailsResult = new NonIndexableItemDetailsResult();

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

            do
            {
                reader.Read();

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Items))
                {
                    List <NonIndexableItem> nonIndexableItems = new List <NonIndexableItem>();
                    if (!reader.IsEmptyElement)
                    {
                        do
                        {
                            reader.Read();
                            NonIndexableItem nonIndexableItem = NonIndexableItem.LoadFromXml(reader);
                            if (nonIndexableItem != null)
                            {
                                nonIndexableItems.Add(nonIndexableItem);
                            }
                        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.Items));

                        nonIndexableItemDetailsResult.Items = nonIndexableItems.ToArray();
                    }
                }

                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.FailedMailboxes))
                {
                    nonIndexableItemDetailsResult.FailedMailboxes = FailedSearchMailbox.LoadFailedMailboxesXml(XmlNamespace.Types, reader);
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.NonIndexableItemDetailsResult));

            return(nonIndexableItemDetailsResult);
        }
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Non indexable item object</returns>
        internal static NonIndexableItem LoadFromXml(EwsServiceXmlReader reader)
        {
            NonIndexableItem result = null;
            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.NonIndexableItemDetail))
            {
                ItemId itemId = null;
                ItemIndexError errorCode = ItemIndexError.None;
                string errorDescription = null;
                bool isPartiallyIndexed = false;
                bool isPermanentFailure = false;
                int attemptCount = 0;
                DateTime? lastAttemptTime = null;
                string additionalInfo = null;
                string sortValue = null;

                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ItemId))
                    {
                        itemId = new ItemId();
                        itemId.ReadAttributesFromXml(reader);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ErrorDescription))
                    {
                        errorDescription = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ErrorDescription);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.IsPartiallyIndexed))
                    {
                        isPartiallyIndexed = reader.ReadElementValue<bool>(XmlNamespace.Types, XmlElementNames.IsPartiallyIndexed);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.IsPermanentFailure))
                    {
                        isPermanentFailure = reader.ReadElementValue<bool>(XmlNamespace.Types, XmlElementNames.IsPermanentFailure);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.AttemptCount))
                    {
                        attemptCount = reader.ReadElementValue<int>(XmlNamespace.Types, XmlElementNames.AttemptCount);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.LastAttemptTime))
                    {
                        lastAttemptTime = reader.ReadElementValue<DateTime>(XmlNamespace.Types, XmlElementNames.LastAttemptTime);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.AdditionalInfo))
                    {
                        additionalInfo = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.AdditionalInfo);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SortValue))
                    {
                        sortValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SortValue);
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.NonIndexableItemDetail));

                result = new NonIndexableItem
                {
                    ItemId = itemId,
                    ErrorCode = errorCode,
                    ErrorDescription = errorDescription,
                    IsPartiallyIndexed = isPartiallyIndexed,
                    IsPermanentFailure = isPermanentFailure,
                    AttemptCount = attemptCount,
                    LastAttemptTime = lastAttemptTime,
                    AdditionalInfo = additionalInfo,
                    SortValue = sortValue,
                };
            }

            return result;
        }
        /// <summary>
        /// Load from xml
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <returns>Non indexable item object</returns>
        internal static NonIndexableItem LoadFromXml(EwsServiceXmlReader reader)
        {
            NonIndexableItem result = null;

            if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.NonIndexableItemDetail))
            {
                ItemId         itemId             = null;
                ItemIndexError errorCode          = ItemIndexError.None;
                string         errorDescription   = null;
                bool           isPartiallyIndexed = false;
                bool           isPermanentFailure = false;
                int            attemptCount       = 0;
                DateTime?      lastAttemptTime    = null;
                string         additionalInfo     = null;
                string         sortValue          = null;

                do
                {
                    reader.Read();
                    if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ItemId))
                    {
                        itemId = new ItemId();
                        itemId.ReadAttributesFromXml(reader);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ErrorDescription))
                    {
                        errorDescription = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.ErrorDescription);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.IsPartiallyIndexed))
                    {
                        isPartiallyIndexed = reader.ReadElementValue <bool>(XmlNamespace.Types, XmlElementNames.IsPartiallyIndexed);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.IsPermanentFailure))
                    {
                        isPermanentFailure = reader.ReadElementValue <bool>(XmlNamespace.Types, XmlElementNames.IsPermanentFailure);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.AttemptCount))
                    {
                        attemptCount = reader.ReadElementValue <int>(XmlNamespace.Types, XmlElementNames.AttemptCount);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.LastAttemptTime))
                    {
                        lastAttemptTime = reader.ReadElementValue <DateTime>(XmlNamespace.Types, XmlElementNames.LastAttemptTime);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.AdditionalInfo))
                    {
                        additionalInfo = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.AdditionalInfo);
                    }
                    else if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.SortValue))
                    {
                        sortValue = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.SortValue);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.NonIndexableItemDetail));

                result = new NonIndexableItem
                {
                    ItemId             = itemId,
                    ErrorCode          = errorCode,
                    ErrorDescription   = errorDescription,
                    IsPartiallyIndexed = isPartiallyIndexed,
                    IsPermanentFailure = isPermanentFailure,
                    AttemptCount       = attemptCount,
                    LastAttemptTime    = lastAttemptTime,
                    AdditionalInfo     = additionalInfo,
                    SortValue          = sortValue,
                };
            }

            return(result);
        }