本文整理汇总了C++中ConnectionPtr::Query方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::Query方法的具体用法?C++ ConnectionPtr::Query怎么用?C++ ConnectionPtr::Query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionPtr
的用法示例。
在下文中一共展示了ConnectionPtr::Query方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveCache
void CPage::SaveCache(ConnectionPtr connection)
{
Trace("SaveCache", "", m_totalUrlList.size());
// save all the cookies in the current memory list to the database
// in the WebPageCookies table
ncc::safe_array<char> strQuery(102400);
ncc::safe_array<char> sqlCache(40961);
{ // scope for lock
// delete the existing cache in the table for this run
snprintf(strQuery, strQuery.size(), SQL_WTT_DEL_CACHE, m_runID);
Trace("Query for SaveCache", strQuery, 0);
connection->Query(strQuery);
try
{
for (URLList::const_iterator it = m_totalUrlList.begin(); it != m_totalUrlList.end(); ++it)
{
// convert the string ready to be inserted
int len = 0;
// convert the string for inserting
len = mysql_escape_string(sqlCache, (*it).c_str(),((*it).size()<40960)?((*it).size()):40960);
// terminate the string
if( len > 40960)
{
sqlCache[40960] = '\0';
}
else
{
sqlCache[len] = '\0';
}
// make sure last char not a \ - it would escape the final quote
if( sqlCache[40959] == '\\')
{
sqlCache[40959] = ' ';
}
else if( sqlCache[len-1] == '\\')
{
sqlCache[len-1] = ' ';
}
// save to the database
snprintf(strQuery, strQuery.size(), SQL_WTT_SAVE_CACHE, m_runID, static_cast<const char*>(sqlCache));
Trace("Query for SaveCache", strQuery, 0);
connection->Query(strQuery);
}
}
catch (const std::exception& e)
{
LogError2("SaveCache() - Caught Exception", e.what(), 0, SC_ERR_GROUP_DB, SC_ERR_CODE_STORE_CACHE);
}
}
}
示例2: LoadCache
void CPage::LoadCache(ConnectionPtr connection)
{
Trace("LoadCache", "",0);
ResultPtr result;
ncc::safe_array<char> strQuery(10240);
try
{
// load from the database
snprintf(strQuery, strQuery.size(), SQL_WTT_LOAD_CACHE, m_runID);
Trace("Query for LoadCache", strQuery, 0);
result = connection->Query(strQuery);
while(result->Next())
{
RowPtr row = result->GetCurrentRow();
// add it
std::string urlStr;
urlStr = row->GetFieldString(1);
{ // scope for lock
Mutex::Lock lock(sm_urlListLock);
m_totalUrlList.push_back(urlStr);
}
}
}
catch (const std::exception& e)
{
LogError2("LoadCache() - Caught Exception", e.what(), 0, SC_ERR_GROUP_DB, SC_ERR_CODE_LOAD_CACHE);
}
}
示例3: loadContentError
void CPage::loadContentError(ConnectionPtr connection)
{
Trace("loadContentError()", "", 0);
std::string strQuery;
try
{
Mutex::Lock lock(m_contentErrorListLock);
// get all of the pages for this customer to test
strQuery = Format(SQL_WTT_CONTENT_ERRORS);
if (ResultPtr result = connection->Query(strQuery))
{
while (result->Next())
{
RowPtr row = result->GetCurrentRow();
StringIDList::value_type contentError(row->GetFieldString(1), row->GetFieldLong(2));
contentError.first = " " + contentError.first + " ";
Trace("loadContentError() - loading string", contentError.first.c_str(), contentError.second);
m_contentError.push_back(contentError);
}
}
}
catch (const std::exception& e)
{
LogError("Exception Caught:", e.what(), 0);
}
}
示例4: loadPhraseCheck
void CPage::loadPhraseCheck(ConnectionPtr connection)
{
Trace("loadPhraseCheck()", "", 0);
std::string strQuery;
try
{
Mutex::Lock lock(m_phraseListLock);
strQuery = Format(SQL_WTT_PHRASE_WORDS, getPageID());
if (ResultPtr result = connection->Query(strQuery))
{
Trace("RowPtr s:","",result->GetRowCount());
while (result->Next())
{
RowPtr row = result->GetCurrentRow();
StringIDList::value_type phrase(row->GetFieldString(1), row->GetFieldLong(2));
Trace("loadPhraseCheck_LT(): pre", phrase.first.c_str(), phrase.second);
std::transform(phrase.first.begin(), phrase.first.end(), phrase.first.begin(), tolower);
Trace("loadPhraseCheck_LT(): post", phrase.first.c_str(), phrase.second);
m_phrase.push_back(phrase);
}
}
}
catch (const std::exception& e)
{
LogError("Exception Caught:", e.what(), 0);
}
}
示例5: checkErrorsAlertable
void CPage::checkErrorsAlertable(ConnectionPtr connection)
{
Trace("checkErrorsAlertable", getURL().c_str(), getOverallResultCode());
std::string strQuery;
std::string colour;
// if colour = red/black then go to downtime testing and send alert to alertable people
try
{
// select Colour from Severity where ErrorCode = %d
strQuery = Format(SQL_WTT_ERROR_COLOUR, (long int)getOverallResultCode());
if (ResultPtr result = connection->Query(strQuery))
{
Trace("RowPtr s:","",result->GetRowCount());
if (result->Next())
{
RowPtr row = result->GetCurrentRow();
colour += row->GetFieldString(1);
}
}
}
catch (const std::exception& e)
{
LogError("Exception Caught:", e.what(), 0);
}
Trace("checkErrorsAlertable", colour.c_str(), getOverallResultCode());
// only report an error if page failed and not a benchmark and IS a normal page
if ((colour == SC_SEVERITY_BLACK) || (colour == SC_SEVERITY_RED))
{
sm_errorAlertable = true;
}
}
示例6: SamplingUpdateHeader
void SamplingUpdateHeader(ConnectionPtr connection,
long pageID, int testServerID,
const std::string& startTimeStr,
int overallResultCode,
long DNSTimeOffsetMs, long firstByteTimeOffsetMs,
long totalLastByteTimeOffsetMs,
long totalBytes, resultid_t* resultID,
long firstDataTimeOffsetMs,
const std::string& sampleDbName,
const std::string& request,
const std::string& header,
const std::string& html,
const std::string& extraInfo,
SC_TEST_TYPE testType,
long customerNo,
SC_WEBPAGE_TYPE pageType,
const std::string& stepName,
long pageNumber,
long currentColourCode,
int localOffset,
long searchID,
const std::string& searchName,
long runID)
{
// updates the ResultHeaderYYMMDD table with the results of this file / page for reloaded steps
// it just adds the details to the current result.
// passed in dailyDbName
try
{
// Get the resultID.
ResultPtr queryResult;
char resultIdQuery[(EXTRA_SQL_MAX_LEN * 4) + 100];
#ifdef SHARD_AWARE
sprintf(resultIdQuery, SQL_WTT_HEADER_SAMPLE_MAX_RESULTID_C3, sampleDbName.c_str(), pageID,
getBoundedDateTimeString(KEY_TIME_COLUMN_RESULTHEADER).c_str());
#else
sprintf(resultIdQuery, SQL_WTT_HEADER_SAMPLE_MAX_RESULTID, sampleDbName.c_str(), pageID);
#endif
Trace("Issuing query", resultIdQuery, 0);
queryResult = connection->Query(resultIdQuery);
queryResult->Next();
RowPtr row = queryResult->GetCurrentRow();
*resultID = strtoull(row->GetField(1), 0, 10);
}
catch (const std::exception &e)
{
LogError("SamplingUpdateHeader() - Caught Exception querying max sampling resultID", e.what(), pageID);
}
ResultPtr result;
char strQuery[(EXTRA_SQL_MAX_LEN * 4) + 200];
try
{
// update the current result in the daily table
// leave start, dns, connect and data start the same
// change complete time
// update result code,
#ifdef SHARD_AWARE
sprintf(strQuery, SQL_WTT_HEADER_SAMPLE_UPD_C3,
sampleDbName.c_str(),
overallResultCode,
totalLastByteTimeOffsetMs,
totalBytes,
*resultID,
getBoundedDateTimeString(KEY_TIME_COLUMN_RESULTHEADER).c_str()
);
#else
sprintf(strQuery, SQL_WTT_HEADER_SAMPLE_UPD,
sampleDbName.c_str(),
overallResultCode,
totalLastByteTimeOffsetMs,
totalBytes,
*resultID
);
#endif
Trace("SamplingUpdateHeader(): Query for ResultHeaderYYMMDD", strQuery, 0);
result = connection->Query(strQuery);
}
catch (const std::exception &e)
{
LogError("SamplingUpdateHeader() - table ResultHeaderYYMMDD Caught Exception", e.what(), pageID);
}
// DO NOT store the extra info for the first component against the header - ALREADY STORED
}
示例7: SamplingStoreResult
long SamplingStoreResult(ConnectionPtr connection, const CResultDetail* pDetail,
resultid_t resultID, const std::string& sampleDbName, int ComponentNo,
long reloadTimeOffset)
{
// stores the results of this file / page into the result detail table
ResultPtr result;
char strQuery[HTML_SQL_MAX_LEN + 100]; // make max of the stuff inserted plus 100 for the SQL
try
{
sprintf(strQuery, SQL_WTT_DETAIL_SAMPLE_INS,
sampleDbName.c_str(),
resultID,
pDetail->getStartTimeStr().c_str(),
reloadTimeOffset + pDetail->getStartTimeOffsetMs(),
pDetail->getDNSTimeOffsetMs(),
pDetail->getConnectTimeOffsetMs(),
pDetail->getFirstDataTimeOffsetMs(),
pDetail->getLastByteTimeOffsetMs(),
pDetail->getResultCode(),
pDetail->getContentLength(),
pDetail->getURLsql().c_str(), // url with 's escaped and only 255 in length
ComponentNo,
pDetail->getSslConnectTimeOffsetMs(),
pDetail->getRequestSentTimeOffsetMs(),
pDetail->getRequestHeaderSize(),
pDetail->getRequestContentSize(),
pDetail->getResponseHeaderSize()
);
Trace("Query for ResultDetail", strQuery, 0);
result = connection->Query(strQuery);
}
catch (const std::exception &e)
{
std::string errorBuffer = Format("ResultID: %llu", resultID);
LogError("SamplingStoreResult() - table ResultDetailYYMMDD Caught Exception", e.what(), 0);
LogError("SamplingStoreResult() - table ResultDetailYYMMDD Caught Exception:", errorBuffer.c_str(), 0);
}
try
{
// convert the string ready to be inserted
int len = 0;
char sqlStr[REQUEST_SQL_MAX_LEN + 1];
// convert the string for inserting
len = mysql_escape_string(sqlStr,
pDetail->getRequest().c_str(),
(pDetail->getRequest().size() < (REQUEST_SQL_MAX_LEN / 2)) ? (pDetail->getRequest().size()) : (REQUEST_SQL_MAX_LEN / 2));
// terminate the string
if ( len > (int)REQUEST_SQL_MAX_LEN)
{
sqlStr[REQUEST_SQL_MAX_LEN] = '\0';
}
else
{
sqlStr[len] = '\0';
}
// make sure last char not a \ - it would escape the final quote
if ( sqlStr[REQUEST_SQL_MAX_LEN] == '\\')
sqlStr[REQUEST_SQL_MAX_LEN] = ' ';
#ifdef SHARD_AWARE
// insert the request
sprintf(strQuery, SQL_WTT_REQUEST_SAMPLE_INS_C3,
sampleDbName.c_str(),
resultID,
ComponentNo,
sqlStr, // with 's escaped and only 255 in length
pDetail->getStartTimeStr().c_str());
#else
// insert the request
sprintf(strQuery, SQL_WTT_REQUEST_SAMPLE_INS,
sampleDbName.c_str(),
resultID,
ComponentNo,
sqlStr // with 's escaped and only 255 in length
);
#endif
Trace("Query for Request", strQuery, 0);
result = connection->Query(strQuery);
}
catch (const std::exception &e)
{
std::string errorBuffer = Format("ResultID: %llu", resultID);
LogError("SamplingStoreResult() - table RequestYYMMDD Caught Exception", e.what(), 0);
LogError("SamplingStoreResult() - table RequestYYMMDD Caught Exception:", errorBuffer.c_str(), 0);
}
try
{
int len = 0;
char sqlStr[HEADER_SQL_MAX_LEN + 1];
// convert the string for inserting
len = mysql_escape_string(sqlStr,
pDetail->getHeaders().c_str(),
(pDetail->getHeaders().size() < (HEADER_SQL_MAX_LEN / 2)) ? (pDetail->getHeaders().size()) : (HEADER_SQL_MAX_LEN / 2));
//.........这里部分代码省略.........
示例8: SamplingStoreHeader
void SamplingStoreHeader(ConnectionPtr connection,
long pageID,
int testServerID,
const std::string& startTimeStr,
int overallResultCode,
long DNSTimeOffsetMs,
long firstByteTimeOffsetMs,
long totalLastByteTimeOffsetMs,
long totalBytes,
resultid_t* resultID,
long firstDataTimeOffsetMs,
const std::string& sampleDbName,
const std::string& request,
const std::string& header,
const std::string& html,
const std::string& extraInfo,
SC_TEST_TYPE testType,
long customerNo,
SC_WEBPAGE_TYPE pageType,
const std::string& stepName,
long pageNumber,
long currentColourCode,
int localOffset,
long searchID,
const std::string& searchName,
long runID,
long sslConnectTime,
long requestSentTime,
long requestHeaderSize,
long requestContentSize,
long responseHeaderSize)
{
// stores the results of this file / page into the result detail table
ResultPtr result;
char strQuery[(EXTRA_SQL_MAX_LEN * 4) + 200];
try
{
// remove the current one stored
Trace("remove the current one stored", "", pageID);
#ifdef SHARD_AWARE
sprintf(strQuery, SQL_WTT_HEADER_SAMPLE_LIST_DEL_C3, sampleDbName.c_str(), pageID, getBoundedDateTimeString(KEY_TIME_COLUMN_RESULTHEADER).c_str());
#else
sprintf(strQuery, SQL_WTT_HEADER_SAMPLE_LIST_DEL, sampleDbName.c_str(), pageID);
#endif
Trace("Issuing query", strQuery, 0);
result = connection->Query(strQuery);
bool addComma = false;
std::string refList;
while (result->Next())
{
RowPtr row = result->GetCurrentRow();
if (addComma)
{
refList += ",";
}
refList += row->GetField(1);
addComma = true;
}
if (addComma)
{
// there was at least one in the list to delete
#ifdef SHARD_AWARE
sprintf(strQuery, SQL_WTT_HEADER_SAMPLE_DEL_C3, sampleDbName.c_str(), refList.c_str(), getBoundedDateTimeString(KEY_TIME_COLUMN_RESULTHEADER).c_str());
#else
sprintf(strQuery, SQL_WTT_HEADER_SAMPLE_DEL, sampleDbName.c_str(), refList.c_str());
#endif
Trace("Issuing query", strQuery, 0);
result = connection->Query(strQuery);
#ifdef SHARD_AWARE
sprintf(strQuery, SQL_WTT_HEADER_EXTRA_INFO_SAMPLE_DEL_C3, sampleDbName.c_str(), refList.c_str(), getBoundedDateTimeString(KEY_TIME_COLUMN_RESULTHEADEREXTRAINFO).c_str());
#else
sprintf(strQuery, SQL_WTT_HEADER_EXTRA_INFO_SAMPLE_DEL, sampleDbName.c_str(), refList.c_str());
#endif
Trace("Issuing query", strQuery, 0);
result = connection->Query(strQuery);
#ifdef SHARD_AWARE
sprintf(strQuery, SQL_WTT_HEADER_DETAIL_SAMPLE_DEL_C3, sampleDbName.c_str(), refList.c_str(), getBoundedDateTimeString(KEY_TIME_COLUMN_RESULTDETAIL).c_str());
#else
sprintf(strQuery, SQL_WTT_HEADER_DETAIL_SAMPLE_DEL, sampleDbName.c_str(), refList.c_str());
#endif
Trace("Issuing query", strQuery, 0);
result = connection->Query(strQuery);
#ifdef SHARD_AWARE
sprintf(strQuery, SQL_WTT_HEADER_REQUEST_SAMPLE_DEL_C3, sampleDbName.c_str(), refList.c_str(), getBoundedDateTimeString(KEY_TIME_COLUMN_REQUEST).c_str());
#else
sprintf(strQuery, SQL_WTT_HEADER_REQUEST_SAMPLE_DEL, sampleDbName.c_str(), refList.c_str());
#endif
Trace("Issuing query", strQuery, 0);
result = connection->Query(strQuery);
//.........这里部分代码省略.........
示例9: checkConnectivity
bool checkConnectivity(ConnectionPtr connection)
{
// checks to see if this server has connectivity
// it does so by finding two servers (from the TestServer table) in other groups, and hence on other carriers
// if both of these pings fail then we can assume that it is our connectivity
// we can then re-schedule the job
// now also used to see if we are down before the end of the check
std::string testHost;
std::string externalTestHost;
std::string externalTestHost1;
std::string externalTestHost2;
int ourGroup = 0;
int testGroup = 0;
ResultPtr result;
ncc::safe_array<char> selectQuery(1024);
bool retVal = true;
std::string site;
std::string clusterGroup;
Trace("checkConnectivity", "CConfig::getServerID()", CConfig::getServerID());
try
{
#ifdef SHARD_AWARE
ConnectionPtr passportShardConnection(
new Connection(
CConfig::getPassportDbServer(),
CConfig::getPassportDbDatabase(),
CConfig::getPassportDbUser(),
CConfig::getPassportDbPass(),
CConfig::getDBRetryTime()));
// get the group of this test server
snprintf(selectQuery, selectQuery.size(), SQL_SCS_TEST_GROUP_CG3, CConfig::getServerID());
Trace("Issuing query",selectQuery,0);
result = passportShardConnection->Query(selectQuery);
Trace("Rows:","",result->GetRowCount());
if (result->GetRowCount() > 0)
{
result->Next();
RowPtr row = result->GetCurrentRow();
ourGroup = row->GetFieldInteger(1);
}
snprintf(selectQuery, selectQuery.size(), SQL_SCS_RETEST_SERVERS_GROUP_RAND_CG3,
SC_SERVER_STATUS_LIVE, ourGroup, 0);
Trace("Issuing query",selectQuery,0);
result = passportShardConnection->Query(selectQuery);
Trace("Rows:","",result->GetRowCount());
#else
// get the group of this test server
snprintf(selectQuery, selectQuery.size(), SQL_SCS_TEST_GROUP, CConfig::getServerID());
Trace("Issuing query",selectQuery,0);
result = connection->Query(selectQuery);
Trace("Rows:","",result->GetRowCount());
if (result->GetRowCount() > 0)
{
result->Next();
RowPtr row = result->GetCurrentRow();
ourGroup = row->GetFieldInteger(1);
site = row->GetFieldString(2);
clusterGroup = row->GetFieldString(3);
}
snprintf(selectQuery, selectQuery.size(), SQL_SCS_RETEST_SERVERS_GROUP_RAND, SC_SERVER_STATUS_LIVE, ourGroup, site.c_str(), clusterGroup.c_str());
Trace("Issuing query",selectQuery,0);
result = connection->Query(selectQuery);
Trace("Rows:","",result->GetRowCount());
#endif
int testGroup1 = 0;
int testGroup2 = 0;
std::string externalTestHost1;
std::string externalTestHost2;
if (result->GetRowCount() > 0)
{
while(result->Next())
{
RowPtr row = result->GetCurrentRow();
testHost = row->GetFieldString(2);
testGroup = row->GetFieldInteger(3);
externalTestHost = row->GetFieldString(4);
Trace("externalHost",externalTestHost.c_str(),testGroup);
if (testGroup1 == 0)
{
// set this to be the first group to test
testGroup1 = testGroup;
externalTestHost1 = externalTestHost;
}
else if (testGroup1 != testGroup)
//.........这里部分代码省略.........
示例10: schedSecondTest
void schedSecondTest(ConnectionPtr connection, long idNo, int portNo, SC_TEST_TYPE testType, unsigned int shardNumber)
{
Trace("schedSecondTest", "", idNo);
std::string strQuery;
// find a server to send the test to
try
{
#ifdef SHARD_AWARE
ConnectionPtr passportShardConnection(
new Connection(
CConfig::getPassportDbServer(),
CConfig::getPassportDbDatabase(),
CConfig::getPassportDbUser(),
CConfig::getPassportDbPass(),
CConfig::getDBRetryTime()));
// get the group of this test server
strQuery = Format(SQL_SCS_TEST_GROUP_CG3, CConfig::getServerID());
TraceSQL("Issuing query", "", 0);
int testGroup = 0;
if (ResultPtr result = passportShardConnection->Query(strQuery))
{
TraceSQL("Rows:","",result->GetRowCount());
if (result->GetRowCount() > 0)
{
result->Next();
RowPtr row = result->GetCurrentRow();
testGroup = row->GetFieldInteger(1);
}
}
// get the carrier to exclude
if (portNo == TCP_PORT_WTTGD)
{
strQuery = Format(SQL_SCS_TEST_GROUP_EXCLUDE_SCRIPT, idNo);
}
else if (portNo == TCP_PORT_ETTD)
{
strQuery = Format(SQL_SCS_TEST_GROUP_EXCLUDE_ISP, idNo);
}
else
{
strQuery = Format(SQL_SCS_TEST_GROUP_EXCLUDE_WEBPAGE, idNo);
}
TraceSQL("Issuing query", "", 0);
unsigned int carrierToExclude = 0;
if (ResultPtr result = connection->Query(strQuery))
{
TraceSQL("Rows:","",result->GetRowCount());
if (result->GetRowCount() > 0)
{
result->Next();
RowPtr row = result->GetCurrentRow();
// make it the customer one
carrierToExclude = row->GetFieldInteger(1);
// override with Script or WebPage one
if (row->GetFieldInteger(2) != 0)
carrierToExclude = row->GetFieldInteger(2);
}
}
#ifdef SC_NON_WEBKIT
strQuery = Format(SQL_SCS_RETEST_SERVERS_GROUP_RAND_CG3, SC_SERVER_STATUS_LIVE, testGroup, carrierToExclude);
#else
#ifdef SC_WEBKIT_V89
strQuery = Format(SQL_SCS_RETEST_SERVERS_GROUP_RAND_CG3, SC_SERVER_JACK_STATUS_LIVE_89, testGroup, carrierToExclude);
#else
strQuery = Format(SQL_SCS_RETEST_SERVERS_GROUP_RAND_CG3, SC_SERVER_JACK_STATUS_LIVE, testGroup, carrierToExclude);
#endif // SC_WEBKIT_V89
#endif // SC_NON_WEBKIT
TraceSQL("Issuing query", "", 0);
if (ResultPtr result = passportShardConnection->Query(strQuery))
{
TraceSQL("Rows:","",result->GetRowCount());
#else
// get the group of this test server
strQuery = Format(SQL_SCS_TEST_GROUP, CConfig::getServerID());
TraceSQL("Issuing query", "", 0);
if (ResultPtr result = connection->Query(strQuery))
{
std::string site;
std::string clusterGroup;
TraceSQL("Rows:","",result->GetRowCount());
if (result->GetRowCount() > 0)
{
result->Next();
RowPtr row = result->GetCurrentRow();
testGroup = row->GetFieldInteger(1);
//.........这里部分代码省略.........
示例11: runWTTT
// per page tests
void runWTTT(scriptid_t scriptID, unsigned int shardNumber, const char* runNo, long batchID, bool wait, bool debug)
{
// only do a sleep if the first run - not for manual or retests
if ((atoi(runNo) == 1) && wait)
{
TraceNoise("Sleeping for a bit", runNo, scriptID);
// sleep for an offset of seconds
sleep(scriptID % 60);
}
ConnectionPtr connection;
std::string strQuery;
bool download = true;
try
{
#ifdef SHARD_AWARE
TraceLogic("Connecting to db", CConfig::getShardDatabase(shardNumber).c_str(), shardNumber);
connection.reset(
new Connection(
CConfig::getShardServer(shardNumber),
CConfig::getShardDatabase(shardNumber),
CConfig::getShardUser(shardNumber),
CConfig::getShardPass(shardNumber),
CConfig::getDBRetryTime()));
#else
TraceLogic("Connecting to db", CConfig::getDBDatabase(), 0);
connection.reset(
new Connection(
CConfig::getDBServer(),
CConfig::getDBDatabase(),
CConfig::getDBUser(),
CConfig::getDBPass(),
CConfig::getDBRetryTime()));
#endif
}
catch (const std::exception &e)
{
LogError("Exception Caught:", e.what(), scriptID);
return;
}
// if the ScriptID == 0 - get it from the batch table
if (scriptID == 0)
{
strQuery = Format(SQL_WTTT_BATCH_SEL, batchID);
TraceSQL("Issuing", "", 0);
if (ResultPtr result = connection->Query(strQuery))
{
if (result->Next())
{
RowPtr row = result->GetCurrentRow();
scriptID = row->GetFieldLong(1);
TraceLogic("batchID", "", batchID);
TraceLogic("scriptID", "", scriptID);
}
}
}
// script and archive names
const std::string filename = Format("/home/sc/bin/monitor_scripts/%ld_%u", scriptID, shardNumber);
const std::string gzfilename = filename + ".gz";
// Get script details
long customerNo = 0;
SC_SCRIPT_LANGUAGE scriptlanguage = SC_SCRIPT_LANGUAGE_UNKNOWN;
std::string scriptversion;
strQuery = Format(SQL_WTTT_SCRIPTINFO_SEL, scriptID);
TraceSQL("Issuing", "", 0);
if (ResultPtr result = connection->Query(strQuery))
{
if (result->Next())
{
RowPtr row = result->GetCurrentRow();
customerNo = row->GetFieldLong(1);
scriptlanguage = static_cast<SC_SCRIPT_LANGUAGE>(row->GetFieldLong(2));
// Field can be NULL, so check before dereference
if (const char* str = row->GetField(3))
{
scriptversion = str;
}
TraceLogic("customerNo", "", customerNo);
TraceLogic("scriptlanguage", to_string(scriptlanguage).c_str(), int(scriptlanguage));
TraceLogic("scriptversion", scriptversion.c_str(), scriptversion.size());
}
}
switch (scriptlanguage)
{
case SC_SCRIPT_LANGUAGE_UNKNOWN:
//
// No recognised script or script language returned
//
//.........这里部分代码省略.........
示例12: loadJavaScriptCheck
void CPage::loadJavaScriptCheck(ConnectionPtr connection)
{
Trace("loadJavaScriptCheck()", "",0);
std::string strQuery;
// need to change all to lower case
std::string lowerCaseBody;
try
{
Mutex::Lock lock(m_javascriptListLock);
strQuery = Format(SQL_WTT_JAVASCRIPT1);
if (ResultPtr result = connection->Query(strQuery))
{
Trace("RowPtr s:","",result->GetRowCount());
while(result->Next())
{
RowPtr row = result->GetCurrentRow();
// add to the list
Trace("loadJavaScriptCheck() - search", row->GetField(1),0);
Trace("loadJavaScriptCheck() - replace", row->GetField(2),0);
m_javascriptSearchList.push_back(row->GetFieldString(1));
m_javascriptReplaceList.push_back(row->GetFieldString(2));
}
}
strQuery = Format(SQL_WTT_JAVASCRIPT2, getPageID());
if (ResultPtr result = connection->Query(strQuery))
{
Trace("RowPtr s:","",result->GetRowCount());
while(result->Next())
{
RowPtr row = result->GetCurrentRow();
// add to the list
Trace("loadJavaScriptCheck() - search", row->GetField(1),0);
Trace("loadJavaScriptCheck() - replace", row->GetField(2),0);
m_javascriptSearchList.push_back(row->GetFieldString(1));
m_javascriptReplaceList.push_back(row->GetFieldString(2));
}
}
}
catch (const std::exception& e)
{
LogError("Exception Caught:", e.what(), 0);
}
try
{
Mutex::Lock lock(m_javascriptExtractListLock);
strQuery = Format(SQL_WTT_JAVASCRIPT3, getPageID());
if (ResultPtr result = connection->Query(strQuery))
{
Trace("RowPtr s:","",result->GetRowCount());
while(result->Next())
{
RowPtr row = result->GetCurrentRow();
// add to the list
Trace("loadJavaScriptCheck() - start", row->GetField(1),0);
Trace("loadJavaScriptCheck() - end", row->GetField(2),0);
m_javascriptStartList.push_back(row->GetFieldString(1));
m_javascriptEndList.push_back(row->GetFieldString(2));
}
}
}
catch (const std::exception& e)
{
LogError("Exception Caught:", e.what(), 0);
}
}