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 <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;
            }
        }