Ejemplo n.º 1
0
        private void UpdateSubscriptionCache(QueryNotification notification, TextWriter writer)
        {
            bool flag = null == this.userContext.SubscriptionCache;

            if (!RecipientCache.RunGetCacheOperationUnderExceptionHandler(delegate
            {
                SubscriptionCache.GetCache(this.userContext);
            }, new RecipientCache.ExceptionHandler(this.HandleSubscriptionLoadException), this.GetHashCode()))
            {
                return;
            }
            SubscriptionCache subscriptionCache = this.userContext.SubscriptionCache;

            if (flag)
            {
                SubscriptionNotificationHandler.RefreshClientCache(writer, subscriptionCache);
                return;
            }
            int num;

            if (QueryNotificationType.RowDeleted == notification.EventType)
            {
                num = subscriptionCache.Delete(notification.Index);
            }
            else
            {
                object obj = notification.Row[0];
                if (!(obj is Guid))
                {
                    return;
                }
                Guid   id   = (Guid)obj;
                string text = notification.Row[1] as string;
                if (text == null)
                {
                    return;
                }
                string text2 = notification.Row[2] as string;
                if (text2 == null)
                {
                    return;
                }
                obj = notification.Row[3];
                if (!(obj is int))
                {
                    return;
                }
                SendAsState sendAsState = (SendAsState)obj;
                obj = notification.Row[4];
                if (!(obj is int))
                {
                    return;
                }
                AggregationStatus      status  = (AggregationStatus)obj;
                string                 address = Utilities.DecodeIDNDomain(text);
                SubscriptionCacheEntry entry   = new SubscriptionCacheEntry(id, address, text2, notification.Index, this.mailboxSession.PreferedCulture);
                switch (notification.EventType)
                {
                case QueryNotificationType.RowAdded:
                    if (!SubscriptionManager.IsValidForSendAs(sendAsState, status))
                    {
                        return;
                    }
                    num = subscriptionCache.Add(entry);
                    goto IL_14B;

                case QueryNotificationType.RowModified:
                    num = subscriptionCache.Modify(entry, sendAsState, status);
                    goto IL_14B;
                }
                num = -1;
            }
IL_14B:
            if (-1 < num)
            {
                SubscriptionNotificationHandler.RefreshClientCache(writer, subscriptionCache);
            }
        }
 // Token: 0x06001476 RID: 5238 RVA: 0x0007D041 File Offset: 0x0007B241
 public SubscriptionPayload(UserContext userContext, MailboxSession mailboxSession, SubscriptionNotificationHandler notificationHandler)
 {
     this.payloadString             = new StringBuilder(256);
     this.userContext               = userContext;
     this.mailboxSessionDisplayName = string.Copy(mailboxSession.DisplayName);
     this.notificationHandler       = notificationHandler;
 }
Ejemplo n.º 3
0
        internal override void HandlePendingGetTimerCallback()
        {
            lock (this.syncRoot)
            {
                if (this.isDisposed)
                {
                    return;
                }
            }
            bool flag2 = false;
            bool flag3 = false;

            try
            {
                this.userContext.Lock();
                flag2 = true;
                Utilities.ReconnectStoreSession(this.mailboxSession, this.userContext);
                lock (this.syncRoot)
                {
                    if (this.needReinitSubscriptions)
                    {
                        this.InitSubscription();
                        this.needReinitSubscriptions = false;
                        this.missedNotifications     = true;
                    }
                    if (this.missedNotifications)
                    {
                        if (!RecipientCache.RunGetCacheOperationUnderExceptionHandler(delegate
                        {
                            SubscriptionCache.GetCache(this.userContext, false);
                        }, new RecipientCache.ExceptionHandler(this.HandleSubscriptionLoadException), this.GetHashCode()))
                        {
                            return;
                        }
                    }
                }
            }
            catch (OwaLockTimeoutException ex)
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug <string>((long)this.GetHashCode(), "User context lock timed out in the pending GET timer callback. Exception: {0}", ex.Message);
                this.missedNotifications = true;
                flag3 = true;
            }
            catch (Exception ex2)
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug <string>((long)this.GetHashCode(), "Unexpected exception in pending GET timer callback thread. Exception: {0}", ex2.Message);
                this.missedNotifications = true;
                flag3 = true;
            }
            finally
            {
                if (this.userContext.LockedByCurrentThread() && flag2)
                {
                    Utilities.DisconnectStoreSessionSafe(this.mailboxSession);
                    this.userContext.Unlock();
                }
            }
            try
            {
                if (this.missedNotifications && !flag3)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    using (StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture))
                    {
                        SubscriptionNotificationHandler.RefreshClientCache(stringWriter, this.userContext.SubscriptionCache);
                    }
                    if (0 < stringBuilder.Length)
                    {
                        this.payload.AddPayload(stringBuilder);
                        this.payload.PickupData();
                    }
                    this.missedNotifications = false;
                }
            }
            catch (Exception ex3)
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug <string>((long)this.GetHashCode(), "Unexpected exception in pending GET timer callback thread. Exception: {0}", ex3.Message);
                this.missedNotifications = true;
            }
        }