Esempio n. 1
0
        private static void SmartReplyOrForward(MessageItem originalItem, MessageItem newItem, UserContext userContext)
        {
            if (!RecipientCache.RunGetCacheOperationUnderDefaultExceptionHandler(delegate
            {
                SubscriptionCache.GetCache(userContext);
            }, userContext.GetHashCode()))
            {
                return;
            }
            SendAddressDefaultSetting sendAddressDefaultSetting = new SendAddressDefaultSetting(userContext);

            if (sendAddressDefaultSetting.IsUserEmailAddress)
            {
                return;
            }
            SubscriptionCacheEntry subscriptionCacheEntry;

            if (userContext.SubscriptionCache.TryGetSendAsDefaultEntry(sendAddressDefaultSetting, out subscriptionCacheEntry))
            {
                newItem.From = new Participant(subscriptionCacheEntry.DisplayName, subscriptionCacheEntry.Address, "SMTP");
                return;
            }
            try
            {
                object obj = originalItem.TryGetProperty(MessageItemSchema.SharingInstanceGuid);
                SubscriptionCacheEntry subscriptionCacheEntry2;
                if (obj is Guid && userContext.SubscriptionCache.TryGetEntry((Guid)obj, out subscriptionCacheEntry2))
                {
                    newItem.From = new Participant(subscriptionCacheEntry2.DisplayName, subscriptionCacheEntry2.Address, "SMTP");
                }
            }
            catch (NotInBagPropertyErrorException)
            {
            }
        }
Esempio n. 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);
            }
        }
Esempio 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;
            }
        }
Esempio n. 4
0
 private static void RefreshClientCache(TextWriter writer, SubscriptionCache cache)
 {
     writer.Write("updSc(\"");
     cache.RenderToJavascript(writer);
     writer.WriteLine("\");");
 }
Esempio n. 5
0
 public static SubscriptionCache GetCache(UserContext userContext)
 {
     return(SubscriptionCache.GetCache(userContext, true));
 }