bool CWizIndexBase::SQLToBizUserDataArray(const QString& strSQL, CWizBizUserDataArray& arrayUser) { try { CppSQLite3Query query = m_db.execQuery(strSQL); while (!query.eof()) { WIZBIZUSER data; data.bizGUID = query.getStringField(userBIZ_GUID); data.userId = query.getStringField(userUSER_ID); data.userGUID = query.getStringField(userUSER_GUID); data.alias = query.getStringField(userUSER_ALIAS); data.pinyin = query.getStringField(userUSER_PINYIN); arrayUser.push_back(data); query.nextRow(); } return true; } catch (const CppSQLite3Exception& e) { return LogSQLException(e, strSQL); } }
bool CWizIndexBase::SQLToStyleDataArray(const CString& strSQL, CWizStyleDataArray& arrayStyle) { try { CppSQLite3Query query = m_db.execQuery(strSQL); while (!query.eof()) { WIZSTYLEDATA data; data.strKbGUID = kbGUID(); data.strGUID = query.getStringField(styleSTYLE_GUID); data.strName = query.getStringField(styleSTYLE_NAME); data.strDescription = query.getStringField(styleSTYLE_DESCRIPTION); data.crTextColor = query.getColorField(styleSTYLE_TEXT_COLOR); data.crBackColor = query.getColorField(styleSTYLE_BACK_COLOR); data.bTextBold = query.getBoolField(styleSTYLE_TEXT_BOLD); data.nFlagIndex = query.getIntField(styleSTYLE_FLAG_INDEX); data.tModified = query.getTimeField(styleDT_MODIFIED); data.nVersion = query.getInt64Field(styleVersion); arrayStyle.push_back(data); query.nextRow(); } std::sort(arrayStyle.begin(), arrayStyle.end()); return true; } catch (const CppSQLite3Exception& e) { return LogSQLException(e, strSQL); } }
vector<lip> limitIP::GetIPList() { vector<lip> lips; __try { CppSQLite3Query query = m_pDB.execQuery(_T("SELECT IP,Remark FROM IPfliter")); while (!query.eof()) { lip l; l.szIP = query.getStringField(_T("IP")); l.remark = query.getStringField(_T("Remark")); lips.push_back(l); query.nextRow(); } return lips; } __except (Global::MyUnhandledExceptionFilter(GetExceptionInformation())) { return lips; } }
void CTerminateNewLocationDialog::OnSelchangeLocationlist() { int iLocationID = m_ctlLocationList.GetItemData(m_ctlLocationList.GetCurSel()); CString sSQL; sSQL.Format("SELECT Industries.id,Industries.name FROM Industries,Sidings WHERE Industries.Sidings_FK=Sidings.id AND Sidings.Locations_FK=%d",iLocationID); TRACE(sSQL); // CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CppSQLite3Query q = pDB->execQuery(sSQL); // while( m_ctlIndustryList.GetCount() > 0 ) m_ctlIndustryList.DeleteString(0); // while (!q.eof()) { int nIndex = m_ctlIndustryList.AddString(q.getStringField("name")); m_ctlIndustryList.SetItemData(nIndex,q.getIntField("id")); q.nextRow(); } // sSQL.Format("SELECT id,name FROM Sidings WHERE Locations_FK=%d;",iLocationID); q = pDB->execQuery(sSQL); // while( m_ctlSidingList.GetCount() > 0 ) m_ctlSidingList.DeleteString(0); // while (!q.eof()) { int nIndex = m_ctlSidingList.AddString(q.getStringField("name")); m_ctlSidingList.SetItemData(nIndex,q.getIntField("id")); q.nextRow(); } q.finalize(); }
int CDBObject::getFirstFile(char* name) { try { if(name != NULL) { char szSql[]= {"SELECT * from Record"}; CppSQLite3DB database; database.open(g_szFile); CppSQLite3Query query = database.execQuery(szSql); if(!query.eof()) { string path = query.getStringField(8); string file= query.getStringField(7); sprintf(name, "%s\\%s", UTF_82ASCII(path).c_str(), UTF_82ASCII(file).c_str()); return query.getIntField(0); } } } catch(...) { g_pLog->WriteLog("数据库查询异常 getFirstFile\n"); } return -1; }
BOOL CLocationDetailDialog::OnInitDialog() { CDialog::OnInitDialog(); if( m_iLocationID == -1 ) m_ctlOK.EnableWindow(FALSE); else { CString sSQL; sSQL.Format("SELECT name,notes FROM Locations WHERE id=%d;",m_iLocationID); CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CppSQLite3Query q = pDB->execQuery(sSQL); // if (!q.eof()) { m_sLocationName = q.getStringField("name"); m_sLocalInstructions = q.getStringField("notes"); } q.finalize(); UpdateData(FALSE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CCarTypesDetailDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here if( m_iCarTypeFK != -1 ) { CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CString sSQL; sSQL.Format("SELECT * FROM CarTypes WHERE id=%d",m_iCarTypeFK); CppSQLite3Query q = pDB->execQuery((LPCTSTR)sSQL); if( !q.eof() ) { m_sCarTypeDescription = q.getStringField("description"); m_sCarTypeID = q.getStringField("type_id"); m_bPassenger = q.getIntField("passenger")==1?TRUE:FALSE; } q.finalize(); } UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
bool CWizIndexBase::SQLToTagDataArray(const CString& strSQL, CWizTagDataArray& arrayTag) { try { CppSQLite3Query query = m_db.execQuery(strSQL); while (!query.eof()) { WIZTAGDATA data; data.strKbGUID = kbGUID(); data.strGUID = query.getStringField(tagTAG_GUID); data.strParentGUID = query.getStringField(tagTAG_GROUP_GUID); data.strName = query.getStringField(tagTAG_NAME); data.strDescription = query.getStringField(tagTAG_DESCRIPTION); data.tModified = query.getTimeField(tagDT_MODIFIED); data.nVersion = query.getInt64Field(tagVersion); arrayTag.push_back(data); query.nextRow(); } std::sort(arrayTag.begin(), arrayTag.end()); return true; } catch (const CppSQLite3Exception& e) { return LogSQLException(e, strSQL); } }
bool CSpace::Load(int64 ParentID,int64 ChildID){ m_ID = ParentID; char ParentName[30], ChildName[30]; int64toa(ParentID,ParentName); int64toa(ChildID,ChildName); CppSQLite3Buffer SQL; SQL.format("select * from \"%s\" where %s = \"%s\" ", ParentName, ITEM_ID, ChildName ); CppSQLite3Query Result = GetWorldDB().execQuery(SQL); if(Result.eof()){ return false; } assert(Size()>5); assert(GetDataType(0) == TYPE_INT); int64& OldID = *(int64*)GetData(0); OldID = ChildID; AnsiString AnsiName = Result.getStringField(1,""); tstring Name = UTF8toWS(AnsiName); SetName(Name); SPACETYPE Type = (SPACETYPE)Result.getIntField(2); SetSpaceType(Type); AnsiString Fingerprint = Result.getStringField(3); tstring Fingerprint1 = UTF8toWS(Fingerprint); SetFingerprint(Fingerprint1); AnsiString AnsiProperty = Result.getStringField(4,""); ePipeline Property; uint32 pos =0; bool ret = Property.FromString(AnsiProperty,pos); if(!ret){ return false; } SetProerty(Property); AnsiString AnsiOwner = Result.getStringField(5,""); ePipeline OwnerInfo; pos=0; ret = OwnerInfo.FromString(AnsiOwner,pos); if(!ret){ return false; } SetOwnerInfo(OwnerInfo); return true; }
bool RPGMapSceneLayer::init(float showObjectTime) { if(RPGBaseSceneLayer::init()) { CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("joystick.plist"); CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("main.plist"); //加载语言文件 string languageFile = CCFileUtils::sharedFileUtils()->fullPathForFilename("scene_map_cns.plist"); this->m_stringList = CCDictionary::createWithContentsOfFileThreadSafe(languageFile.c_str()); this->m_stringList->retain(); //数据库部分,读取进度记录 CppSQLite3Query query = this->m_db.execQuery(SAVEDATA_MAP_QUERY); this->m_mapData.mapId = query.getIntField("map_id"); this->m_mapData.mapName = query.getStringField("map_name"); this->m_mapData.hasEnemy = query.getIntField("has_enemy") == 1 ? true : false; this->m_mapData.bgAudio = query.getStringField("bg_audio"); this->m_mapData.playerToX = query.getFloatField("player_to_x"); this->m_mapData.playerToY = query.getFloatField("player_to_y"); this->m_mapData.playerDirection = query.getStringField("player_direction"); this->m_mapData.location = query.getStringField("location_cns"); this->m_mapData.gold = query.getIntField("gold"); query.finalize(); CCTMXTiledMap *bgMap = CCTMXTiledMap::create(this->m_mapData.mapName.c_str()); bgMap->setTag(kRPGMapSceneLayerTagBgMap); bgMap->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - bgMap->getContentSize().width) / 2.0, (CCDirector::sharedDirector()->getWinSize().height - bgMap->getContentSize().height) / 2.0)); this->addChild(bgMap); //背景音乐 if(SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying()) { SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true); SimpleAudioEngine::sharedEngine()->playBackgroundMusic(this->m_mapData.bgAudio.c_str(), true); } this->m_playerMoveAct = NULL; this->m_playerMoveSpeed = GAME_PLAYER_MOVESPEED; this->m_touchedDialogNPC = NULL; this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionNone; this->m_hasEnemy = this->m_mapData.hasEnemy; //是否会遇敌 this->m_releaseTexture = false; //是否在释构方法里面释放占用纹理 this->scheduleOnce(schedule_selector(RPGMapSceneLayer::startPlay), showObjectTime); // CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); return true; } return false; }
EXPORT_C gint32 CContactDb::GetRecentContacts(GPtrArray ** pContacts) { char sql[64] = {0}; char times[20] = {0}; // time_t t; // time(&t); *pContacts = NULL; *pContacts = g_ptr_array_new(); if (*pContacts == NULL) { return ERROR(ESide_Client, EModule_Db, ECode_No_Memory); } OpenDatabase(); strcpy(sql, "select * from recent_contact;"); CppSQLite3Query query = m_dbBeluga.execQuery(sql); while (!query.eof()) { stRecentContact * recentContact = (stRecentContact*)g_malloc0(sizeof(stRecentContact)); if (recentContact == NULL) { CloseDatabase(); return ERROR(ESide_Client, EModule_Db, ECode_No_Memory); } recentContact->nContactId = query.getIntField(1); recentContact->event = (EContactEvent)query.getIntField(2); strcpy(recentContact->eventCommInfo, query.getStringField(3)); strcpy(times, query.getStringField(4)); /* exp: 2009-6-30 21:51:23 */ //recentContact->time = localtime(&t); GetLocalTime(&recentContact->time); char * tmp = strrchr(times, '-'); recentContact->time.tm_mon = atoi(tmp+1); tmp = strrchr(tmp, '-'); recentContact->time.tm_mday = atoi(tmp+1); tmp = strrchr(tmp, ' '); recentContact->time.tm_hour = atoi(tmp+1); tmp = strrchr(tmp, ':'); recentContact->time.tm_min = atoi(tmp+1); tmp = strrchr(tmp, ':'); recentContact->time.tm_sec = atoi(tmp+1); g_ptr_array_add(*pContacts, recentContact); query.nextRow(); } CloseDatabase(); return 0; }
void CVoxSQLite::GetMergedContacts( const char* parent_username, MergedContacts& rList ) { CppSQLite3Buffer buf; buf.format( "SELECT * from [MergedContact] WHERE [parent_username] = %Q;", parent_username ); try { CppSQLite3Statement stmt = m_db.compileStatement( (const char*)buf ); int nContactId = 0; std::string type = ""; CppSQLite3Query q = stmt.execQuery(); MergedContact mc; //Process record set. while (!q.eof()) { mc.setParentUsername( q.getStringField( 0 ) ); mc.setUsername ( q.getStringField( 1 ) ); rList.Add( &mc ); q.nextRow(); } stmt.reset(); } catch (CppSQLite3Exception& e) { e.errorCode(); } }
bool DBSetting::GetValue(long lKey,std::string &strValue) { //打开数据库 CppSQLite3DB dbTask; dbTask.open(m_strDB.c_str()); CheckCreateSettingTable(dbTask); CppSQLite3Buffer strSql; try{ strSql.format("select value from T_Setting where key=%d;",lKey); CppSQLite3Query q = dbTask.execQuery(strSql); if (q.eof()) { return false; } strValue = q.getStringField(0); } catch(CppSQLite3Exception &exp) { exp; ATLTRACE("error:%s\n",exp.errorMessage()); ATLASSERT(FALSE); return false; } return true; }
void CVoxSQLite::GetGroups( const char* username, Groups& rList ) { CppSQLite3Buffer buf; buf.format( "SELECT * from [Group] WHERE [username] = %Q;", username ); try { CppSQLite3Statement stmt = m_db.compileStatement( (const char*)buf ); int nContactId = 0; std::string type = ""; CppSQLite3Query q = stmt.execQuery(); Group grp; //Process record set. while (!q.eof()) { grp.setUsername( q.getStringField( 0 ) ); grp.setName ( q.getStringField( 1 ) ); rList.Add( &grp ); q.nextRow(); } stmt.reset(); } catch (CppSQLite3Exception& e) { e.errorCode(); } }
//Método que monta as tab do Tab Control void CRcGen::GetGrupos(WPARAM wParam, CStringArray& arrayGrp) { CStringA sQuery; sQuery.Format("select distinct res.grupo, resgrupo.descricao from res, resgrupo where res.grupo = resgrupo.grupo and res.pagina between %d and %d", LOWORD(wParam), HIWORD(wParam)); try { CppSQLite3Query q = CppSQLite3DB::getInstance()->execQuery(sQuery); if(!q.eof()) { m_nGrupo = q.getIntField(0); m_nGrupoInicial = m_nGrupo; } while(!q.eof()) { arrayGrp.Add(CString(q.getStringField(1))); q.nextRow(); } } catch(CppSQLite3Exception e) { } }
//private void RPGMapItemsMenuLayer::loadItemsData() { //道具数据 this->m_itemsList->removeAllObjects(); CppSQLite3Query query = this->m_db->execQuery(ITEMS_EXISTING_QUERY); while(!query.eof()) { RPGExistingItems *itemsData = RPGExistingItems::create(); itemsData->m_dataId = query.getIntField("id"); itemsData->m_name = query.getStringField("name_cns"); itemsData->m_buy = query.getIntField("buy"); itemsData->m_sell = query.getIntField("sell"); itemsData->m_type = query.getIntField("type"); itemsData->m_attack = query.getFloatField("attack"); itemsData->m_defense = query.getFloatField("defense"); itemsData->m_speed = query.getFloatField("speed"); itemsData->m_skillAttack = query.getFloatField("skill_attack"); itemsData->m_skillDefense = query.getFloatField("skill_defense"); itemsData->m_total = query.getIntField("total"); this->m_itemsList->addObject(itemsData); query.nextRow(); } query.finalize(); CCTableView *tableView = (CCTableView*)this->getChildByTag(kRPGMapItemsMenuLayerTagItemListTable); tableView->reloadData(); }
bool mtn_cms_page_builder::getcache(const std::string& page, mtn_cms_cache_item* cache_item) { std::string _q = "SELECT * FROM `page_cache` WHERE page = \'" + page + "\';"; try { CppSQLite3Query q = _db->execQuery(_q.c_str()); while (!q.eof()) { int len; cache_item->data = q.getStringField("data"); cache_item->created = q.getIntField("created"); cache_item->ttl = q.getIntField("ttl"); cache_item->valid = true; q.nextRow(); } } catch (CppSQLite3Exception ex) { cache_item->valid = false; } return cache_item->valid; }
// Allocates a new CClipTypes CClipTypes* CCP_MainApp::LoadTypesFromDB() { CClipTypes* pTypes = new CClipTypes; try { CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT TypeText FROM Types")); while(q.eof() == false) { pTypes->Add(GetFormatID(q.getStringField(_T("TypeText")))); q.nextRow(); } } CATCH_SQLITE_EXCEPTION if(pTypes->GetSize() <= 0) { pTypes->Add(CF_TEXT); pTypes->Add(RegisterClipboardFormat(CF_RTF)); pTypes->Add(CF_UNICODETEXT); pTypes->Add(CF_HDROP); if(g_Opt.m_bU3 == false) { pTypes->Add(CF_DIB); } } return pTypes; }
BOOL CStaticDataMgr::ProcessDBFile( std::string strDbFile ) { try { m_DBConnection.open(strDbFile.c_str()); } catch(CppSQLite3Exception& e) { printf("%s",e.errorMessage()); return FALSE; } CppSQLite3Query TableNames = m_DBConnection.execQuery("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"); while(!TableNames.eof()) { std::string strSql ="SELECT * from "; std::string strTbName = TableNames.getStringField("name", NULL); strSql += strTbName; CppSQLite3Query Tabledatas = m_DBConnection.execQuery(strSql.c_str()); ProcessTable(strTbName, Tabledatas); TableNames.nextRow(); } m_DBConnection.close(); return TRUE; }
int32 GetAllChildList(int64 ParentID, ePipeline& ChildList,int64 NotIncludeChildID /*=0*/){ assert(ParentID >0); ChildList.Clear(); char TableName[30]; int64toa(ParentID,TableName); if(!GetWorldDB().tableExists(TableName)){ return 0; } //ChildList.SetID(ParentID); CppSQLite3Buffer SQL; SQL.format("select %s,%s,%s,%s from \"%s\"", ITEM_ID, ITEM_NAME, ITEM_TYPE, ITEM_FINGERPRINT, TableName ); CppSQLite3Query Result = GetWorldDB().execQuery(SQL); while(!Result.eof()){ int64 ChildID = Result.getInt64Field(0); if (ChildID !=NotIncludeChildID) { AnsiString s = Result.getStringField(1,""); tstring Name = UTF8toWS(s); Name = GetFileNoPathName(Name); Name = GetFileName(Name); int32 Type = Result.getIntField(2); AnsiString FingerPrint = Result.getStringField(3,""); //ChildList.PushInt64(ChildID); ChildList.PushString(Name); ChildList.PushInt(Type); ChildList.PushString(FingerPrint); } Result.nextRow(); } return ChildList.Size()/3; }
BOOL DatabaseModule_Impl::sqlGetGroupInfoByGId(IN std::string& gId, OUT module::GroupInfoEntity& groupInfo) { try { CppSQLite3Statement stmt; stmt = m_pSqliteDB->compileStatement(getGroupInfoByGIdSql.c_str()); stmt.bind(1, gId.c_str()); CppSQLite3Query query = stmt.execQuery(); if (!query.eof()) { groupInfo.gId = gId; groupInfo.csName = util::stringToCString(query.getStringField(2)); groupInfo.desc = util::stringToCString(query.getStringField(3)); groupInfo.avatarUrl = query.getStringField(4); groupInfo.creatorId = query.getStringField(5); groupInfo.type = query.getIntField(6); groupInfo.version = query.getIntField(7); groupInfo.groupUpdated = query.getIntField(8); groupInfo.shieldStatus = query.getIntField(9); _parseJsonForGroupMembers(query.getStringField(10), groupInfo.groupMemeberList); } else { return FALSE; } } catch (CppSQLite3Exception& sqliteException) { #ifdef _DEBUG MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND); #endif CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8); LOG__(ERR, _T("db failed,error msg:%s"), csErrMsg); return FALSE; } catch (...) { LOG__(ERR, _T("db unknown exception")); return FALSE; } return TRUE; }
bool CWizIndexBase::SQLToDocumentAttachmentDataArray(const CString& strSQL, CWizDocumentAttachmentDataArray& arrayAttachment) { try { CppSQLite3Query query = m_db.execQuery(strSQL); while (!query.eof()) { WIZDOCUMENTATTACHMENTDATA data; data.strKbGUID = kbGUID(); data.strGUID = query.getStringField(documentattachmentATTACHMENT_GUID); data.strDocumentGUID = query.getStringField(documentattachmentDOCUMENT_GUID); data.strName = query.getStringField(documentattachmentATTACHMENT_NAME); data.strURL = query.getStringField(documentattachmentATTACHMENT_URL); data.strDescription = query.getStringField(documentattachmentATTACHMENT_DESCRIPTION); data.tInfoModified = query.getTimeField(documentattachmentDT_INFO_MODIFIED); data.strInfoMD5 = query.getStringField(documentattachmentATTACHMENT_INFO_MD5); data.tDataModified = query.getTimeField(documentattachmentDT_DATA_MODIFIED); data.strDataMD5 = query.getStringField(documentattachmentATTACHMENT_DATA_MD5); data.nVersion = query.getInt64Field(documentattachmentVersion); arrayAttachment.push_back(data); query.nextRow(); } std::sort(arrayAttachment.begin(), arrayAttachment.end()); return true; } catch (const CppSQLite3Exception& e) { return LogSQLException(e, strSQL); } }
// Added By Begemot, exact as execScalar but return CString 08/06/06 16:30:37 CString CppSQLite3DB::execScalarStr(LPCTSTR szSQL) { CppSQLite3Query q = execQuery(szSQL); if (q.eof() || q.numFields() < 1) throw CppSQLite3Exception(CPPSQLITE_ERROR, _T("Invalid scalar query"), DONT_DELETE_MSG); return (CString)q.getStringField(0); }
CString CEquipmentLocationDialog::GetCarType(int iCarTypeFK) { CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CString sSQL; sSQL.Format("SELECT description FROM CarTypes WHERE id=%d;",iCarTypeFK); CppSQLite3Query q = pDB->execQuery(sSQL); CString sType(""); if( !q.eof() ) sType = q.getStringField("description"); q.finalize(); return sType; }
void BudgetWindow::RefreshBudgetGrid(void) { fIncomeGrid.MakeEmpty(); fSpendingGrid.MakeEmpty(); CppSQLite3Query query = gDatabase.DBQuery("select category,amount,period from " "budgetlist order by category", "BudgetWindow::RefreshCategories"); while(!query.eof()) { BString cat = DeescapeIllegalCharacters(query.getStringField(0)); Fixed amount; amount.SetPremultiplied(query.getInt64Field(1)); BudgetPeriod period = (BudgetPeriod)query.getIntField(2); ReportGrid *grid = (amount.IsPositive()) ? &fIncomeGrid : &fSpendingGrid; int32 index = grid->CountItems(); grid->AddItem(); grid->SetRowTitle(index, cat.String()); Fixed f(amount.AbsoluteValue()); switch(period) { case BUDGET_QUARTERLY: { f /= 3; Fixed qamt(amount); qamt *= 4; grid->SetValue(12,index,qamt); break; } case BUDGET_ANNUALLY: { f /=12; grid->SetValue(12,index,amount); break; } default: { Fixed mamt(f); mamt *= 12; grid->SetValue(12,index,mamt); break; } } for(int32 i=0; i<12; i++) grid->SetValue(i,index,f); query.nextRow(); } }
BOOL DatabaseModule_Impl::sqlGetRecentSessionInfoByGId(IN std::string& sId, OUT module::SessionEntity& sessionInfo) { try { CppSQLite3Statement stmt; stmt = m_pSqliteDB->compileStatement(getRecentSessionByIdSql.c_str()); stmt.bind(1, sId.c_str()); CppSQLite3Query query = stmt.execQuery(); if (!query.eof()) { sessionInfo.sessionID = sId; sessionInfo.sessionType = query.getIntField(2); sessionInfo.updatedTime = query.getIntField(3); sessionInfo.latestmsgId = query.getIntField(4); sessionInfo.latestMsgContent = query.getStringField(5); sessionInfo.latestMsgFromId = query.getStringField(6); } else { return FALSE; } } catch (CppSQLite3Exception& sqliteException) { #ifdef _DEBUG MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND); #endif CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8); LOG__(ERR, _T("db failed,error msg:%s"), csErrMsg); return FALSE; } catch (...) { LOG__(ERR, _T("db unknown exception")); return FALSE; } return TRUE; }
BOOL DatabaseModule_Impl::sqlGetFileTransferHistory(OUT std::vector<TransferFileEntity>& fileList) { try { CppSQLite3Statement stmt; stmt = m_pSqliteDB->compileStatement(getFileTransferHistoryBySIdSql.c_str()); stmt.bind(1, 20); CppSQLite3Query query = stmt.execQuery(); while (!query.eof()) { TransferFileEntity fileInfo; fileInfo.sTaskID = query.getStringField(1); fileInfo.sFromID = query.getStringField(2); fileInfo.sFileName = query.getStringField(3); CString strSavePath = util::stringToCString(query.getStringField(7)); fileInfo.setSaveFilePath(strSavePath); fileInfo.nFileSize = query.getIntField(8); fileInfo.time = query.getIntField(9); fileList.push_back(fileInfo); query.nextRow(); } } catch (CppSQLite3Exception& sqliteException) { #ifdef _DEBUG MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND); #endif CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8); LOG__(ERR, _T("db failed,error msg:%s"), csErrMsg); return FALSE; } catch (...) { return FALSE; } return TRUE; }
BOOL CDBCmdHandler::OnCmdDBLoadCharReq( UINT16 wCommandID, UINT64 u64ConnID, CBufferHelper *pBufferHelper ) { StDBLoadCharInfoReq DBLoadCharInfoReq; pBufferHelper->Read(DBLoadCharInfoReq); StDBLoadCharInfoAck DBLoadCharInfoAck; DBLoadCharInfoAck.dwProxySvrID = DBLoadCharInfoReq.dwProxySvrID; CBufferHelper WriteHelper(TRUE, &m_WriteBuffer); WriteHelper.BeginWrite(CMD_DB_LOAD_CHAR_ACK, 0, DBLoadCharInfoReq.dwSceneID, DBLoadCharInfoReq.u64CharID); WriteHelper.Write(DBLoadCharInfoAck); CDBPlayerObject *pDBPlayer = m_DBPlayerMgr.GetPlayer(DBLoadCharInfoReq.u64CharID); if(pDBPlayer == NULL) { //读取一条记录, //读出成功 pDBPlayer = m_DBPlayerMgr.InsertAlloc(DBLoadCharInfoReq.u64CharID); pDBPlayer->Init(); pDBPlayer->m_u64ObjectID = DBLoadCharInfoReq.u64CharID; CHAR szSql[MAX_PATH]; sprintf(szSql, "select * from t_charinfo where F_CharID = '%lld'", DBLoadCharInfoReq.u64CharID); CppSQLite3Query QueryRes = m_DBProcManager.m_DBConnection.execQuery(szSql); if(!QueryRes.eof()) { pDBPlayer->m_dwFeature = QueryRes.getIntField("F_Feature", 0); strncpy(pDBPlayer->m_szObjectName, QueryRes.getStringField("F_Name", ""), 32); pDBPlayer->m_dwLevel = QueryRes.getIntField("F_Level", 0); } //if(!pDBPlayer->LoadFromDB()) //{ // return TRUE; //} } pDBPlayer->WriteToPacket(&WriteHelper); WriteHelper.EndWrite(); CGameService::GetInstancePtr()->SendCmdToConnection(DBLoadCharInfoReq.dwGameSvrID, &m_WriteBuffer); return TRUE; }
BOOL DatabaseModule_Impl::sqlGetAllRecentSessionInfo(OUT std::vector<module::SessionEntity>& sessionList) { try { CppSQLite3Statement stmt; stmt = m_pSqliteDB->compileStatement(getAllRecentSessionSql.c_str()); CppSQLite3Query query = stmt.execQuery(); while (!query.eof()) { module::SessionEntity sessionInfo; sessionInfo.sessionID = query.getStringField(1);; sessionInfo.sessionType = query.getIntField(2); sessionInfo.updatedTime = query.getIntField(3); sessionInfo.latestmsgId = query.getIntField(4); sessionInfo.latestMsgContent = query.getStringField(5); sessionInfo.latestMsgFromId = query.getStringField(6); sessionList.push_back(sessionInfo); query.nextRow(); } } catch (CppSQLite3Exception& sqliteException) { #ifdef _DEBUG MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND); #endif CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8); LOG__(ERR, _T("select failed,error msg:%s"), csErrMsg); return FALSE; } catch (...) { LOG__(ERR, _T("db unknown exception")); return FALSE; } return TRUE; }
void CVoxSQLite::GetEmailAddresses( int nProfileId, EmailAddresses& rList ) { CppSQLite3Buffer buf; buf.format( "SELECT * from EmailAddress WHERE profile_id = %d;", nProfileId ); try { CppSQLite3Statement stmt = m_db.compileStatement( (const char*)buf ); int nProfileId = 0; std::string type = ""; EmailAddress addr; CppSQLite3Query q = stmt.execQuery(); //Process record set. while (!q.eof()) { // "( [profile_id], [type], [email], [visiblity] nProfileId = q.getIntField(0); //Not part of Profile. type = q.getStringField( 1 ); //Use to determine which address to update. addr.setType ( q.getStringField(1) ); addr.setAddress ( q.getStringField(2) ); addr.setVisibility( (EnumVisibility::Visibility) q.getIntField(3) ); rList.Add( &addr ); q.nextRow(); } stmt.reset(); } catch (CppSQLite3Exception& e) { e.errorCode(); } }