// 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; } } }
// Token: 0x06001BEA RID: 7146 RVA: 0x0006C5F4 File Offset: 0x0006A7F4 protected override bool InternalExecute() { IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(CallContext.Current.HttpContext, CallContext.Current.EffectiveCaller, false); if (mailboxContext.NotificationManager == null) { throw new OwaInvalidOperationException("UserContext.NotificationManager is null"); } for (int i = 0; i < this.subscriptionData.Length; i++) { SubscriptionData subscriptionData = this.subscriptionData[i]; bool flag = RemoteRequestProcessor.IsRemoteRequest(base.CallContext.HttpContext.Request.Headers); if (flag && string.IsNullOrWhiteSpace(subscriptionData.Parameters.ChannelId)) { throw new OwaInvalidRequestException("ChannelId is null or empty. ChannelId is required for remote notification unsubscribe requests."); } this.InternalUnsubscribeNotification(mailboxContext, subscriptionData); if (flag) { RemoteNotificationManager.Instance.UnSubscribe(mailboxContext.Key.ToString(), subscriptionData.SubscriptionId, subscriptionData.Parameters.ChannelId, RemoteRequestProcessor.GetRequesterUserId(base.CallContext.HttpContext.Request.Headers)); } } return(true); }
// 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; } }
// 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); }