int CWorldDbmgr::UpdateArrayItemsToDb(T_VECTOR_OBJECT* p, CDbOper& db) { if( p->size() != 5 ) { return -1; } const string & itemName = VOBJECT_GET_SSTR((*p)[0]); const TDBID dbid = VOBJECT_GET_U64((*p)[1]); const uint16_t nBaseappId = VOBJECT_GET_U16((*p)[2]); const int32_t ref = VOBJECT_GET_I32((*p)[3]); const string& itemsData = VOBJECT_GET_SSTR((*p)[4]); //uint32_t l = itemsData.size(); //LogError("UpdateArrayItemsToDb", "[itemName = %s] [dbid = %d] [nBaseappId = %d] [ref = %d] [itemsData = %d]", // itemName.c_str(), dbid, nBaseappId, ref, itemsData.size()); //cout<<itemsData.c_str()<<endl; //cout<<itemsData.size()<<endl; CPluto* u = new CPluto(); u->FillBuff(itemsData.c_str(), itemsData.size()); u->SetMaxLen(u->GetLen()); string strErr; //cout<<"world update"<<endl; if( !db.UpdateArrayToDb(itemName, dbid, *u, nBaseappId, ref, strErr) ) { LogError("UpdateArrayToDb failure", "[error = %s] [status = %d]", strErr.c_str(), -1); CPluto* u1 = new CPluto; u1->Encode(MSGID_BASEAPP_UPDATE_ITEMS_CALLBACK); *u1 << ref << (uint16_t)1 << strErr<< EndPluto; CMailBox* mb = GetServerMailbox(nBaseappId); if(mb) { //cout<<"send pluto"<<endl; u1->SetMailbox(mb); //LogDebug("CWorldDbmgr::UpdateArrayItemsToDb", "u1.GenLen()=%d", u1->GetLen()); g_pluto_sendlist.PushPluto(u1); } else { delete u1; LogWarning("CWorldDbmgr::UpdateArrayItemsToDb", ""); } } delete u; //cout<<"do success update"<<endl; return 0; }
int CWorldDbmgr::TableUpdateBatch(T_VECTOR_OBJECT* p, CDbOper& db) { LogDebug("CWorldDbmgr::TableUpdateBatch", ""); if( p->size() != 5 ) { return -1; } const string & itemName = VOBJECT_GET_SSTR((*p)[0]); const string & uniqKey = VOBJECT_GET_SSTR((*p)[1]); const uint16_t nBaseappId = VOBJECT_GET_U16((*p)[2]); const int32_t ref = VOBJECT_GET_I32((*p)[3]); const string& itemsData = VOBJECT_GET_SSTR((*p)[4]); //cout<<itemsData.c_str()<<endl; //cout<<itemsData.size()<<endl; CPluto* u = new CPluto(); u->FillBuff(itemsData.c_str(), itemsData.size()); u->SetMaxLen(u->GetLen()); string strErr; int ret = db.UpdateBatch(itemName, uniqKey, *u, nBaseappId, ref, strErr); //cout<<"world update"<<endl; if( 0 == ret) { delete u; return 0; } LogError("UpdateArrayToDb failure", "[error = %s] [ret = %d]", strErr.c_str(), ret); delete u; CPluto* u1 = new CPluto; u1->Encode(MSGID_BASEAPP_TABLE_UPDATE_BATCH_CB); *u1 << ref << (uint16_t)ret << EndPluto; CMailBox* mb = GetServerMailbox(nBaseappId); if(mb) { //cout<<"send pluto"<<endl; u1->SetMailbox(mb); //LogDebug("CWorldDbmgr::UpdateArrayItemsToDb", "u1.GenLen()=%d", u1->GetLen()); g_pluto_sendlist.PushPluto(u1); } else { delete u1; LogWarning("CWorldDbmgr::UpdateArrayItemsToDb", ""); } return -11; }
int CWorldDbmgr::IncremantalUpdateItems(T_VECTOR_OBJECT* p, CDbOper& db) { if ( p->size() != 5 ) { LogError("CWorldDbmgr::IncremantalUpdateItems", "p->size()=%d", p->size()); return -1; } const string & tblName = VOBJECT_GET_SSTR((*p)[0]); const string & optName = VOBJECT_GET_SSTR((*p)[1]); const uint16_t nBaseappId = VOBJECT_GET_U16((*p)[2]); const int32_t ref = VOBJECT_GET_I32((*p)[3]); const string& itemsData = VOBJECT_GET_SSTR((*p)[4]); LogDebug("CWorldDbmgr::IncremantalUpdateItems", "tblName=%s;optName=%s;nBaseappId=%d;ref=%d", tblName.c_str(), optName.c_str(), nBaseappId, ref); CPluto* u = new CPluto(); u->FillBuff(itemsData.c_str(), itemsData.size()); u->SetMaxLen(u->GetLen()); string strErr; uint8_t ret = -1; if ( optName.compare("update") == 0 ) { ret = db.IncrementalUpdateItems(tblName, nBaseappId, *u, ref, strErr); if( ret != 0 ) { CPluto* u1 = new CPluto; u1->Encode(MSGID_BASEAPP_UPDATE_ITEMS_CALLBACK); *u1 << ref << (uint16_t)1 << strErr<< EndPluto; CMailBox* mb = GetServerMailbox(nBaseappId); if(mb) { u1->SetMailbox(mb); //LogDebug("CWorldDbmgr::IncremantalUpdateItems", "u1.GenLen()=%d", u1->GetLen()); g_pluto_sendlist.PushPluto(u1); } else { delete u1; u1 = NULL; LogWarning("CWorldDbmgr::IncremantalUpdateItems", ""); } } delete u; u = NULL; return 0; } else if( optName.compare("insert") == 0 ) { ret = db.IncremantalInsertItems(tblName, nBaseappId, *u, ref, strErr); if( ret != 0 ) { CPluto* u1 = new CPluto; u1->Encode(MSGID_BASEAPP_INSERT_ITEMS_CALLBACK); *u1 << ref << (uint16_t)1 << strErr<< EndPluto; CMailBox* mb = GetServerMailbox(nBaseappId); if(mb) { u1->SetMailbox(mb); //LogDebug("CWorldDbmgr::IncremantalInsertItems", "u1.GenLen()=%d", u1->GetLen()); g_pluto_sendlist.PushPluto(u1); } else { delete u1; u1 = NULL; LogWarning("CWorldDbmgr::IncremantalInsertItems", ""); } } delete u; u = NULL; return 0; } }