public static void AttachmentListDraw <T>(Object owner, AttachmentHierarchy <T> attachedHierarchy, ref Vector2 vScrollPos)
            where T : class, IGameObject, IAttachment, IFloatValue, new()
        {
            if (attachedHierarchy == null)
            {
                return;
            }

            if (attachedHierarchy.childList.Count > 0)
            {
                if (attachedHierarchy.bFoldout = EditorGUILayout.Foldout(attachedHierarchy.bFoldout, "Attchment List", true))
                {
                    using (var scroll = new EditorGUILayout.ScrollViewScope(vScrollPos))
                    {
                        vScrollPos = scroll.scrollPosition;

                        using (new EditorGUIIndentLevelScope())
                        {
                            EditorGUI.indentLevel++;
                            for (int i = 0; i < attachedHierarchy.childList.Count; ++i)
                            {
                                AttachmentDraw(owner, attachedHierarchy.childList[i]);
                            }
                        }
                    }
                }
            }
        }
        // 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);
        }
Beispiel #3
0
        // 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);
        }
Beispiel #4
0
        // 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);
        }