Esempio n. 1
0
void veroRestApiTest() {
    // rest authenticate
    bool ret = restAuthenticate(KServerAddr, KPort, KUserName, KPassword);
    if (!ret) {
        report();
    }

    // rest projects
	std::map<string, string> projectMap;
	restListProjects(KServerAddr, KPort, KUserName, KPassword, projectMap);

	for (std::map<string, string>::iterator i = projectMap.begin(); i != projectMap.end(); i++) {
		cout << "Project = " << (*i).first << endl;
	}

    // rest meta
    std::unique_ptr<MetadataResponse> metaResponse = restGetMeta(KServerAddr, KPort, KUserName, KPassword, KDefaultProject);

	// rest query
	{
		std::unique_ptr<SQLResponse> y = restQuery(L"select Year", KServerAddr, KPort,
			KUserName, KPassword, KDefaultProject);

		if ((int)y->results.size() != 1) {
			report();
		}
	}
}
Esempio n. 2
0
void restAPITest() {
    {
        bool ret = restAuthenticate ( KServerAddr, KPort, KUserName, KPassword );
        
        if ( !ret )
        { report(); }
    }
    {
        std::vector<string> holder;
        restListProjects ( KServerAddr, KPort, KUserName, KPassword, holder );
        
        if ( holder.size() == 0 )
        { report(); }
    }
    {
        std::unique_ptr<MetadataResponse> ret = restGetMeta ( KServerAddr, KPort, KUserName, KPassword, KDefaultProject );
    }
}
Esempio n. 3
0
INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
    pODBCConn pgConn = NULL;
    eGoodBad status = GOOD;
    RETCODE ret = SQL_SUCCESS;
    
    switch ( uMsg ) {
        case WM_INITDIALOG:
            // store the structure for future use
            SetWindowLongPtr ( hDlg, DWLP_USER, lParam );
            // initialize the dialog with data from conn struct
            PutDataToDlgDSNCfg1 ( ( pODBCConn ) lParam, hDlg );
            // set focus automatically
            return TRUE;
            
        case WM_COMMAND:
            switch ( LOWORD ( wParam ) ) {
                case IDC_CONNECT: {
                        HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
                        HWND hwndOK = GetDlgItem ( hDlg, IDOK );
                        // fetch all information from controls & feed to struct
                        pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
                        status = GetDataFromDlgDSNCfg1 ( hDlg, pgConn );
                        
                        if ( status == BAD ) {
                            //Blank input, already popped message
                            return FALSE;
                        }
                        
                        ret = TryAuthenticate ( pgConn );
                        
                        if ( ret == SQL_ERROR ) {
                            //validation of data & other prompts goes here
                            __ODBCPopMsg ( "Username/Password not authorized, or server out of service." );
                            return FALSE;
                        }
                        
                        //passed verification
                        EnableWindow ( hwndCombo, TRUE );
                        
                        try {
                            std::vector<string> projects;
                            restListProjects ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password, projects );
                            
                            for ( unsigned int i = 0 ; i < projects.size(); ++i ) {
                                SendMessage ( hwndCombo, ( UINT ) CB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) projects.at ( i ).c_str() );
                            }
                            
                            SendMessage ( hwndCombo, CB_SETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
                        }
                        
                        catch ( exception& e ) {
                            __ODBCPopMsg ( e.what() );
                            return FALSE;
                        }
                        
                        EnableWindow ( hwndOK, TRUE );
                        return TRUE;
                    }
                    
                case IDOK: {
                        pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
                        HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
                        int ItemIndex = SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETCURSEL,
                                                      ( WPARAM ) 0, ( LPARAM ) 0 );
                        TCHAR  projectName[256];
                        ( TCHAR ) SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETLBTEXT,
                                                ( WPARAM ) ItemIndex, ( LPARAM ) projectName );
                        SetConnProp ( pgConn, CONN_PROP_PROJECT, projectName );
                        //last trial with project given
                        ret = TryFetchMetadata ( pgConn );
                        
                        if ( ret == SQL_ERROR ) {
                            //validation of data & other prompts goes here
                            __ODBCPopMsg ( "Something went wrong with your selected project" );
                            return FALSE;
                        }
                        
                        EndDialog ( hDlg, wParam );
                        return TRUE;
                    }
                    
                // Fall through, do not break or return
                case IDCANCEL:
                    // indicate end with control id as return value
                    EndDialog ( hDlg, wParam );
                    return TRUE;
            }
    }
    
    return FALSE;
}