Пример #1
0
        /// <summary>
        /// Logs the debug message
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="session">The session.</param>
        /// <param name="message">The message.</param>
        public static void Debug(this ILog logger, ISessionBase session, string message)
        {
            if (!logger.IsDebugEnabled)
                return;

            logger.Debug(string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint) + Environment.NewLine + message);
        }
Пример #2
0
        /// <summary>
        /// Logs the debug message
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="session">The session.</param>
        /// <param name="message">The message.</param>
        public static void Debug(this ILog logger, ISessionBase session, string message)
        {
            if (!logger.IsDebugEnabled)
            {
                return;
            }

            logger.Debug(string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint) + Environment.NewLine + message);
        }
Пример #3
0
        /// <summary>
        /// Initialises a new instance of the <see cref="Transaction" /> class.
        /// </summary>
        /// <param name="sessionBase">The session that the transaction is being created for.</param>
        /// <param name="isolationLevel">The isolation level.</param>
        internal Transaction(ISessionBase sessionBase, IsolationLevel isolationLevel)
        {
            _sessionBase = sessionBase;

            if (s_log.IsDebug)
            {
                s_log.Debug(LogMessages.Transaction_BeginTransactionWithIsolationLevel, isolationLevel.ToString());
            }

            _transaction = _sessionBase.Connection.BeginTransaction(isolationLevel);
        }
Пример #4
0
        /// <summary>
        /// Initialises a new instance of the <see cref="Transaction" /> class.
        /// </summary>
        /// <param name="sessionBase">The session that the transaction is being created for.</param>
        /// <param name="isolationLevel">The isolation level.</param>
        internal Transaction(ISessionBase sessionBase, IsolationLevel isolationLevel)
        {
            this.sessionBase = sessionBase;

            if (log.IsDebug)
            {
                log.Debug(LogMessages.Transaction_BeginTransactionWithIsolationLevel, isolationLevel.ToString());
            }

            this.transaction = this.sessionBase.Connection.BeginTransaction(isolationLevel);
        }
 private bool CheckSessionId(string sessionId)
 {
     using (var scope = LocContainer.Main.BeginLifetimeScope())
     {
         if (_session == null)
         {
             _session = scope.Resolve <ISessionBase>();
         }
         return(_session.CheckSession(sessionId));
     }
 }
Пример #6
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                try
                {
                    if (IsActive)
                    {
                        s_log.Warn(LogMessages.Transaction_DisposedUncommitted);
                        RollbackTransaction();
                    }
                    else if (_failed && !_rolledBack)
                    {
                        s_log.Warn(LogMessages.Transaction_RollingBackFailedCommit);
                        RollbackTransaction();
                    }
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch
#pragma warning restore CA1031 // Do not catch general exception types
                {
                }
                finally
                {
                    _transaction.Dispose();
                    _transaction = null;
                    _sessionBase = null;
                    _disposed    = true;

                    if (s_log.IsDebug)
                    {
                        s_log.Debug(LogMessages.Transaction_Disposed);
                    }
                }
            }
        }
Пример #7
0
        private void Dispose(bool disposing)
        {
            if (this.disposed)
            {
                return;
            }

            if (disposing)
            {
                try
                {
                    if (this.IsActive)
                    {
                        log.Warn(LogMessages.Transaction_DisposedUncommitted);
                        this.RollbackTransaction();
                    }
                    else if (this.failed && !this.rolledBack)
                    {
                        log.Warn(LogMessages.Transaction_RollingBackFailedCommit);
                        this.RollbackTransaction();
                    }
                }
                catch
                {
                }
                finally
                {
                    this.transaction.Dispose();
                    this.transaction = null;
                    this.sessionBase = null;
                    this.disposed    = true;

                    if (log.IsDebug)
                    {
                        log.Debug(LogMessages.Transaction_Disposed);
                    }
                }
            }
        }
Пример #8
0
        private void Dispose(bool disposing)
        {
            if (this.disposed)
            {
                return;
            }

            if (disposing)
            {
                try
                {
                    if (this.IsActive)
                    {
                        log.Warn(LogMessages.Transaction_DisposedUncommitted);
                        this.RollbackTransaction();
                    }
                    else if (this.failed && !this.rolledBack)
                    {
                        log.Warn(LogMessages.Transaction_RollingBackFailedCommit);
                        this.RollbackTransaction();
                    }
                }
                catch
                {
                }
                finally
                {
                    this.transaction.Dispose();
                    this.transaction = null;
                    this.sessionBase = null;
                    this.disposed = true;

                    if (log.IsDebug)
                    {
                        log.Debug(LogMessages.Transaction_Disposed);
                    }
                }
            }
        }
Пример #9
0
 /// <summary>
 /// Logs the information
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="session">The session.</param>
 /// <param name="message">The message.</param>
 public static void Info(this ILog logger, ISessionBase session, string message)
 {
     string info = string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint) + Environment.NewLine + message;
     logger.Info(info);
 }
Пример #10
0
 /// <summary>
 /// Logs the error
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="session">The session.</param>
 /// <param name="message">The message.</param>
 public static void Error(this ILog logger, ISessionBase session, string message)
 {
     logger.Error(string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint) + Environment.NewLine + message);
 }
Пример #11
0
 public static void LogDebug(this ILogger logger, ISessionBase session, string message)
 {
     logger.LogDebug(string.Format(m_SessionInfoTemplate, session.IdentityKey, session.RemoteEndPoint) + Environment.NewLine + message);
 }
Пример #12
0
        /// <summary>
        /// Logs the information
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="session">The session.</param>
        /// <param name="message">The message.</param>
        public static void Info(this ILog logger, ISessionBase session, string message)
        {
            string info = string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint) + Environment.NewLine + message;

            logger.Info(info);
        }
Пример #13
0
        public AzureService(ILoggerFactory loggerFactory, IOptions <AzureServiceOptions> azureServiceOptions, ISessionBase sessionBase)
        {
            _cloudStorageAccount = string.IsNullOrWhiteSpace(azureServiceOptions?.Value?.ConnectionString) ? throw new ArgumentNullException(nameof(azureServiceOptions)) : CloudStorageAccount.Parse(azureServiceOptions.Value.ConnectionString);


            _logger    = loggerFactory.CreateLogger <AnswerService>();
            _sessionId = sessionBase.SessionId;
        }
Пример #14
0
 /// <summary>
 /// Logs the error with the session's information
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="title">The title.</param>
 /// <param name="e">The e.</param>
 /// <param name="session">The session.</param>
 public static void Error(this ILog logger, string title, Exception e, ISessionBase session)
 {
     logger.Error(string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint) + Environment.NewLine + title, e);
 }
Пример #15
0
        public AnswerService(ILoggerFactory loggerFactory, ISurveySystemDbContext dbContext, ISessionBase sessionBase)
        {
            _dbContext = (SurveySystemDbContext)dbContext ?? throw new ArgumentNullException(nameof(dbContext));

            _dbContext.Database.EnsureCreated();

            _logger    = loggerFactory.CreateLogger <AnswerService>();
            _sessionId = sessionBase.SessionId;
        }
Пример #16
0
 /// <summary>
 /// Logs the error
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="session">The session.</param>
 /// <param name="e">The e.</param>
 public static void Error(this ILog logger, ISessionBase session, Exception e)
 {
     logger.Error(string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint), e);
 }
Пример #17
0
 /// <summary>
 /// Logs the error with the session's information
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="title">The title.</param>
 /// <param name="e">The e.</param>
 /// <param name="session">The session.</param>
 public static void Error(this ILog logger, string title, Exception e, ISessionBase session)
 {
     logger.Error(string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint) + Environment.NewLine + title, e);
 }
Пример #18
0
 /// <summary>
 /// Logs the error
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="session">The session.</param>
 /// <param name="e">The e.</param>
 public static void Error(this ILog logger, ISessionBase session, Exception e)
 {
     logger.Error(string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint), e);
 }
Пример #19
0
 public static void LogError(this ILogger logger, ISessionBase session, string title, Exception e)
 {
     logger.LogError(string.Format(m_SessionInfoTemplate, session.IdentityKey, session.RemoteEndPoint) + Environment.NewLine + title, e);
 }
Пример #20
0
 /// <summary>
 /// Logs the error
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="session">The session.</param>
 /// <param name="message">The message.</param>
 public static void Error(this ILog logger, ISessionBase session, string message)
 {
     logger.Error(string.Format(m_SessionInfoTemplate, session.SessionID, session.RemoteEndPoint) + Environment.NewLine + message);
 }
Пример #21
0
 public static void LogError(this ILogger logger, ISessionBase session, string title, Exception e)
 {
     logger.LogError(string.Format(m_SessionInfoTemplate, session.IdentityKey, session.RemoteEndPoint) + Environment.NewLine + title, e);
 }
Пример #22
0
 public static void LogDebug(this ILogger logger, ISessionBase session, string message)
 {
     logger.LogDebug(string.Format(m_SessionInfoTemplate, session.IdentityKey, session.RemoteEndPoint) + Environment.NewLine + message);
 }
Пример #23
0
 public AnswerController(ILoggerFactory logger, IAnswerService answerService, IAzureService azureService, ISessionBase sessionBase)
 {
     _logger        = logger.CreateLogger <AnswerController>();
     _answerService = answerService;
     _azureService  = azureService;
     _sessionId     = sessionBase.SessionId;
 }
Пример #24
0
 public static void LogError(this ILogger logger, ISessionBase session, Exception e)
 {
     logger.LogError(string.Format(m_SessionInfoTemplate, session.IdentityKey, session.RemoteEndPoint), e);
 }
Пример #25
0
 public static void LogError(this ILogger logger, ISessionBase session, Exception e)
 {
     logger.LogError(string.Format(m_SessionInfoTemplate, session.IdentityKey, session.RemoteEndPoint), e);
 }