Exemplo n.º 1
0
ObjectResultPtr UserNetworkPreloaderFactory::create(const MyUtil::IntSeq& ids)
{
	
	ObjectResultPtr results = new ObjectResult;

	ostringstream idsSql;

	idsSql<<" WHERE userid IN (";
	
	for(MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it)
	{
		mop::hi::svc::model::NetworkDataIPtr tempData = new mop::hi::svc::model::NetworkDataI;
		tempData->userId = *it;
		results->data.insert(make_pair(*it, tempData)); 
		
		if (it != ids.begin()) 
		{
			idsSql<< ", ";
		}
		idsSql << *it;
	}
	
	idsSql << ")";
	
	MCE_INFO("UserNetworkPreloaderFactory::create group -> id from: "<<idsSql.str());
	
	{
		BatchUserNetworkResultHandler handler(results );
		Statement sql;
		sql << "SELECT id, userid, stage, network_id, network_name," 
			<< 	" info_id, join_time, status" 
			<<  " FROM " << TABLE_NETWORK << idsSql.str();
		QueryRunner(DB_NETWORK , CDbRServer ).query(sql, handler);
	}
	{
		BatchUserHighSchoolResultHandler handler(results );
		Statement sql;
		sql << "SELECT id, userid, high_school_id, high_school_name," 
			<< 	" enroll_year, h_class1, h_class2, h_class3" 
			<<  " FROM " << TABLE_HIGH_SCHOOL_INFO << idsSql.str();
		QueryRunner(DB_NETWORK , CDbRServer ).query(sql, handler);
	}
	{
		BatchUserUniversityResultHandler handler(results );
		Statement sql;
		sql << "SELECT id, userid, university_id, university_name, dorm," 
			<< 	" department, type_of_course, enroll_year" 
			<<  " FROM " << TABLE_UNIVERSITY_INFO << idsSql.str();
		QueryRunner(DB_NETWORK , CDbRServer ).query(sql, handler);
	}
	{
		BatchUserWorkplaceResultHandler handler(results );
		Statement sql;
		sql << "SELECT id, userid, workplace_id, workplace_name, address," 
			<< 	" province, city_id, city_name, " 
			<< 	" description, join_year, join_month, " 
			<< 	" quit_year, quit_month, type, " 
			<< 	" job_title_id, position_id" 
			<<  " FROM " << TABLE_WORKPLACE_INFO << idsSql.str();
		QueryRunner(DB_NETWORK , CDbRServer ).query(sql, handler);
	}
	{
		BatchUserCollegeResultHandler handler(results );
		Statement sql;
		sql << "SELECT id, userid, college_id, college_name, department," 
			<< 	" enroll_year" 
			<<  " FROM " << TABLE_COLLEGE_INFO << idsSql.str();
		QueryRunner(DB_NETWORK , CDbRServer ).query(sql, handler);
	}
	{
		BatchUserElementarySchoolResultHandler handler(results );
		Statement sql;
		sql << "SELECT id, userid, elementary_school_id, elementary_school_name, elementary_school_year" 
			<<  " FROM " << TABLE_ELEMENTARY_SCHOOL_INFO << idsSql.str();
		QueryRunner(DB_NETWORK , CDbRServer ).query(sql, handler);
	}
	{
		BatchUserJuniorHighSchoolResultHandler handler(results );
		Statement sql;
		sql << "SELECT id, userid, junior_high_school_id, junior_high_school_name, junior_high_school_year" 
			<<  " FROM " << TABLE_JUNIOR_HIGH_SCHOOL_INFO << idsSql.str();
		QueryRunner(DB_NETWORK , CDbRServer ).query(sql, handler);
	}
	{
		BatchUserRegionResultHandler handler(results );
		Statement sql;
		sql << "SELECT id, userid, region_id, province_name, city_name" 
			<<  " FROM " << TABLE_REGION_INFO << idsSql.str();
		QueryRunner(DB_NETWORK , CDbRServer ).query(sql, handler);
	}
	
	return results;
}
Exemplo n.º 2
0
void MiniGroupWriterAdapter::reloadUsers(const MyUtil::IntSeq& userIds) {
  IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_mutex);
  _userIdSet.insert(userIds.begin(), userIds.end());
  _mutex.notify();
}
Exemplo n.º 3
0
ObjectResultPtr UserApiCachePreloaderFactory::create(const MyUtil::IntSeq& ids) {
	MCE_DEBUG("UserApiCachePreloaderLoaderI::create group -> id size: "<<ids.size());
        ObjectResultPtr result = new ObjectResult;
        {
                Statement sql;
				sql<<	"SELECT	id,status  FROM "<<	TABLE_USER_PASSPORT <<"	WHERE	id	IN (	";
                for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
                        if (it != ids.begin()) {
                                sql << ",";
                        }
                        sql << *it;
                }
                sql << ")";
                QueryRunner(DB_USER_PASSPORT,CDbRServer).query(sql, BatchUserPassportResultHandler(result));
        }
        {
                Statement sql;
	      sql<< "SELECT id,gender,birth_year,birth_month,birth_day,home_province, home_city FROM " << TABLE_USER_BORN << " WHERE id IN ( " ;
                for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
                        if (it != ids.begin()) {
                                sql << ", ";
                        }
                        sql << *it;
                }
                sql << ")";
                QueryRunner(DB_USER_BORN,CDbRServer).query(sql, BatchUserBornResultHandler(result));
        }
        {
                Statement sql;
				sql<< "SELECT id,stage,univ FROM " << TABLE_USER_STAGE << " WHERE id IN ( " ;
                for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
                        if (it != ids.begin()) {
                                sql << ", ";
                        }
                        sql << *it;
                }
                sql << ")";
                QueryRunner(DB_USER_STAGE,CDbRServer).query(sql, BatchUserStageResultHandler(result));
        }
        {
                Statement sql;
				sql<< "SELECT id,basic_config,status_config,profile_privacy FROM "<< TABLE_USER_CONFIG <<" WHERE id IN ( " ;
                for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
                        if (it != ids.begin()) {
                                sql << ",";
                        }
                        sql << *it;
                }
                sql << ")";
                QueryRunner(DB_USER_CONFIG,CDbRServer).query(sql, BatchUserConfigResultHandler(result));
        }
        {
                Statement sql;
				sql<<	"SELECT	id,mainurl,headurl,tinyurl FROM "<<	TABLE_USER_URL	<<"	WHERE	id	IN ( ";
                for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
                        if (it != ids.begin()) {
                                sql << ",";
                        }
                        sql << *it;
                }
                sql << ")";
                QueryRunner(DB_USER_URL,CDbRServer).query(sql, BatchUserUrlResultHandler(result));
        }
        {
                Statement sql;
				sql<<	"SELECT	id,name FROM "<<	TABLE_USER_NAME	<<"	WHERE	id	IN ( ";
                for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
                        if (it != ids.begin()) {
                                sql << ",";
                        }
                        sql << *it;
                }
                sql << ")";
                QueryRunner(DB_USER_NAME,CDbRServer).query(sql, BatchUserNameResultHandler(result));
        }
        {
                Statement sql;
				sql<<	"SELECT	id,auth FROM "<<	TABLE_USER_RIGHT	<<"	WHERE	id	IN (	";
                for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
                        if (it != ids.begin()) {
                                sql << ",";
                        }
                        sql << *it;
                }
                sql << ")";
                QueryRunner(DB_USER_RIGHT,CDbRServer).query(sql, BatchUserRightResultHandler(result));
        }
        {
                Statement sql;
				sql<<	"SELECT	id,state,level FROM "<<	TABLE_USER_STATE	<<"	WHERE	id	IN (	";
                for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
                        if (it != ids.begin()) {
                                sql << ",";
                        }
                        sql << *it;
                }
                sql << ")";
                QueryRunner(DB_USER_STATE,CDbRServer).query(sql, BatchUserStateResultHandler(result));
        }
        return result;
}
Exemplo n.º 4
0
MucActiveUserSeq RoomPool::GetRoomActiveUserSeq(const MucRoomIdPtr& roomid){
  MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> ROOMNAME = " << roomid->roomname);
  RoomMemberListPtr rmlptr;
  MucActiveUserSeq ans;

  MyUtil::IntSeq userids;
  rmlptr = GetMemberList(roomid);
  if(rmlptr){
    IceUtil::RWRecMutex::RLock lock(_rwmutex);
		userids = rmlptr->GetAllMembersSeq();
  }
  if(userids.empty()){
		MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> userids is empty so return");
    return ans;
  }
	JidSeqMap jseqmap;
	try{
	  MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> call OnlineCenterAdapter.getUsersJids userids.size = " << userids.size());
  	jseqmap = OnlineCenterAdapter::instance().getUsersJids(userids);
	}
	catch(Ice::Exception& e){
		MCE_WARN("RoomPool::GetRoomActiveUserSeq-->OnlineCenter::getUserJids-->line:"<<__LINE__<<" err:"<<e);
	}
	catch(std::exception& e){
		MCE_WARN("RoomPool::GetRoomActiveUserSeq--> call OnlineCenter.getUserJids ERR  line:"<<__LINE__<<" err:"<<e.what());
	}
  if(jseqmap.empty()){
    return ans;
  }
	TalkUserMap uinfoPtr;
	try{
		uinfoPtr = TalkCacheClient::instance().GetUserBySeqWithLoad(0, userids);
	}catch(Ice::Exception& e){
		MCE_WARN("RoomPool::GetRoomActiveUserSeq-->TalkCacheClient::GetUserBySeqWithLoad-->error:" << e);
	}
  MyUtil::IntSeq::iterator uidit = userids.begin();
  for(; uidit != userids.end(); ++uidit){
    int userid = (*uidit);
    JidSeqMap::const_iterator jit = jseqmap.find(userid);
    if(jit == jseqmap.end()){
      continue;
    }

    Permisions permision = PMember;
		try{
		  MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> CALL MucUserRoomAdapter.GetMemberPermision(" << userid << ", " << roomid->roomname << ")");
			MucMemberPtr m = MucUserRoomAdapter::instance().GetMemberPermision(userid, roomid);
			if(m){
				permision = m->permision;
			}
			else{
				MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> CALL MucUserRoomAdapter.GetMemberPermision's return is NULL, it means the user is not in the room so continue!");
				continue;
			}
		}
		catch(Ice::Exception& e){
			MCE_WARN("RoomPool::GetRoomActiveUserSeq-->MucUserRoom::GetMemberPermision-->line:"<<__LINE__<<" err:"<<e);
		}
		catch(std::exception& e){
			MCE_WARN("RoomPool::GetRoomActiveUserSeq--> call MucUserRoom.GetMemberPermision ERR  line:"<<__LINE__<<" err:"<<e.what());
		}

    string nickname = "";
    TalkUserMap::iterator infoit = uinfoPtr.find(userid);
    if(infoit == uinfoPtr.end()){
      //取不到用户的名称,默认用id 
      try{
        nickname = boost::lexical_cast<string>(userid);
      }
      catch (exception& e){
        MCE_WARN("RoomPool::GetRoomActiveUserSeq-->boost::lexical_cast to string exception  val = " << userid);
      }
    }
    else{
      TalkUserPtr u = infoit->second;
      nickname = u->name;
    }


    for (size_t index = 0; index < jit->second.size(); ++index) {
      char endpoint = jit->second.at(index)->endpoint[0];
      if(endpoint != 'T' && endpoint != 'W'){
        continue;
      }
      MucRoomIdPtr roomid = new MucRoomId();
      roomid->roomname = rmlptr->_roomname;
      roomid->domain = MUCDOMAIN;
      MucUserIdentityPtr identity = new MucUserIdentity();
      identity->roomid = roomid;
      identity->nickname = makeMucNickname(jit->second.at(index), nickname);
      identity->userid = userid;
      MucActiveUserPtr activeuserptr = new MucActiveUser();
      activeuserptr->jid = jit->second.at(index);
      activeuserptr->identity = identity;
      activeuserptr->permision = permision;
      ans.push_back(activeuserptr);
    }
  }
  MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> roomname = " << roomid->roomname << " ans.size = " << ans.size());
  return ans;
}