Exemple #1
0
        internal void BeginGetThumbnailPhotoFromMailbox(List <string> targetPrimarySmtpAddresses, UserPhotoSize photoSize)
        {
            foreach (string text in targetPrimarySmtpAddresses)
            {
                if (AirSyncPhotoRetriever.userPhotosCache.ContainsKey(text))
                {
                    if ((from s in AirSyncPhotoRetriever.userPhotosCache[text]
                         where s.PhotoSize == photoSize
                         select s).Count <AirSyncPhotoRetriever.UserPhotoWithSize>() != 0)
                    {
                        goto IL_111;
                    }
                }
                if (!this.delegatesCollection.ContainsKey(text))
                {
                    AirSyncDiagnostics.TraceDebug <string, string, UserPhotoSize>(ExTraceGlobals.ProtocolTracer, null, "AirSyncPhotoRetriever::BeginGetThumbnailPhotoFromMailbox - {0} requesting photo for {1} , with photosize {2}", this.Context.User.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), text, photoSize);
                    AirSyncPhotoRetriever.GetThumbnailPhotoFromMailboxDelegate getThumbnailPhotoFromMailboxDelegate = new AirSyncPhotoRetriever.GetThumbnailPhotoFromMailboxDelegate(AirSyncPhotoRetriever.GetThumbnailPhotoFromMailbox);
                    IAsyncResult value = getThumbnailPhotoFromMailboxDelegate.BeginInvoke(this.Context, text, photoSize, null, new AirSyncPhotoRetriever.UserPhotoWithSize
                    {
                        UserEmail = text,
                        PhotoSize = photoSize
                    });
                    this.delegatesCollection.TryAdd(text, value);
                    this.NumberOfPhotosRequested++;
                    continue;
                }
IL_111:
                this.NumberOfPhotosFromCache++;
            }
        }
Exemple #2
0
 private static void GetThumbnailPhotoCompleted(IAsyncResult result)
 {
     AirSyncPhotoRetriever.GetThumbnailPhotoFromMailboxDelegate getThumbnailPhotoFromMailboxDelegate = ((AsyncResult)result).AsyncDelegate as AirSyncPhotoRetriever.GetThumbnailPhotoFromMailboxDelegate;
     AirSyncPhotoRetriever.UserPhotoWithSize userPhotoWithSize = result.AsyncState as AirSyncPhotoRetriever.UserPhotoWithSize;
     try
     {
         byte[] userPhotoBytes = getThumbnailPhotoFromMailboxDelegate.EndInvoke(result);
         lock (AirSyncPhotoRetriever.lockObject)
         {
             List <AirSyncPhotoRetriever.UserPhotoWithSize> list;
             if (!AirSyncPhotoRetriever.userPhotosCache.ContainsKey(userPhotoWithSize.UserEmail))
             {
                 list = new List <AirSyncPhotoRetriever.UserPhotoWithSize>();
             }
             else
             {
                 list = AirSyncPhotoRetriever.userPhotosCache[userPhotoWithSize.UserEmail];
             }
             list.Add(new AirSyncPhotoRetriever.UserPhotoWithSize
             {
                 UserEmail      = userPhotoWithSize.UserEmail,
                 PhotoSize      = userPhotoWithSize.PhotoSize,
                 UserPhotoBytes = userPhotoBytes
             });
             AirSyncPhotoRetriever.userPhotosCache.Add(userPhotoWithSize.UserEmail, list);
         }
     }
     catch (AccessDeniedException arg)
     {
         AirSyncDiagnostics.TraceError <AccessDeniedException>(ExTraceGlobals.ProtocolTracer, "AirSyncPhotoRetriever::GetThumbnailPhotoCompleted- Access denied retrieving thumbnailPhoto via GetUserPhoto. TargetUser: {0}.  Exception: {1}", userPhotoWithSize.UserEmail, arg);
     }
 }