Exemple #1
0
/**
 * \brief 从数据库中加载争夺目标记录
 * \return true 加载成功
 */
bool CCityM::load()
{
  DBFieldSet* city = SessionService::metaData->getFields("CITY");

  if (city)
  {
    connHandleID handle = SessionService::dbConnPool->getHandle();

    if ((connHandleID)-1 == handle)
    {
      Xlogger->error("不能获取数据库句柄");
      return false;
    }

    DBRecordSet* recordset = NULL;

    if ((connHandleID)-1 != handle)
    {
      recordset = SessionService::dbConnPool->exeSelect(handle,city,NULL,NULL);
    }

    SessionService::dbConnPool->putHandle(handle);

    if (recordset)
    {
      for (DWORD i=0; i<recordset->size(); i++)
      {
        DBRecord* rec = recordset->get(i);


        CCity* pCity = new CCity();

        if (pCity)
        {
          pCity->init(rec);

          if (CUnionM::getMe().getUnionByID(pCity->dwUnionID) == NULL)
          {//如果拥有者
            pCity->dwUnionID = 0;
            pCity->isAward = 0;
            pCity->dwGold = 50000; 
            Xlogger->info("帮会已不存在,城市归属清空");
          }
        }


        citys.push_back(pCity);
      }

      SAFE_DELETE(recordset)
    }
  }
  else
  {
Exemple #2
0
bool CAllyM::loadAllyFromDB()
{
  DBFieldSet* ally = SessionService::metaData->getFields("ALLY");

  if (ally)
  {       
    connHandleID handle = SessionService::dbConnPool->getHandle();

    if ((connHandleID)-1 == handle)
    {       
      Zebra::logger->error("不能获取数据库句柄");
      return false;
    }               

    DBRecordSet* recordset = NULL;

    if ((connHandleID)-1 != handle)
    {
      recordset = SessionService::dbConnPool->exeSelect(handle,ally,NULL,NULL);
    }

    SessionService::dbConnPool->putHandle(handle);
    if (recordset)
    {
      for (DWORD i=0; i<recordset->size(); i++)
      {
        DBRecord* rec = recordset->get(i);
        CAlly* pAlly = new CAlly();

        if (pAlly)
        {
          pAlly->init(rec);

          if (this->findAlly(pAlly->dwCountryID,pAlly->dwAllyCountryID) != NULL)
          {
            Zebra::logger->error("[国家联盟]: %d 与 %d 有重复的联盟数据.",
                pAlly->dwCountryID,pAlly->dwAllyCountryID);
            SAFE_DELETE(pAlly);
          }
          else
          {
            rwlock.wrlock();
            allies.push_back(pAlly);
            rwlock.unlock();
          }
        }
      }

      SAFE_DELETE(recordset)
    }
  }
  else
  {
Exemple #3
0
bool Top100::init()
{
  DBFieldSet* fs = MiniService::metaData->getFields("MINIGAME");

  if (fs)
  {
    connHandleID handle = MiniService::dbConnPool->getHandle();

    if ((connHandleID)-1 == handle)
    {
      Xlogger->error("Top100::init()不能获取数据库句柄");
      return false;
    }

    DBRecord order;
    order.put("score","desc");

    DBRecordSet *recordset = MiniService::dbConnPool->exeSelect(handle,fs,NULL,NULL,&order,200);

    DWORD count=0;
    if (recordset)
    {
      for (DWORD i=0; i<recordset->size() && count<120; i++)
      {
        DBRecord* rec = recordset->get(i);

        Cmd::MiniUserData d;
        strncpy(d.name,(const char*)rec->get("name"),MAX_NAMESIZE-1);
        d.id = rec->get("charid");
        d.countryID = rec->get("country");
        d.face = rec->get("face");
        d.score.gameType = rec->get("gametype");
        d.score.win = rec->get("win");
        d.score.lose = rec->get("lose");
        d.score.draw = rec->get("draw");
        d.score.score = rec->get("score");

        if (d.score.win||d.score.lose||d.score.draw||d.score.score)
        {
          top100.push_back(d);
          Xlogger->debug("Top100  %s(%u)  score=%d",d.name,d.id,d.score.score);
        }
      }

      SAFE_DELETE(recordset)
    }

    MiniService::dbConnPool->putHandle(handle);
    return true;
  }
  return false;
}
/**
 * \brief 从数据库中加载争夺目标记录
 * \return true 加载成功
 */
bool CDareRecordM::load()
{
  DBFieldSet* dareRecord = SessionService::metaData->getFields("DARERECORD");
  
  if (dareRecord)
  {
    connHandleID handle = SessionService::dbConnPool->getHandle();

    if ((connHandleID)-1 == handle)
    {
      Zebra::logger->error("不能获取数据库句柄");
      return false;
    }

    DBRecordSet* recordset = NULL;
    DBRecord rec;
    rec.put("daretime","DESC");

    if ((connHandleID)-1 != handle)
    {
      recordset = SessionService::dbConnPool->exeSelect(handle,dareRecord,NULL,NULL,&rec,100);
    }

    SessionService::dbConnPool->putHandle(handle);

    if (recordset)
    {
      for (DWORD i=0; i<recordset->size(); i++)
      {
        DBRecord* rec = recordset->get(i);
        CDareRecord* pDareRecord = new CDareRecord();

        if (pDareRecord)
        {
          pDareRecord->init(rec);
        }
          
        vDareRecord.push_back(pDareRecord);
      }

      SAFE_DELETE(recordset)
    }
  }
  else
  {
Exemple #5
0
bool CVoteM::load()
{
  DBFieldSet* vote = SessionService::metaData->getFields("VOTE");
  
  if (vote)
  {
    connHandleID handle = SessionService::dbConnPool->getHandle();

    if ((connHandleID)-1 == handle)
    {
      Zebra::logger->error("不能获取数据库句柄");
      return false;
    }

    DBRecordSet* recordset = NULL;

    if ((connHandleID)-1 != handle)
    {
      recordset = SessionService::dbConnPool->exeSelect(handle,vote,NULL,NULL);
    }

    SessionService::dbConnPool->putHandle(handle);

    if (recordset)
    {
      for (DWORD i=0; i<recordset->size(); i++)
      {
        DBRecord* rec = recordset->get(i);
        CVote* pVote = new CVote();

        if (pVote)
        {
          pVote->init(rec);
          pVote->loadItemFromDB();
        }
          
        votes.push_back(pVote);
      }

      SAFE_DELETE(recordset)
    }
  }
  else
  {
bool RecommendM::load()
{
  DBFieldSet* recommend = SessionService::metaData->getFields("RECOMMEND");
  
  if (recommend)
  {
    connHandleID handle = SessionService::dbConnPool->getHandle();

    if ((connHandleID)-1 == handle)
    {
      Xlogger->error("不能获取数据库句柄");
      return false;
    }

    DBRecordSet* recordset = NULL;

    if ((connHandleID)-1 != handle)
    {
      recordset = SessionService::dbConnPool->exeSelect(handle,recommend,NULL,NULL);
    }

    SessionService::dbConnPool->putHandle(handle);

    if (recordset)
    {
      for (DWORD i=0; i<recordset->size(); i++)
      {
        DBRecord* rec = recordset->get(i);
        Recommend* pRecommend = new Recommend();

        if (pRecommend)
        {
          pRecommend->init(rec);
          pRecommend->loadRecommendSubFromDB();
          this->addRecommend(pRecommend->id,pRecommend);
        }
      }

      SAFE_DELETE(recordset)
    }
  }
  else
  {