bool SchemaManager::checkDispatch(const MyUtil::Str2StrMap& props) const { IceUtil::RWRecMutex::RLock lock(_mutex); MyUtil::Str2StrMap::const_iterator it_to = props.find("to"); MyUtil::Str2StrMap::const_iterator it_tominigroup = props.find("tominigroup"); if (it_to == props.end() && it_tominigroup == props.end()) { MCE_WARN("SchemaManager::checkDispatch no target IDs"); return false; //throw KeyAbsentException("no to id and tominigroup id"); } string to_ids; if (it_to != props.end()) { to_ids = it_to->second; } else if(it_tominigroup != props.end()) { to_ids.append("group["); to_ids.append(it_tominigroup->second); } else { to_ids = "NULL"; } MCE_INFO("SchemaManager::checkDispatch --> to_ids:" << to_ids); MyUtil::Str2StrMap::const_iterator it_schema = props.find("schema_id"); if (it_schema == props.end()) { MCE_WARN("SchemaManager::checkDispatch --> no schema id, to:" << to_ids); return false; //throw KeyAbsentException("schema_id"); } MyUtil::Str2StrMap::const_iterator it_type = props.find("type"); if (it_type == props.end()) { MCE_WARN("SchemaManager::checkDispatch --> no type, to:" << to_ids); return false; //throw KeyAbsentException("type"); } int schemaid = 0; try { schemaid = boost::lexical_cast<int>(it_schema->second); } catch (boost::bad_lexical_cast & e) { MCE_WARN("SchemaManager::checkDispatch --> schemaid cast exception, to:" << to_ids); return false; //throw KeyAbsentException("wrong schema id "); } SchemaMap::const_iterator i = _schema_map.find(schemaid); if (i == _schema_map.end()) { MCE_WARN("SchemaManager::checkDispatch --> wrong schemaid:" << schemaid << " to:" << to_ids); return false; //throw KeyAbsentException("wrong schema id"); } set<string>::iterator k = i->second.keys.begin(); for (; k != i->second.keys.end(); ++k) { if (props.find(*k) == props.end()) { MCE_WARN("SchemaManager::checkDispatch --> not match key schemaid:" << schemaid << " key:" << *k << " to:" << to_ids); return false; //throw KeyAbsentException(*k); } } return true; }
void DispatchNManagerI::SpecialProcess(const MyUtil::Str2StrMap& props, int & task_level, bool& store) { if (props.find("schema_id")->second == "48") { task_level = kTaskLevelActivity;} //干旱捐款活动,应该没用了 props.find("schema_id")->second; Str2StrMap::const_iterator i = props.find("schema_id"); if (i != props.end() && i->second == "193") { store = false;//193是A在群回复B(无气泡,通知用) } }
void VipMemberDataWriterI::setVipMemberData(Ice::Int id, const MyUtil::Str2StrMap& props, const Ice::Current & current) { std::ostringstream inMsg; inMsg<<"id = "<<id; MyUtil::InvokeClient ic = MyUtil::InvokeClient::create(current, inMsg.str(), MyUtil::InvokeClient::INVOKE_LEVEL_INFO); //去掉map中的用户id MyUtil::Str2StrMap::iterator it = const_cast<MyUtil::Str2StrMap&>(props).find("UID"); if(it!=props.end()) { const_cast<MyUtil::Str2StrMap&>(props).erase(it); } MyUtil::Str2StrMap::const_iterator tIt = props.find("TYPE"); if(tIt == props.end()) { MCE_WARN("VipMemberDataWriterI::setVipMemberData Exception no type in props for id " << boost::lexical_cast<std::string>(id)); return; } MyUtil::Str2StrMap filter; filter["uid"] = boost::lexical_cast<string>(id); filter["type"] = tIt->second; { xce::tempmutex::Lock lock(_tempMutexManager,id); com::xiaonei::xce::QueryRunner(DB_MEMBERS,com::xiaonei::xce::CDbWServer).execute(com::xiaonei::xce::Statement::buildUpdate(TABLE_VIP_MEMBER, filter, props)); xce::adapter::vipmemberdata::VipMemberDataReaderAdapter::instance().setVipMemberData(id,props); } }
void VipMemberDataWriterI::createVipMemberData(const MyUtil::Str2StrMap& props, const Ice::Current & current) { MyUtil::InvokeClient ic = MyUtil::InvokeClient::create(current, "", MyUtil::InvokeClient::INVOKE_LEVEL_INFO); MyUtil::Str2StrMap::const_iterator it = props.find("UID"); int id; if (it == props.end()) { MCE_WARN("VipMemberDataWriterI::createVipMemberData , Exception no id!"); return; } else { id = boost::lexical_cast<int>(it->second); } it = props.find("TYPE"); if (it == props.end()) { MCE_WARN("VipMemberDataWriterI::createVipMemberData , Exception no type!"); return; } { xce::tempmutex::Lock lock(_tempMutexManager,id); com::xiaonei::xce::QueryRunner(DB_MEMBERS,com::xiaonei::xce::CDbWServer).execute(com::xiaonei::xce::Statement::buildInsert(TABLE_VIP_MEMBER, props)); VipMemberMemDataIPtr result = new VipMemberMemDataI; com::xiaonei::xce::Statement sql; sql << "SELECT * FROM " << TABLE_VIP_MEMBER << " WHERE uid = '" << id << "'"; VipMemberMemDataResultHandlerI handler(result); com::xiaonei::xce::QueryRunner(DB_MEMBERS, com::xiaonei::xce::CDbWServer).query(sql, handler); if (result->data.empty()) { MCE_WARN("VipMemberDataWriterI::createVipMemberData , Exception NoSuchVipMemberData id = " << id); return; } xce::adapter::vipmemberdata::VipMemberDataReaderAdapter::instance().setData(id, result); } }
Ice::Long DispatchManagerI::GetServreIndex(Ice::Long nid, const MyUtil::Str2StrMap& props) { Ice::Long server_index = nid; MyUtil::Str2StrMap::const_iterator it = props.find("feed_source"); if (it != props.end()) { try { server_index = boost::lexical_cast<Ice::Long>(it->second); } catch (boost::bad_lexical_cast & e) {} } return server_index; }
void UserDoingManagerI::createUserDoing(const MyUtil::Str2StrMap& props, const Ice::Current& current ) { MCE_INFO("UserPassportManagerI::createUserDoing" << " " << current.con->toString().substr(current.con->toString().find("remote",25))); int id; MyUtil::Str2StrMap::const_iterator it = props.find("ID"); if(it!=props.end()) { id=boost::lexical_cast<Ice::Int>(it->second); } else { MCE_WARN("UserDoingManagerI::createUserDoing CreateUserDoingException::Can find userID in props"); return; } UserDoingAdapter::instance().getUserDoingManager(id)->createUserDoing(props); }
void UserContactManagerI::createUserContact(const MyUtil::Str2StrMap& properities, const Ice::Current & current) { InvokeClient::create(current, "", InvokeClient::INVOKE_LEVEL_INFO); MyUtil::Str2StrMap::const_iterator itr = properities.find("ID"); int id; if (itr == properities.end()) { MCE_WARN("UserContactManagerI::createUserContact, Exception[NoId]"); return; } else { id = boost::lexical_cast<int>(itr->second); } UserContactWriterAdapter::instance().createUserContact(id, properities); }
void DispatchManagerI::deliverWebpager(const MyUtil::Str2StrMap& props, const Ice::Current&) { if (!SchemaManager::instance().checkDispatch(props)) { MCE_WARN("DispatchManagerI::deliverWebpager illegal input"); return; } Ice::Long nid = createNotifyId(); MCE_INFO("DispatchManagerI::deliverWebpager nid=" << nid << " to=" << props.find("to")->second); Ice::Long server_index = GetServreIndex(nid, props); try { NotifyDispatcherNAdapter::instance().dispatchN(server_index, nid, false, props); } catch(Ice::Exception& e) { MCE_WARN("NotifyDispatcherNAdapter error : " << e); } }
void Icon2UrlDataWriterI::createIcon2UrlData(const MyUtil::Str2StrMap& props, const Ice::Current & current) { MyUtil::InvokeClient ic = MyUtil::InvokeClient::create(current, "", MyUtil::InvokeClient::INVOKE_LEVEL_INFO); MyUtil::Str2StrMap::const_iterator it = props.find("ID"); int id; if (it == props.end()) { MCE_WARN("Icon2UrlDataWriterI::createIcon2UrlData , Exception no id!"); return; } else { id = boost::lexical_cast<int>(it->second); } { xce::tempmutex::Lock lock(_tempMutexManager,id); com::xiaonei::xce::QueryRunner(DB_MEMBERS,com::xiaonei::xce::CDbWServer).execute(com::xiaonei::xce::Statement::buildInsert(TABLE_ICON_URL, props)); Icon2UrlDataIPtr result = new Icon2UrlDataI; com::xiaonei::xce::Statement sql; sql << "SELECT * FROM " << TABLE_ICON_URL << " WHERE id = '" << id << "'"; Icon2UrlDataResultHandlerI handler(result); com::xiaonei::xce::QueryRunner(DB_MEMBERS, com::xiaonei::xce::CDbWServer).query(sql, handler); if (id != result->iconId) { MCE_WARN("Icon2UrlDataWriterI::createIcon2UrlData , Exception NoSuchIcon2UrlData id = " << id); return; } xce::adapter::icon2urldata::Icon2UrlDataReaderAdapter::instance().setData(id, result); } }
UserConfigInfoPtr xce::adapter::UserConfigInfo::parse(const MyUtil::Str2StrMap& data) { Str2StrMap::const_iterator i; i = data.find("ID"); if (i != data.end()) { userId_ = boost::lexical_cast<int>(i->second); } i = data.find("BASIC_CONFIG"); if (i != data.end()) { basicConfig_ = boost::lexical_cast<int>(i->second); } i = data.find("POKE_CONFIG"); if (i != data.end()) { pokeConfig_ = boost::lexical_cast<int>(i->second); } i = data.find("REQUEST_FRIEND_CONFIG"); if (i != data.end()) { requestFriendConfig_ = boost::lexical_cast<int>(i->second); } i = data.find("PHOTO_CONFIG"); if (i != data.end()) { photoConfig_ = boost::lexical_cast<int>(i->second); } i = data.find("MESSAGE_CONFIG"); if (i != data.end()) { messageConfig_ = boost::lexical_cast<int>(i->second); } i = data.find("EMAIL_CONFIG"); if (i != data.end()) { emailConfig_ = boost::lexical_cast<long>(i->second); } i = data.find("BROWSE_CONFIG"); if (i != data.end()) { browseConfig_ = boost::lexical_cast<int>(i->second); } i = data.find("RECV_FEED_CONFIG"); if (i != data.end()) { recvFeedConfig_ = i->second; } i = data.find("SEND_FEED_CONFIG"); if (i != data.end()) { sendFeedConfig_ = i->second; } i = data.find("WANT_SEE_CSS"); if (i != data.end()) { wantSeeCss_ = boost::lexical_cast<short>(i->second); } i = data.find("DISPLAY_MENU_LIST"); if (i != data.end()) { displayMenuList_ = i->second; } i = data.find("MORE_MENU_LIST"); if (i != data.end()) { moreMenuList_ = i->second; } i = data.find("PROFILE_PRIVACY"); if (i != data.end()) { profilePrivacy_ = i->second; } i = data.find("STATUS_CONFIG"); if (i != data.end()) { statusConfig_ = boost::lexical_cast<int>(i->second); } return this; }
void DispatchManagerI::dispatch(const MyUtil::Str2StrMap& props, const Ice::Current& cur) { TimeStat ts; if (!SchemaManager::instance().checkDispatch(props)) { MCE_WARN("DispatchManagerI::dispatch illegal input"); return; } if(props.find("type")->second == "213"){ MCE_WARN("type = 213. not send. " << GetIp(cur)); return ; } Ice::Int from_uid = 0; try { from_uid = boost::lexical_cast<Ice::Int>(props.find("from")->second); } catch (boost::bad_lexical_cast & e) { return; } // TODO 取消注释 // UserPassportDataPtr data = UserPassportAdapter::instance().getUserPassport(from_uid); // if (data && (data->safeStatus & 0x07C0)) { // MCE_INFO("user blocked : " << from_uid); // return; // } UserPassportInfoPtr data; try { data = UserPassportAdapter::instance().getUserPassport(from_uid); } catch(Ice::Exception& e) { MCE_WARN("NotifyDispatcherNAdapter call UserPassportAdapter from id " << from_uid <<" error : " << e); } if (data && (data->safestatus() & 0x07C0)) { MCE_WARN("user blocked : " << from_uid); return; } Ice::Long nid = createNotifyId(); Ice::Long server_index = GetServreIndex(nid, props); try { NotifyDispatcherNAdapter::instance().dispatchN(server_index, nid, true, props); } catch(Ice::Exception& e) { MCE_WARN("NotifyDispatcherNAdapter error : " << e); } MyUtil::Str2StrMap::const_iterator it = props.find("tominigroup"); string groups = "NULL"; if(it != props.end()){ groups = it->second; } MCE_INFO("DispatchManagerI::dispatch nid:" << nid << " to:" << props.find("to")->second << " schema:" << props.find("schema_id")->second << " type:" << props.find("type")->second << " from:" << props.find("from")->second << " idx:" << server_index << " tog:" << groups << " cost:" << ts.getTime() << " " << GetIp(cur) ); }