예제 #1
0
//----------------------------------------------------------------------------------//
void CTradesCache::LoadTrades()
{
	try
	{
		if (static_cast<bool>(m_spTradeChannel))
		{
			BSTR bstrConnectionString;
			if (GetSettingsImpl().get() == NULL)
				utils::ThrowErrorNoSetErrorInfo(E_POINTER, L"Failed to GetSettings.");

			GetSettingsImpl()->GetDBConnection(&bstrConnectionString);
			SetConnectionString(bstrConnectionString);

			HRESULT hr = m_spTradeChannel->put_DatabaseString(bstrConnectionString);

			hr = m_spTradeChannel->LoadTrades(0, GetMain(), VARIANT_FALSE);
			if(FAILED(hr))
				utils::ThrowErrorNoSetErrorInfo(hr, L"Failed to LoadTrades.");
		}
	}
	catch (_com_error& err){
		std::ostringstream out_stream;
		out_stream << "Exception occured while loading trades.";
		TRACE_COM_ERROR(LOG4CPLUS_ERROR, VS::Log, err, std::string(out_stream.str()));	
	}
	catch (...){
		std::ostringstream out_stream;
		out_stream<<"Unknown C++ exception occured while loading trades.";
		TRACE_UNKNOWN_ERROR(LOG4CPLUS_ERROR, VS::Log, std::string(out_stream.str()));
		ATLASSERT(FALSE);
	}
};
예제 #2
0
/**
 * Opens a connection to the database.
 *
 * @param	ConnectionString	Connection string passed to database layer
 * @param   RemoteConnectionIP  The IP address which the RemoteConnection should connect to
 * @param   RemoteConnectionStringOverride  The connection string which the RemoteConnection is going to utilize
 *
 * @return	TRUE if connection was successfully established, FALSE otherwise
 */
UBOOL FRemoteDatabaseConnection::Open( const TCHAR* ConnectionString, const TCHAR* RemoteConnectionIP, const TCHAR* RemoteConnectionStringOverride )
{
	UBOOL bIsValid = FALSE;
	if ( Socket )
	{
		FInternetIpAddr Address;
		Address.SetIp(RemoteConnectionIP, bIsValid);
		Address.SetPort(10500);

		if(bIsValid)
		{
			bIsValid = Socket->Connect(Address);

			if(bIsValid && RemoteConnectionStringOverride)
			{
				SetConnectionString(RemoteConnectionStringOverride);
			}
		}
	}
	return bIsValid;
}