// 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: 0x0600199D RID: 6557 RVA: 0x0005A534 File Offset: 0x00058734 internal static AttachmentIdType CreateAttachmentAndSendPendingGetNotification(UserContext userContext, string itemId, byte[] bytes, string name, CreateAttachmentNotificationPayload result, IdConverter idConverter, string channelId) { AttachmentIdType result2 = null; if (!userContext.IsDisposed) { AttachmentBuilder attachmentBuilder = null; try { userContext.LockAndReconnectMailboxSession(); if (result.ResultCode == AttachmentResultCode.Success) { IdAndSession idAndSession = new IdAndSession(StoreId.EwsIdToStoreObjectId(itemId), userContext.MailboxSession); FileAttachmentType fileAttachmentType = new FileAttachmentType { Content = bytes, IsInline = false, Name = name, Size = bytes.Length }; AttachmentHierarchy attachmentHierarchy = new AttachmentHierarchy(idAndSession, true, true); attachmentBuilder = new AttachmentBuilder(attachmentHierarchy, new AttachmentType[] { fileAttachmentType }, idConverter, true); ServiceError serviceError; using (Attachment attachment = attachmentBuilder.CreateAttachment(fileAttachmentType, out serviceError)) { if (serviceError == null) { attachmentHierarchy.SaveAll(); } result.Response = CreateAttachmentHelper.CreateAttachmentResponse(attachmentHierarchy, attachment, fileAttachmentType, idAndSession, serviceError); } if (result.Response.ResponseMessages.Items != null && result.Response.ResponseMessages.Items.Length > 0 && result.Response.ResponseMessages.Items[0].ResponseCode == ResponseCodeType.NoError) { ((AttachmentInfoResponseMessage)result.Response.ResponseMessages.Items[0]).Attachments[0].Size = fileAttachmentType.Size; result2 = CreateAttachmentHelper.GetAttachmentIdFromCreateAttachmentResponse(result.Response); } } CreateAttachmentHelper.SendPendingGetNotification(userContext, result, channelId); } finally { userContext.UnlockAndDisconnectMailboxSession(); if (attachmentBuilder != null) { attachmentBuilder.Dispose(); } } } return(result2); }