Beispiel #1
0
        internal static bool ItemIsMessageDraft(Item item, Attachment attachment, out string referenceAttachmentWebServiceUrl, out string referenceAttachmentUrl)
        {
            ReferenceAttachment referenceAttachment = attachment as ReferenceAttachment;

            if (referenceAttachment != null)
            {
                referenceAttachmentWebServiceUrl = referenceAttachment.ProviderEndpointUrl;
                referenceAttachmentUrl           = referenceAttachment.AttachLongPathName;
            }
            else
            {
                referenceAttachmentWebServiceUrl = null;
                referenceAttachmentUrl           = null;
            }
            MessageItem messageItem = item as MessageItem;

            return(messageItem != null && messageItem.IsDraft);
        }
Beispiel #2
0
        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;
        }