// Token: 0x06001BD6 RID: 7126 RVA: 0x0006BC30 File Offset: 0x00069E30
        private List <SubscriptionResponseData> InternalSubscribe(IMailboxContext userContext)
        {
            List <SubscriptionResponseData> list = new List <SubscriptionResponseData>();

            SubscriptionData[] array = this.subscriptionData;
            for (int i = 0; i < array.Length; i++)
            {
                SubscriptionData subscription   = array[i];
                string           subscriptionId = subscription.SubscriptionId;
                try
                {
                    Stopwatch notificationLatency     = Stopwatch.StartNew();
                    SubscriptionResponseData response = new SubscriptionResponseData(subscriptionId, true);
                    OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                    {
                        if (subscription.Parameters == null)
                        {
                            throw new ArgumentNullException("Subscription data parameters cannot be null");
                        }
                        ExTraceGlobals.NotificationsCallTracer.TraceDebug(0L, string.Format("[SubscribeToNotificationBase.InternalCreateASubscription] Creating subscription of type {0}.", subscription.Parameters.NotificationType));
                        this.metricType             = SubscribeToNotificationMetadata.Other;
                        NameValueCollection headers = this.CallContext.HttpContext.Request.Headers;
                        bool flag = RemoteRequestProcessor.IsRemoteRequest(headers);
                        if (flag && string.IsNullOrWhiteSpace(subscription.Parameters.ChannelId))
                        {
                            throw new OwaInvalidRequestException("ChannelId is null or empty. ChannelId is required for remote notification subscribe requests.");
                        }
                        this.InternalCreateASubscription(userContext, subscription, flag);
                        if (flag)
                        {
                            bool subscriptionExists;
                            RemoteNotificationManager.Instance.Subscribe(userContext.Key.ToString(), userContext.ExchangePrincipal.MailboxInfo.MailboxGuid.ToString(), subscription.SubscriptionId, subscription.Parameters.ChannelId, RemoteRequestProcessor.GetRequesterUserId(headers), subscription.Parameters.NotificationType, headers["X-OWA-Test-RemoteNotificationEndPoint"], out subscriptionExists);
                            response.SubscriptionExists = subscriptionExists;
                        }
                        if (!this.latenciesPerNotificationType.ContainsKey(this.metricType))
                        {
                            this.latenciesPerNotificationType.Add(this.metricType, 0);
                        }
                        Dictionary <SubscribeToNotificationMetadata, int> dictionary;
                        SubscribeToNotificationMetadata key;
                        (dictionary = this.latenciesPerNotificationType)[key = this.metricType] = dictionary[key] + (int)notificationLatency.ElapsedMilliseconds;
                    });
                    list.Add(response);
                }
                catch (GrayException ex)
                {
                    ExTraceGlobals.NotificationsCallTracer.TraceError <NotificationType, string, string>((long)this.GetHashCode(), "[SubscribeToNotificationBase.InternalSubscribe]: Exception thrown while creating subscription of type [{0}] with id {1}. Error: {2}", subscription.Parameters.NotificationType, subscriptionId, ex.ToString());
                    OwaServerTraceLogger.AppendToLog(new TraceLogEvent("SubErr", userContext, "SubscribeToNotificationBase.InternalSubscribe", ex.ToString()));
                    list.Add(new SubscriptionResponseData(subscriptionId, false)
                    {
                        ErrorInfo = ((ex.InnerException != null) ? ex.InnerException.Message : ex.Message)
                    });
                }
            }
            foreach (KeyValuePair <SubscribeToNotificationMetadata, int> keyValuePair in this.latenciesPerNotificationType)
            {
                base.CallContext.ProtocolLog.Set(keyValuePair.Key, keyValuePair.Value);
            }
            return(list);
        }
        // Token: 0x06001BD5 RID: 7125 RVA: 0x0006B918 File Offset: 0x00069B18
        protected virtual void InternalCreateASubscription(IMailboxContext userContext, SubscriptionData subscription, bool remoteSubscription)
        {
            switch (subscription.Parameters.NotificationType)
            {
            case NotificationType.RowNotification:
                if (userContext.NotificationManager == null)
                {
                    throw new OwaInvalidOperationException("User context does not have a valid NotificationManager. Can't subsribe to RowNotification.");
                }
                this.metricType = SubscribeToNotificationMetadata.RowNotificationLatency;
                userContext.NotificationManager.SubscribeToRowNotification(subscription.SubscriptionId, subscription.Parameters, this.request.Header.TimeZoneContext.TimeZoneDefinition.ExTimeZone, base.CallContext, remoteSubscription);
                return;

            case NotificationType.CalendarItemNotification:
                if (userContext.NotificationManager == null)
                {
                    throw new OwaInvalidOperationException("User context does not have a valid NotificationManager. Can't subsribe to CalendarItenNotification.");
                }
                this.metricType = SubscribeToNotificationMetadata.CalendarItemNotificationLatency;
                userContext.NotificationManager.SubscribeToRowNotification(subscription.SubscriptionId, subscription.Parameters, this.request.Header.TimeZoneContext.TimeZoneDefinition.ExTimeZone, base.CallContext, remoteSubscription);
                return;

            default:
                ExTraceGlobals.NotificationsCallTracer.TraceWarning(0L, "[SubscribeToNotificationBase.InternalCreateASubscription] Unsupported subscription type provided.");
                return;
            }
        }
示例#3
0
        private static void InsertIntoCache(HttpContext httpContext, IMailboxContext userContext)
        {
            UserContextManager.UserContextCacheWrapper userContextCacheWrapper = (UserContextManager.UserContextCacheWrapper)HttpRuntime.Cache.Get(userContext.Key.ToString());
            if (userContextCacheWrapper == null)
            {
                userContextCacheWrapper = new UserContextManager.UserContextCacheWrapper
                {
                    Lock = new OwaRWLockWrapper()
                };
            }
            UserContextManager.TombstoneExistingUserContext(userContextCacheWrapper);
            userContextCacheWrapper.UserContext = userContext;
            int num = UserContextManager.UserContextTimeout;

            if (UserAgentUtilities.IsMonitoringRequest(httpContext.Request.UserAgent))
            {
                num = 1;
                if (userContext.UserPrincipalName.EndsWith(".exchangemon.net", StringComparison.InvariantCultureIgnoreCase))
                {
                    ExMonitoringRequestTracker.Instance.ReportMonitoringRequest(httpContext.Request);
                }
            }
            HttpRuntime.Cache.Insert(userContext.Key.ToString(), userContextCacheWrapper, null, DateTime.MaxValue, new TimeSpan((long)num * 600000000L), CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(UserContextManager.UserContextRemovedCallback));
            userContext.LogBreadcrumb("Cached:Key=" + userContext.Key.ToString());
        }
        internal static void LogExceptionsOnly(IMailboxContext userContext, string eventId, Action action)
        {
            ExchangeVersion value = ExchangeVersion.Current;

            try
            {
                ExchangeVersion.Current = ExchangeVersion.Latest;
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                {
                    action();
                });
            }
            catch (GrayException ex)
            {
                string primarySmtpAddress = SimulatedWebRequestContext.GetPrimarySmtpAddress(userContext);
                bool   flag = false;
                RequestDetailsLogger requestDetailsLogger = SimulatedWebRequestContext.GetRequestDetailsLogger(eventId, userContext, primarySmtpAddress ?? "[user logged out]", out flag);
                SimulatedWebRequestContext.ProcessException(requestDetailsLogger, eventId, ex.InnerException);
                if (flag)
                {
                    requestDetailsLogger.Commit();
                }
            }
            finally
            {
                ExchangeVersion.Current = value;
            }
        }
 internal static void Execute(IMailboxContext userContext, string eventId, Action <MailboxSession, IRecipientSession, RequestDetailsLogger> action)
 {
     SimulatedWebRequestContext.Execute(userContext, eventId, delegate(RequestDetailsLogger logger)
     {
         ExchangePrincipal exchangePrincipal = userContext.ExchangePrincipal;
         if (exchangePrincipal == null)
         {
             return;
         }
         IRecipientSession arg = InstantMessageUtilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, exchangePrincipal, userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN);
         try
         {
             userContext.LockAndReconnectMailboxSession(3000);
             MailboxSession mailboxSession = userContext.MailboxSession;
             action(mailboxSession, arg, logger);
         }
         catch (OwaLockTimeoutException exception)
         {
             SimulatedWebRequestContext.ProcessException(logger, eventId, exception);
         }
         finally
         {
             if (userContext.MailboxSessionLockedByCurrentThread())
             {
                 userContext.UnlockAndDisconnectMailboxSession();
             }
         }
     });
 }
 internal PendingRequestManager(IMailboxContext userContext, ListenerChannelsManager listenerChannelsManager)
 {
     this.notifiersStateLock         = new OwaRWLockWrapper();
     this.notifierDataAvailableState = new Dictionary <IPendingRequestNotifier, PendingRequestManager.PendingNotifierState>();
     this.userContext             = userContext;
     this.listenerChannelsManager = listenerChannelsManager;
 }
示例#7
0
 public TraceLogEvent(string eventId, IMailboxContext userContext, string methodName, string message)
 {
     this.eventId     = (eventId ?? string.Empty);
     this.userContext = userContext;
     this.methodName  = (methodName ?? string.Empty);
     this.message     = (message ?? string.Empty);
 }
示例#8
0
 // Token: 0x06000CA7 RID: 3239 RVA: 0x0002EA1C File Offset: 0x0002CC1C
 internal BrokerNotificationManager(IMailboxContext userContext)
 {
     this.userContext             = userContext;
     this.mapiNotificationManager = new OwaMapiNotificationManager(userContext);
     this.activeHandlers          = new Dictionary <string, BrokerHandlerReferenceCounter>();
     this.userContext.PendingRequestManager.KeepAlive += this.KeepHandlersAlive;
 }
示例#9
0
 public static void TerminateSession(IMailboxContext userContext, CacheItemRemovedReason abandonedReason)
 {
     ExTraceGlobals.UserContextTracer.TraceDebug(0L, "UserContextManager.TerminateSession");
     if (userContext == null)
     {
         throw new ArgumentNullException("userContext");
     }
     try
     {
         userContext.LogBreadcrumb("TerminateSession");
         string text = string.Empty;
         if (userContext.LogonIdentity != null && userContext.LogonIdentity.UserSid != null)
         {
             text = userContext.LogonIdentity.UserSid.ToString();
         }
         if (!string.IsNullOrEmpty(text))
         {
             PerformanceCounterManager.UpdatePerfCounteronUserContextDeletion(text, false, false, Globals.ArePerfCountersEnabled);
         }
     }
     finally
     {
         userContext.Dispose();
         userContext = null;
     }
 }
 private static void FillItemDataInPayload(IMailboxContext userContext, OwaSearchContext searchContext, SearchNotificationPayload payload)
 {
     try
     {
         userContext.LockAndReconnectMailboxSession(3000);
         int serverSearchResultsRowCount = 0;
         if (searchContext.SearchContextType == SearchContextType.ItemSearch)
         {
             payload.MessageItems = SearchFolderItemDataRetriever.GetItemDataFromSearchFolder(searchContext, userContext.MailboxSession, out serverSearchResultsRowCount);
         }
         else if (searchContext.SearchContextType == SearchContextType.ConversationSearch)
         {
             payload.Conversations = SearchFolderConversationRetriever.GetConversationDataFromSearchFolder(searchContext, userContext.MailboxSession, out serverSearchResultsRowCount);
         }
         payload.ServerSearchResultsRowCount = serverSearchResultsRowCount;
     }
     catch (OwaLockTimeoutException ex)
     {
         ExTraceGlobals.CoreCallTracer.TraceError <string>(0L, "User context lock timed out in FillItemDataInPayload. Exception: {0}", ex.Message);
     }
     finally
     {
         if (userContext.MailboxSessionLockedByCurrentThread())
         {
             userContext.UnlockAndDisconnectMailboxSession();
         }
     }
 }
示例#11
0
        // Token: 0x06001BEB RID: 7147 RVA: 0x0006C6D8 File Offset: 0x0006A8D8
        protected virtual void InternalUnsubscribeNotification(IMailboxContext userContext, SubscriptionData subscription)
        {
            if (subscription.Parameters == null)
            {
                throw new ArgumentNullException("Subscription data parameters cannot be null");
            }
            NotificationType notificationType = subscription.Parameters.NotificationType;

            switch (notificationType)
            {
            case NotificationType.RowNotification:
            case NotificationType.CalendarItemNotification:
                userContext.NotificationManager.UnsubscribeForRowNotifications(subscription.SubscriptionId, subscription.Parameters);
                ExTraceGlobals.NotificationsCallTracer.TraceDebug <NotificationType>((long)this.GetHashCode(), "[UnsubscribeToNotificationBase::InternalExecute] Unsubscribe for row notifications ({0})", subscription.Parameters.NotificationType);
                return;

            default:
                if (notificationType == NotificationType.SearchNotification)
                {
                    RemoteNotificationManager.Instance.UnSubscribe(userContext.Key.ToString(), "SearchNotification", subscription.Parameters.ChannelId, RemoteRequestProcessor.GetRequesterUserId(base.CallContext.HttpContext.Request.Headers));
                    return;
                }
                if (notificationType != NotificationType.InstantSearchNotification)
                {
                    throw new OwaInvalidOperationException("Invalid Notification type specified when calling unsubscribe");
                }
                return;
            }
        }
 public MapiNotificationHandlerBase(string subscriptionId, IMailboxContext userContext, bool remoteSubscription)
 {
     this.SubscriptionId            = subscriptionId;
     this.userContext               = userContext;
     this.connectionAliveTimerCount = 1;
     this.syncRoot           = new object();
     this.remoteSubscription = remoteSubscription;
     if (!Globals.Owa2ServerUnitTestsHook)
     {
         ExTraceGlobals.NotificationsCallTracer.TraceDebug <string, bool>((long)this.GetHashCode(), "MapiNotificationHandlerBase.Constructor. Type: {0}, RemoteSusbcription: {1}.", base.GetType().Name, this.remoteSubscription);
         if ((this.remoteSubscription || this is ConnectionDroppedNotificationHandler) && this.userContext.NotificationManager != null)
         {
             this.userContext.NotificationManager.RemoteKeepAliveEvent += this.RemoteKeepAlive;
         }
         if (remoteSubscription)
         {
             if (this.userContext.NotificationManager != null)
             {
                 this.userContext.NotificationManager.StartRemoteKeepAliveTimer();
             }
         }
         else
         {
             this.userContext.PendingRequestManager.KeepAlive += this.KeepAlive;
         }
         this.verboseLoggingEnabled = Globals.LogVerboseNotifications;
     }
 }
        internal static void DisposeXSOObjects(object o, IMailboxContext userContext)
        {
            bool flag = false;

            try
            {
                if (!userContext.MailboxSessionLockedByCurrentThread())
                {
                    ExTraceGlobals.UserContextTracer.TraceDebug(0, 0L, "MapiNotificationHandlerBase.DisposeXSOObjects(): Mailbox session not locked. Attempting to grab the lock.");
                    userContext.LockAndReconnectMailboxSession(3000);
                    flag = true;
                }
                IDisposable xsoObject = o as IDisposable;
                if (o != null)
                {
                    try
                    {
                        OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                        {
                            try
                            {
                                xsoObject.Dispose();
                            }
                            catch (StoragePermanentException ex2)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase. Unable to dispose object.  exception {0}", ex2.Message);
                            }
                            catch (StorageTransientException ex3)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase. Unable to dispose object.  exception {0}", ex3.Message);
                            }
                            catch (MapiExceptionObjectDisposed mapiExceptionObjectDisposed)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase.Unable to dispose object.  exception {0}", mapiExceptionObjectDisposed.Message);
                            }
                            catch (ThreadAbortException ex4)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase Unable to dispose object.  exception {0}", ex4.Message);
                            }
                            catch (ResourceUnhealthyException ex5)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase Unable to dispose object.  exception {0}", ex5.Message);
                            }
                        });
                    }
                    catch (GrayException ex)
                    {
                        ExTraceGlobals.NotificationsCallTracer.TraceError <string>(0L, "MapiNotificationHandlerBase.DisposeXSOObjects Unable to dispose object.  exception {0}", ex.Message);
                    }
                }
            }
            finally
            {
                if (flag)
                {
                    ExTraceGlobals.UserContextTracer.TraceDebug(0, 0L, "MapiNotificationHandlerBase.DisposeXSOObjects(): Attempting to release the lock taken.");
                    userContext.UnlockAndDisconnectMailboxSession();
                }
            }
        }
 protected override void InternalUnsubscribeNotification(IMailboxContext userContext, SubscriptionData subscription)
 {
     if (subscription.Parameters == null)
     {
         throw new ArgumentNullException("Subscription data parameters cannot be null");
     }
     base.InternalUnsubscribeNotification(userContext, subscription);
 }
示例#15
0
 public static NewMailNotificationHandler Create(string subscriptionId, IMailboxContext userContext, SubscriptionParameters parameters)
 {
     if (parameters.InferenceEnabled)
     {
         return(new InferenceNewMailNotificationHandler(subscriptionId, userContext));
     }
     return(new NewMailNotificationHandler(subscriptionId, userContext));
 }
 // Token: 0x06000DE1 RID: 3553 RVA: 0x00034A56 File Offset: 0x00032C56
 public static MailboxLocation FromMailboxContext(IMailboxContext mailboxContext)
 {
     if (mailboxContext != null && mailboxContext.ExchangePrincipal != null)
     {
         return(new MailboxLocation(mailboxContext.ExchangePrincipal.MailboxInfo.MailboxGuid));
     }
     return(null);
 }
示例#17
0
 public PendingRequestNotifierBase(string subscriptionId, IMailboxContext userContext)
 {
     if (userContext == null)
     {
         throw new ArgumentNullException("userContext");
     }
     this.SubscriptionId = subscriptionId;
     this.UserContext    = userContext;
 }
示例#18
0
 // Token: 0x06002597 RID: 9623 RVA: 0x00088317 File Offset: 0x00086517
 public SignInLogEvent(IMailboxContext userContext, string userContextKey, UserContextStatistics userContextStatistics, Uri requestUri)
 {
     if (userContextStatistics == null)
     {
         throw new ArgumentNullException("userContextStatistics");
     }
     this.userContext           = userContext;
     this.userContextKey        = (userContextKey ?? string.Empty);
     this.userContextStatistics = userContextStatistics;
     this.requestUri            = requestUri;
 }
示例#19
0
 internal static bool IsObsoleteRequest(RequestContext requestContext, IMailboxContext userContext)
 {
     if (requestContext.RequestType == OwaRequestType.Oeh && userContext == null)
     {
         string queryStringParameter  = HttpUtilities.GetQueryStringParameter(requestContext.HttpContext.Request, "ns", false);
         string queryStringParameter2 = HttpUtilities.GetQueryStringParameter(requestContext.HttpContext.Request, "ev", false);
         string queryStringParameter3 = HttpUtilities.GetQueryStringParameter(requestContext.HttpContext.Request, "Fn", false);
         return(queryStringParameter == "PendingRequest" && queryStringParameter2 == "FinishNotificationRequest" && queryStringParameter3 == "1");
     }
     return(false);
 }
示例#20
0
 protected override void InternalUnsubscribeNotification(IMailboxContext userContext, SubscriptionData subscription)
 {
     if (subscription.Parameters == null)
     {
         throw new ArgumentNullException("Subscription data parameters cannot be null");
     }
     if (subscription.Parameters.NotificationType != NotificationType.UnseenItemNotification)
     {
         throw new OwaInvalidOperationException("Invalid Notification type specified when calling UnsubscribeToGroupUnseenNotification");
     }
     ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "[UnsubscribeToGroupUnseenNotification::InternalUnsubscribeNotification] Unsubscribe for unseen notifications for subscription {0}", subscription.SubscriptionId);
 }
        // Token: 0x0600105A RID: 4186 RVA: 0x0003ED74 File Offset: 0x0003CF74
        private void NoActiveListeners(object sender, RemoteSubscriptionEventArgs eventArgs)
        {
            UserContextKey userContextKey;

            if (this.TryParseUserContextKey(eventArgs.ContextKey, out userContextKey))
            {
                IMailboxContext mailboxContextFromCache = UserContextManager.GetMailboxContextFromCache(userContextKey);
                if (mailboxContextFromCache != null)
                {
                    mailboxContextFromCache.NotificationManager.ReleaseSubscription(eventArgs.SubscriptionId);
                }
            }
        }
示例#22
0
        // Token: 0x06001BF2 RID: 7154 RVA: 0x0006C848 File Offset: 0x0006AA48
        protected override void InternalUnsubscribeNotification(IMailboxContext userContext, SubscriptionData subscription)
        {
            if (subscription.Parameters == null)
            {
                throw new ArgumentNullException("Subscription data parameters cannot be null");
            }
            NotificationType notificationType = subscription.Parameters.NotificationType;

            if (notificationType == NotificationType.UnseenItemNotification)
            {
                userContext.NotificationManager.UnsubscribeToUnseenCountNotification(subscription.SubscriptionId, subscription.Parameters);
                return;
            }
            base.InternalUnsubscribeNotification(userContext, subscription);
        }
示例#23
0
        private static void TombstoneExistingUserContext(UserContextManager.UserContextCacheWrapper wrapper)
        {
            IMailboxContext userContext = wrapper.UserContext;

            if (userContext != null)
            {
                userContext.LogBreadcrumb("This context will be tombstoned.");
                string key = string.Format("Tombstoned-{0}", userContext.Key.ToString());
                UserContextManager.UserContextCacheWrapper value = new UserContextManager.UserContextCacheWrapper
                {
                    Lock        = new OwaRWLockWrapper(),
                    UserContext = userContext
                };
                HttpRuntime.Cache.Insert(key, value, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1.0), CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(UserContextManager.UserContextRemovedCallback));
            }
        }
示例#24
0
        internal static UserContext GetUserContext(HttpContext httpContext, AuthZClientInfo effectiveCaller = null, bool create = true)
        {
            IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(httpContext, effectiveCaller, create);

            if (mailboxContext == null)
            {
                return(null);
            }
            UserContext userContext = mailboxContext as UserContext;

            if (userContext == null)
            {
                throw new OwaInvalidOperationException("Invalid user context returned. It was expected to be a full user context.");
            }
            return(userContext);
        }
        private static string GetPrimarySmtpAddress(IMailboxContext userContext)
        {
            OwaIdentity mailboxIdentity = userContext.MailboxIdentity;

            if (mailboxIdentity == null)
            {
                return(null);
            }
            string text = (string)mailboxIdentity.PrimarySmtpAddress;

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }
            return(text);
        }
示例#26
0
 // Token: 0x06001BD9 RID: 7129 RVA: 0x0006BF04 File Offset: 0x0006A104
 private void CreateSubscriptionForWellKnownFolder(IMailboxContext userContext, SubscriptionData subscription, DefaultFolderType folderType)
 {
     try
     {
         userContext.LockAndReconnectMailboxSession(3000);
         StoreObjectId defaultFolderId = userContext.MailboxSession.GetDefaultFolderId(folderType);
         subscription.Parameters.FolderId = StoreId.StoreIdToEwsId(userContext.MailboxSession.MailboxGuid, defaultFolderId);
     }
     finally
     {
         if (userContext.MailboxSessionLockedByCurrentThread())
         {
             userContext.UnlockAndDisconnectMailboxSession();
         }
     }
     base.InternalCreateASubscription(userContext, subscription, true);
 }
示例#27
0
        // Token: 0x06001BD8 RID: 7128 RVA: 0x0006BDF4 File Offset: 0x00069FF4
        protected override void InternalCreateASubscription(IMailboxContext userContext, SubscriptionData subscription, bool remoteSubscription)
        {
            NotificationType notificationType = subscription.Parameters.NotificationType;

            switch (notificationType)
            {
            case NotificationType.RowNotification:
                if (subscription.Parameters.FolderId != null)
                {
                    throw new ArgumentException("Subscription parameter FolderId cannot be specified on Group subscriptions");
                }
                this.CreateSubscriptionForWellKnownFolder(userContext, subscription, DefaultFolderType.Inbox);
                return;

            case NotificationType.CalendarItemNotification:
                this.CreateSubscriptionForWellKnownFolder(userContext, subscription, DefaultFolderType.Calendar);
                return;

            default:
            {
                if (notificationType == NotificationType.SearchNotification)
                {
                    bool flag;
                    RemoteNotificationManager.Instance.Subscribe(userContext.Key.ToString(), userContext.ExchangePrincipal.MailboxInfo.MailboxGuid.ToString(), "SearchNotification", subscription.Parameters.ChannelId, RemoteRequestProcessor.GetRequesterUserId(base.CallContext.HttpContext.Request.Headers), NotificationType.SearchNotification, out flag);
                    return;
                }
                if (notificationType != NotificationType.InstantSearchNotification)
                {
                    base.InternalCreateASubscription(userContext, subscription, true);
                    return;
                }
                UserContext userContext2 = userContext as UserContext;
                if (userContext2 == null)
                {
                    throw new OwaInvalidOperationException("UserContext isn't a full user context. Cannot subscribe to InstantSearch notifications.");
                }
                InstantSearchRemoteNotificationHandler instantSearchRemoteNotificationHandler = userContext2.InstantSearchNotificationHandler as InstantSearchRemoteNotificationHandler;
                if (instantSearchRemoteNotificationHandler == null)
                {
                    throw new OwaInvalidOperationException("Wrong notification handler for an InstantSearch remote subscription scenario.");
                }
                instantSearchRemoteNotificationHandler.RegisterNotifier(subscription.SubscriptionId);
                return;
            }
            }
        }
        internal static void Execute(IMailboxContext userContext, string eventId, Action <RequestDetailsLogger> action)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            if (string.IsNullOrEmpty(eventId))
            {
                throw new ArgumentException("String should not be null or empty.", "eventId");
            }
            string primarySmtpAddress = SimulatedWebRequestContext.GetPrimarySmtpAddress(userContext);

            if (primarySmtpAddress == null)
            {
                return;
            }
            ExchangeVersion      value = ExchangeVersion.Current;
            bool                 flag;
            RequestDetailsLogger logger = SimulatedWebRequestContext.GetRequestDetailsLogger(eventId, userContext, primarySmtpAddress, out flag);

            try
            {
                ExchangeVersion.Current = ExchangeVersion.Latest;
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                {
                    action(logger);
                });
            }
            catch (GrayException ex)
            {
                SimulatedWebRequestContext.ProcessException(logger, eventId, ex.InnerException);
            }
            finally
            {
                if (flag)
                {
                    logger.Commit();
                }
                ExchangeVersion.Current = value;
            }
        }
示例#29
0
        public void DisposePendingNotificationClientRequest()
        {
            IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(HttpContext.Current, null, false);
            HttpResponse    response       = HttpContext.Current.Response;
            object          parameter      = base.GetParameter("Fn");
            bool            flag           = false;

            if (parameter != null)
            {
                flag = (bool)parameter;
            }
            bool   flag2 = false;
            string text  = (string)base.GetParameter("cid");

            text = this.ProcessChannelIdOnRequestAndGenerateIfNeeded(text, flag);
            if (mailboxContext != null && text != null)
            {
                PendingRequestChannel pendingGetChannel = mailboxContext.PendingRequestManager.GetPendingGetChannel(text);
                if (pendingGetChannel != null)
                {
                    flag2 = pendingGetChannel.HandleFinishRequestFromClient();
                    if (flag)
                    {
                        ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "[PendingRequestEventHandler::DisposePendingNotificationClientRequest] userContext.PendingRequestManager.RemovePendingGetChannel. ChannelId: {0}", text);
                        mailboxContext.PendingRequestManager.RemovePendingGetChannel(text);
                    }
                }
                else
                {
                    mailboxContext.PendingRequestManager.AddPendingGetChannel(text);
                }
            }
            response.AppendHeader("X-OWA-EventResult", "0");
            response.Write("{");
            if (text != null)
            {
                response.Write("cid:\"");
                response.Write(text);
                response.Write("\",");
            }
            response.Write("syncFnshRq:");
            response.Write(flag2 ? "1}" : "0}");
            HttpUtilities.MakePageNoCacheNoStore(response);
            response.ContentType = HttpUtilities.GetContentTypeString(base.ResponseContentType);
        }
        // Token: 0x06001BD4 RID: 7124 RVA: 0x0006B82C File Offset: 0x00069A2C
        protected override SubscriptionResponseData[] InternalExecute()
        {
            ExTraceGlobals.NotificationsCallTracer.TraceDebug(0L, "[SubscribeToNotificationBase.InternalExecute] Acquiring the UserContext.");
            Stopwatch       stopwatch      = Stopwatch.StartNew();
            IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(CallContext.Current.HttpContext, CallContext.Current.EffectiveCaller, false);

            if (mailboxContext.NotificationManager == null)
            {
                throw new OwaInvalidOperationException("UserContext.MapiNotificationManager is null");
            }
            base.CallContext.ProtocolLog.Set(SubscribeToNotificationMetadata.UserContextLatency, stopwatch.ElapsedMilliseconds);
            base.CallContext.ProtocolLog.Set(SubscribeToNotificationMetadata.SubscriptionCount, this.subscriptionData.Length);
            if (this.request.Header.TimeZoneContext != null)
            {
                base.CallContext.ProtocolLog.Set(SubscribeToNotificationMetadata.RequestTimeZone, this.request.Header.TimeZoneContext.TimeZoneDefinition.ExTimeZone.DisplayName);
            }
            return(this.InternalSubscribe(mailboxContext).ToArray());
        }