Пример #1
0
void DbSettingDialog::DoSavePgSQLHistory()
{
    clConfig config(DBE_CONFIG_FILE);
    DbExplorerSettings settings;
    config.ReadItem(&settings);
    DbConnectionInfoVec pgconns = settings.GetPgSQLConnections();

    long port = 0;
    DbConnectionInfo conn;
    conn.SetConnectionType(DbConnectionInfo::DbConnTypePgSQL);
    conn.SetConnectionName(m_txPgName->GetValue());
    conn.SetDefaultDatabase(m_txPgDatabase->GetValue());
    conn.SetPassword(m_txPgPassword->GetValue());
    conn.SetServer(m_txPgServer->GetValue());
    m_txPgPort->GetValue().ToLong(&port);
    conn.SetPort(port);
    conn.SetUsername(m_txPgUserName->GetValue());

    if(!conn.IsValid()) return;

    // remove any connection with this name
    DbConnectionInfoVec::iterator iter = pgconns.begin();
    for(; iter != pgconns.end(); iter++) {
        if(iter->GetConnectionName() == conn.GetConnectionName()) {
            pgconns.erase(iter);
            break;
        }
    }

    pgconns.insert(pgconns.begin(), conn);
    settings.SetPgSQLConnections(pgconns);
    config.WriteItem(&settings);
}
Пример #2
0
DbConnectionInfoVec DbSettingDialog::DoLoadPgSQLHistory()
{
    clConfig config(DBE_CONFIG_FILE);
    DbExplorerSettings settings;
    config.ReadItem(&settings);
    return settings.GetPgSQLConnections();
}