// Token: 0x0600199E RID: 6558 RVA: 0x0005A6C8 File Offset: 0x000588C8 internal static void SendPendingGetNotification(UserContext userContext, CreateAttachmentNotificationPayload result) { CreateAttachmentHelper.SendPendingGetNotification(userContext, result, null); }
// 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); }
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); } } }
// Token: 0x0600199C RID: 6556 RVA: 0x0005A520 File Offset: 0x00058720 internal static void CreateAttachmentAndSendPendingGetNotification(UserContext userContext, string itemId, byte[] bytes, string name, CreateAttachmentNotificationPayload result, IdConverter idConverter) { CreateAttachmentHelper.CreateAttachmentAndSendPendingGetNotification(userContext, itemId, bytes, name, result, idConverter, null); }
internal static void DownloadAndAttachFileFromUri(Uri uri, string name, string subscriptionId, Guid operationId, ItemId itemId, UserContext userContext, IdConverter idConverter) { try { OwaDiagnostics.SendWatsonReportsForGrayExceptions(async delegate() { try { using (HttpClient client = new HttpClient()) { using (HttpResponseMessage response = await client.GetAsync(uri)) { HttpStatusCode statusCode = response.StatusCode; AttachmentResultCode resultCode; if (statusCode != HttpStatusCode.OK) { switch (statusCode) { case HttpStatusCode.Forbidden: resultCode = AttachmentResultCode.AccessDenied; break; case HttpStatusCode.NotFound: resultCode = AttachmentResultCode.NotFound; break; default: if (statusCode != HttpStatusCode.RequestTimeout) { resultCode = AttachmentResultCode.GenericFailure; } else { resultCode = AttachmentResultCode.Timeout; } break; } } else { resultCode = AttachmentResultCode.Success; } if (resultCode != AttachmentResultCode.Success) { CreateAttachmentHelper.SendFailureNotification(userContext, subscriptionId, operationId.ToString(), resultCode, null, null); } byte[] buffer = await response.Content.ReadAsByteArrayAsync(); CreateAttachmentNotificationPayload result = new CreateAttachmentNotificationPayload { SubscriptionId = subscriptionId, Id = operationId.ToString(), Bytes = buffer, Item = null, ResultCode = resultCode }; CreateAttachmentHelper.CreateAttachmentAndSendPendingGetNotification(userContext, itemId.Id, buffer, name, result, idConverter); } } } catch (TaskCanceledException) { } }); } catch (GrayException ex) { CreateAttachmentHelper.SendFailureNotification(userContext, subscriptionId, operationId.ToString(), AttachmentResultCode.GenericFailure, null, ex); ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "CreateAttachmentFromUri.DownloadAndAttachFileFromUri Exception while trying to download and attach file async : {0}", ex.StackTrace); } }