public bool IsDatabaseConnectable() { try { DatabaseSession session = m_sessionFactory.GetDatabaseSession(); return(session.CheckDatabaseConnection()); } catch (DatabaseConnectionException e) { } return(false); }
public DatabaseSession GetDatabaseSession() { string Function_Name = "GetDatabaseSession"; LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered"); bool bConnected = false; int nTrytimes = 0; while (!bConnected && nTrytimes++ <= MAX_TIMES) { DatabaseSession currentSession = m_sessionStore.GetCurrentSession(); if (currentSession != null && currentSession.IsTransactionOpen()) { LogHelper.Debug(CLASS_NAME, Function_Name, "Transaction open in current Session"); if (currentSession.CheckDatabaseConnection()) { LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited"); return(currentSession); } } else { string connectionString = DBConnectionStrings.GetInstance().GetConnectionString(); if (connectionString != null) { DatabaseSession session = m_sessionStore.GetSession(connectionString); if (session == null) { CreateDatabaseSession(connectionString); session = m_sessionStore.GetSession(connectionString); } if (session.CheckDatabaseConnection()) { /*if (m_DBSwitched.Length != 0 && (m_DBSwitched == connectionString)) * { * m_DBSwitched = ""; * }*/ m_sessionStore.StoreCurrentSession(session); LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited"); return(session); } else { // m_DBSwitched = connectionString; // DBConnectionStrings.GetInstance().UpdateDBStatus(connectionString, DBStatus.DB_OFFLINE); } } } } throw new DatabaseConnectionException("No Database Connection"); }
public bool IsDatabaseConnectable(string ConnectionString) { DatabaseSession session = m_sessionFactory.GetDatabaseSession(ConnectionString); return(session.CheckDatabaseConnection()); }