// Token: 0x060019CD RID: 6605 RVA: 0x0005C2F0 File Offset: 0x0005A4F0 internal static CreateAttachmentResponse AttachReferenceAttachment(AttachmentDataProvider attachmentDataProvider, UserContext userContext, string location, string dataProviderItemId, string parentItemId, IdConverter idConverter, string dataProviderParentItemId = null, string providerEndpointUrl = null) { CreateAttachmentResponse result = null; if (!userContext.IsDisposed) { if (string.IsNullOrEmpty(providerEndpointUrl)) { providerEndpointUrl = attachmentDataProvider.GetEndpointUrlFromItemLocation(location); } string linkingUrl = attachmentDataProvider.GetLinkingUrl(userContext, location, providerEndpointUrl, dataProviderItemId, dataProviderParentItemId); string text = Path.GetFileName(HttpUtility.UrlDecode(linkingUrl)); if (OneDriveProUtilities.IsDurableUrlFormat(text)) { text = text.Substring(0, text.LastIndexOf("?", StringComparison.InvariantCulture)); } try { userContext.LockAndReconnectMailboxSession(); IdAndSession idAndSession = new IdAndSession(StoreId.EwsIdToStoreObjectId(parentItemId), userContext.MailboxSession); ReferenceAttachmentType referenceAttachmentType = new ReferenceAttachmentType { Name = text, AttachLongPathName = linkingUrl, ProviderEndpointUrl = providerEndpointUrl, ProviderType = attachmentDataProvider.Type.ToString() }; if (!userContext.IsGroupUserContext) { referenceAttachmentType.ContentId = Guid.NewGuid().ToString(); referenceAttachmentType.ContentType = "image/png"; } AttachmentHierarchy attachmentHierarchy = new AttachmentHierarchy(idAndSession, true, true); using (AttachmentBuilder attachmentBuilder = new AttachmentBuilder(attachmentHierarchy, new AttachmentType[] { referenceAttachmentType }, idConverter, true)) { ServiceError serviceError; Attachment attachment = attachmentBuilder.CreateAttachment(referenceAttachmentType, out serviceError); if (serviceError == null) { attachmentHierarchy.SaveAll(); } result = CreateAttachmentHelper.CreateAttachmentResponse(attachmentHierarchy, attachment, referenceAttachmentType, idAndSession, serviceError); } } finally { userContext.UnlockAndDisconnectMailboxSession(); } } return(result); }
// Token: 0x0600199B RID: 6555 RVA: 0x0005A370 File Offset: 0x00058570 internal static CreateAttachmentResponse CreateAttachmentResponse(AttachmentHierarchy attachmentHierarchy, Attachment attachment, AttachmentType attachmentType, IdAndSession parentIdAndSession, ServiceError warning) { IdAndSession idAndSession = parentIdAndSession.Clone(); attachment.Load(); idAndSession.AttachmentIds.Add(attachment.Id); AttachmentType attachmentType2; if (attachment is StreamAttachment) { attachmentType2 = new FileAttachmentType(); } else if (attachment is ReferenceAttachment) { attachmentType2 = new ReferenceAttachmentType(); ((ReferenceAttachmentType)attachmentType2).AttachLongPathName = (string)attachment.TryGetProperty(AttachmentSchema.AttachLongPathName); ((ReferenceAttachmentType)attachmentType2).ProviderType = (string)attachment.TryGetProperty(AttachmentSchema.AttachmentProviderType); ((ReferenceAttachmentType)attachmentType2).ProviderEndpointUrl = (string)attachment.TryGetProperty(AttachmentSchema.AttachmentProviderEndpointUrl); object obj = attachment.TryGetProperty(AttachmentSchema.AttachContentId); if (!(obj is PropertyError)) { ((ReferenceAttachmentType)attachmentType2).ContentId = (string)obj; } attachmentType2.Name = attachmentType.Name; } else { attachmentType2 = new ItemAttachmentType(); } attachmentType2.AttachmentId = new AttachmentIdType(idAndSession.GetConcatenatedId().Id); if (attachmentType is ItemIdAttachmentType || attachmentType is ReferenceAttachmentType) { attachmentType2.Size = ((attachment.Size > 2147483647L) ? int.MaxValue : ((int)attachment.Size)); } CreateAttachmentResponse createAttachmentResponse = new CreateAttachmentResponse(); ServiceResult <AttachmentType> serviceResult = (warning == null) ? new ServiceResult <AttachmentType>(attachmentType2) : new ServiceResult <AttachmentType>(attachmentType2, warning); attachmentHierarchy.RootItem.Load(); if (serviceResult.Value != null) { ConcatenatedIdAndChangeKey concatenatedId = IdConverter.GetConcatenatedId(attachmentHierarchy.RootItem.Id, parentIdAndSession, null); serviceResult.Value.AttachmentId.RootItemId = concatenatedId.Id; serviceResult.Value.AttachmentId.RootItemChangeKey = concatenatedId.ChangeKey; } createAttachmentResponse.AddResponses(new ServiceResult <AttachmentType>[] { serviceResult }); return(createAttachmentResponse); }
// Token: 0x06001AD2 RID: 6866 RVA: 0x00065C5C File Offset: 0x00063E5C private static void PostUploadMessage(string groupAddress, string userAddress, string userDisplayName, BaseItemId referenceItemId, string fileName, string contentUrl, string providerType, string endpointUrl, string sessionId) { BodyContentType bodyContentType = new BodyContentType(); bodyContentType.Value = string.Format(Strings.ModernGroupAttachmentUploadNoticeBody, fileName, userDisplayName); ReferenceAttachmentType referenceAttachmentType = new ReferenceAttachmentType(); referenceAttachmentType.AttachLongPathName = contentUrl; referenceAttachmentType.ProviderEndpointUrl = endpointUrl; referenceAttachmentType.ProviderType = providerType; referenceAttachmentType.Name = fileName; ReplyToItemType replyToItemType = new ReplyToItemType(); replyToItemType.NewBodyContent = bodyContentType; replyToItemType.Attachments = new AttachmentType[1]; replyToItemType.Attachments[0] = referenceAttachmentType; replyToItemType.ReferenceItemId = referenceItemId; PostModernGroupItemJsonRequest postModernGroupItemJsonRequest = new PostModernGroupItemJsonRequest(); postModernGroupItemJsonRequest.Body = new PostModernGroupItemRequest(); postModernGroupItemJsonRequest.Body.Items = new NonEmptyArrayOfAllItemsType(); postModernGroupItemJsonRequest.Body.Items.Add(replyToItemType); postModernGroupItemJsonRequest.Body.ModernGroupEmailAddress = new EmailAddressWrapper(); postModernGroupItemJsonRequest.Body.ModernGroupEmailAddress.EmailAddress = groupAddress; postModernGroupItemJsonRequest.Body.ModernGroupEmailAddress.MailboxType = MailboxHelper.MailboxTypeType.GroupMailbox.ToString(); OWAService owaservice = new OWAService(); GetWacAttachmentInfo.PostUploadMessageAsyncState postUploadMessageAsyncState = new GetWacAttachmentInfo.PostUploadMessageAsyncState(); postUploadMessageAsyncState.MailboxSmtpAddress = groupAddress; postUploadMessageAsyncState.LogonSmtpAddress = userAddress; postUploadMessageAsyncState.OwaService = owaservice; postUploadMessageAsyncState.SessionId = sessionId; IAsyncResult asyncResult = owaservice.BeginPostModernGroupItem(postModernGroupItemJsonRequest, null, null); asyncResult.AsyncWaitHandle.WaitOne(); PostModernGroupItemResponse body = owaservice.EndPostModernGroupItem(asyncResult).Body; }
private static void PopulateAttachmentProperties(IdAndSession idAndSession, Item item, Attachment attachment, ModernAttachment outAttachment) { if (outAttachment == null || attachment == null || item == null) { return; } outAttachment.Data = new ModernAttachment.AttachmentData(); outAttachment.Data.AttachmentEx = new AttachmentTypeEx(); switch (attachment.AttachmentType) { case AttachmentType.NoAttachment: break; case AttachmentType.Stream: { StreamAttachment streamAttachment = attachment as StreamAttachment; if (streamAttachment != null) { FileAttachmentType fileAttachmentType = new FileAttachmentType(); outAttachment.Data.Attachment = fileAttachmentType; fileAttachmentType.IsContactPhoto = streamAttachment.IsContactPhoto; } break; } case AttachmentType.EmbeddedMessage: { ItemAttachment itemAttachment = attachment as ItemAttachment; if (itemAttachment != null) { outAttachment.Data.Attachment = new ItemAttachmentType(); } break; } case AttachmentType.Ole: { OleAttachment oleAttachment = attachment as OleAttachment; if (oleAttachment != null) { FileAttachmentType fileAttachmentType2 = new FileAttachmentType(); outAttachment.Data.Attachment = fileAttachmentType2; fileAttachmentType2.IsContactPhoto = oleAttachment.IsContactPhoto; } break; } case AttachmentType.Reference: { ReferenceAttachment referenceAttachment = attachment as ReferenceAttachment; if (referenceAttachment != null) { UserContext userContext = UserContextManager.GetUserContext(HttpContext.Current); if (userContext != null && userContext.FeaturesManager != null && userContext.FeaturesManager.ClientServerSettings.AttachmentsFilePicker.Enabled) { ReferenceAttachmentType referenceAttachmentType = new ReferenceAttachmentType(); outAttachment.Data.Attachment = referenceAttachmentType; referenceAttachmentType.AttachLongPathName = referenceAttachment.AttachLongPathName; referenceAttachmentType.ProviderEndpointUrl = referenceAttachment.ProviderEndpointUrl; referenceAttachmentType.ProviderType = referenceAttachment.ProviderType; } else { outAttachment.Data.Attachment = new FileAttachmentType(); } } break; } default: return; } if (outAttachment.Data.Attachment == null) { outAttachment.Data.Attachment = new AttachmentType(); } IdAndSession idAndSession2; if (idAndSession == null) { idAndSession2 = new IdAndSession(item.Id, item.Session); } else { idAndSession2 = idAndSession.Clone(); } idAndSession2.AttachmentIds.Add(attachment.Id); outAttachment.Data.Attachment.AttachmentId = new AttachmentIdType(idAndSession2.GetConcatenatedId().Id); outAttachment.Data.Attachment.ContentId = (string.IsNullOrEmpty(attachment.ContentId) ? null : attachment.ContentId); outAttachment.Data.Attachment.ContentLocation = ((attachment.ContentLocation == null) ? null : attachment.ContentLocation.PathAndQuery); outAttachment.Data.Attachment.ContentType = attachment.ContentType; outAttachment.Data.Attachment.IsInline = attachment.IsInline; outAttachment.Data.Attachment.LastModifiedTime = GetModernAttachmentsCommand.Utilities.FormatExDateTime(attachment.LastModifiedTime); outAttachment.Data.Attachment.Name = attachment.DisplayName; outAttachment.Data.Attachment.Size = (int)attachment.Size; }
/// <summary> /// Creates an item or file attachment on an item. /// </summary> /// <param name="parentItemId">Identifies the parent item in the server store that contains the attachment.</param> /// <param name="attachmentsType">Attachment type.</param> /// <returns>A response message for "CreateAttachment" operation.</returns> protected CreateAttachmentResponseType CallCreateAttachmentOperation(string parentItemId, params AttachmentTypeValue[] attachmentsType) { // Configure attachments. int attachmentCount = attachmentsType.Length; this.Attachments = new AttachmentType[attachmentCount]; for (int attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++) { AttachmentType attachment = null; if (attachmentsType[attachmentIndex] == AttachmentTypeValue.FileAttachment) { FileAttachmentType fileAttachment = new FileAttachmentType() { ContentLocation = @"http://www.contoso.com/xyz.abc", Name = "attach.jpg", // Ensure content id is unique. ContentId = Guid.NewGuid().ToString(), ContentType = "image/jpeg", Content = Convert.FromBase64String("/9j/4AAQSkZJRgABAQEAYABgAAD/7AARRHVja3kAAQAEAAAARgAA/9sAQwACAQECAQECAgICAgICAgMFAwMDAwMGBAQDBQcGBwcHBgcHCAkLCQgICggHBwoNCgoLDAwMDAcJDg8NDA4LDAwM/9sAQwECAgIDAwMGAwMGDAgHCAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgADAAUAwEi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ndex] == AttachmentTypeValue.ReferenceAttachment) { ReferenceAttachmentType referenceAttachment = new ReferenceAttachmentType() { AttachLongPathName = @"http://www.contoso.com/xyz.abc", ProviderType = "abc", ProviderEndpointUrl = @"http://www.contoso.com", AttachmentPreviewUrl = @"http://www.contoso.com/Preview.abc", AttachmentThumbnailUrl = @"http://www.contoso.com/Thumbnail.abc", ContentLocation = @"http://www.contoso.com/xyz.abc", Name = "RefAttachment", ContentId = Guid.NewGuid().ToString(), ContentType = "image/jpeg", }; attachment = referenceAttachment; } else { ItemAttachmentType itemAttachment = new ItemAttachmentType() { ContentLocation = @"http://www.contoso.com/xyz.abc", Name = "ItemName", // Ensure content id is unique. ContentId = Guid.NewGuid().ToString(), ContentType = "image/jpeg", }; switch (attachmentsType[attachmentIndex]) { case AttachmentTypeValue.ItemAttachment: itemAttachment.Item = new ItemType(); break; case AttachmentTypeValue.MessageAttachment: itemAttachment.Item = new MessageType() { Body = new BodyType() { BodyType1 = BodyTypeType.HTML, Value = "<html><body><b>Bold</b><script>alert('Alert!');</script></body></html>" }, }; break; case AttachmentTypeValue.CalendarAttachment: itemAttachment.Item = new CalendarItemType() { StartSpecified = true, EndSpecified = true }; break; case AttachmentTypeValue.ContactAttachment: itemAttachment.Item = new ContactItemType(); break; case AttachmentTypeValue.PostAttachment: itemAttachment.Item = new PostItemType(); break; case AttachmentTypeValue.TaskAttachment: itemAttachment.Item = new TaskType(); break; case AttachmentTypeValue.MeetingMessageAttachemnt: itemAttachment.Item = new MeetingMessageType(); break; case AttachmentTypeValue.MeetingRequestAttachment: itemAttachment.Item = new MeetingRequestMessageType(); break; case AttachmentTypeValue.MeetingResponseAttachment: itemAttachment.Item = new MeetingResponseMessageType(); break; case AttachmentTypeValue.MeetingCancellationAttachment: itemAttachment.Item = new MeetingCancellationMessageType(); break; case AttachmentTypeValue.PersonAttachment: itemAttachment.Item = new AbchPersonItemType() { AntiLinkInfo = "", PersonId = Guid.NewGuid().ToString(), ContactHandles = new AbchPersonContactHandle[] { new AbchPersonContactHandle(), }, ContactCategories = new string[] { "test category" }, }; break; } attachment = itemAttachment; } this.Attachments[attachmentIndex] = attachment; } CreateAttachmentType createAttachmentRequest = new CreateAttachmentType() { ParentItemId = new ItemIdType() { Id = parentItemId }, Attachments = this.Attachments }; return(this.ATTAdapter.CreateAttachment(createAttachmentRequest)); }