void EventsWatcherDbOp::UpdateServiceVersion( const string& serviceName, const string& name, const string& version, const string& machine, const string& hash )
{
	Database* config = getConfig();
	
	ParametersVector params;
	
	DataParameterBase *serviceIdParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	serviceIdParam->setDimension( serviceName.size() );
	serviceIdParam->setString( serviceName );
	params.push_back( serviceIdParam );
	
	DataParameterBase *nameParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	nameParam->setDimension( name.size() );
	nameParam->setString( name );
	params.push_back( nameParam );	

	DataParameterBase *versionParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	versionParam->setDimension( version.size() );
	versionParam->setString( version );
	params.push_back( versionParam );	

	DataParameterBase *machineParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	machineParam->setDimension( machine.size() );
	machineParam->setString( machine );
	params.push_back( machineParam );	

	DataParameterBase *hashParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	hashParam->setDimension( hash.size() );
	hashParam->setString( hash );
	params.push_back( hashParam );	
	
	try
	{
		config->BeginTransaction();
		config->ExecuteNonQuery( DataCommand::SP, "UPDATEVERSION", params );
	}
	catch( const std::exception& ex )
	{
		config->EndTransaction( TransactionType::ROLLBACK );
		TRACE( "Update service version failed [" << ex.what() << "] for [" << serviceName << "]" );
		
		throw;
	}
	catch( ... )
	{
		config->EndTransaction( TransactionType::ROLLBACK );
		TRACE( "Update service version failed [unknown reason] for [" << serviceName << "]" );

		throw;
	}

	config->EndTransaction( TransactionType::COMMIT );
}
void EventsWatcherDbOp::InsertPerformanceInfo( long serviceId, long sessionId, const string& timestamp,
	long minTT, long maxTT, long meanTT, long sequenceNo, long ioIdentifier, long commitedNo )
{
	// executes the SP UPDATEINSERTSERVICE ( IN in_serviceID INTEGER, IN in_sessionID INTEGER,
	//		IN in_timeSt TIMESTAMP, IN in_minTT DOUBLE, IN in_maxTT DOUBLE, IN in_meanTT DOUBLE,
	// 		IN in_sequence INTEGER, IN in_ioIdentifier INTEGER, 
	//		IN in_commited INTEGER )

	Database* config = getConfig();
	
	ParametersVector params;
	
	DataParameterBase *serviceIdParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	serviceIdParam->setLong( serviceId );
	params.push_back( serviceIdParam );
	
	DataParameterBase *sessionIdParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	sessionIdParam->setLong( sessionId );
	params.push_back( sessionIdParam );
	
	DataParameterBase *timestampParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	timestampParam->setDimension( timestamp.size() );
	timestampParam->setString( timestamp );
	params.push_back( timestampParam );
	
	DataParameterBase *minTTParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	minTTParam->setLong( minTT );
	params.push_back( minTTParam );
	
	DataParameterBase *maxTTParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	maxTTParam->setLong( maxTT );
	params.push_back( maxTTParam );
	
	DataParameterBase *meanTTParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	meanTTParam->setLong( meanTT );
	params.push_back( meanTTParam );
	
	DataParameterBase *sequenceNoParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	sequenceNoParam->setLong( sequenceNo );
	params.push_back( sequenceNoParam );
	
	DataParameterBase *ioIdentifierParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	ioIdentifierParam->setLong( ioIdentifier );
	params.push_back( ioIdentifierParam );
	
	DataParameterBase *commitedParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	commitedParam->setLong( commitedNo );
	params.push_back( commitedParam );

	config->ExecuteNonQuery( DataCommand::SP, "UPDATEINSERTSERVICE", params );
}
void EventsWatcherDbOp::UpdateServiceState( const long serviceId, const long newState, const string& sessionId )
{
	Database* config = getConfig();
	
	ParametersVector params;
	
	DataParameterBase *serviceIdParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	serviceIdParam->setLong( serviceId );
	params.push_back( serviceIdParam );
	
	DataParameterBase *newStateParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	newStateParam->setLong( newState );
	params.push_back( newStateParam );

	DataParameterBase *sessionIdParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	sessionIdParam->setDimension( sessionId.size() );
	sessionIdParam->setString( sessionId );
	params.push_back( sessionIdParam );	
	
	try
	{
		config->BeginTransaction();
		config->ExecuteNonQuery( DataCommand::SP, "UPDATESERVICESTATE", params );
	}
	catch( const std::exception& ex )
	{
		config->EndTransaction( TransactionType::ROLLBACK );
		TRACE( "Update service state failed [" << ex.what() << "] for [" << serviceId << "]" );
		
		throw;
	}
	catch( ... )
	{
		config->EndTransaction( TransactionType::ROLLBACK );
		TRACE( "Update service state failed [unknown reason] for [" << serviceId << "]" );

		throw;
	}

	config->EndTransaction( TransactionType::COMMIT );
}