void ParseDisplayReturnInterfacePage::display(std::ostream& stream, const std::string& text, VariablesMap& variables, const server::Request* request /*= NULL*/) const
		{
			ParametersVector pv;
			pv.push_back(text);

			InterfacePage::_display(stream, pv, variables, NULL, request);
		}
		void DeparturesTableInterfacePage::display( std::ostream& stream
			, VariablesMap& vars
			, const std::string& title
			, int wiringCode
			, bool displayServiceNumber
			, bool displayTrackNumber
			, bool displayTeam,
			optional<size_t> intermediatesStopsToDisplay,
			int blinkingDelay,
			bool displayClock
			, const pt::StopArea* place
			, const ArrivalDepartureList& rows
			, const server::Request* request /*= NULL*/ ) const
		{
			ParametersVector pv;
			pv.push_back(title);
			pv.push_back(lexical_cast<string>(wiringCode));
			pv.push_back(lexical_cast<string>(displayServiceNumber));
			pv.push_back(lexical_cast<string>(displayTrackNumber));
			pv.push_back(intermediatesStopsToDisplay ? lexical_cast<string>(*intermediatesStopsToDisplay) : string());
			pv.push_back(lexical_cast<string>(displayTeam));
			pv.push_back(place->getFullName());
			pv.push_back(lexical_cast<string>(blinkingDelay));
			pv.push_back(lexical_cast<string>(displayClock));

			InterfacePage::_display(
				stream
				, pv
				, vars
				, (const void*) &rows
				, request);
		}
void EventsWatcherDbOp::InsertEvent( const string& dadbuffer, const string& message )
{
	Database* data = getData();
	
	ParametersVector params;

	DataParameterBase *dadParam = m_DatabaseProvider->createParameter( DataType::LARGE_CHAR_TYPE );
	dadParam->setDimension( dadbuffer.length() );
	dadParam->setString( dadbuffer );
	dadParam->setName( "DAD_buffer" );
	params.push_back( dadParam );

	DataParameterBase *messageParam = m_DatabaseProvider->createParameter( DataType::LARGE_CHAR_TYPE );
	messageParam->setDimension( message.length() );
	messageParam->setName( "XML_buffer" );
	messageParam->setString( message );

	params.push_back( messageParam );

	DataParameterBase *paramReturnCode = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE, DataParameterBase::PARAM_OUT );
	DataParameterBase *paramReturnMessage = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE, DataParameterBase::PARAM_OUT );

	// return code from upload proc
	paramReturnCode->setDimension( 11 );
	params.push_back( paramReturnCode );
		
	// return message from upload proc
	paramReturnMessage->setDimension( 1024 );
	params.push_back( paramReturnMessage );

	data->BeginTransaction();
	try
	{
		data->ExecuteNonQueryCached( DataCommand::SP, "INSERTEVENTSBATCH", params );

		string returnCode = StringUtil::Trim( paramReturnCode->getString() );
		DEBUG( "Insert XML data return code : [" << returnCode << "]" );	 	
		if ( returnCode != "0" )
	 	{
	 		stringstream messageBuffer;
	  		messageBuffer << "Error inserting XML. Message : [" << paramReturnMessage->getString() << "]";
			TRACE( messageBuffer.str() );
			TRACE( "Original_buffer [" << message << "]" );

	 		throw runtime_error( messageBuffer.str() );
	 	}
	}
	catch( const std::exception& ex )
	{
		TRACE( "Insert event failed [" << ex.what() << "]" );
	}
	catch( ... )
	{
		TRACE( "Insert event failed [unknown reason]" );
	}

	data->EndTransaction( TransactionType::COMMIT );
	DEBUG2( "done" );
}
		void DeparturesTableInterfacePage::display(
			std::ostream& stream ,
			interfaces::VariablesMap& vars ,
			const std::string& title ,
			int wiringCode ,
			bool displayServiceNumber ,
			bool displayTrackNumber ,
			int blinkingDelay,
			bool displayClock,
			const pt::StopArea* place ,
			const RoutePlanningList& rows ,
			const server::Request* request /*= NULL */
		) const	{
			ParametersVector pv;
			pv.push_back(title);
			pv.push_back(lexical_cast<string>(wiringCode));
			pv.push_back(lexical_cast<string>(displayServiceNumber));
			pv.push_back(lexical_cast<string>(displayTrackNumber));
			pv.push_back(string());
			pv.push_back(string());
			pv.push_back(place->getFullName());
			pv.push_back(lexical_cast<string>(blinkingDelay));
			pv.push_back(lexical_cast<string>(displayClock));

			InterfacePage::_display(
				stream
				, pv
				, vars
				, (const void*) &rows
				, request
			);
		}
Exemple #5
0
		const ParametersVector ValueElementList::fillParameters(
			const ParametersVector& parameters
			, VariablesMap& vars
			, const void* object, const server::Request* request ) const
		{
			ParametersVector pv;
			for (ElementsList::const_iterator it = _elements.begin(); it != _elements.end(); ++it)
			{
				pv.push_back((*it)->getValue(parameters, vars, object, request));
			}
			return pv;
		}
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 CustomerPasswordEMailSubjectInterfacePage::display(
			std::ostream& stream,
			const User& customer,
			VariablesMap& variables,
			const server::Request* request /*= NULL*/
		) const	{
			ParametersVector pv;
			pv.push_back(customer.getLogin());

			InterfacePage::_display(
				stream
				, pv
				, variables
				, static_cast<const void*>(&customer)
				, request
			);
		}
		void ReservationConfirmationEMailSubjectInterfacePage::display(
			std::ostream& stream,
			const ReservationTransaction& resa,
			VariablesMap& variables,
			const server::Request* request /*= NULL*/
		) const	{
			ParametersVector pv;
			pv.push_back(to_simple_string((*resa.getReservations().begin())->getDepartureTime().date())); // 0
			pv.push_back((*resa.getReservations().begin())->getDeparturePlaceName()); // 1
			pv.push_back((*resa.getReservations().rbegin())->getArrivalPlaceName()); // 2


			InterfacePage::_display(
				stream
				, pv
				, variables
				, static_cast<const void*>(&resa)
				, request
			);
		}
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 );
}
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::InsertEvent( const long serviceId, const string& correlationId, const string& sessionId,
	const string& evtype, const string& machine, const string& date, const string& messageBuffer, 
	const string& event_class, const string& additionalInfo, const string& innerException )
{
	Database* data = getData();
	
	ParametersVector params;
	
	string guid = Collaboration::GenerateGuid();
	DEBUG2( "guidParam [" << guid << "]" );
	DataParameterBase *guidParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	guidParam->setDimension( guid.size() );
	guidParam->setString( guid );
	params.push_back( guidParam );
		
	DEBUG2( "serviceIdParam [" << serviceId << "]" );
	DataParameterBase *serviceIdParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	serviceIdParam->setLong( serviceId );
	params.push_back( serviceIdParam );

	DEBUG2( "correl [" << correlationId << "]" );
	DataParameterBase *correlIdParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	correlIdParam->setDimension( correlationId.size() );
	correlIdParam->setString( correlationId );
	params.push_back( correlIdParam );
		
	DEBUG2( "session [" << sessionId << "]" );
	DataParameterBase *sessionIdParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	sessionIdParam->setDimension( sessionId.size() );
	sessionIdParam->setString( sessionId );
	params.push_back( sessionIdParam );	

	DEBUG2( "type [" << evtype << "]" );
	DataParameterBase *typeParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	typeParam->setDimension( evtype.size() );
	typeParam->setString( evtype );
	params.push_back( typeParam );	
	
	DEBUG2( "machine [" << machine << "]" );
	DataParameterBase *machineParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	machineParam->setDimension( machine.size() );
	machineParam->setString( machine );
	params.push_back( machineParam );
	
	DEBUG2( "eventdate [" << date << "]" );
	DataParameterBase *dateParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	dateParam->setDimension( date.size() );
	dateParam->setString( date );
	params.push_back( dateParam );

	DEBUG2( "message" );
	DataParameterBase *messageParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	string::size_type messageBufferLength = messageBuffer.length();
	if( messageBufferLength > 256 )
	{
		messageParam->setDimension( 256 );
		messageParam->setString( messageBuffer.substr( 0, 256 ) );
	}
	else
	{
		messageParam->setDimension( messageBufferLength );
		messageParam->setString( messageBuffer );
	}
	params.push_back( messageParam );

	DEBUG2( "class [" << event_class << "]" );
	DataParameterBase *classParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	classParam->setDimension( event_class.size() );
	classParam->setString( event_class );
	params.push_back( classParam );
		
	DEBUG2( "addinfo [" << additionalInfo << "]" );
	DataParameterBase *addInfoParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	if( ( additionalInfo.length() == 0 ) && ( messageBufferLength > 256 ) )
	{
		addInfoParam->setDimension( messageBufferLength );
		addInfoParam->setString( messageBuffer );
	}
	else
	{
		if ( additionalInfo.length() > 2999 )
		{
			addInfoParam->setDimension( 2999 );
			addInfoParam->setString( additionalInfo.substr( 0, 2999 ) );
		}
		else
		{
			addInfoParam->setDimension( additionalInfo.length() );
			addInfoParam->setString( additionalInfo );
		}
	}
	params.push_back( addInfoParam );	

	DEBUG2( "innerex [" << innerException << "]" );
	DataParameterBase *innerExParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );

	if( innerException.length() > 3499 )
	{
		innerExParam->setDimension( 3499 );
		innerExParam->setString( innerException.substr( 0, 3499 ) );
	}
	else
	{
		innerExParam->setDimension( innerException.length() );
		innerExParam->setString( innerException );
	}
	params.push_back( innerExParam );	
	
	data->BeginTransaction();
	try
	{
		data->ExecuteNonQueryCached( DataCommand::SP, "INSERTEVENT", params );
	}
	catch( const std::exception& ex )
	{
		TRACE( "Insert event failed [" << ex.what() << "]" );
	}
	catch( ... )
	{
		TRACE( "Insert event failed [unknown reason]" );
	}

	data->EndTransaction( TransactionType::COMMIT );
	DEBUG_GLOBAL( "done" );
}
		void DeparturesTableTransferDestinationInterfacePage::display(
			std::ostream& stream,
			const ServicePointer& object,
			size_t localTransferRank,
			size_t totalTransferRank,
			VariablesMap& variables,
			const server::Request* request /*= NULL*/
		) const	{
			ParametersVector pv;

			const JourneyPattern* line(dynamic_cast<const JourneyPattern*>(object.getService()->getPath()));
			const StopArea* place(dynamic_cast<const StopArea*>(object.getArrivalEdge()->getFromVertex()->getHub()));

			pv.push_back(line->getRollingStock() ? lexical_cast<string>(line->getRollingStock()->getKey()) : string()); //0
			pv.push_back(lexical_cast<string>(line->getCommercialLine()->getKey())); //1
			pv.push_back(line->getCommercialLine()->getShortName()); //2
			pv.push_back(lexical_cast<string>(line->getCommercialLine()->getStyle())); //3
			pv.push_back(lexical_cast<string>(line->getCommercialLine()->getImage())); //4
			pv.push_back(lexical_cast<string>(place->getKey())); //5
			pv.push_back(place->getCity() ? place->getCity()->getName() : string());
			pv.push_back(place->getName()); //7
			pv.push_back(place->getName26());
			pv.push_back(place->getName13()); //9
			{
				stringstream s;
				s << setw(2) << setfill('0') << object.getDepartureDateTime().time_of_day().hours() << ":" << setw(2) << setfill('0') << object.getDepartureDateTime().time_of_day().minutes();
				pv.push_back(s.str()); // 10
			}
			{
				stringstream s;
				s << setw(2) << setfill('0') << object.getArrivalDateTime().time_of_day().hours() << ":" << setw(2) << setfill('0') << object.getArrivalDateTime().time_of_day().minutes();
				pv.push_back(s.str()); // 11
			}
			pv.push_back(lexical_cast<string>(localTransferRank)); //12
			pv.push_back(lexical_cast<string>(totalTransferRank)); //13

			InterfacePage::_display(
				stream
				, pv
				, variables
				, static_cast<const void*>(&object)
				, request
			);
		}