public static string GetItemIdDisplayName(BaseItemId baseItemId) { ItemId itemId = baseItemId as ItemId; string text = baseItemId.GetType().Name + ":"; if (itemId != null) { text += itemId.Id; } else { RecurringMasterItemId recurringMasterItemId = baseItemId as RecurringMasterItemId; if (recurringMasterItemId != null) { text += recurringMasterItemId.OccurrenceId; } else { OccurrenceItemId occurrenceItemId = baseItemId as OccurrenceItemId; if (occurrenceItemId != null) { object obj = text; text = string.Concat(new object[] { obj, occurrenceItemId.RecurringMasterId, "[", occurrenceItemId.InstanceIndex, "]" }); } else { RecurringMasterItemIdRanges recurringMasterItemIdRanges = baseItemId as RecurringMasterItemIdRanges; if (recurringMasterItemIdRanges != null) { object obj2 = text; text = string.Concat(new object[] { obj2, recurringMasterItemIdRanges.Id, "Ranges[", recurringMasterItemIdRanges.Ranges.Length, "]" }); } } } } return(text); }
private void GetAttachmentsFromEwsItem(BaseItemId baseItemId, ModernAttachmentGroup outGroup) { if (baseItemId == null || outGroup == null) { return; } string itemIdDisplayName = GetModernAttachmentsCommand.Utilities.GetItemIdDisplayName(baseItemId); try { IdAndSession idAndSession = base.IdConverter.ConvertItemIdToIdAndSessionReadOnly(baseItemId); using (Item item = Item.Bind(idAndSession.Session, idAndSession.Id)) { List <ModernAttachment> list = new List <ModernAttachment>(0); this.GetAttachmentsFromItemByStoreId(item.Session, item.Id, list); outGroup.AttachmentGroup = list.ToArray(); outGroup.Path = new string[] { GetModernAttachmentsCommand.Utilities.FormatParam("itemId.DisplayName", itemIdDisplayName), GetModernAttachmentsCommand.Utilities.FormatParam("itemId.Id", baseItemId.GetId()), GetModernAttachmentsCommand.Utilities.FormatParam("itemId.ChangeKey", baseItemId.GetChangeKey()) }; } } catch (Exception exception) { StructuredErrors structuredErrors = this.ConvertToNestedErrors(exception); structuredErrors.Path = new string[] { "GetAttachmentsFromEwsItem", GetModernAttachmentsCommand.Utilities.FormatParam("itemId.DisplayName", itemIdDisplayName), GetModernAttachmentsCommand.Utilities.FormatParam("itemId.Id", baseItemId.GetId()), GetModernAttachmentsCommand.Utilities.FormatParam("itemId.ChangeKey", baseItemId.GetChangeKey()) }; this.response.AddError(structuredErrors); } }
// 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); }
// 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); }
// 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; }
// Token: 0x06001A27 RID: 6695 RVA: 0x0005F2E8 File Offset: 0x0005D4E8 internal static void SetReceiveRequestLogData(PolicyTipRequestLogger policyTipRequestLogger, BaseItemId itemId, bool needToReclassify, bool bodyOrSubjectChanged, EmailAddressWrapper[] recipients, EventTrigger eventTrigger, bool customizedStringsNeeded, bool clientSupportsScanResultData, string scanResultData) { policyTipRequestLogger.AppendData("NeedToReclassify", needToReclassify ? "1" : "0"); policyTipRequestLogger.AppendData("ItemId", (itemId == null) ? string.Empty : (itemId.GetId() ?? string.Empty)); policyTipRequestLogger.AppendData("BodyChanged", bodyOrSubjectChanged ? "1" : "0"); string key = "Recipients"; string value; if (recipients != null) { value = string.Join(";", from recipient in recipients select PolicyTipRequestLogger.MarkAsPII((recipient == null || recipient.EmailAddress == null) ? string.Empty : recipient.EmailAddress)); } else { value = string.Empty; } policyTipRequestLogger.AppendData(key, value); policyTipRequestLogger.AppendData("EventTrigger", eventTrigger.ToString()); policyTipRequestLogger.AppendData("CustomizedStringsNeeded", customizedStringsNeeded ? "1" : "0"); policyTipRequestLogger.AppendData("ClientSupportsScanResultData", clientSupportsScanResultData ? "1" : "0"); policyTipRequestLogger.AppendData("ScanResultData", scanResultData ?? string.Empty); }