コード例 #1
0
        public static void ProcessAttachment(IStoreSession session, string ewsAttachmentId, IExchangePrincipal exchangePrincipal, PropertyOpenMode openMode, WacUtilities.AttachmentProcessor attachmentProcessor)
        {
            IdConverterDependencies converterDependencies = new IdConverterDependencies.FromRawData(false, false, null, null, exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), session as MailboxSession, session as MailboxSession, session as PublicFolderSession);

            using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(ewsAttachmentId, converterDependencies))
            {
                bool flag = WacUtilities.IsIrmRestricted(attachmentRetriever.RootItem);
                if (openMode == PropertyOpenMode.Modify)
                {
                    attachmentRetriever.RootItem.OpenAsReadWrite();
                }
                StreamAttachment streamAttachment = attachmentRetriever.Attachment as StreamAttachment;
                if (streamAttachment == null)
                {
                    attachmentProcessor(exchangePrincipal, attachmentRetriever.Attachment, null, flag);
                }
                else
                {
                    using (Stream contentStream = streamAttachment.GetContentStream(openMode))
                    {
                        bool flag2 = WacUtilities.IsContentProtected(attachmentRetriever.Attachment.FileName, contentStream);
                        attachmentProcessor(exchangePrincipal, streamAttachment, contentStream, flag || flag2);
                        if (openMode == PropertyOpenMode.Modify)
                        {
                            attachmentRetriever.RootItem.Save(SaveMode.NoConflictResolution);
                        }
                    }
                }
            }
        }
コード例 #2
0
        private static bool TryProcessUnprotectedAttachment(IExchangePrincipal exchangePrincipal, Item item, StreamAttachment streamAttachment, PropertyOpenMode openMode, WacUtilities.AttachmentProcessor attachmentProcessor)
        {
            if (openMode == PropertyOpenMode.Modify)
            {
                item.OpenAsReadWrite();
            }
            bool result;

            using (Stream contentStream = streamAttachment.GetContentStream(openMode))
            {
                bool flag = WacUtilities.IsContentProtected(streamAttachment.FileName, contentStream);
                if (flag)
                {
                    result = false;
                }
                else
                {
                    attachmentProcessor(exchangePrincipal, streamAttachment, contentStream, false);
                    if (openMode == PropertyOpenMode.Modify)
                    {
                        item.Save(SaveMode.NoConflictResolution);
                    }
                    result = true;
                }
            }
            return(result);
        }
コード例 #3
0
        private static void ProcessAttachment(WacRequest wacRequest, PropertyOpenMode openMode, WacUtilities.AttachmentProcessor attachmentProcessor)
        {
            ADSessionSettings adSessionSettings;
            ExchangePrincipal exchangePrincipal = WacUtilities.GetExchangePrincipal(wacRequest, out adSessionSettings, wacRequest.WacFileRep.IsArchive);

            WacRequestHandler.ProcessUsingBudget(wacRequest.WacFileRep.LogonSid, delegate
            {
                string ewsAttachmentId  = wacRequest.EwsAttachmentId;
                CultureInfo cultureInfo = CultureInfo.GetCultureInfo(wacRequest.CultureName);
                string clientInfoString = "Client=OWA;Action=WAC";
                if (exchangePrincipal.RecipientTypeDetails.HasFlag(RecipientTypeDetails.PublicFolder) || exchangePrincipal.RecipientTypeDetails.HasFlag(RecipientTypeDetails.PublicFolderMailbox))
                {
                    using (PublicFolderSession publicFolderSession = PublicFolderSession.OpenAsAdmin(null, exchangePrincipal, null, cultureInfo, clientInfoString, null))
                    {
                        WacUtilities.ProcessAttachment(publicFolderSession, ewsAttachmentId, exchangePrincipal, openMode, attachmentProcessor);
                        return;
                    }
                }
                using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(exchangePrincipal, cultureInfo, clientInfoString))
                {
                    WacUtilities.ProcessAttachment(mailboxSession, ewsAttachmentId, exchangePrincipal, openMode, attachmentProcessor);
                }
            }, adSessionSettings);
        }