/// <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); }
/// <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); }
/// <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); }
/// <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)); } }
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); } } } }
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); } } } }
/// <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); }
/// <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); }
public static void LogDebug(this ILogger logger, ISessionBase session, string message) { logger.LogDebug(string.Format(m_SessionInfoTemplate, session.IdentityKey, session.RemoteEndPoint) + Environment.NewLine + message); }
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; }
/// <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); }
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; }
/// <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); }
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); }
public AnswerController(ILoggerFactory logger, IAnswerService answerService, IAzureService azureService, ISessionBase sessionBase) { _logger = logger.CreateLogger <AnswerController>(); _answerService = answerService; _azureService = azureService; _sessionId = sessionBase.SessionId; }
public static void LogError(this ILogger logger, ISessionBase session, Exception e) { logger.LogError(string.Format(m_SessionInfoTemplate, session.IdentityKey, session.RemoteEndPoint), e); }