Exemple #1
0
        public int Modify(SubscriptionCacheEntry entry, SendAsState sendAsState, AggregationStatus status)
        {
            int index = -1;

            this.ForFirstEntryByIdThenAddress(entry, delegate(int i)
            {
                if (!SubscriptionManager.IsValidForSendAs(sendAsState, status))
                {
                    this.cacheEntries.RemoveAt(i);
                    index = i;
                    return;
                }
                if (this.cacheEntries[i].Id.Equals(entry.Id))
                {
                    int num = this.cacheEntries[i].CompareTo(entry);
                    if (num == 0 && entry.DisplayNameMatch(this.cacheEntries[i]))
                    {
                        index = -2;
                        return;
                    }
                    if (0 < num)
                    {
                        while (0 < i)
                        {
                            if (0 >= this.cacheEntries[i - 1].CompareTo(entry))
                            {
                                break;
                            }
                            this.cacheEntries[i] = this.cacheEntries[--i];
                        }
                    }
                    else if (0 > num)
                    {
                        while (this.cacheEntries.Count - 1 > i && 0 > this.cacheEntries[i + 1].CompareTo(entry))
                        {
                            this.cacheEntries[i] = this.cacheEntries[++i];
                        }
                    }
                }
                this.cacheEntries[i] = entry;
                index = i;
            });
            if (-1 == index && SubscriptionManager.IsValidForSendAs(sendAsState, status))
            {
                index = this.Add(entry);
            }
            return(index);
        }
Exemple #2
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);
            }
        }