示例#1
0
OutputUsedDataRegister()
{
	//Connect to second VTS server
	pvci = vtc_connect(VtsServer2,nPort2,VTOPT_KEEP_ALIVE);
    //lr_output_message("pvci=%d\n", pvci);   
    
    lr_start_transaction("BP2_RegisterNew_WriteData");
    
    //Append rows of "used" data as well as unique identifier {_VTS_ID}
    ret = vtc_send_row1(pvci, 
                        "_VTS_ID;first_name;last_name;company_name;address;city;county;postal;phone1;phone2;email;web",
        				"{pVuserID}_{pTimeStamp};{first_name};{last_name};{company_name};{address};{city};{county};{postal};{phone1};{phone2};{email};{web}",
        				";",
        				VTSEND_SAME_ROW,
        				&status);
    
    lr_end_transaction("BP2_RegisterNew_WriteData", LR_AUTO);
    
	//lr_output_message("Row submission ret=%d\n", ret);
        
	//Disconnect from VTS
    vtc_disconnect(pvci);  
    
    return 0;
}
示例#2
0
int vi_set_VTS3(){

	int rc=LR_PASS;
	
	// Using VTS3 (Virtual Table Service version 3) available since LR 11.52+:
	// See blog by its developer at http://h30499.www3.hp.com/t5/HP-LoadRunner-and-Performance/The-New-Virtual-Table-Server-VTS-in-LoadRunner-11-52/ba-p/6069435#.Ukt79rHnb4Y
	// HP Support article at http://support.openview.hp.com/selfsolve/document/KM305130

       LPCSTR_VTS_Host = lr_get_attrib_string("VTS_Host"); // from Run-time settings Attributes or command line.
 	if(LPCSTR_VTS_Host==NULL){                 // Not specified in Run-Time Settings Attributes or command line.
 	          VTS_Host_string="localhost"; // VTS_Host_default; // such as "localhost"; 

			wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"VTS_Host\" not specified in command-line or run-time settings. Default to \"%s\"."
					,VTS_Host_string
					);
			wi_stopPrinting();
    }else{
		sprintf( VTS_Host_string ,"%s",LPCSTR_VTS_Host);
	} // if(LPCSTR_VTS_Host==NULL)
       

       LPCSTR_VTS_Port = lr_get_attrib_string("VTS_Port"); // from Run-time settings Attributes or command line.
 	if(LPCSTR_VTS_Port==NULL){             // Not specified in Run-Time Settings Attributes or command line.
 	             nPort=8787; // nVTS_Port_default; // such as 8787 or 8888;
		    wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"VTS_Port\" not specified in command-line or run-time settings. Default to \"%d\"."
					,nPort 
					);
			wi_stopPrinting();
    }else{
     	nPort = atoi(LPCSTR_VTS_Port); 
	} // if(LPCSTR_VTS_Port==NULL)

    /// Connect using LoadRunner native functions:
 		pvci = vtc_connect( VTS_Host_string , nPort , VTOPT_KEEP_ALIVE ); // VTS_Host_string
	if( pvci <= 0){
	    wi_startPrintingDebug();
		lr_error_message(">> VTS pvci=%d (non-zero).", pvci);
		wi_stopPrinting();
	}else{
		rc = vtc_get_last_error(pvci);
		if( rc != LR_PASS ) {
		    wi_startPrintingDebug();
			lr_error_message(">> rc from vtc_get_last_error(pvci)=%d for VTC connection to %s port .", rc, VTS_Host_string,nPort);
			wi_stopPrinting();
			return LR_FAIL; // FAIL
		}

		// Count rows in VTS table:
		vtc_column_size(pvci, "web", &nVTS_row_count);
		wi_startPrintingInfo();
		lr_output_message(">> nVTS_row_count=%d.", nVTS_row_count);
		wi_stopPrinting();
	}

	return rc;
} // vi_set_VTS3()
示例#3
0
GetSourceDataRegister()  
{
	//Connect to first VTS server (may prefer to do this in vuser_init)
	pvci = vtc_connect(VtsServer1,nPort1,VTOPT_KEEP_ALIVE);
    //lr_output_message("pvci=%d\n", pvci);
	
    lr_start_transaction("BP1_RegisterNew_GetData");
    
	//Retrieve the topmost row, removes the row from the table.
	//To take data from the table non destructively, use the lrvtc_query_row function.	
	ret = vtc_retrieve_row(pvci, &colnames, &rowdata);
	//lr_output_message("Row retrieval ret=%d\n", ret);
	
	// Because the vtc_retrieve_row function returns an array, not a populated list
	// We have to check the content and save the parameters ourselves
	// If we stick to lrvtc_retrieve_row this step is unneeded

	if (!colnames){
	//	lr_output_message("No data found");
		lr_save_string("","first_name");
	}else
		for (inx=0; colnames[inx]; inx++){
			lr_save_string(rowdata[inx],colnames[inx]);
		}
	
    lr_end_transaction("BP1_RegisterNew_GetData", LR_AUTO);
    
    //Can refer to the variables returned from VTS using the parameter names.
    //lr_output_message("First name was  : %s . Last name was : %s", 
    //                  lr_eval_string("{first_name}"),
    //                  lr_eval_string("{last_name}"));
    
    //Deallocate the buffers containing arrays of returned strings
    vtc_free_list(colnames);
	vtc_free_list(rowdata);    

	//Disconnect from VTS (may prefer to do this in vuser_end)
    vtc_disconnect(pvci);  

	return 0;    
}