// Token: 0x060019E8 RID: 6632 RVA: 0x0005D538 File Offset: 0x0005B738 protected override GetAttachmentDataProviderItemsResponse InternalExecute() { UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext, base.CallContext.EffectiveCaller, true); AttachmentDataProvider provider = userContext.AttachmentDataProviderManager.GetProvider(base.CallContext, this.request.AttachmentDataProviderId); return(provider.GetItems(this.request.Paging, this.request.Scope, base.MailboxIdentityMailboxSession)); }
public AttachmentDataProvider AddProvider(CallContext callContext, AttachmentDataProvider attachmentDataProvider) { this.EnsureAttachmentDataProviders(callContext); attachmentDataProvider.Id = Guid.NewGuid().ToString(); this.AddProviderInternal(callContext, new PolymorphicConfiguration <AttachmentDataProvider>(), attachmentDataProvider); return(attachmentDataProvider); }
// Token: 0x060019CC RID: 6604 RVA: 0x0005C200 File Offset: 0x0005A400 protected override CreateAttachmentResponse InternalExecute() { UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext, base.CallContext.EffectiveCaller, true); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); CancellationToken token = cancellationTokenSource.Token; if (this.cancellationId != null && userContext.CancelAttachmentManager.OnCreateAttachment(this.cancellationId, cancellationTokenSource)) { return(null); } CreateAttachmentResponse createAttachmentResponse = null; try { AttachmentDataProvider provider = userContext.AttachmentDataProviderManager.GetProvider(base.CallContext, this.attachmentDataProviderId); createAttachmentResponse = CreateReferenceAttachmentFromAttachmentDataProvider.AttachReferenceAttachment(provider, userContext, this.location, this.dataProviderItemId, this.itemId.Id, base.IdConverter, this.dataProviderParentItemId, this.providerEndpointUrl); } finally { if (this.cancellationId != null) { AttachmentIdType attachmentIdFromCreateAttachmentResponse = CreateAttachmentHelper.GetAttachmentIdFromCreateAttachmentResponse(createAttachmentResponse); if (attachmentIdFromCreateAttachmentResponse != null) { userContext.CancelAttachmentManager.CreateAttachmentCompleted(this.cancellationId, attachmentIdFromCreateAttachmentResponse); } else { userContext.CancelAttachmentManager.CreateAttachmentCancelled(this.cancellationId); } } } return(createAttachmentResponse); }
// Token: 0x060019EE RID: 6638 RVA: 0x0005D5FC File Offset: 0x0005B7FC protected override string InternalExecute() { UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext, base.CallContext.EffectiveCaller, true); AttachmentDataProvider defaultUploadDataProvider = userContext.AttachmentDataProviderManager.GetDefaultUploadDataProvider(base.CallContext); if (defaultUploadDataProvider is OneDriveProAttachmentDataProvider) { return(((OneDriveProAttachmentDataProvider)defaultUploadDataProvider).GetUploadFolderName(userContext)); } return(null); }
// 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); }
internal static void DownloadAndAttachFile(Guid operationId, AttachmentDataProvider attachmentDataProvider, UserContext userContext, string location, string dataProviderItemId, string parentItemId, string subscriptionId, IdConverter idConverter, string channelId, string dataProviderParentItemId, string providerEndpointUrl, CancellationToken cancellationToken, string cancellationId) { AttachmentResultCode errorCode = AttachmentResultCode.GenericFailure; Exception exception = null; AttachmentIdType attachmentId = null; try { OwaDiagnostics.SendWatsonReportsForGrayExceptions(async delegate() { try { DownloadItemAsyncResult downloadItemResult = await attachmentDataProvider.DownloadItemAsync(location, dataProviderItemId, dataProviderParentItemId, providerEndpointUrl, cancellationToken).ConfigureAwait(false); CreateAttachmentNotificationPayload result = new CreateAttachmentNotificationPayload { SubscriptionId = subscriptionId, Id = operationId.ToString(), Bytes = downloadItemResult.Bytes, Item = downloadItemResult.Item, ResultCode = downloadItemResult.ResultCode }; attachmentId = CreateAttachmentHelper.CreateAttachmentAndSendPendingGetNotification(userContext, parentItemId, result.Bytes, result.Item.Name, result, idConverter, channelId); } catch (OperationCanceledException exception) { errorCode = AttachmentResultCode.Cancelled; exception = exception; if (cancellationId != null) { userContext.CancelAttachmentManager.CreateAttachmentCancelled(cancellationId); } } }); } catch (GrayException ex) { ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "CreateAttachmentFromAttachmentDataProvider.DownloadAndAttachFile Exception while trying to download and attach file async : {0}", ex.StackTrace); exception = ex; } finally { if (cancellationId != null) { userContext.CancelAttachmentManager.CreateAttachmentCompleted(cancellationId, attachmentId); } if (exception != null) { CreateAttachmentHelper.SendFailureNotification(userContext, subscriptionId, operationId.ToString(), errorCode, channelId, exception); } } }
// Token: 0x06001AF7 RID: 6903 RVA: 0x000663EC File Offset: 0x000645EC public Implementation(AttachmentDataProvider provider, IXSOFactory factory, IStoreSession attachmentSession, ModernGroupObjectType attachmentSessionModernGroupType, IItem rootItem, IAttachment attachment, string attachmentId, IMailboxSession draftAttachmentSession, StoreObjectId draftObjectId, bool isEdit, string userDisplayName, Func <IStoreSession, StoreId, AttachmentId, string> idConverter) { this.provider = provider; this.factory = factory; this.originalAttachmentSession = attachmentSession; this.originalSessionModernGroupType = attachmentSessionModernGroupType; this.originalAttachmentRootItem = rootItem; this.originalAttachment = attachment; this.originalAttachmentId = attachmentId; this.draftAttachmentSession = draftAttachmentSession; this.draftObjectId = draftObjectId; this.isEdit = isEdit; this.userDisplayName = userDisplayName; this.idConverter = idConverter; }
protected override string InternalExecute() { CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); CancellationToken token = cancellationTokenSource.Token; UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext, base.CallContext.EffectiveCaller, true); if (this.cancellationId != null && userContext.CancelAttachmentManager.OnCreateAttachment(this.cancellationId, cancellationTokenSource)) { return(null); } AttachmentDataProvider provider = userContext.AttachmentDataProviderManager.GetProvider(base.CallContext, this.attachmentDataProviderId); Guid operationId = Guid.NewGuid(); CreateAttachmentFromAttachmentDataProvider.DownloadAndAttachFile(operationId, provider, userContext, this.location, this.dataProviderItemId, this.draftEmailId.Id, this.subscriptionId, base.IdConverter, this.channelId, this.dataProviderParentItemId, this.providerEndpointUrl, token, this.cancellationId); return(operationId.ToString()); }
private void ProviderChanged(AttachmentDataProvider provider, AttachmentDataProviderChangedEventArgs args) { if (this.dataProviders.ContainsKey(provider.Id)) { lock (this.lockObject) { if (this.dataProviders.ContainsKey(provider.Id)) { PolymorphicConfiguration <AttachmentDataProvider> polymorphicConfiguration = new PolymorphicConfiguration <AttachmentDataProvider>(); foreach (AttachmentDataProvider item in this.dataProviders.Values) { polymorphicConfiguration.Entries.Add(item); polymorphicConfiguration.Save(args.MailboxSession); } } } } }
public GetAttachmentDataProviderItemsResponse GetGroups(CallContext callContext, MailboxSession mailboxSession) { AttachmentDataProvider attachmentDataProvider = this.GetDefaultUploadDataProvider(callContext); GetAttachmentDataProviderItemsResponse getAttachmentDataProviderItemsResponse; if (attachmentDataProvider is OneDriveProAttachmentDataProvider) { OneDriveProAttachmentDataProvider oneDriveProAttachmentDataProvider = (OneDriveProAttachmentDataProvider)attachmentDataProvider; getAttachmentDataProviderItemsResponse = oneDriveProAttachmentDataProvider.GetGroups(mailboxSession); } else { getAttachmentDataProviderItemsResponse = new GetAttachmentDataProviderItemsResponse(); getAttachmentDataProviderItemsResponse.Items = new AttachmentDataProviderItem[0]; getAttachmentDataProviderItemsResponse.TotalItemCount = 0; getAttachmentDataProviderItemsResponse.ResultCode = AttachmentResultCode.GenericFailure; } return(getAttachmentDataProviderItemsResponse); }
private void AddProviderInternal(CallContext callContext, PolymorphicConfiguration <AttachmentDataProvider> attachmentDataProvidersConfig, AttachmentDataProvider provider) { lock (this.lockObject) { this.dataProviders[provider.Id] = provider; if (attachmentDataProvidersConfig != null) { attachmentDataProvidersConfig.Entries.Add(provider); attachmentDataProvidersConfig.Save(callContext); } } }
// Token: 0x06001AD5 RID: 6869 RVA: 0x00065E80 File Offset: 0x00064080 private static WacAttachmentType GetResultForReferenceAttachment(CallContext callContext, UserContext userContext, GetWacAttachmentInfo.Implementation implementation, AttachmentDataProvider provider, string mailboxAddress, BaseItemId referenceItemId, string fileName, bool isEdit, string userDisplayName, string sessionId, RequestDetailsLogger logger) { GetWacAttachmentInfo.LogReferenceAttachmentProperties(logger, implementation.ResultAttachmentWebServiceUrl, GetWacAttachmentInfoMetadata.ResultReferenceAttachmentServiceUrl, implementation.ResultAttachmentContentUrl, GetWacAttachmentInfoMetadata.ResultReferenceAttachmentUrl); AttachmentIdType ewsAttachmentIdType = GetWacAttachmentInfo.GetEwsAttachmentIdType(callContext, implementation.ResultItemId, implementation.ResultAttachmentId); WacAttachmentType result = GetWacAttachmentInfo.CreateWacAttachmentType(userContext.LogonIdentity, ewsAttachmentIdType, implementation.ResultAttachmentWebServiceUrl, implementation.ResultAttachmentContentUrl, isEdit, implementation.ResultIsInDraft); if (implementation.ResultAttachmentCreation == WacAttachmentCreationType.Upload) { try { GetWacAttachmentInfo.PostUploadMessage(mailboxAddress, userContext.LogonIdentity.PrimarySmtpAddress.ToString(), userDisplayName, referenceItemId, fileName, implementation.ResultAttachmentContentUrl, implementation.ResultAttachmentProviderType, implementation.ResultAttachmentWebServiceUrl, sessionId); } catch (Exception value) { logger.Set(GetWacAttachmentInfoMetadata.HandledException, value); } } return(result); }
internal static void UploadAndAttachReferenceAttachment(Guid operationId, UserContext userContext, CallContext callContext, ItemId itemId, string fileName, byte[] fileContent, IdConverter idConverter, string subscriptionId, string channelId, CancellationToken cancellationToken, string cancellationId) { AttachmentResultCode errorCode = AttachmentResultCode.GenericFailure; AttachmentIdType attachmentId = null; Exception exception = null; try { OwaDiagnostics.SendWatsonReportsForGrayExceptions(async delegate() { try { AttachmentDataProvider attachmentDataProvider = userContext.AttachmentDataProviderManager.GetDefaultUploadDataProvider(callContext); if (attachmentDataProvider == null) { throw new InvalidOperationException("The user has no default data provider"); } UploadItemAsyncResult uploadResult = await attachmentDataProvider.UploadItemAsync(fileContent, fileName, cancellationToken, callContext).ConfigureAwait(false); CreateAttachmentNotificationPayload notificationPayload = new CreateAttachmentNotificationPayload { SubscriptionId = subscriptionId, Id = operationId.ToString(), Item = uploadResult.Item, ResultCode = uploadResult.ResultCode }; if (uploadResult.ResultCode == AttachmentResultCode.Success) { notificationPayload.Response = CreateReferenceAttachmentFromAttachmentDataProvider.AttachReferenceAttachment(attachmentDataProvider, userContext, uploadResult.Item.Location, string.Empty, itemId.Id, idConverter, null, uploadResult.Item.ProviderEndpointUrl); attachmentId = CreateAttachmentHelper.GetAttachmentIdFromCreateAttachmentResponse(notificationPayload.Response); } if (!userContext.IsDisposed) { try { userContext.LockAndReconnectMailboxSession(); CreateAttachmentHelper.SendPendingGetNotification(userContext, notificationPayload, channelId); } finally { userContext.UnlockAndDisconnectMailboxSession(); } } } catch (OperationCanceledException exception) { errorCode = AttachmentResultCode.Cancelled; exception = exception; if (cancellationId != null) { userContext.CancelAttachmentManager.CreateAttachmentCancelled(cancellationId); } } }); } catch (GrayException ex) { ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "CreateReferenceAttachmentFromLocalFile.UploadAndAttachReferenceAttachment Exception while trying to upload and attach file async : {0}", ex.StackTrace); exception = ex; } finally { if (cancellationId != null) { userContext.CancelAttachmentManager.CreateAttachmentCompleted(cancellationId, attachmentId); } if (exception != null) { CreateAttachmentHelper.SendFailureNotification(userContext, subscriptionId, operationId.ToString(), errorCode, channelId, exception); } } }