コード例 #1
0
        private PhotoMetadata ReadPhotoOfSizeOrBestMatch(IItem photo, UserPhotoSize size, Stream output)
        {
            UserPhotoSize userPhotoSize = size;
            PhotoMetadata result;

            try
            {
IL_02:
                using (Stream stream = photo.OpenPropertyStream(MailboxPhotoReader.GetPropertyDefinitionForSize(userPhotoSize), PropertyOpenMode.ReadOnly))
                {
                    stream.CopyTo(output);
                    result = new PhotoMetadata
                    {
                        Length      = stream.Length,
                        ContentType = "image/jpeg"
                    };
                }
            }
            catch (ObjectNotFoundException)
            {
                this.tracer.TraceDebug <UserPhotoSize>((long)this.GetHashCode(), "Mailbox photo reader: photo of size {0} not found.", userPhotoSize);
                userPhotoSize = MailboxPhotoReader.NextSmallerSize(userPhotoSize);
                goto IL_02;
            }
            return(result);
        }
コード例 #2
0
        // Token: 0x0600133F RID: 4927 RVA: 0x0004F5E8 File Offset: 0x0004D7E8
        public PhotoUploadPipeline(PhotosConfiguration configuration, IMailboxSession mailboxSession, IRecipientSession recipientSession, ITracer upstreamTracer)
        {
            MailboxPhotoReader reader  = new MailboxPhotoReader(upstreamTracer);
            MailboxPhotoWriter writer  = new MailboxPhotoWriter(mailboxSession, upstreamTracer);
            ADPhotoReader      reader2 = new ADPhotoReader(upstreamTracer);
            ADPhotoWriter      writer2 = new ADPhotoWriter(recipientSession, upstreamTracer);

            this.pipeline = new PreviewPhotoUploadHandler(mailboxSession, reader, writer, PhotoEditor.Default, upstreamTracer).Then(new ADPhotoUploadHandler(recipientSession, configuration, reader2, writer2, upstreamTracer)).Then(new MailboxPhotoUploadHandler(mailboxSession, reader, writer, upstreamTracer)).Then(new FileSystemPhotoUploadHandler(configuration, new FileSystemPhotoWriter(upstreamTracer), upstreamTracer));
        }
コード例 #3
0
        public PhotoManagementRetrievalPipeline(PhotosConfiguration configuration, IMailboxSession mailboxSession, IRecipientSession recipientSession, ITracer upstreamTracer)
        {
            MailboxPhotoReader reader  = new MailboxPhotoReader(upstreamTracer);
            MailboxPhotoWriter writer  = new MailboxPhotoWriter(mailboxSession, upstreamTracer);
            ADPhotoReader      reader2 = new ADPhotoReader(upstreamTracer);
            ADPhotoWriter      writer2 = new ADPhotoWriter(recipientSession, upstreamTracer);

            this.pipeline = new MailboxPhotoUploadHandler(mailboxSession, reader, writer, upstreamTracer).Then(new ADPhotoUploadHandler(recipientSession, configuration, reader2, writer2, upstreamTracer));
        }
コード例 #4
0
        private PhotoMetadata ReadActual(IMailboxSession session, UserPhotoSize size, Stream output, IPerformanceDataLogger perfLogger)
        {
            StoreId       photoId = this.FindActualItem(session, perfLogger);
            PhotoMetadata result;

            using (IItem item = MailboxPhotoReader.BindAndTrackPerformance(session, photoId, "MailboxPhotoReaderBindPhotoItem", perfLogger))
            {
                using (new StopwatchPerformanceTracker("MailboxPhotoReaderReadStream", perfLogger))
                {
                    using (new StorePerformanceTracker("MailboxPhotoReaderReadStream", perfLogger))
                    {
                        result = this.ReadPhotoOfSizeOrBestMatch(item, size, output);
                    }
                }
            }
            return(result);
        }
コード例 #5
0
        private int ReadThumbprintInternal(IMailboxSession session, bool preview, bool forceReloadThumbprint)
        {
            Mailbox mailbox = ((MailboxSession)session).Mailbox;

            if (forceReloadThumbprint)
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "Mailbox photo reader: reloading thumbprint properties");
                mailbox.ForceReload(MailboxPhotoReader.ThumbprintProperties);
            }
            object obj = mailbox.TryGetProperty(preview ? MailboxPhotoReader.UserPhotoPreviewCacheIdProperty : MailboxPhotoReader.UserPhotoCacheIdProperty);

            if (!(obj is int))
            {
                this.tracer.TraceDebug <bool>((long)this.GetHashCode(), "Mailbox photo reader: no thumbprint.  Preview? {0}", preview);
                throw new ObjectNotFoundException(Strings.UserPhotoThumbprintNotFound(preview));
            }
            if (0.Equals(obj))
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "Mailbox photo reader: thumbprint indicates photo has been deleted.");
                throw MailboxPhotoReader.CreateExceptionIndicatingPhotoHasBeenDeleted();
            }
            this.tracer.TraceDebug <int, bool>((long)this.GetHashCode(), "Mailbox photo reader: read thumbprint: {0:X8}.  Preview? {1}", (int)obj, preview);
            return((int)obj);
        }
コード例 #6
0
 // Token: 0x0600121B RID: 4635 RVA: 0x0004CA34 File Offset: 0x0004AC34
 private void CreatePreviewItem(IDictionary <UserPhotoSize, byte[]> photos)
 {
     using (IItem item = Item.Create((MailboxSession)this.session, "IPM.UserPhoto.Preview", this.GetPhotoStoreId()))
     {
         foreach (UserPhotoSize userPhotoSize in MailboxPhotoWriter.AllPhotoSizes)
         {
             byte[] buffer;
             if (!photos.TryGetValue(userPhotoSize, out buffer))
             {
                 this.tracer.TraceDebug <UserPhotoSize>((long)this.GetHashCode(), "Mailbox photo writer: photo of size {0} not available in preview (input).  Skipped.", userPhotoSize);
             }
             else
             {
                 this.tracer.TraceDebug <UserPhotoSize>((long)this.GetHashCode(), "Mailbox photo writer: storing photo of size {0} onto preview item.", userPhotoSize);
                 using (MemoryStream memoryStream = new MemoryStream(buffer))
                 {
                     this.StorePhotoOfSpecificSize(item, userPhotoSize, MailboxPhotoReader.GetPropertyDefinitionForSize(userPhotoSize), memoryStream);
                 }
             }
         }
         item.Save(SaveMode.ResolveConflicts);
         this.tracer.TraceDebug((long)this.GetHashCode(), "Mailbox photo writer: preview item created successfully.");
     }
 }