本文整理汇总了C++中CMySQLQuery::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ CMySQLQuery::Format方法的具体用法?C++ CMySQLQuery::Format怎么用?C++ CMySQLQuery::Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMySQLQuery
的用法示例。
在下文中一共展示了CMySQLQuery::Format方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCurrentWorkerText
bool CJobWatchDlg::GetCurrentWorkerText(
CUtlVector<char> &text,
unsigned long &curMessageIndex )
{
text.SetSize( 0 );
unsigned long jobWorkerID;
if ( !GetCurJobWorkerID( jobWorkerID ) )
return false;
// Now copy all the text out.
CMySQLQuery query;
if ( curMessageIndex == 0 )
query.Format( "select * from text_messages where JobWorkerID=%lu", jobWorkerID );
else
query.Format( "select * from text_messages where JobWorkerID=%lu and MessageIndex >= %lu", jobWorkerID, curMessageIndex );
GetMySQL()->Execute( query );
while ( GetMySQL()->NextRow() )
{
const char *pTextStr = GetMySQL()->GetColumnValue( "text" ).String();
int len = strlen( pTextStr );
text.AddMultipleToTail( len, pTextStr );
curMessageIndex = GetMySQL()->GetColumnValue( "MessageIndex" ).UInt32() + 1;
}
text.AddToTail( 0 );
return true;
}
示例2: RunCommand
virtual int RunCommand()
{
CMySQLQuery query;
query.Format( "insert into job_master_end values ( %lu, %d, %d, \"no errors\" )", g_JobPrimaryID, g_nWorkersConnected, g_nWorkersDisconnected );
g_pSQL->Execute( query );
// Now set RunningTimeMS.
query.Format( "update job_master_start set RunningTimeMS=%lu where JobID=%lu", g_RunningTimeMS, g_JobPrimaryID );
g_pSQL->Execute( query );
return 1;
}
示例3: RunCommand
virtual int RunCommand()
{
CMySQLQuery query;
query.Format( "insert into job_master_end values ( %lu, %d, %d, \"no errors\" )", g_JobPrimaryID, g_nWorkersConnected, g_nWorkersDisconnected );
query.Execute( g_pSQL );
// Now set RunningTimeMS.
unsigned long runningTimeMS = GetTickCount() - g_StatsStartTime;
query.Format( "update job_master_start set RunningTimeMS=%lu where JobID=%lu", runningTimeMS, g_JobPrimaryID );
query.Execute( g_pSQL );
return 1;
}
示例4: VMPI_Stats_Init_Worker
bool VMPI_Stats_Init_Worker( const char *pHostName, const char *pDBName, const char *pUserName, unsigned long DBJobID )
{
g_StatsStartTime = GetTickCount();
// If pDBServerName is null, then we're the master and we just want to make the job_worker_start entry.
if ( pHostName )
{
Assert( !g_pDB );
// Connect the database.
g_pDB = new CMySqlDatabase;
if ( !g_pDB || !g_pDB->Initialize() || !LoadMySQLWrapper( pHostName, pDBName, pUserName ) )
{
delete g_pDB;
g_pDB = NULL;
return false;
}
// Get our machine name to store in the database.
DWORD size = sizeof( g_MachineName );
GetComputerName( g_MachineName, &size );
}
g_JobPrimaryID = DBJobID;
g_JobWorkerID = 0;
CMySQLQuery query;
query.Format( "insert into job_worker_start ( JobID, CurrentStage, IsMaster, MachineName ) values ( %lu, \"none\", %d, \"%s\" )",
g_JobPrimaryID, g_bMaster, g_MachineName );
query.Execute( g_pSQL );
g_JobWorkerID = g_pSQL->InsertID();
if ( g_JobWorkerID == 0 )
{
delete g_pDB;
g_pDB = NULL;
return false;
}
// Now create a thread that samples perf data and stores it in the database.
g_hPerfThreadExitEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
g_hPerfThread = CreateThread(
NULL,
0,
PerfThreadFn,
NULL,
0,
&g_PerfThreadID );
return true;
}
示例5: VMPI_Stats_Init_Master
bool VMPI_Stats_Init_Master(
const char *pHostName,
const char *pDBName,
const char *pUserName,
const char *pBSPFilename,
unsigned long *pDBJobID )
{
Assert( !g_pDB );
g_bMaster = true;
// Connect the database.
g_pDB = new CMySqlDatabase;
if ( !g_pDB || !g_pDB->Initialize() || !LoadMySQLWrapper( pHostName, pDBName, pUserName ) )
{
delete g_pDB;
g_pDB = NULL;
return false;
}
DWORD size = sizeof( g_MachineName );
GetComputerName( g_MachineName, &size );
// Create the job_master_start row.
Q_FileBase( pBSPFilename, g_BSPFilename, sizeof( g_BSPFilename ) );
g_JobPrimaryID = 0;
CMySQLQuery query;
query.Format( "insert into job_master_start ( BSPFilename, StartTime, MachineName, RunningTimeMS ) values ( \"%s\", null, \"%s\", %lu )", g_BSPFilename, g_MachineName, RUNNINGTIME_MS_SENTINEL );
query.Execute( g_pSQL );
g_JobPrimaryID = g_pSQL->InsertID();
if ( g_JobPrimaryID == 0 )
{
delete g_pDB;
g_pDB = NULL;
return false;
}
// Now init the worker portion.
*pDBJobID = g_JobPrimaryID;
return VMPI_Stats_Init_Worker( NULL, NULL, NULL, g_JobPrimaryID );
}
示例6: UpdateJobWorkerRunningTime
void UpdateJobWorkerRunningTime()
{
unsigned long runningTimeMS = GetTickCount() - g_StatsStartTime;
char curStage[256];
VMPI_GetCurrentStage( curStage, sizeof( curStage ) );
CMySQLQuery query;
query.Format( "update job_worker_start set RunningTimeMS=%lu, CurrentStage=\"%s\", "
"Thread0WU=%d, Thread1WU=%d, Thread2WU=%d, Thread3WU=%d where JobWorkerID=%lu",
runningTimeMS,
curStage,
(int) g_ThreadWUs[0],
(int) g_ThreadWUs[1],
(int) g_ThreadWUs[2],
(int) g_ThreadWUs[3],
g_JobWorkerID );
query.Execute( g_pSQL );
}
示例7: FillGraph
void CJobWatchDlg::FillGraph()
{
// Get all the graph samples.
unsigned long jobWorkerID;
if ( !GetCurJobWorkerID( jobWorkerID ) )
return;
CMySQLQuery query;
query.Format( "select * from graph_entry where JobWorkerID=%lu", jobWorkerID );
GetMySQL()->Execute( query );
int iMSTime = GetMySQL()->GetColumnIndex( "MSSinceJobStart" );
int iBytesSent = GetMySQL()->GetColumnIndex( "BytesSent" );
int iBytesReceived = GetMySQL()->GetColumnIndex( "BytesReceived" );
// See if there's anything new.
CUtlVector<CGraphEntry> entries;
int highest = m_CurGraphTime;
while ( GetMySQL()->NextRow() )
{
CGraphEntry entry;
entry.m_msTime = GetMySQL()->GetColumnValue( iMSTime ).Int32();
entry.m_nBytesSent = GetMySQL()->GetColumnValue( iBytesSent ).Int32();
entry.m_nBytesReceived = GetMySQL()->GetColumnValue( iBytesReceived ).Int32();
entries.AddToTail( entry );
highest = max( highest, entry.m_msTime );
}
if ( highest > m_CurGraphTime )
{
m_CurGraphTime = highest;
m_GraphControl.Clear();
m_GraphControl.Fill( entries );
}
}
示例8: OnInitDialog
BOOL CJobWatchDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_GraphControl.SubclassDlgItem( IDC_GRAPH_AREA, this );
CString str;
// Get all our startup info from the command line.
const char *pJobID = FindArg( "-JobID", NULL );
const char *pDBName = FindArg( "-dbname", NULL );
const char *pHostName = FindArg( "-hostname", NULL );
const char *pUserName = FindArg( "-username", NULL );
if ( !pJobID || !pDBName || !pHostName || !pUserName )
{
str.Format( "Missing a command line parameter (-JobID or -dbname or -hostname or -username)" );
MessageBox( str, "Error", MB_OK );
EndDialog( 1 );
return FALSE;
}
m_JobID = atoi( pJobID );
m_pSQL = InitMySQL( pDBName, pHostName, pUserName );
if ( !m_pSQL )
{
str.Format( "Can't init MYSQL db (db = '%s', host = '%s', user = '%s')", pDBName, pHostName, pUserName );
MessageBox( str, "Error", MB_OK );
EndDialog( 0 );
return FALSE;
}
// Fill the workers list.
CMySQLQuery query;
query.Format( "select * from job_worker_start where JobID=%lu order by MachineName", m_JobID );
GetMySQL()->Execute( query );
while ( GetMySQL()->NextRow() )
{
const char *pMachineName = GetMySQL()->GetColumnValue( "MachineName" ).String();
int index;
if ( GetMySQL()->GetColumnValue( "IsMaster" ).Int32() )
{
char tempStr[512];
Q_snprintf( tempStr, sizeof( tempStr ), "%s (master)", pMachineName );
index = m_Workers.AddString( tempStr );
}
else
{
index = m_Workers.AddString( pMachineName );
}
unsigned long jobWorkerID = GetMySQL()->GetColumnValue( "JobWorkerID" ).UInt32();
m_Workers.SetItemData( index, jobWorkerID );
}
// (Init the idle processor so we can update text and graphs).
StartIdleProcessing( 300 );
// Setup anchors.
m_AnchorMgr.AddAnchor( this, GetDlgItem( IDC_WORKERS_PANEL ), ANCHOR_LEFT, ANCHOR_TOP, ANCHOR_WIDTH_PERCENT, ANCHOR_HEIGHT_PERCENT );
m_AnchorMgr.AddAnchor( this, GetDlgItem( IDC_WORKERS ), ANCHOR_LEFT, ANCHOR_TOP, ANCHOR_WIDTH_PERCENT, ANCHOR_HEIGHT_PERCENT );
m_AnchorMgr.AddAnchor( this, GetDlgItem( IDC_TEXT_OUTPUT_PANEL ), ANCHOR_LEFT, ANCHOR_HEIGHT_PERCENT, ANCHOR_WIDTH_PERCENT, ANCHOR_BOTTOM );
m_AnchorMgr.AddAnchor( this, GetDlgItem( IDC_TEXTOUTPUT ), ANCHOR_LEFT, ANCHOR_HEIGHT_PERCENT, ANCHOR_WIDTH_PERCENT, ANCHOR_BOTTOM );
m_AnchorMgr.AddAnchor( this, GetDlgItem( IDC_GRAPHS_PANEL ), ANCHOR_WIDTH_PERCENT, ANCHOR_TOP, ANCHOR_RIGHT, ANCHOR_HEIGHT_PERCENT );
m_AnchorMgr.AddAnchor( this, &m_GraphControl, ANCHOR_WIDTH_PERCENT, ANCHOR_TOP, ANCHOR_RIGHT, ANCHOR_HEIGHT_PERCENT );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}