// Token: 0x0600199B RID: 6555 RVA: 0x0005A370 File Offset: 0x00058570 internal static CreateAttachmentResponse CreateAttachmentResponse(AttachmentHierarchy attachmentHierarchy, Attachment attachment, AttachmentType attachmentType, IdAndSession parentIdAndSession, ServiceError warning) { IdAndSession idAndSession = parentIdAndSession.Clone(); attachment.Load(); idAndSession.AttachmentIds.Add(attachment.Id); AttachmentType attachmentType2; if (attachment is StreamAttachment) { attachmentType2 = new FileAttachmentType(); } else if (attachment is ReferenceAttachment) { attachmentType2 = new ReferenceAttachmentType(); ((ReferenceAttachmentType)attachmentType2).AttachLongPathName = (string)attachment.TryGetProperty(AttachmentSchema.AttachLongPathName); ((ReferenceAttachmentType)attachmentType2).ProviderType = (string)attachment.TryGetProperty(AttachmentSchema.AttachmentProviderType); ((ReferenceAttachmentType)attachmentType2).ProviderEndpointUrl = (string)attachment.TryGetProperty(AttachmentSchema.AttachmentProviderEndpointUrl); object obj = attachment.TryGetProperty(AttachmentSchema.AttachContentId); if (!(obj is PropertyError)) { ((ReferenceAttachmentType)attachmentType2).ContentId = (string)obj; } attachmentType2.Name = attachmentType.Name; } else { attachmentType2 = new ItemAttachmentType(); } attachmentType2.AttachmentId = new AttachmentIdType(idAndSession.GetConcatenatedId().Id); if (attachmentType is ItemIdAttachmentType || attachmentType is ReferenceAttachmentType) { attachmentType2.Size = ((attachment.Size > 2147483647L) ? int.MaxValue : ((int)attachment.Size)); } CreateAttachmentResponse createAttachmentResponse = new CreateAttachmentResponse(); ServiceResult <AttachmentType> serviceResult = (warning == null) ? new ServiceResult <AttachmentType>(attachmentType2) : new ServiceResult <AttachmentType>(attachmentType2, warning); attachmentHierarchy.RootItem.Load(); if (serviceResult.Value != null) { ConcatenatedIdAndChangeKey concatenatedId = IdConverter.GetConcatenatedId(attachmentHierarchy.RootItem.Id, parentIdAndSession, null); serviceResult.Value.AttachmentId.RootItemId = concatenatedId.Id; serviceResult.Value.AttachmentId.RootItemChangeKey = concatenatedId.ChangeKey; } createAttachmentResponse.AddResponses(new ServiceResult <AttachmentType>[] { serviceResult }); return(createAttachmentResponse); }
private static void PopulateAttachmentProperties(IdAndSession idAndSession, Item item, Attachment attachment, ModernAttachment outAttachment) { if (outAttachment == null || attachment == null || item == null) { return; } outAttachment.Data = new ModernAttachment.AttachmentData(); outAttachment.Data.AttachmentEx = new AttachmentTypeEx(); switch (attachment.AttachmentType) { case AttachmentType.NoAttachment: break; case AttachmentType.Stream: { StreamAttachment streamAttachment = attachment as StreamAttachment; if (streamAttachment != null) { FileAttachmentType fileAttachmentType = new FileAttachmentType(); outAttachment.Data.Attachment = fileAttachmentType; fileAttachmentType.IsContactPhoto = streamAttachment.IsContactPhoto; } break; } case AttachmentType.EmbeddedMessage: { ItemAttachment itemAttachment = attachment as ItemAttachment; if (itemAttachment != null) { outAttachment.Data.Attachment = new ItemAttachmentType(); } break; } case AttachmentType.Ole: { OleAttachment oleAttachment = attachment as OleAttachment; if (oleAttachment != null) { FileAttachmentType fileAttachmentType2 = new FileAttachmentType(); outAttachment.Data.Attachment = fileAttachmentType2; fileAttachmentType2.IsContactPhoto = oleAttachment.IsContactPhoto; } break; } case AttachmentType.Reference: { ReferenceAttachment referenceAttachment = attachment as ReferenceAttachment; if (referenceAttachment != null) { UserContext userContext = UserContextManager.GetUserContext(HttpContext.Current); if (userContext != null && userContext.FeaturesManager != null && userContext.FeaturesManager.ClientServerSettings.AttachmentsFilePicker.Enabled) { ReferenceAttachmentType referenceAttachmentType = new ReferenceAttachmentType(); outAttachment.Data.Attachment = referenceAttachmentType; referenceAttachmentType.AttachLongPathName = referenceAttachment.AttachLongPathName; referenceAttachmentType.ProviderEndpointUrl = referenceAttachment.ProviderEndpointUrl; referenceAttachmentType.ProviderType = referenceAttachment.ProviderType; } else { outAttachment.Data.Attachment = new FileAttachmentType(); } } break; } default: return; } if (outAttachment.Data.Attachment == null) { outAttachment.Data.Attachment = new AttachmentType(); } IdAndSession idAndSession2; if (idAndSession == null) { idAndSession2 = new IdAndSession(item.Id, item.Session); } else { idAndSession2 = idAndSession.Clone(); } idAndSession2.AttachmentIds.Add(attachment.Id); outAttachment.Data.Attachment.AttachmentId = new AttachmentIdType(idAndSession2.GetConcatenatedId().Id); outAttachment.Data.Attachment.ContentId = (string.IsNullOrEmpty(attachment.ContentId) ? null : attachment.ContentId); outAttachment.Data.Attachment.ContentLocation = ((attachment.ContentLocation == null) ? null : attachment.ContentLocation.PathAndQuery); outAttachment.Data.Attachment.ContentType = attachment.ContentType; outAttachment.Data.Attachment.IsInline = attachment.IsInline; outAttachment.Data.Attachment.LastModifiedTime = GetModernAttachmentsCommand.Utilities.FormatExDateTime(attachment.LastModifiedTime); outAttachment.Data.Attachment.Name = attachment.DisplayName; outAttachment.Data.Attachment.Size = (int)attachment.Size; }