Пример #1
0
        /// <summary>
        /// Create the response object.
        /// </summary>
        /// <param name="destinationFolderId">The destination folder id.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        /// <returns>The list of items returned by EWS.</returns>
        internal Task <List <Item> > InternalCreate(FolderId destinationFolderId, MessageDisposition messageDisposition)
        {
            ((ItemId)this.PropertyBag[ResponseObjectSchema.ReferenceItemId]).Assign(this.referenceItem.Id);

            return(this.Service.InternalCreateResponseObject(
                       this,
                       destinationFolderId,
                       messageDisposition));
        }
        /// <summary>
        /// Send message.
        /// </summary>
        /// <param name="parentFolderId">The parent folder id.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        private void InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition)
        {
            this.ThrowIfThisIsAttachment();

            if (this.IsNew)
            {
                if ((this.Attachments.Count == 0) || (messageDisposition == MessageDisposition.SaveOnly))
                {
                    this.InternalCreate(
                        parentFolderId,
                        messageDisposition,
                        null);
                }
                else
                {
                    // If the message has attachments, save as a draft (and add attachments) before sending.
                    this.InternalCreate(
                        null,                           // null means use the Drafts folder in the mailbox of the authenticated user.
                        MessageDisposition.SaveOnly,
                        null);

                    this.Service.SendItem(this, parentFolderId);
                }
            }
            else
            {
                // Regardless of whether item is dirty or not, if it has unprocessed
                // attachment changes, process them now.

                // Validate and save attachments before sending.
                if (this.HasUnprocessedAttachmentChanges())
                {
                    this.Attachments.Validate();
                    this.Attachments.Save();
                }

                if (this.PropertyBag.GetIsUpdateCallNecessary())
                {
                    this.InternalUpdate(
                        parentFolderId,
                        ConflictResolutionMode.AutoResolve,
                        messageDisposition,
                        null);
                }
                else
                {
                    this.Service.SendItem(this, parentFolderId);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Create a PostItem response.
        /// </summary>
        /// <param name="parentFolderId">The parent folder id.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        /// <returns>Created PostItem.</returns>
        internal PostItem InternalCreate(FolderId parentFolderId, MessageDisposition? messageDisposition)
        {
            ((ItemId)this.PropertyBag[ResponseObjectSchema.ReferenceItemId]).Assign(this.referenceItem.Id);

            List<Item> items = this.Service.InternalCreateResponseObject(
                this,
                parentFolderId,
                messageDisposition);
            
            PostItem postItem = EwsUtilities.FindFirstItemOfType<PostItem>(items);

            // This should never happen. If it does, we have a bug.
            EwsUtilities.Assert(
                postItem != null,
                "PostReply.InternalCreate",
                "postItem is null. The CreateItem call did not return the expected PostItem.");

            return postItem;
        }
        /// <summary>
        /// Create response object.
        /// </summary>
        /// <param name="parentFolderId">The parent folder id.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        /// <returns>A list of items that were created or modified as a results of this operation.</returns>
        internal List<Item> InternalCreate(FolderId parentFolderId, MessageDisposition? messageDisposition)
        {
            ((ItemId)this.PropertyBag[ResponseObjectSchema.ReferenceItemId]).Assign(this.referenceItem.Id);

            return this.Service.InternalCreateResponseObject(
                this,
                parentFolderId,
                messageDisposition);
        }
Пример #5
0
        /// <summary>
        /// Send message.
        /// </summary>
        /// <param name="parentFolderId">The parent folder id.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        private void InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition)
        {
            this.ThrowIfThisIsAttachment();

            if (this.IsNew)
            {
                if ((this.Attachments.Count == 0) || (messageDisposition == MessageDisposition.SaveOnly))
                {
                    this.InternalCreate(
                        parentFolderId,
                        messageDisposition,
                        null);
                }
                else
                {
                    // If the message has attachments, save as a draft (and add attachments) before sending.
                    this.InternalCreate(
                        null,                           // null means use the Drafts folder in the mailbox of the authenticated user.
                        MessageDisposition.SaveOnly,
                        null);

                    this.Service.SendItem(this, parentFolderId);
                }
            }
            else
            {
                // Regardless of whether item is dirty or not, if it has unprocessed
                // attachment changes, process them now.

                // Validate and save attachments before sending.
                if (this.HasUnprocessedAttachmentChanges())
                {
                    this.Attachments.Validate();
                    this.Attachments.Save();
                }

                if (this.PropertyBag.GetIsUpdateCallNecessary())
                {
                    this.InternalUpdate(
                        parentFolderId,
                        ConflictResolutionMode.AutoResolve,
                        messageDisposition,
                        null);
                }
                else
                {
                    this.Service.SendItem(this, parentFolderId);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Update item.
        /// </summary>
        /// <param name="parentFolderId">The parent folder id.</param>
        /// <param name="conflictResolutionMode">The conflict resolution mode.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        /// <param name="sendInvitationsOrCancellationsMode">The send invitations or cancellations mode.</param>
        /// <param name="suppressReadReceipts">Whether to suppress read receipts</param>
        /// <returns>Updated item.</returns>
        internal Item InternalUpdate(
            FolderId parentFolderId,
            ConflictResolutionMode conflictResolutionMode,
            MessageDisposition? messageDisposition,
            SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode,
            bool suppressReadReceipts)
        {
            this.ThrowIfThisIsNew();
            this.ThrowIfThisIsAttachment();

            Item returnedItem = null;

            if (this.IsDirty && this.PropertyBag.GetIsUpdateCallNecessary())
            {
                returnedItem = this.Service.UpdateItem(
                    this,
                    parentFolderId,
                    conflictResolutionMode,
                    messageDisposition,
                    sendInvitationsOrCancellationsMode.HasValue ? sendInvitationsOrCancellationsMode : this.DefaultSendInvitationsOrCancellationsMode,
                    suppressReadReceipts);
            }

            // Regardless of whether item is dirty or not, if it has unprocessed
            // attachment changes, validate them and process now.
            if (this.HasUnprocessedAttachmentChanges())
            {
                this.Attachments.Validate();
                this.Attachments.Save();
            }

            return returnedItem;
        }
Пример #7
0
 /// <summary>
 /// Update item.
 /// </summary>
 /// <param name="parentFolderId">The parent folder id.</param>
 /// <param name="conflictResolutionMode">The conflict resolution mode.</param>
 /// <param name="messageDisposition">The message disposition.</param>
 /// <param name="sendInvitationsOrCancellationsMode">The send invitations or cancellations mode.</param>
 /// <returns>Updated item.</returns>
 internal Item InternalUpdate(
     FolderId parentFolderId,
     ConflictResolutionMode conflictResolutionMode,
     MessageDisposition? messageDisposition,
     SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode)
 {
     return this.InternalUpdate(parentFolderId, conflictResolutionMode, messageDisposition, sendInvitationsOrCancellationsMode, false);
 }
Пример #8
0
        /// <summary>
        /// Create item.
        /// </summary>
        /// <param name="parentFolderId">The parent folder id.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        /// <param name="sendInvitationsMode">The send invitations mode.</param>
        internal void InternalCreate(
            FolderId parentFolderId,
            MessageDisposition? messageDisposition,
            SendInvitationsMode? sendInvitationsMode)
        {
            this.ThrowIfThisIsNotNew();
            this.ThrowIfThisIsAttachment();

            if (this.IsNew || this.IsDirty)
            {
                this.Service.CreateItem(
                    this,
                    parentFolderId,
                    messageDisposition,
                    sendInvitationsMode.HasValue ? sendInvitationsMode : this.DefaultSendInvitationsMode);

                this.Attachments.Save();
            }
        }
Пример #9
0
 /// <summary>
 /// Update item.
 /// </summary>
 /// <param name="parentFolderId">The parent folder id.</param>
 /// <param name="conflictResolutionMode">The conflict resolution mode.</param>
 /// <param name="messageDisposition">The message disposition.</param>
 /// <param name="sendInvitationsOrCancellationsMode">The send invitations or cancellations mode.</param>
 /// <returns>Updated item.</returns>
 internal async System.Threading.Tasks.Task<Item> InternalUpdateAsync(
     FolderId parentFolderId,
     ConflictResolutionMode conflictResolutionMode,
     MessageDisposition? messageDisposition,
     SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode)
 {
     return await this.InternalUpdateAsync(parentFolderId, conflictResolutionMode, messageDisposition, sendInvitationsOrCancellationsMode, false);
 }
Пример #10
0
        /// <summary>
        /// Create item.
        /// </summary>
        /// <param name="parentFolderId">The parent folder id.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        /// <param name="sendInvitationsMode">The send invitations mode.</param>
        internal async System.Threading.Tasks.Task InternalCreateAsync(
            FolderId parentFolderId,
            MessageDisposition? messageDisposition,
            SendInvitationsMode? sendInvitationsMode)
        {
            this.ThrowIfThisIsNotNew();
            this.ThrowIfThisIsAttachment();

            if (this.IsNew || this.IsDirty)
            {
                await this.Service.CreateItemAsync(
                    this,
                    parentFolderId,
                    messageDisposition,
                    sendInvitationsMode.HasValue ? sendInvitationsMode : this.DefaultSendInvitationsMode);

                await this.Attachments.SaveAsync();
            }
        }
        /// <summary>
        /// Create the response object.
        /// </summary>
        /// <param name="parentFolderId">The parent folder id.</param>
        /// <param name="messageDisposition">The message disposition.</param>
        internal async System.Threading.Tasks.Task InternalCreateAsync(FolderId parentFolderId, MessageDisposition? messageDisposition)
        {
            ((ItemId)this.PropertyBag[ResponseObjectSchema.ReferenceItemId]).Assign(this.referenceItem.Id);

            await this.Service.InternalCreateResponseObjectAsync(
                this,
                parentFolderId,
                messageDisposition);
        }