sqldata/sqldata.cpp
// Start a communication with a worker process
Start a communication with a worker process
Start a communication with a worker process
int SqlData::StartWorker(HANDLE hp)
{
	SqlDataCommand cmd;
	SqlDataReply reply;
	DWORD written, read;
	BOOL rcb;
	cmd._cmd = SQLDATA_CMD_CONNECT;
	strcpy(cmd._s_name, _source_conn.c_str());
	strcpy(cmd._t_name, _target_conn.c_str());
	rcb = WriteFile(hp, &cmd, sizeof(SqlDataCommand), &written, NULL);  
	rcb = ReadFile(hp, &reply, sizeof(SqlDataReply), &read, NULL);
	bool more = true;
	while(more)
	{
		std::string table = GetNextTask();
		if(table.empty() == true)
		{
			more = false;
			break;
		}
		strncpy(cmd._s_name, table.c_str(), 256);
		rcb = WriteFile(hp, &cmd, sizeof(SqlDataCommand), &written, NULL);  
		rcb = ReadFile(hp, &reply, sizeof(SqlDataReply), &read, NULL);
	}
	cmd._cmd = SQLDATA_CMD_NO_MORE_TASKS;	
	rcb = WriteFile(hp, &cmd, sizeof(SqlDataCommand), &written, NULL);  
	FlushFileBuffers(hp); 
	DisconnectNamedPipe(hp); 
	CloseHandle(hp); 
	return 0;
}
int SqlData :: StartWorker ( HANDLE hp ) { SqlDataCommand cmd ; SqlDataReply reply ; DWORD written , read ; BOOL rcb ; cmd . _cmd = SQLDATA_CMD_CONNECT ; strcpy ( cmd . _s_name , _source_conn . c_str ( ) ) ; strcpy ( cmd . _t_name , _target_conn . c_str ( ) ) ; rcb = WriteFile ( hp , & cmd , sizeof ( SqlDataCommand ) , & written , NULL ) ; rcb = ReadFile ( hp , & reply , sizeof ( SqlDataReply ) , & read , NULL ) ; bool more = true ; while ( more ) { std :: string table = GetNextTask ( ) ; if ( table . empty ( ) == true ) { more = false ; break ; } strncpy ( cmd . _s_name , table . c_str ( ) , 256 ) ; rcb = WriteFile ( hp , & cmd , sizeof ( SqlDataCommand ) , & written , NULL ) ; rcb = ReadFile ( hp , & reply , sizeof ( SqlDataReply ) , & read , NULL ) ; } cmd . _cmd = SQLDATA_CMD_NO_MORE_TASKS ; rcb = WriteFile ( hp , & cmd , sizeof ( SqlDataCommand ) , & written , NULL ) ; FlushFileBuffers ( hp ) ; DisconnectNamedPipe ( hp ) ; CloseHandle ( hp ) ; return 0 ; }
Start a communication with a worker process
Start a communication with a worker process
// Send te connection command with source and target connection strings // Send the command to the client // Wait for a reply from the worker process // Process tasks in a loop // Get next table for processing // No more tables for processing // Send the command to the client // Wait for a reply from the worker process // Notify the worker that it can finish