예제 #1
0
        // Token: 0x06001193 RID: 4499 RVA: 0x00049780 File Offset: 0x00047980
        public PhotoMetadata Read(string photoFullPath, Stream output)
        {
            if (string.IsNullOrEmpty(photoFullPath))
            {
                throw new ArgumentNullException("photoFullPath");
            }
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            this.tracer.TraceDebug <string>((long)this.GetHashCode(), "File system photo reader: reading photo file {0}", photoFullPath);
            PhotoMetadata result;

            using (FileStream fileStream = new FileStream(photoFullPath, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete))
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "File system photo reader: writing photo to output stream.");
                fileStream.CopyTo(output);
                result = new PhotoMetadata
                {
                    Length      = fileStream.Length,
                    ContentType = "image/jpeg"
                };
            }
            return(result);
        }
예제 #2
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);
        }
예제 #3
0
 // Token: 0x0600114D RID: 4429 RVA: 0x00047BA8 File Offset: 0x00045DA8
 private PhotoResponse ReadPhotoOntoResponse(PhotoRequest request, PhotoResponse response)
 {
     using (new StopwatchPerformanceTracker("ADHandlerReadPhoto", request.PerformanceLogger))
     {
         using (new ADPerformanceTracker("ADHandlerReadPhoto", request.PerformanceLogger))
         {
             PhotoMetadata photoMetadata = this.reader.Read(this.recipientSession, request.TargetAdObjectId, response.OutputPhotoStream);
             response.Served        = true;
             response.Status        = HttpStatusCode.OK;
             response.ContentLength = photoMetadata.Length;
             response.ContentType   = photoMetadata.ContentType;
             response.Thumbprint    = null;
             request.PerformanceLogger.Log("ADHandlerPhotoAvailable", string.Empty, 1U);
             request.PerformanceLogger.Log("ADHandlerPhotoServed", string.Empty, 1U);
         }
     }
     return(response);
 }
예제 #4
0
 private PhotoResponse ReadPhotoFromMailboxOntoResponse(PhotoRequest request, PhotoResponse response, IMailboxSession session)
 {
     this.tracer.TraceDebug((long)this.GetHashCode(), "MAILBOX HANDLER: reading photo from mailbox onto response.");
     using (new StopwatchPerformanceTracker("MailboxHandlerReadPhoto", request.PerformanceLogger))
     {
         using (new StorePerformanceTracker("MailboxHandlerReadPhoto", request.PerformanceLogger))
         {
             PhotoMetadata photoMetadata = this.reader.Read(session, request.Size, request.Preview, response.OutputPhotoStream, request.PerformanceLogger);
             this.tracer.TraceDebug((long)this.GetHashCode(), "MAILBOX HANDLER: photo was written to response.");
             response.Served            = true;
             response.Status            = HttpStatusCode.OK;
             response.HttpExpiresHeader = UserAgentPhotoExpiresHeader.Default.ComputeExpiresHeader(DateTime.UtcNow, HttpStatusCode.OK, this.configuration);
             response.ServerCacheHit    = false;
             response.ContentLength     = photoMetadata.Length;
             response.ContentType       = photoMetadata.ContentType;
             request.PerformanceLogger.Log("MailboxHandlerPhotoAvailable", string.Empty, 1U);
             request.PerformanceLogger.Log("MailboxHandlerPhotoServed", string.Empty, 1U);
         }
     }
     return(response);
 }
        private PhotoResponse ReadPhotoFromFileOntoResponse(PhotoRequest request, PhotoResponse response, string photoFullPath)
        {
            this.tracer.TraceDebug <string>((long)this.GetHashCode(), "FILE SYSTEM HANDLER: reading photo file {0}", photoFullPath);
            PhotoResponse result;

            using (new StopwatchPerformanceTracker("FileSystemHandlerReadPhoto", request.PerformanceLogger))
            {
                using (new CpuPerformanceTracker("FileSystemHandlerReadPhoto", request.PerformanceLogger))
                {
                    PhotoMetadata photoMetadata = this.reader.Read(photoFullPath, response.OutputPhotoStream);
                    if (this.IsNegativeCachingPhoto(photoMetadata.Length))
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "FILE SYSTEM HANDLER: photo file is empty.  NEGATIVE caching.");
                        response.Served                  = true;
                        response.Status                  = HttpStatusCode.NotFound;
                        response.ServerCacheHit          = true;
                        response.IsPhotoFileOnFileSystem = true;
                        request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 1U);
                        request.PerformanceLogger.Log("FileSystemHandlerPhotoServed", string.Empty, 1U);
                        result = response;
                    }
                    else
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "FILE SYSTEM HANDLER: photo was written into output stream.");
                        response.Served                  = true;
                        response.Status                  = HttpStatusCode.OK;
                        response.ServerCacheHit          = true;
                        response.IsPhotoFileOnFileSystem = true;
                        response.ContentLength           = photoMetadata.Length;
                        response.ContentType             = photoMetadata.ContentType;
                        request.PerformanceLogger.Log("FileSystemHandlerPhotoAvailable", string.Empty, 1U);
                        request.PerformanceLogger.Log("FileSystemHandlerPhotoServed", string.Empty, 1U);
                        result = response;
                    }
                }
            }
            return(result);
        }