Esempio n. 1
0
        protected override Stream InternalExecute()
        {
            UserContext          userContext          = UserContextManager.GetUserContext(HttpContext.Current, CallContext.Current.EffectiveCaller, true);
            ConfigurationContext configurationContext = new ConfigurationContext(userContext);
            AttachmentHandler    attachmentHandler    = new AttachmentHandler(this.id, this.webOperationContext, base.CallContext, configurationContext);
            Stream result;

            try
            {
                using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(this.id, base.CallContext))
                {
                    Stream attachmentStream = attachmentHandler.GetAllAttachmentsAsZipStream(attachmentRetriever);
                    base.CallContext.OnDisposed += delegate(object sender, EventArgs args)
                    {
                        if (attachmentStream != null)
                        {
                            attachmentStream.Dispose();
                        }
                    };
                    result = attachmentStream;
                }
            }
            catch (CannotOpenFileAttachmentException)
            {
                this.webOperationContext.StatusCode = HttpStatusCode.NotFound;
                result = null;
            }
            catch (ObjectNotFoundException)
            {
                this.webOperationContext.StatusCode = HttpStatusCode.NotFound;
                result = null;
            }
            return(result);
        }
Esempio n. 2
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);
                        }
                    }
                }
            }
        }
        private static bool MessageIsDraft(WacRequest wacRequest)
        {
            ADSessionSettings adsessionSettings;
            ExchangePrincipal exchangePrincipal = WacUtilities.GetExchangePrincipal(wacRequest, out adsessionSettings, wacRequest.WacFileRep.IsArchive);
            CultureInfo       cultureInfo       = CultureInfo.GetCultureInfo(wacRequest.CultureName);

            if (exchangePrincipal.RecipientTypeDetails == RecipientTypeDetails.PublicFolder)
            {
                return(false);
            }
            bool result;

            using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(exchangePrincipal, cultureInfo, "Client=OWA;Action=WAC"))
            {
                IdConverterDependencies converterDependencies = new IdConverterDependencies.FromRawData(false, false, null, null, wacRequest.MailboxSmtpAddress.ToString(), null, mailboxSession, null);
                using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(wacRequest.EwsAttachmentId, converterDependencies))
                {
                    Item       rootItem   = attachmentRetriever.RootItem;
                    Attachment attachment = attachmentRetriever.Attachment;
                    string     text;
                    string     text2;
                    result = WacUtilities.ItemIsMessageDraft(rootItem, attachment, out text, out text2);
                }
            }
            return(result);
        }
        // Token: 0x06001ACE RID: 6862 RVA: 0x000655DC File Offset: 0x000637DC
        protected override WacAttachmentType InternalExecute()
        {
            if (string.IsNullOrEmpty(this.attachmentId))
            {
                throw new OwaInvalidRequestException("You must provide an attachmentId when calling GetWacAttachmentInfo.");
            }
            WacAttachmentType result;

            using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(this.attachmentId, base.CallContext))
            {
                result = GetWacAttachmentInfo.Execute(base.CallContext, attachmentRetriever.RootItem.Session, attachmentRetriever.RootItem, attachmentRetriever.Attachment, this.draftId, this.attachmentId, this.isEdit);
            }
            return(result);
        }
        // Token: 0x06001B14 RID: 6932 RVA: 0x00066B94 File Offset: 0x00064D94
        protected override string InternalExecute()
        {
            string wacUrl;

            using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(this.attachmentId, base.CallContext))
            {
                StoreSession      session           = attachmentRetriever.RootItem.Session;
                Item              rootItem          = attachmentRetriever.RootItem;
                Attachment        attachment        = attachmentRetriever.Attachment;
                WacAttachmentType wacAttachmentType = GetWacAttachmentInfo.Execute(base.CallContext, session, rootItem, attachment, null, this.attachmentId, false);
                if (wacAttachmentType == null)
                {
                    throw new OwaInvalidOperationException("There is no reason known for code to reach here without throwing an unhandled exception elsewhere");
                }
                wacUrl = wacAttachmentType.WacUrl;
            }
            return(wacUrl);
        }
Esempio n. 6
0
        protected override Stream InternalExecute()
        {
            UserContext          userContext          = UserContextManager.GetUserContext(HttpContext.Current, CallContext.Current.EffectiveCaller, true);
            ConfigurationContext configurationContext = new ConfigurationContext(userContext);
            string           mailboxSmtpAddress       = userContext.MailboxIdentity.PrimarySmtpAddress.ToString();
            CobaltStoreSaver cobaltStoreSaver;

            if (WacUtilities.ShouldUpdateAttachment(mailboxSmtpAddress, this.id, out cobaltStoreSaver))
            {
                base.CallContext.ProtocolLog.Set(GetAttachmentMetadata.Updated, true);
                cobaltStoreSaver.SaveAndLogExceptions(base.CallContext.ProtocolLog);
            }
            else
            {
                base.CallContext.ProtocolLog.Set(GetAttachmentMetadata.Updated, false);
            }
            AttachmentHandler attachmentHandler = new AttachmentHandler(this.id, this.webOperationContext, base.CallContext, configurationContext);

            attachmentHandler.IsImagePreview = this.isImagePreview;
            Stream result;

            try
            {
                using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(this.id, base.CallContext))
                {
                    AttachmentHandler.IAttachmentPolicyChecker policyChecker = AttachmentPolicyChecker.CreateInstance(configurationContext.AttachmentPolicy);
                    Stream attachmentStream = attachmentHandler.GetAttachmentStream(attachmentRetriever, policyChecker, this.asDataUri);
                    GetAttachment.EliminateGzFileDoubleCompression(attachmentRetriever);
                    base.CallContext.OnDisposed += delegate(object sender, EventArgs args)
                    {
                        if (attachmentStream != null)
                        {
                            attachmentStream.Dispose();
                        }
                    };
                    if (attachmentRetriever.Attachment != null)
                    {
                        base.CallContext.ProtocolLog.Set(GetAttachmentMetadata.Extension, attachmentRetriever.Attachment.FileExtension);
                        base.CallContext.ProtocolLog.Set(GetAttachmentMetadata.Length, attachmentRetriever.Attachment.Size);
                    }
                    result = attachmentStream;
                }
            }
            catch (InvalidStoreIdException innerException)
            {
                throw new OwaInvalidRequestException("Invalid ID, " + this.GetParametersForLogging(), innerException);
            }
            catch (InvalidIdMalformedException innerException2)
            {
                throw new OwaInvalidRequestException("Malformed ID, " + this.GetParametersForLogging(), innerException2);
            }
            catch (CannotOpenFileAttachmentException)
            {
                this.webOperationContext.StatusCode = HttpStatusCode.NotFound;
                result = null;
            }
            catch (ObjectNotFoundException)
            {
                this.webOperationContext.StatusCode = HttpStatusCode.NotFound;
                result = null;
            }
            return(result);
        }