Example #1
0
static void CPROC RefreshProc( uintptr_t psvTimer )
{
	CTEXTSTR *results;
	PODBC odbc = SQLGetODBCEx( cashball_local.DSN, cashball_local.user, cashball_local.password );

	SQLRecordQueryf( odbc, NULL, &results, NULL, "select Cashball from v_SessionCashball" );
	if( results && results[0] )
	{
		if( StrCmp( cashball_local.value, results[0] ) )
		{
			if( cashball_local.value )
			{
				Deallocate( TEXTSTR, cashball_local.value );
			}
			cashball_local.value = StrDup( results[0] );
			{
				INDEX idx;
				PSI_CONTROL pc;
				LIST_FORALL( cashball_local.timers, idx, PSI_CONTROL, pc )
					SmudgeCommon( pc );
			}
		}
	}
	else
	{
		if( cashball_local.value )
		{
			Deallocate( TEXTSTR, cashball_local.value );
			cashball_local.value = NULL;
			{
				INDEX idx;
				PSI_CONTROL pc;
				LIST_FORALL( cashball_local.timers, idx, PSI_CONTROL, pc )
					SmudgeCommon( pc );
			}
		}
	}
	SQLEndQuery( odbc );
	SQLDropODBC( odbc );
}
Example #2
0
static void InitView()
{
	CTEXTSTR *results;
	PODBC odbc = SQLGetODBCEx( cashball_local.DSN, cashball_local.user, cashball_local.password );
	SQLCommandf( odbc, "use %s", cashball_local.database );

	if( SQLRecordQueryf( odbc, NULL, &results, NULL, "select count(*) from INFORMATION_SCHEMA.VIEWS where table_name = 'v_SessionCashball'" ) )
	{
		if( results && results[0][0] == '0' )
		{
			SQLEndQuery( odbc );
			if( !SQLCommandf( odbc, "CREATE VIEW v_SessionCashball as "
				"SELECT top 1 itemprog.pri_sunball Cashball"
				" FROM   Itemprog  inner join"
				"	  (SELECT top 1  dbo.session.ses_id, dbo.session.hallid, dbo.session.ses_date, ISNULL(RTRIM(dbo.program.prg_desc) + ' - ' + RTRIM(dbo.sesslot.slt_desc)"
				"             + CASE WHEN [Session].Ses_Test = 1 THEN ' (Test)' ELSE '' END, '') AS SessionName"
				"        FROM  dbo.session\n"
				"        INNER JOIN dbo.program ON dbo.session.prg_id = dbo.program.prg_id \n"
				"         INNER JOIN dbo.sesslot ON dbo.session.slt_id = dbo.sesslot.slt_id \n"
				"        WHERE ses_status=2"
				"        ORDER BY dbo.session.ses_id desc )\n"
				"          AS SessionTemp ON itemprog.ses_id=sessionTemp.ses_id"
				) )
			{
				CTEXTSTR error;
				FetchSQLError( odbc, &error );
				lprintf( "Error : %s", error );
			}
		}
		SQLEndQuery( odbc );
	}
	else
	{
		CTEXTSTR error;
		FetchSQLError( odbc, &error );
		lprintf( "Error : %s", error );
	}
	SQLDropODBC( odbc );
}
Example #3
0
static LOGICAL HaveCurrentUser( PODBC odbc )
{
	CTEXTSTR *results;

	SQLRecordQueryf( odbc, NULL, &results, NULL, WIDE("select count(*) from login_history")
	                                             WIDE(" where logout_whenstamp=11111111111111")
	                                             WIDE(" and system_id=%d")
						     , g.system_id );

	if( results )
	{		
		if( results[0] )
		{			
			if( atoi( results[0] ) > 0 )
			{				
				SQLEndQuery( odbc );
				return TRUE;
			}
		}
	}
	SQLEndQuery( odbc );
	return FALSE;
}
Example #4
0
LAYER::LAYER( PODBC odbc, PLIST peices, INDEX iLoadLayer )
{
	if( !this )
		return;
	if( iLayer && iLayer != INVALID_INDEX )
	{
		lprintf( WIDE("Recovering prior layer") );
		return;
	}
	{
		CTEXTSTR *results;
		if( SQLRecordQueryf( odbc, NULL, &results, NULL
					  , WIDE("select x,y,min_x,min_y,width,height,linked_from_id,linked_from_x,linked_from_y,linked_to_id,linked_to_x,linked_to_y,route,peice_info_id,peice_type from board_layer where board_layer_id=%lu")
					  , iLoadLayer
					  ) && results )
		{
			PIPEICE peice_type = ::GetPeice( peices, results[14] );
			
			pLayerData->psvInstance = peice_type->Load( odbc, atoi( results[13] ) );//, pLayerData->psvInstance );
			pLayerData->SetPeice( peice_type );
			pds_path = CreateDataStack( sizeof( LAYER_PATH_NODE ) );
			x = atoi( results[0] );
			y = atoi( results[1] );
			min_x = atoi( results[2] );
			min_y = atoi( results[3] );
			w = IntCreateFromText( results[4] );
			h = IntCreateFromText( results[5] );
			flags.bRoute = atoi( results[12] );

		    iLayer = iLoadLayer;

			INDEX iStart = IntCreateFromText( results[6] );
			if( iStart != INVALID_INDEX )
			{
				int32_t x, y;
				x = atoi( results[7] );
				y = atoi( results[8] );
				PLAYER loaded_route_start_layer;
				loaded_route_start_layer = FindLayer( iStart );
				if( !loaded_route_start_layer )
					loaded_route_start_layer = GetFromSet( LAYER, pool ); //new(pool,pLayerData->pool) LAYER( odbc, peices, iStart );
				loaded_route_start_layer->pLayerData->peice->methods->ConnectBegin( loaded_route_start_layer->pLayerData->psvInstance
												, x, y // connect x, y
												, pLayerData->peice, pLayerData->psvInstance );
				loaded_route_start_layer->Link( this, LINK_VIA_START, x, y);
			}

			INDEX iEnd = IntCreateFromText( results[9] );
			if( iEnd != INVALID_INDEX )
			{
				int32_t x, y;
				x = atoi( results[10] );
				y = atoi( results[11] );
				PLAYER loaded_route_end_layer;
				loaded_route_end_layer = FindLayer( iEnd );
				if( !loaded_route_end_layer )
					loaded_route_end_layer = GetFromSet( LAYER, pool ); //new(pool,pLayerData->pool) LAYER( odbc, peices, iEnd );
				loaded_route_end_layer->pLayerData->peice->methods->ConnectEnd( loaded_route_end_layer->pLayerData->psvInstance
												, x, y // connect x, y
												, pLayerData->peice, pLayerData->psvInstance );
				loaded_route_end_layer->Link( this, LINK_VIA_END, x, y );
			}



			//}
		}
		SQLEndQuery( odbc );
		for( SQLRecordQueryf( odbc, NULL, &results, NULL, WIDE("select x,y,fore,back from board_layer_path where board_layer_id=%lu order by board_layer_path_id desc"), iLoadLayer );
			results;
			FetchSQLRecord( odbc, &results ) )
		{
			// add path node for a routed type peice
			LAYER_PATH_NODE node;
			node.x = atoi( results[0] );
			node.y = atoi( results[1] );
			node.flags.ForeDir = atoi( results[2] );
			node.flags.BackDir = atoi( results[3] );
			PushData( &pds_path, &node );
		}
	}
   //return iLayer;
}