// Token: 0x06001B00 RID: 6912 RVA: 0x00066904 File Offset: 0x00064B04 private void CopyAttachment(IAttachment attachment, IItem draftItem, out IAttachment newAttachment, out AttachmentId newAttachmentId) { newAttachment = this.factory.CloneAttachment(attachment, draftItem); if (newAttachment is IStreamAttachment) { newAttachment.FileName = GetWacAttachmentInfo.Implementation.GenerateDocumentNameForEditing(attachment.FileName, this.userDisplayName); } else { newAttachment.FileName = attachment.FileName; } newAttachmentId = newAttachment.Id; this.ResultAttachmentExtension = newAttachment.FileExtension; IReferenceAttachment referenceAttachment = newAttachment as IReferenceAttachment; if (referenceAttachment != null) { this.ResultAttachmentContentUrl = referenceAttachment.AttachLongPathName; this.ResultAttachmentWebServiceUrl = referenceAttachment.ProviderEndpointUrl; this.ResultAttachmentProviderType = referenceAttachment.ProviderType; } newAttachment.IsInline = false; newAttachment.Save(); draftItem.Save(SaveMode.NoConflictResolutionForceSave); }
// Token: 0x06001AFB RID: 6907 RVA: 0x00066610 File Offset: 0x00064810 private void SetResultPropertiesFromOriginalAttachment() { this.ResultAttachmentType = this.OriginalAttachmentType; this.ResultAttachmentCreation = WacAttachmentCreationType.UseExisting; this.ResultStoreSession = this.originalAttachmentSession; this.ResultItem = this.originalAttachmentRootItem; this.ResultItemId = this.ResultItem.Id; this.ResultAttachment = this.originalAttachment; this.ResultAttachmentId = this.originalAttachmentId; this.ResultAttachmentExtension = this.originalAttachment.FileExtension; IReferenceAttachment referenceAttachment = this.originalAttachment as IReferenceAttachment; if (referenceAttachment != null) { this.ResultAttachmentContentUrl = referenceAttachment.AttachLongPathName; this.ResultAttachmentWebServiceUrl = referenceAttachment.ProviderEndpointUrl; this.ResultAttachmentProviderType = referenceAttachment.ProviderType; } }
// Token: 0x06001AFF RID: 6911 RVA: 0x0006673C File Offset: 0x0006493C private void UploadAttachment(IAttachment attachment, IItem draftItem, out IAttachment newAttachment, out AttachmentId newAttachmentId) { IStreamAttachment streamAttachment = attachment as IStreamAttachment; if (streamAttachment == null) { throw new InvalidOperationException("UploadAttachment requires a stream attachment, but was given a " + attachment.GetType().Name); } UploadItemAsyncResult uploadItemAsyncResult; using (Stream contentStream = streamAttachment.GetContentStream()) { byte[] array = new byte[contentStream.Length]; while (contentStream.Position != contentStream.Length) { int count = (int)Math.Min(4000L, contentStream.Length - contentStream.Position); contentStream.Read(array, (int)contentStream.Position, count); } CancellationToken cancellationToken = default(CancellationToken); uploadItemAsyncResult = this.provider.UploadItemSync(array, attachment.FileName, cancellationToken); } if (uploadItemAsyncResult.ResultCode != AttachmentResultCode.Success) { throw new GetWacAttachmentInfo.AttachmentUploadException(uploadItemAsyncResult.ResultCode.ToString()); } UserContext userContext = UserContextManager.GetUserContext(CallContext.Current.HttpContext, CallContext.Current.EffectiveCaller, true); this.ResultAttachmentWebServiceUrl = uploadItemAsyncResult.Item.ProviderEndpointUrl; this.ResultAttachmentProviderType = uploadItemAsyncResult.Item.ProviderType.ToString(); this.ResultAttachmentContentUrl = this.provider.GetItemAbsoulteUrl(userContext, uploadItemAsyncResult.Item.Location, uploadItemAsyncResult.Item.ProviderEndpointUrl, null, null); this.ResultAttachmentExtension = attachment.FileExtension; IReferenceAttachment referenceAttachment = (IReferenceAttachment)this.factory.CreateAttachment(draftItem, AttachmentType.Reference); newAttachment = referenceAttachment; newAttachmentId = newAttachment.Id; referenceAttachment.AttachLongPathName = this.ResultAttachmentContentUrl; referenceAttachment.ProviderEndpointUrl = this.ResultAttachmentWebServiceUrl; referenceAttachment.ProviderType = this.ResultAttachmentProviderType; referenceAttachment.FileName = attachment.FileName; newAttachment.IsInline = false; newAttachment.Save(); draftItem.Save(SaveMode.NoConflictResolutionForceSave); }
// Token: 0x06001ACF RID: 6863 RVA: 0x0006569C File Offset: 0x0006389C public static WacAttachmentType Execute(CallContext callContext, IStoreSession originalAttachmentSession, IItem originalAttachmentItem, IAttachment originalAttachment, string draftId, string ewsAttachmentId, bool isEdit) { MdbCache.GetInstance().BeginAsyncUpdate(); UserContext userContext = UserContextManager.GetUserContext(callContext.HttpContext, callContext.EffectiveCaller, true); if (userContext == null) { throw new OwaInvalidRequestException("Unable to determine user context."); } if (!userContext.IsWacEditingEnabled) { isEdit = false; } ConfigurationContext configurationContext = new ConfigurationContext(userContext); AttachmentPolicy attachmentPolicy = configurationContext.AttachmentPolicy; bool isPublicLogon = userContext.IsPublicLogon; if (!attachmentPolicy.GetWacViewingEnabled(isPublicLogon)) { throw new OwaOperationNotSupportedException("WAC viewing not enabled for the current user"); } MailboxSession mailboxSession = null; StoreObjectId draftObjectId = null; if (draftId != null) { IdAndSession idAndSession = GetWacAttachmentInfo.GetIdAndSession(callContext, draftId, false); mailboxSession = (idAndSession.Session as MailboxSession); draftObjectId = StoreId.EwsIdToStoreObjectId(draftId); if (mailboxSession == null) { throw new OwaOperationNotSupportedException("We need a MailboxSession to create the draft, but this a " + idAndSession.Session.GetType().Name); } } string text = originalAttachmentSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); string primarySmtpAddress = callContext.EffectiveCaller.PrimarySmtpAddress; RequestDetailsLogger protocolLog = callContext.ProtocolLog; protocolLog.Set(GetWacAttachmentInfoMetadata.LogonSmtpAddress, primarySmtpAddress); protocolLog.Set(GetWacAttachmentInfoMetadata.MailboxSmtpAddress, text); protocolLog.Set(GetWacAttachmentInfoMetadata.Edit, isEdit); protocolLog.Set(GetWacAttachmentInfoMetadata.Extension, originalAttachment.FileExtension); protocolLog.Set(GetWacAttachmentInfoMetadata.DraftProvided, draftId != null); string displayName = callContext.AccessingPrincipal.MailboxInfo.DisplayName; XSOFactory factory = new XSOFactory(); AttachmentDataProvider defaultUploadDataProvider = new AttachmentDataProviderManager().GetDefaultUploadDataProvider(callContext); IReferenceAttachment referenceAttachment = originalAttachment as IReferenceAttachment; if (referenceAttachment != null) { GetWacAttachmentInfo.LogReferenceAttachmentProperties(protocolLog, referenceAttachment.ProviderEndpointUrl, GetWacAttachmentInfoMetadata.OriginalReferenceAttachmentServiceUrl, referenceAttachment.AttachLongPathName, GetWacAttachmentInfoMetadata.OriginalReferenceAttachmentUrl); } if (defaultUploadDataProvider != null) { protocolLog.Set(GetWacAttachmentInfoMetadata.AttachmentDataProvider, defaultUploadDataProvider.ToString()); } WacAttachmentType wacAttachmentType; try { using (GetWacAttachmentInfo.Implementation implementation = new GetWacAttachmentInfo.Implementation(defaultUploadDataProvider, factory, originalAttachmentSession, originalAttachmentSession.MailboxOwner.ModernGroupType, originalAttachmentItem, originalAttachment, ewsAttachmentId, mailboxSession, draftObjectId, isEdit, displayName, (IStoreSession session, StoreId itemId, AttachmentId attachmentId) => new IdAndSession(itemId, (StoreSession)session) { AttachmentIds = { attachmentId } }.GetConcatenatedId().Id)) { implementation.Execute(); protocolLog.Set(GetWacAttachmentInfoMetadata.OriginalAttachmentType, implementation.OriginalAttachmentType); protocolLog.Set(GetWacAttachmentInfoMetadata.ResultAttachmentType, implementation.ResultAttachmentType); protocolLog.Set(GetWacAttachmentInfoMetadata.ResultAttachmentCreation, implementation.ResultAttachmentCreation); if (implementation.ResultAttachmentType == AttachmentType.Reference) { IMailboxInfo mailboxInfo = originalAttachmentSession.MailboxOwner.MailboxInfo; string mailboxAddress = mailboxInfo.PrimarySmtpAddress.ToString(); StoreId id = originalAttachmentItem.Id; BaseItemId itemIdFromStoreId = IdConverter.GetItemIdFromStoreId(id, new MailboxId(mailboxInfo.MailboxGuid)); string exchangeSessionId = WacUtilities.GetExchangeSessionId(default(Guid).ToString()); protocolLog.Set(GetWacAttachmentInfoMetadata.ExchangeSessionId, exchangeSessionId); wacAttachmentType = GetWacAttachmentInfo.GetResultForReferenceAttachment(callContext, userContext, implementation, defaultUploadDataProvider, mailboxAddress, itemIdFromStoreId, originalAttachment.FileName, isEdit, displayName, exchangeSessionId, protocolLog); } else { if (implementation.ResultAttachmentType != AttachmentType.Stream) { throw new OwaNotSupportedException("Unsupported attachment type " + implementation.ResultAttachmentType); } AttachmentIdType ewsAttachmentIdType = GetWacAttachmentInfo.GetEwsAttachmentIdType(callContext, implementation.ResultItemId, implementation.ResultAttachmentId); wacAttachmentType = GetWacAttachmentInfo.GetResultForStreamAttachment(callContext, userContext, configurationContext, attachmentPolicy, isPublicLogon, Thread.CurrentThread.CurrentCulture.Name, isEdit, (IStreamAttachment)implementation.ResultAttachment, implementation.ResultAttachmentExtension, ewsAttachmentIdType, implementation.ResultIsInDraft, implementation.ResultStoreSession, text, originalAttachmentSession.MailboxOwner.MailboxInfo.IsArchive); } } } catch (ServerException exception) { wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception, WacAttachmentStatus.UploadFailed); } catch (GetWacAttachmentInfo.AttachmentUploadException exception2) { wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception2, WacAttachmentStatus.UploadFailed); } catch (RightsManagementPermanentException exception3) { wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception3, WacAttachmentStatus.ProtectedByUnsupportedIrm); } catch (AttachmentProtectionException exception4) { wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception4, WacAttachmentStatus.ProtectedByUnsupportedIrm); } catch (ObjectNotFoundException exception5) { wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception5, WacAttachmentStatus.NotFound); } catch (OwaInvalidRequestException exception6) { wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception6, WacAttachmentStatus.InvalidRequest); } catch (WacDiscoveryFailureException exception7) { wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception7, WacAttachmentStatus.WacDiscoveryFailed); } catch (WebException exception8) { wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception8, WacAttachmentStatus.AttachmentDataProviderError); } if (wacAttachmentType == null) { throw new OwaInvalidOperationException("There is no reason known for code to reach here without throwing an unhandled exception elsewhere"); } protocolLog.Set(GetWacAttachmentInfoMetadata.Status, wacAttachmentType.Status.ToString()); return(wacAttachmentType); }