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();
                }
            }
        }
 // Token: 0x0600115A RID: 4442 RVA: 0x000429B0 File Offset: 0x00040BB0
 internal override void ExecuteApplicationEndRequest(object sender, EventArgs e)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             try
             {
                 RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger;
                 if (getRequestDetailsLogger != null)
                 {
                     HttpApplication httpApplication = (HttpApplication)sender;
                     OwaServerLogger.LogHttpContextData(httpApplication.Context, getRequestDetailsLogger);
                     RequestDetailsLogger.LogEvent(getRequestDetailsLogger, OwaServerLogger.LoggerData.RequestEndTime);
                 }
                 OwaApplication.FinalizeResponse();
             }
             finally
             {
                 Global.CleanUpRequestObjects();
             }
         });
     }
     catch (GrayException arg)
     {
         ExTraceGlobals.ConfigurationManagerTracer.TraceDebug <GrayException>(0L, "OwaApplication.ExecuteApplicationEndRequest: GrayException: {0}", arg);
         throw;
     }
 }
Пример #3
0
        internal void InvokeEndMethod(ServiceMethodInfo methodInfo, object service, IAsyncResult result, HttpResponse httpResponse)
        {
            ExTraceGlobals.CoreTracer.TraceDebug(0L, "OwaServiceMethodDispatcher.InvokeEndMethod");
            object response = null;

            using (CpuTracker.StartCpuTracking("END"))
            {
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                {
                    response = methodInfo.EndMethod.Invoke(service, new object[]
                    {
                        result
                    });
                }, new Func <Exception, bool>(this.CanIgnoreExceptionForWatsonReport));
            }
            if (methodInfo.ShouldAutoDisposeResponse && response != null)
            {
                this.delayedDisposalResponseObject = response;
            }
            this.inspector.BeforeSendReply(httpResponse, methodInfo.Name, response);
            using (CpuTracker.StartCpuTracking("WRITE"))
            {
                OwaServiceMethodDispatcher.WriteResponse(methodInfo, httpResponse, response);
            }
        }
        // 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);
        }
 internal virtual void DisposeSubscriptions(bool disposeQueryResult)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             try
             {
                 ExTraceGlobals.NotificationsCallTracer.TraceDebug <bool, Type>((long)this.GetHashCode(), "MapiNotificationHandlerBase.DisposeInternal. doNotDisposeQueryResult: {0}, Type: {1}", disposeQueryResult, this.GetType());
                 if (disposeQueryResult && this.result != null)
                 {
                     MapiNotificationHandlerBase.DisposeXSOObjects(this.result, this.UserContext);
                     this.result = null;
                 }
                 if (this.mapiSubscription != null)
                 {
                     MapiNotificationHandlerBase.DisposeXSOObjects(this.mapiSubscription, this.UserContext);
                     this.mapiSubscription = null;
                 }
             }
             catch (StoragePermanentException ex2)
             {
                 ExTraceGlobals.NotificationsCallTracer.TraceError <string, SmtpAddress, Type>((long)this.GetHashCode(), "Unexpected exception in MapiNotificationHandlerBase Dispose. User: {1}. Exception: {0}, type: {2}", ex2.Message, this.UserContext.PrimarySmtpAddress, this.GetType());
             }
             catch (StorageTransientException ex3)
             {
                 ExTraceGlobals.NotificationsCallTracer.TraceError <string, SmtpAddress, Type>((long)this.GetHashCode(), "Unexpected exception in MapiNotificationHandlerBase Dispose. User: {1}. Exception: {0}, type: {2}", ex3.Message, this.UserContext.PrimarySmtpAddress, this.GetType());
             }
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.NotificationsCallTracer.TraceError <string>(0L, "MapiNotificationHandlerBase.Dispose Unable to dispose object.  exception {0}", ex.Message);
     }
 }
 // Token: 0x06000EA2 RID: 3746 RVA: 0x00038194 File Offset: 0x00036394
 internal void Clear()
 {
     ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "[RowNotificationHandlerCache::Clear] disposing all row notification handlers");
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             if (this.handlerCache == null)
             {
                 throw new OwaInvalidOperationException("this.handlerCache may not be null");
             }
             if (this.channelIdCache == null)
             {
                 throw new OwaInvalidOperationException("this.channelIdCache may not be null");
             }
             foreach (string key in this.handlerCache.Keys)
             {
                 RowNotificationHandler rowNotificationHandler = this.handlerCache[key];
                 ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "[RowNotificationHandlerCache::Clear] Disposing handler for SubscriptionId: {0}", rowNotificationHandler.SubscriptionId);
                 rowNotificationHandler.Dispose();
             }
             this.handlerCache   = new Dictionary <string, RowNotificationHandler>();
             this.channelIdCache = new Dictionary <string, List <string> >();
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.NotificationsCallTracer.TraceError <string>(0L, "MapiNotificationHandlerBase.Dispose Unable to dispose object.  exception {0}", ex.Message);
     }
 }
 internal void RemovePendingGetChannel(string channelId)
 {
     if (this.pendingRequestChannels != null)
     {
         lock (this.pendingRequestChannels)
         {
             PendingRequestChannel pendingGetChannel = this.GetPendingGetChannel(channelId);
             if (pendingGetChannel != null)
             {
                 this.pendingRequestChannels.Remove(channelId);
                 pendingGetChannel.Dispose();
             }
             this.listenerChannelsManager.RemovePendingGetChannel(channelId);
         }
     }
     ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "[PendingRequestManager::RemovePendingGetChannel] ChannelId: {0}", channelId);
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             if (this.userContext.NotificationManager != null)
             {
                 this.userContext.NotificationManager.ReleaseSubscriptionsForChannelId(channelId);
             }
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.NotificationsCallTracer.TraceError <string>(0L, "MapiNotificationHandlerBase.DisposeXSOObjects Unable to dispose object.  exception {0}", ex.Message);
     }
 }
        // Token: 0x06001F07 RID: 7943 RVA: 0x00076EBC File Offset: 0x000750BC
        public void GetDlpPolicyTipsCommand(GetDlpPolicyTipsRequest request)
        {
            if (Interlocked.Increment(ref GetDlpPolicyTipsAsyncResult.PendingRequestCount) > 50)
            {
                Interlocked.Decrement(ref GetDlpPolicyTipsAsyncResult.PendingRequestCount);
                this.Response = GetDlpPolicyTipsResponse.TooManyPendingRequestResponse;
                base.Callback(this);
                return;
            }
            CallContext callContext = CallContext.Current;

            ThreadPool.QueueUserWorkItem(delegate(object obj)
            {
                try
                {
                    OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                    {
                        CallContext.SetCurrent(callContext);
                        this.Response = new GetDlpPolicyTipsCommand(callContext, request).Execute();
                        this.Callback(this);
                    });
                }
                catch (GrayException arg)
                {
                    ExTraceGlobals.OwaRulesEngineTracer.TraceError <GrayException>(0L, "GetDlpPolicyTipsAsyncResult GrayException occured while evaluating for Dlp.  exception {0}", arg);
                }
                finally
                {
                    CallContext.SetCurrent(null);
                    Interlocked.Decrement(ref GetDlpPolicyTipsAsyncResult.PendingRequestCount);
                }
            }, base.AsyncState);
        }
        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;
            }
        }
Пример #10
0
 internal static void SetSignedOutFlag(MailboxSession session, bool signedOut)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             using (Folder folder = InstantMessageUtilities.SafeFolderBind(session, DefaultFolderType.Root, new PropertyDefinition[]
             {
                 ViewStateProperties.SignedOutOfIM
             }))
             {
                 if (folder != null)
                 {
                     folder[ViewStateProperties.SignedOutOfIM] = signedOut;
                     folder.Save();
                 }
             }
         });
     }
     catch (GrayException ex)
     {
         Microsoft.Exchange.Clients.Owa.Server.LyncIMLogging.ExTraceGlobals.InstantMessagingTracer.TraceError(0L, "InstantMessageUtilities.SetSignedOutFlag failed. Exception message is {0}.", new object[]
         {
             ex
         });
     }
 }
Пример #11
0
        internal static MailboxSession GetClonedMailboxSession(Guid mailboxGuid, CultureInfo cultureInfo, LogonType logonType, string userContextKey, ExchangePrincipal exchangePrincipal, IADOrgPerson person, ClientSecurityContext clientSecurityContext, GenericIdentity genericIdentity, bool unifiedLogon)
        {
            MailboxSession clonedMailboxSession = null;
            UserContext    userContext          = null;
            string         expectedMailboxKey   = string.Empty;

            if (!string.IsNullOrEmpty(userContextKey))
            {
                try
                {
                    OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                    {
                        UserContextManager.UserContextCacheWrapper userContextCacheWrapper = (UserContextManager.UserContextCacheWrapper)HttpRuntime.Cache.Get(userContextKey);
                        if (userContextCacheWrapper != null && userContextCacheWrapper.UserContext != null && userContextCacheWrapper.UserContext.TerminationStatus == UserContextTerminationStatus.NotTerminate)
                        {
                            userContext = (userContextCacheWrapper.UserContext as UserContext);
                            if (userContext != null && userContext.FeaturesManager != null && userContext.FeaturesManager.ServerSettings.OwaMailboxSessionCloning.Enabled && userContext.UserCulture != null && !userContext.IsExplicitLogon)
                            {
                                expectedMailboxKey   = AccessingPrincipalTiedCache.BuildKeyCacheKey(mailboxGuid, cultureInfo, logonType);
                                clonedMailboxSession = userContext.CloneMailboxSession(expectedMailboxKey, exchangePrincipal, person, clientSecurityContext, genericIdentity, unifiedLogon);
                            }
                        }
                    });
                }
                catch (GrayException ex)
                {
                    ExTraceGlobals.UserContextCallTracer.TraceError(0L, string.Format("Exception while cloning MailboxSession, MailboxKey: {0}, Exception: {1}", expectedMailboxKey, ex.Message));
                }
            }
            return(clonedMailboxSession);
        }
Пример #12
0
        internal static bool IsSignedOut(MailboxSession session)
        {
            bool signedOut = false;

            try
            {
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                {
                    using (Folder folder = InstantMessageUtilities.SafeFolderBind(session, DefaultFolderType.Root, new PropertyDefinition[]
                    {
                        ViewStateProperties.SignedOutOfIM
                    }))
                    {
                        if (folder != null)
                        {
                            bool defaultValue = false;
                            signedOut         = InstantMessageUtilities.GetFolderProperty <bool>(folder, ViewStateProperties.SignedOutOfIM, defaultValue);
                        }
                    }
                });
            }
            catch (GrayException ex)
            {
                Microsoft.Exchange.Clients.Owa.Server.LyncIMLogging.ExTraceGlobals.InstantMessagingTracer.TraceError(0L, "InstantMessageUtilities.IsSignedOut failed. Exception message is {0}.", new object[]
                {
                    ex
                });
            }
            return(signedOut);
        }
 private void ProcessKeepAlive(MapiNotificationsLogEvent logEvent)
 {
     try
     {
         if (!base.IsDisposed)
         {
             OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
             {
                 this.HandlePendingGetTimerCallback(logEvent);
             });
         }
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.NotificationsCallTracer.TraceError <string, string>((long)this.GetHashCode(), "MapiNotificationHandlerBase.KeepAlive for {0} encountered an exception: {1}", base.GetType().Name, ex.ToString());
         logEvent.HandledException = ex;
     }
     finally
     {
         if (this.ShouldLog(logEvent))
         {
             OwaServerTraceLogger.AppendToLog(logEvent);
         }
     }
 }
Пример #14
0
        private void InternalInvokeMethod(ServiceMethodInfo methodInfo, object service, HttpRequest httpRequest, HttpResponse httpResponse, object[] arguments)
        {
            object request = (arguments != null) ? arguments[0] : null;

            this.inspector.AfterReceiveRequest(httpRequest, methodInfo.Name, request);
            if (methodInfo.ShouldAutoDisposeRequest && arguments != null)
            {
                this.delayedDisposalRequestObjects = arguments;
            }
            object response = null;

            using (CpuTracker.StartCpuTracking("EXEC"))
            {
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                {
                    response = this.InvokeSyncMethod(httpRequest, methodInfo, service, arguments);
                }, new Func <Exception, bool>(this.CanIgnoreExceptionForWatsonReport));
            }
            if (methodInfo.ShouldAutoDisposeResponse && response != null)
            {
                this.delayedDisposalResponseObject = response;
            }
            using (CpuTracker.StartCpuTracking("WRITE"))
            {
                OwaServiceMethodDispatcher.WriteResponse(methodInfo, httpResponse, response);
            }
        }
Пример #15
0
 public void HandleNotification(BrokerNotification notification)
 {
     try
     {
         if (!base.IsDisposed)
         {
             OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
             {
                 this.HandleNotificatonInternal(notification);
             });
         }
     }
     catch (GrayException handledException)
     {
         OwaServerTraceLogger.AppendToLog(new BrokerLogEvent
         {
             Principal            = this.UserContext.ExchangePrincipal,
             UserContextKey       = this.UserContext.Key.ToString(),
             SubscriptionId       = this.SubscriptionId,
             BrokerSubscriptionId = this.BrokerSubscriptionId,
             EventName            = "HandleNotification",
             HandledException     = handledException
         });
     }
 }
Пример #16
0
        internal static void DownloadAndAttachFile(Guid operationId, AttachmentDataProvider attachmentDataProvider, UserContext userContext, string location, string dataProviderItemId, string parentItemId, string subscriptionId, IdConverter idConverter, string channelId, string dataProviderParentItemId, string providerEndpointUrl, CancellationToken cancellationToken, string cancellationId)
        {
            AttachmentResultCode errorCode    = AttachmentResultCode.GenericFailure;
            Exception            exception    = null;
            AttachmentIdType     attachmentId = null;

            try
            {
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(async delegate()
                {
                    try
                    {
                        DownloadItemAsyncResult downloadItemResult = await attachmentDataProvider.DownloadItemAsync(location, dataProviderItemId, dataProviderParentItemId, providerEndpointUrl, cancellationToken).ConfigureAwait(false);
                        CreateAttachmentNotificationPayload result = new CreateAttachmentNotificationPayload
                        {
                            SubscriptionId = subscriptionId,
                            Id             = operationId.ToString(),
                            Bytes          = downloadItemResult.Bytes,
                            Item           = downloadItemResult.Item,
                            ResultCode     = downloadItemResult.ResultCode
                        };
                        attachmentId = CreateAttachmentHelper.CreateAttachmentAndSendPendingGetNotification(userContext, parentItemId, result.Bytes, result.Item.Name, result, idConverter, channelId);
                    }
                    catch (OperationCanceledException exception)
                    {
                        errorCode = AttachmentResultCode.Cancelled;
                        exception = exception;
                        if (cancellationId != null)
                        {
                            userContext.CancelAttachmentManager.CreateAttachmentCancelled(cancellationId);
                        }
                    }
                });
            }
            catch (GrayException ex)
            {
                ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "CreateAttachmentFromAttachmentDataProvider.DownloadAndAttachFile Exception while trying to download and attach file async : {0}", ex.StackTrace);
                exception = ex;
            }
            finally
            {
                if (cancellationId != null)
                {
                    userContext.CancelAttachmentManager.CreateAttachmentCompleted(cancellationId, attachmentId);
                }
                if (exception != null)
                {
                    CreateAttachmentHelper.SendFailureNotification(userContext, subscriptionId, operationId.ToString(), errorCode, channelId, exception);
                }
            }
        }
        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;
            }
        }
Пример #18
0
 internal static HashSet <string> GetExpandedGroups(MailboxSession session)
 {
     string[] groupIds = null;
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             using (Folder folder = InstantMessageUtilities.SafeFolderBind(session, DefaultFolderType.Root, new PropertyDefinition[]
             {
                 ViewStateProperties.ExpandedGroups
             }))
             {
                 if (folder != null)
                 {
                     string[] defaultValue = null;
                     groupIds = InstantMessageUtilities.GetFolderProperty <string[]>(folder, ViewStateProperties.ExpandedGroups, defaultValue);
                     if (groupIds != null)
                     {
                         if (groupIds.Length == 1 && groupIds[0] == string.Empty)
                         {
                             groupIds = new string[0];
                         }
                     }
                 }
             }
         });
     }
     catch (GrayException ex)
     {
         Microsoft.Exchange.Clients.Owa.Server.LyncIMLogging.ExTraceGlobals.InstantMessagingTracer.TraceError(0L, "InstantMessageUtilities.GetExpandedGroups failed. Exception {0}.", new object[]
         {
             ex
         });
     }
     if (groupIds == null)
     {
         return(null);
     }
     return(new HashSet <string>(groupIds));
 }
        internal void HandleNotification(Notification notification, object context)
        {
            MapiNotificationsLogEvent logEvent = new MapiNotificationsLogEvent(this.UserContext.ExchangePrincipal, this.UserContext.Key.ToString(), this, this.EventPrefix + "HandleNotification");

            try
            {
                if (base.IsDisposed)
                {
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "MapiNotificationHandlerBase.HandleNotification for {0}: Ignoring notification because we're disposed.", base.GetType().Name);
                }
                else if (this.MissedNotifications)
                {
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "MapiNotificationHandlerBase.HandleNotification for {0}: Ignoring notification because we've missed notifications.", base.GetType().Name);
                }
                else if (this.NeedToReinitSubscriptions)
                {
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "MapiNotificationHandlerBase.HandleNotification for {0}: Ignoring notification because we need to re-init subscription.", base.GetType().Name);
                }
                else
                {
                    OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                    {
                        this.HandleNotificationInternal(notification, logEvent, context);
                    });
                }
            }
            catch (GrayException ex)
            {
                ExTraceGlobals.NotificationsCallTracer.TraceError <string, string>((long)this.GetHashCode(), "MapiNotificationHandlerBase.HandleNotification for {0} encountered an exception: {1}", base.GetType().Name, ex.ToString());
                logEvent.HandledException = ex;
                this.MissedNotifications  = true;
            }
            finally
            {
                if (this.ShouldLog(logEvent))
                {
                    OwaServerTraceLogger.AppendToLog(logEvent);
                }
            }
        }
Пример #20
0
        private IAsyncResult InternalInvokeBeginMethod(ServiceMethodInfo methodInfo, object service, HttpRequest httpRequest, AsyncCallback asyncCallback, object[] arguments)
        {
            int    num     = (arguments != null) ? arguments.Length : 0;
            object request = (num > 0) ? arguments[0] : null;

            this.inspector.AfterReceiveRequest(httpRequest, methodInfo.Name, request);
            if (methodInfo.ShouldAutoDisposeRequest && arguments != null)
            {
                this.delayedDisposalRequestObjects = arguments;
            }
            IAsyncResult result = null;

            using (CpuTracker.StartCpuTracking("BEGIN"))
            {
                object[] invokeArgs = this.ConstructAsyncInvokeArguments(arguments, asyncCallback);
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                {
                    result = (IAsyncResult)OwaServiceMethodDispatcher.InvokeMethod(httpRequest, methodInfo.BeginMethod, service, invokeArgs);
                }, new Func <Exception, bool>(this.CanIgnoreExceptionForWatsonReport));
            }
            return(result);
        }
            public static SearchNotificationPayload CreatePayLoad(IMailboxContext userContext, OwaSearchContext searchContext)
            {
                SearchNotificationPayload payload = new SearchNotificationPayload();

                payload.ClientId   = searchContext.ClientSearchFolderIdentity;
                payload.IsComplete = true;
                payload.Source     = MailboxLocation.FromMailboxContext(userContext);
                SearchNotificationHandler.SearchPayloadCreator.SetHighlightTerms(payload, searchContext.HighlightTerms);
                try
                {
                    OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                    {
                        SearchNotificationHandler.SearchPayloadCreator.FillItemDataInPayload(userContext, searchContext, payload);
                    });
                }
                catch (GrayException arg)
                {
                    payload.ServerSearchResultsRowCount = -1;
                    ExTraceGlobals.NotificationsCallTracer.TraceError <GrayException>(0L, "MapiNotificationHandlerBase.CreatePayLoad Unable to create payload with data for search results.  exception {0}", arg);
                }
                return(payload);
            }
 protected override void InternalDispose(bool isDisposing)
 {
     ExTraceGlobals.NotificationsCallTracer.TraceDebug <bool, SmtpAddress, Type>((long)this.GetHashCode(), "MapiNotificationHandlerBase.Dispose. IsDisposing: {0}, User: {1}, Type: {2}", isDisposing, this.UserContext.PrimarySmtpAddress, base.GetType());
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             lock (this.syncRoot)
             {
                 if (this.OnBeforeDisposed != null)
                 {
                     ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "MapiNotificationHandlerBase.InternalDispose Call OnBeforeDisposed.");
                     this.OnBeforeDisposed(new ConnectionDroppedNotificationHandler.ConnectionDroppedEventHandler(this.HandleConnectionDroppedNotification));
                 }
                 if ((this.remoteSubscription || this is ConnectionDroppedNotificationHandler) && this.userContext.NotificationManager != null)
                 {
                     this.userContext.NotificationManager.RemoteKeepAliveEvent -= this.RemoteKeepAlive;
                 }
                 if (!this.remoteSubscription && this.userContext.PendingRequestManager != null)
                 {
                     this.userContext.PendingRequestManager.KeepAlive -= this.KeepAlive;
                 }
                 if ((!Globals.Owa2ServerUnitTestsHook && !this.IsDisposed_Reentrant) || this.Subscription != null || this.QueryResult != null)
                 {
                     if (isDisposing)
                     {
                         this.IsDisposed_Reentrant = true;
                         this.CleanupSubscriptions();
                     }
                 }
             }
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.NotificationsCallTracer.TraceError <string>(0L, "MapiNotificationHandlerBase.Dispose Unable to dispose object.  exception {0}", ex.Message);
     }
 }
        internal static void ExecuteWithoutUserContext(string eventId, Action <RequestDetailsLogger> action)
        {
            RequestDetailsLogger logger = OwaApplication.GetRequestDetailsLogger;

            ActivityContext.ClearThreadScope();
            logger = RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();

            try
            {
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                {
                    action(logger);
                });
            }
            catch (GrayException ex)
            {
                SimulatedWebRequestContext.ProcessException(logger, eventId, ex.InnerException);
            }
            finally
            {
                logger.Commit();
            }
        }
Пример #24
0
 // Token: 0x06000CBB RID: 3259 RVA: 0x0002F270 File Offset: 0x0002D470
 protected override void InternalDispose(bool isDisposing)
 {
     ExTraceGlobals.NotificationsCallTracer.TraceDebug <bool>((long)this.GetHashCode(), "BrokerNotificationManager.Dispose. IsDisposing: {0}", isDisposing);
     if (isDisposing)
     {
         try
         {
             OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
             {
                 lock (this.syncRoot)
                 {
                     this.isDisposed = true;
                     if (this.userContext != null && this.userContext.PendingRequestManager != null)
                     {
                         this.userContext.PendingRequestManager.KeepAlive -= this.KeepHandlersAlive;
                     }
                     foreach (BrokerHandlerReferenceCounter brokerHandlerReferenceCounter in this.activeHandlers.Values)
                     {
                         brokerHandlerReferenceCounter.Dispose();
                     }
                     this.activeHandlers.Clear();
                     this.activeHandlers = null;
                     if (this.mapiNotificationManager != null)
                     {
                         this.mapiNotificationManager.Dispose();
                         this.mapiNotificationManager = null;
                     }
                 }
             });
         }
         catch (GrayException ex)
         {
             ExTraceGlobals.NotificationsCallTracer.TraceError <string>(0L, "[BrokerNotificationManager.Dispose]. Unable to dispose object.  exception {0}", ex.Message);
         }
     }
 }
 // Token: 0x06001159 RID: 4441 RVA: 0x000428F8 File Offset: 0x00040AF8
 internal override void ExecuteApplicationBeginRequest(object sender, EventArgs e)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();
             RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger;
             getRequestDetailsLogger.ActivityScope.UpdateFromMessage(HttpContext.Current.Request);
             getRequestDetailsLogger.ActivityScope.SerializeTo(HttpContext.Current.Response);
             getRequestDetailsLogger.ActivityScope.SetProperty(OwaServerLogger.LoggerData.IsRequest, "1");
             string requestCorrelationId = HttpUtilities.GetRequestCorrelationId(HttpContext.Current);
             getRequestDetailsLogger.Set(OwaServerLogger.LoggerData.CorrelationId, requestCorrelationId);
             getRequestDetailsLogger.Set(OwaServerLogger.LoggerData.RequestStartTime, DateTime.UtcNow);
             HttpContext.Current.Response.AppendToLog("&ActID=" + getRequestDetailsLogger.ActivityId);
             HttpContext.Current.Response.AppendToLog("&CorrelationID=" + requestCorrelationId);
         });
     }
     catch (GrayException arg)
     {
         ExTraceGlobals.ConfigurationManagerTracer.TraceDebug <GrayException>(0L, "OwaApplication.ExecuteApplicationBeginRequest: GrayException: {0}", arg);
         throw;
     }
 }
 protected override void InternalDispose(bool isDisposing)
 {
     if (!this.disposed && isDisposing)
     {
         try
         {
             OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
             {
                 try
                 {
                     bool flag = false;
                     try
                     {
                         flag = this.notifiersStateLock.LockWriterElastic(5000);
                     }
                     catch (OwaLockTimeoutException)
                     {
                         ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "Dispose was called but the writer lock is not available:");
                         return;
                     }
                     if (!flag)
                     {
                         ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "Dispose was called but the writer lock is not available:");
                         return;
                     }
                     foreach (KeyValuePair <IPendingRequestNotifier, PendingRequestManager.PendingNotifierState> keyValuePair in this.notifierDataAvailableState)
                     {
                         keyValuePair.Value.Dispose();
                     }
                     this.notifierDataAvailableState = null;
                 }
                 finally
                 {
                     if (this.notifiersStateLock.IsWriterLockHeld)
                     {
                         this.notifiersStateLock.ReleaseWriterLock();
                     }
                 }
                 lock (this.pendingRequestChannels)
                 {
                     if (this.pendingRequestChannels != null)
                     {
                         foreach (string channelId in this.pendingRequestChannels.Keys)
                         {
                             PendingRequestChannel pendingGetChannel = this.GetPendingGetChannel(channelId);
                             if (pendingGetChannel != null)
                             {
                                 pendingGetChannel.Dispose();
                             }
                             this.listenerChannelsManager.RemovePendingGetChannel(channelId);
                         }
                     }
                     this.pendingRequestChannels.Clear();
                     this.pendingRequestChannels = null;
                 }
                 if (this.budget != null)
                 {
                     this.budget.Dispose();
                     this.budget = null;
                 }
             });
         }
         catch (GrayException ex)
         {
             ExTraceGlobals.NotificationsCallTracer.TraceError <string>(0L, "MapiNotificationHandlerBase.DisposeXSOObjects Unable to dispose object.  exception {0}", ex.Message);
         }
         this.disposed = true;
     }
 }
Пример #27
0
        internal static void DownloadAndAttachFileFromUri(Uri uri, string name, string subscriptionId, Guid operationId, ItemId itemId, UserContext userContext, IdConverter idConverter)
        {
            try
            {
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(async delegate()
                {
                    try
                    {
                        using (HttpClient client = new HttpClient())
                        {
                            using (HttpResponseMessage response = await client.GetAsync(uri))
                            {
                                HttpStatusCode statusCode = response.StatusCode;
                                AttachmentResultCode resultCode;
                                if (statusCode != HttpStatusCode.OK)
                                {
                                    switch (statusCode)
                                    {
                                    case HttpStatusCode.Forbidden:
                                        resultCode = AttachmentResultCode.AccessDenied;
                                        break;

                                    case HttpStatusCode.NotFound:
                                        resultCode = AttachmentResultCode.NotFound;
                                        break;

                                    default:
                                        if (statusCode != HttpStatusCode.RequestTimeout)
                                        {
                                            resultCode = AttachmentResultCode.GenericFailure;
                                        }
                                        else
                                        {
                                            resultCode = AttachmentResultCode.Timeout;
                                        }
                                        break;
                                    }
                                }
                                else
                                {
                                    resultCode = AttachmentResultCode.Success;
                                }
                                if (resultCode != AttachmentResultCode.Success)
                                {
                                    CreateAttachmentHelper.SendFailureNotification(userContext, subscriptionId, operationId.ToString(), resultCode, null, null);
                                }
                                byte[] buffer = await response.Content.ReadAsByteArrayAsync();
                                CreateAttachmentNotificationPayload result = new CreateAttachmentNotificationPayload
                                {
                                    SubscriptionId = subscriptionId,
                                    Id             = operationId.ToString(),
                                    Bytes          = buffer,
                                    Item           = null,
                                    ResultCode     = resultCode
                                };
                                CreateAttachmentHelper.CreateAttachmentAndSendPendingGetNotification(userContext, itemId.Id, buffer, name, result, idConverter);
                            }
                        }
                    }
                    catch (TaskCanceledException)
                    {
                    }
                });
            }
            catch (GrayException ex)
            {
                CreateAttachmentHelper.SendFailureNotification(userContext, subscriptionId, operationId.ToString(), AttachmentResultCode.GenericFailure, null, ex);
                ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "CreateAttachmentFromUri.DownloadAndAttachFileFromUri Exception while trying to download and attach file async : {0}", ex.StackTrace);
            }
        }
Пример #28
0
        internal static void UploadAndAttachReferenceAttachment(Guid operationId, UserContext userContext, CallContext callContext, ItemId itemId, string fileName, byte[] fileContent, IdConverter idConverter, string subscriptionId, string channelId, CancellationToken cancellationToken, string cancellationId)
        {
            AttachmentResultCode errorCode    = AttachmentResultCode.GenericFailure;
            AttachmentIdType     attachmentId = null;
            Exception            exception    = null;

            try
            {
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(async delegate()
                {
                    try
                    {
                        AttachmentDataProvider attachmentDataProvider = userContext.AttachmentDataProviderManager.GetDefaultUploadDataProvider(callContext);
                        if (attachmentDataProvider == null)
                        {
                            throw new InvalidOperationException("The user has no default data provider");
                        }
                        UploadItemAsyncResult uploadResult = await attachmentDataProvider.UploadItemAsync(fileContent, fileName, cancellationToken, callContext).ConfigureAwait(false);
                        CreateAttachmentNotificationPayload notificationPayload = new CreateAttachmentNotificationPayload
                        {
                            SubscriptionId = subscriptionId,
                            Id             = operationId.ToString(),
                            Item           = uploadResult.Item,
                            ResultCode     = uploadResult.ResultCode
                        };
                        if (uploadResult.ResultCode == AttachmentResultCode.Success)
                        {
                            notificationPayload.Response = CreateReferenceAttachmentFromAttachmentDataProvider.AttachReferenceAttachment(attachmentDataProvider, userContext, uploadResult.Item.Location, string.Empty, itemId.Id, idConverter, null, uploadResult.Item.ProviderEndpointUrl);
                            attachmentId = CreateAttachmentHelper.GetAttachmentIdFromCreateAttachmentResponse(notificationPayload.Response);
                        }
                        if (!userContext.IsDisposed)
                        {
                            try
                            {
                                userContext.LockAndReconnectMailboxSession();
                                CreateAttachmentHelper.SendPendingGetNotification(userContext, notificationPayload, channelId);
                            }
                            finally
                            {
                                userContext.UnlockAndDisconnectMailboxSession();
                            }
                        }
                    }
                    catch (OperationCanceledException exception)
                    {
                        errorCode = AttachmentResultCode.Cancelled;
                        exception = exception;
                        if (cancellationId != null)
                        {
                            userContext.CancelAttachmentManager.CreateAttachmentCancelled(cancellationId);
                        }
                    }
                });
            }
            catch (GrayException ex)
            {
                ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "CreateReferenceAttachmentFromLocalFile.UploadAndAttachReferenceAttachment Exception while trying to upload and attach file async : {0}", ex.StackTrace);
                exception = ex;
            }
            finally
            {
                if (cancellationId != null)
                {
                    userContext.CancelAttachmentManager.CreateAttachmentCompleted(cancellationId, attachmentId);
                }
                if (exception != null)
                {
                    CreateAttachmentHelper.SendFailureNotification(userContext, subscriptionId, operationId.ToString(), errorCode, channelId, exception);
                }
            }
        }
 // Token: 0x06000E92 RID: 3730 RVA: 0x000379F8 File Offset: 0x00035BF8
 protected override void InternalDispose(bool isDisposing)
 {
     ExTraceGlobals.NotificationsCallTracer.TraceDebug <bool>((long)this.GetHashCode(), "OwaMapiNotificationManager.Dispose. IsDisposing: {0}", isDisposing);
     if (isDisposing)
     {
         try
         {
             OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
             {
                 lock (this.syncRoot)
                 {
                     if (this.hierarchyHandlerLoggedUser != null)
                     {
                         this.hierarchyHandlerLoggedUser.Dispose();
                         this.hierarchyHandlerLoggedUser = null;
                     }
                     if (this.reminderHandlerLoggedUser != null)
                     {
                         this.reminderHandlerLoggedUser.Dispose();
                         this.reminderHandlerLoggedUser = null;
                     }
                     if (this.newMailHandlerLoggedUser != null)
                     {
                         this.newMailHandlerLoggedUser.Dispose();
                         this.newMailHandlerLoggedUser = null;
                     }
                     if (this.unseenItemHandler != null)
                     {
                         this.unseenItemHandler.Dispose();
                         this.unseenItemHandler = null;
                     }
                     if (this.groupAssociationHandlerLoggedUser != null)
                     {
                         this.groupAssociationHandlerLoggedUser.Dispose();
                         this.groupAssociationHandlerLoggedUser = null;
                     }
                     if (this.searchHandlerLoggedUser != null)
                     {
                         this.searchHandlerLoggedUser.Dispose();
                         this.searchHandlerLoggedUser = null;
                     }
                     if (this.rowNotificationHandlerCache != null)
                     {
                         ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "[OwaMapiNotificationManager.Dispose]. Calling this.rowNotificationHandlerCache.Clear()");
                         this.rowNotificationHandlerCache.Clear();
                         this.rowNotificationHandlerCache = null;
                     }
                     if (this.connectionDroppedNotificationHandler != null)
                     {
                         this.connectionDroppedNotificationHandler.Dispose();
                         this.connectionDroppedNotificationHandler = null;
                     }
                     if (this.notificationHandlers != null)
                     {
                         this.notificationHandlers.Clear();
                         this.notificationHandlers = null;
                     }
                     if (this.remoteKeepAliveTimer != null)
                     {
                         this.remoteKeepAliveTimer.Dispose();
                         this.remoteKeepAliveTimer = null;
                     }
                     this.isDisposed = true;
                 }
             });
         }
         catch (GrayException ex)
         {
             ExTraceGlobals.NotificationsCallTracer.TraceError <string>(0L, "[OwaMapiNotificationManager.Dispose]. Unable to dispose object.  exception {0}", ex.Message);
         }
     }
 }
        private void WriteNotification(bool asyncOperation, double throttleInterval, IPendingRequestNotifier notifier, PendingRequestManager.PendingNotifierState notifierState)
        {
            bool flag = false;

            if (notifier.ShouldThrottle)
            {
                int num = notifierState.IncrementOnDataAvailableThrottleCount();
                if (num > 100)
                {
                    flag = true;
                }
                else if (num == 100 && throttleInterval <= 10.0)
                {
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug <string, int>((long)this.GetHashCode(), "Start throttling mechanism - timer was started and from now on notifier {0} / {1} will be on throttling mode ", notifier.GetType().Name, notifier.GetHashCode());
                    flag = true;
                    if (notifierState.ThrottleTimer == null)
                    {
                        notifierState.ThrottleTimer = new Timer(new TimerCallback(this.ThrottleTimeout), notifier, 20000, -1);
                    }
                    else
                    {
                        notifierState.ThrottleTimer.Change(20000, -1);
                    }
                }
                if (num <= 100 && throttleInterval > 10.0 && num != 1)
                {
                    notifierState.ExchangeOnDataAvailableThrottleCount(1);
                }
            }
            if (flag)
            {
                ExTraceGlobals.NotificationsCallTracer.TraceDebug <string, int>((long)this.GetHashCode(), "PendingRequestManager.WriteNotification throttled notifier: {0} / {1}", notifier.GetType().Name, notifier.GetHashCode());
                return;
            }
            ExTraceGlobals.NotificationsCallTracer.TraceDebug <string, int>((long)this.GetHashCode(), "PendingRequestManager.WriteNotification is reading data from the notifier. Notifier: {0} / {1}", notifier.GetType().Name, notifier.GetHashCode());
            try
            {
                List <NotificationPayloadBase> payloadList = (List <NotificationPayloadBase>)notifier.ReadDataAndResetState();
                if (notifier.SubscriptionId != null)
                {
                    Pusher.Instance.Distribute(payloadList, notifier.ContextKey, notifier.SubscriptionId);
                }
                if (this.pendingRequestChannels != null)
                {
                    lock (this.pendingRequestChannels)
                    {
                        if (this.pendingRequestChannels != null)
                        {
                            if (this.budget == null)
                            {
                                this.budget = StandardBudget.Acquire(this.userContext.ExchangePrincipal.Sid, BudgetType.Owa, this.userContext.ExchangePrincipal.MailboxInfo.OrganizationId.ToADSessionSettings());
                            }
                            this.budget.CheckOverBudget();
                            this.budget.StartLocal("PendingRequestManager.WriteNotification", default(TimeSpan));
                            try
                            {
                                using (Dictionary <string, PendingRequestChannel> .Enumerator enumerator = this.pendingRequestChannels.GetEnumerator())
                                {
                                    while (enumerator.MoveNext())
                                    {
                                        KeyValuePair <string, PendingRequestChannel> channel = enumerator.Current;
                                        try
                                        {
                                            OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                                            {
                                                KeyValuePair <string, PendingRequestChannel> channel = channel;
                                                channel.Value.WritePayload(asyncOperation, payloadList);
                                                Dictionary <string, long> dictionary = this.channelNotificationMarks;
                                                KeyValuePair <string, PendingRequestChannel> channel2 = channel;
                                                if (dictionary.ContainsKey(channel2.Key))
                                                {
                                                    Dictionary <string, long> dictionary3;
                                                    Dictionary <string, long> dictionary2 = dictionary3 = this.channelNotificationMarks;
                                                    KeyValuePair <string, PendingRequestChannel> channel3 = channel;
                                                    string key;
                                                    dictionary2[key = channel3.Key] = dictionary3[key] + (long)payloadList.Count;
                                                    return;
                                                }
                                                Dictionary <string, long> dictionary4 = this.channelNotificationMarks;
                                                KeyValuePair <string, PendingRequestChannel> channel4 = channel;
                                                dictionary4.Add(channel4.Key, (long)payloadList.Count);
                                            });
                                        }
                                        catch (GrayException ex)
                                        {
                                            Exception ex2 = (ex.InnerException != null) ? ex.InnerException : ex;
                                            ExTraceGlobals.NotificationsCallTracer.TraceError((long)this.GetHashCode(), "Exception when writing the notifications to the client. Notifier {0} / {1}, exception message: {2}, stack: {3};", new object[]
                                            {
                                                notifier.GetType().Name,
                                                notifier.GetHashCode(),
                                                ex2.Message,
                                                ex2.StackTrace
                                            });
                                        }
                                    }
                                }
                            }
                            finally
                            {
                                this.budget.EndLocal();
                            }
                        }
                    }
                }
            }
            catch (Exception ex3)
            {
                ExTraceGlobals.NotificationsCallTracer.TraceError <string, int, string>((long)this.GetHashCode(), "Exception when writing the notifications to the client. Notifier {0} / {1}, exception message: {2};", notifier.GetType().Name, notifier.GetHashCode(), (ex3.InnerException != null) ? ex3.InnerException.Message : ex3.Message);
                throw;
            }
        }