Esempio n. 1
0
//Checked
XTDBError
XTDBDrop(XTDBHandle* handle) {
    if (!XTDBForAllIDX(handle,XTDBUnlinkIndexIter,NULL,NULL,NULL)) {
        return handle->error;
    }


    //unlink();
    /*HashTableIterator iter;
    hash_table_iterate(handle->indexes,&iter);
    while (hash_table_iter_has_more(&iter)) {
       DataBaseBE* be = hash_table_iter_next(&iter);

       unlink(DBName(be));
       //DBClose(be);
       //DBFree(be);

       /*DBClose(be);
       DBOpen(be,BDBOWRITER);*
    }*/
    unlink(DBName(handle->descDB));
    unlink(DBName(handle->mainDB));

    XTDBFreeHandle(handle);
    return XTDB_OK;
}
Esempio n. 2
0
//---------------------------------------------------------
bool CWKSP_Project::_Load_DBConnections(CSG_MetaData &Data)
{
	int			i;
	CSG_Strings	Connections;

	for(i=0; i<Data.Get_Children_Count(); i++)
	{
		CSG_String	Connection(Data[i].Get_Child("FILE") ? Data[i].Get_Child("FILE")->Get_Content() : "");

		if( !Connection.BeforeFirst(':').CmpNoCase("PGSQL") )
		{
			Connection	= Connection.AfterFirst(':');	CSG_String	Host  (Connection.BeforeFirst(':'));
			Connection	= Connection.AfterFirst(':');	CSG_String	Port  (Connection.BeforeFirst(':'));
			Connection	= Connection.AfterFirst(':');	CSG_String	DBName(Connection.BeforeFirst(':'));

			Connection	= Host + ":" + Port + ":" + DBName;

			bool	bAdd	= true;

			for(int j=0; j<Connections.Get_Count() && bAdd; j++)
			{
				if( !Connection.Cmp(Connections[j]) )
				{
					bAdd	= false;
				}
			}

			if( bAdd )
			{
				Connections	+= Connection;
			}
		}
	}

	for(i=0; i<Connections.Get_Count(); i++)
	{
		CSG_String	Host  (Connections[i].BeforeFirst(':'));
		CSG_String	Port  (Connections[i].AfterFirst (':').BeforeLast(':'));
		CSG_String	DBName(Connections[i].AfterLast  (':'));

		if( !PGSQL_Connect(Host, Port, DBName) )
		{
			return( false );
		}
	}

	return( true );
}
Esempio n. 3
0
void ProgSettings::openSettingConnection()
{
    DlgSettingConnect *dlg = new DlgSettingConnect(QApplication::activeWindow());

    dlg->SetDBType(DBType());
    dlg->SetDBName(DBName());
    dlg->SetDBHostName(DBHostName());
    dlg->SetDBUserName(DBUserName());
    dlg->SetDBPassword(DBPassword());
    dlg->SetDBPort(DBPort());

    if ((dlg->exec() == QDialog::Accepted) && (dlg->IsModified()))
    {
        SetDBType(dlg->DBType());
        SetDBName(dlg->DBName());
        SetDBHostName(dlg->DBHostName());
        SetDBUserName(dlg->DBUserName());
        SetDBPassword(dlg->DBPassword());
        SetDBPort(dlg->DBPort());

        if (QSqlDatabase::database().isValid() & QSqlDatabase::database().isOpen())
        {
            QSqlDatabase::database().close();
            QSqlDatabase::removeDatabase(QSqlDatabase::database().connectionName());
        }
    }
}
Esempio n. 4
0
// Checked
uint8_t
XTDBUnlinkIndexIter(XTDBHandle* handle,const char* indexName,DataBaseBE* db,void* voidArgs) {
    // XXX not checking unlink errors cant do anything
    handle->error = XTDB_OK;
    //DBClose(db);
    if (!unlink(DBName(db))) {
        if (errno == ENOENT) {
            return True;
        }
        handle->error = XTDB_IO_ERR;
        return False;
    }
    DBFree(db);
    return True;
}
Esempio n. 5
0
//---------------------------------------------------------
bool CSG_Shapes::Create(const CSG_String &File_Name)
{
	Destroy();

	SG_UI_Msg_Add(CSG_String::Format("%s: %s...", _TL("Load shapes"), File_Name.c_str()), true);

	//-----------------------------------------------------
	bool	bResult	= File_Name.BeforeFirst(':').Cmp("PGSQL") && SG_File_Exists(File_Name) && _Load_ESRI(File_Name);

	if( bResult )
	{
		Set_File_Name(File_Name, true);
	}

	//-----------------------------------------------------
	else if( File_Name.BeforeFirst(':').Cmp("PGSQL") == 0 )	// database source
	{
		CSG_String	s(File_Name);

		s	= s.AfterFirst(':');	CSG_String	Host  (s.BeforeFirst(':'));
		s	= s.AfterFirst(':');	CSG_String	Port  (s.BeforeFirst(':'));
		s	= s.AfterFirst(':');	CSG_String	DBName(s.BeforeFirst(':'));
		s	= s.AfterFirst(':');	CSG_String	Table (s.BeforeFirst(':'));

		CSG_Tool	*pTool	= SG_Get_Tool_Library_Manager().Get_Tool("db_pgsql", 0);	// CGet_Connections

		if(	pTool != NULL )
		{
			SG_UI_ProgressAndMsg_Lock(true);

			//---------------------------------------------
			CSG_Table	Connections;
			CSG_String	Connection	= DBName + " [" + Host + ":" + Port + "]";

			pTool->Settings_Push();

			if( pTool->On_Before_Execution() && SG_TOOL_PARAMETER_SET("CONNECTIONS", &Connections) && pTool->Execute() )	// CGet_Connections
			{
				for(int i=0; !bResult && i<Connections.Get_Count(); i++)
				{
					if( !Connection.Cmp(Connections[i].asString(0)) )
					{
						bResult	= true;
					}
				}
			}

			pTool->Settings_Pop();

			//---------------------------------------------
			if( bResult && (bResult = (pTool = SG_Get_Tool_Library_Manager().Get_Tool("db_pgsql", 20)) != NULL) == true )	// CPGIS_Shapes_Load
			{
				pTool->Settings_Push();

				bResult	= pTool->On_Before_Execution()
					&& SG_TOOL_PARAMETER_SET("CONNECTION", Connection)
					&& SG_TOOL_PARAMETER_SET("TABLES"    , Table)
					&& SG_TOOL_PARAMETER_SET("SHAPES"    , this)
					&& pTool->Execute();

				pTool->Settings_Pop();
			}

			SG_UI_ProgressAndMsg_Lock(false);
		}
	}

	//-----------------------------------------------------
	if( bResult )
	{
		Set_Modified(false);
		Set_Update_Flag();

		SG_UI_Process_Set_Ready();
		SG_UI_Msg_Add(_TL("okay"), false, SG_UI_MSG_STYLE_SUCCESS);

		return( true );
	}

	for(int iShape=Get_Count()-1; iShape>=0; iShape--)	// be kind, keep at least those shapes that have been loaded successfully
	{
		if( !Get_Shape(iShape)->is_Valid() )
		{
			Del_Shape(iShape);
		}
	}

	if( Get_Count() <= 0 )
	{
		Destroy();
	}

	SG_UI_Process_Set_Ready();
	SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE);

	return( false );
}