protected override CreateAttachmentResponse InternalExecute()
        {
            UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext, base.CallContext.EffectiveCaller, true);
            CreateAttachmentResponse createAttachmentResponse;

            if (this.translatedRequest.CancellationId != null && userContext.CancelAttachmentManager.OnCreateAttachment(this.translatedRequest.CancellationId, null))
            {
                createAttachmentResponse = CreateAttachmentHelper.BuildCreateAttachmentResponseForCancelled();
            }
            else
            {
                createAttachmentResponse = CreateAttachmentHelper.CreateAttachment(base.CallContext, this.translatedRequest);
                if (createAttachmentResponse != null && createAttachmentResponse.ResponseMessages != null && createAttachmentResponse.ResponseMessages.Items != null && createAttachmentResponse.ResponseMessages.Items.Length == 1 && createAttachmentResponse.ResponseMessages.Items[0].ResponseCode == ResponseCodeType.NoError)
                {
                    ((AttachmentInfoResponseMessage)createAttachmentResponse.ResponseMessages.Items[0]).Attachments[0].Size        = this.fileSize;
                    ((AttachmentInfoResponseMessage)createAttachmentResponse.ResponseMessages.Items[0]).Attachments[0].ContentType = this.contentType;
                }
                if (this.translatedRequest.CancellationId != null)
                {
                    AttachmentIdType attachmentIdFromCreateAttachmentResponse = CreateAttachmentHelper.GetAttachmentIdFromCreateAttachmentResponse(createAttachmentResponse);
                    userContext.CancelAttachmentManager.CreateAttachmentCompleted(this.translatedRequest.CancellationId, attachmentIdFromCreateAttachmentResponse);
                }
            }
            return(createAttachmentResponse);
        }
示例#2
0
        protected override CreateAttachmentResponse InternalExecute()
        {
            UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext, base.CallContext.EffectiveCaller, true);
            CreateAttachmentResponse createAttachmentResponse;

            if (this.request.CancellationId != null && userContext.CancelAttachmentManager.OnCreateAttachment(this.request.CancellationId, null))
            {
                createAttachmentResponse = CreateAttachmentHelper.BuildCreateAttachmentResponseForCancelled();
            }
            else
            {
                createAttachmentResponse = CreateAttachmentFromLocalFile.CreateAttachment(this.request);
                if (this.request.CancellationId != null)
                {
                    AttachmentIdType attachmentIdFromCreateAttachmentResponse = CreateAttachmentHelper.GetAttachmentIdFromCreateAttachmentResponse(createAttachmentResponse);
                    userContext.CancelAttachmentManager.CreateAttachmentCompleted(this.request.CancellationId, attachmentIdFromCreateAttachmentResponse);
                }
            }
            return(createAttachmentResponse);
        }