//检查是否员工电话是否已存在 bool Utils::CheckTel(MYSQL mysql,SQLUtils* sqlutils, CString staff_tel) { MYSQL_RES *result = NULL; mysql_init(&mysql); string serverName = sqlutils->getServerName(); string userName = sqlutils->getUserName(); string password = sqlutils->getPassword(); string databaseName = sqlutils->getDatabaseName(); int port = sqlutils->getPort(); if (mysql_real_connect(&mysql,serverName.c_str(),userName.c_str(),password.c_str(),databaseName.c_str(),port,NULL,0)) { string tel(staff_tel.GetBuffer(staff_tel.GetLength())); string sql = "select staff_tel from t_staff where staff_tel="; sql.append(1,'\'').append(tel).append(1,'\''); mysql_query(&mysql,sql.c_str()); result = mysql_store_result(&mysql); int rowcount = mysql_num_rows(result); if (rowcount > 0) { return true; } }else{ AfxMessageBox("系统出错"); } return false; }
void MsgDispatcher::addMsg(long int delay, int sender, int receiver, int msg, void* extraInfo) { auto E_receiver = EMGR->getEntityByID(receiver); auto Msg = MsgType(msg); assert(E_receiver&&"recevier cannot be found"); Telegram tel(clock(), sender, receiver, Msg, extraInfo); if (delay==0) { } else { long int currentTime = clock(); tel.dispatchTime_ = delay + currentTime; } this->_msgQueue.insert(tel); }
void S411FeedBack::submit(CCObject * pSender) { AppDelegate::loadingLabel = CCLabelTTF::create("提交中", s1FontName_macro, 40); AppDelegate::loadingLabel->setPosition(ccp(visibleSize.width/2,visibleSize.height/2)); AppDelegate::loadingLabel->setColor(ccRED); this->addChild(AppDelegate::loadingLabel,zNum+1000); string name(nameBox->getText()); string sex; if (isMale) { sex = "男"; } else { sex = "女"; } string tel(telBox->getText()); if (name.size()==0||tel.size()==0) { AppDelegate::loadingLabel ->setString("请完整填写必填信息"); this->schedule(schedule_selector(S411FeedBack::time),1.0f,false,0.0); return; } string mobilePhone(mobilePhoneBox->getText()); string mail(mailBox->getText()); string msn(msnBox->getText()); string address(addressBox->getText()); //textView->setTextViewString(""); string yanzheng(yanzhengBox->getText()); string submitStr(submitBox->getText()); string requestSr = "http://www.jrsp.cn/app/iwant.php?name="+name+"&sex="+sex+"&phone="+tel+"&mobile="+mobilePhone+"&email="+mail+"&qq="+msn+"&address="+address+"&message="+submitStr; requestSr = PersonalApi::string_replace(requestSr," ","%20"); requestSr = PersonalApi::string_replace(requestSr,"\n","%0D"); PostToUrl(requestSr.c_str(),"name","name"); //setButtonEnabel(true); }
void System<EffectsComp>::deliverMessage_(Message message) { std::cout << "Delivering message to EffectsComps" << std::endl; //check if target entity is registered with this subsystem EffectsComp* targetComponent = getComponent(message.getTargetId()); std::cout << "Source component: " << message.getSourceId() << std::endl; std::cout << "Target component: " << message.getTargetId() << std::endl; if(targetComponent==NULL) { return; } Parameters params = message.getParameters(); //read message! std::string mainCmd = params[1]; if (mainCmd=="add") //e.g. add SpeedBoost { std::cout << "Message params: " << params.size() << std::endl; //check if an effect of this type already exists and if so, end that one before applying this one std::string effectName = params[2]; std::string effectString = params[3]; if (targetComponent->hasEffect(effectName)) { //carry out onEnd messages std::vector<Parameters> endParams = targetComponent->getEffect(effectName)->getOnEnd(); std::vector<Parameters>::iterator iParams = endParams.begin(); while(iParams!= endParams.end()) { if(iParams->size()>0) { Message msg(message.getSourceId(), targetComponent->getId(), *iParams); Telegram tel(message.getSourceId(), targetComponent->getId(), 0.0, msg); core_->getMessageCentre()->addTelegram(tel); } ++iParams; } } //replace effect targetComponent->addEffect(effectName, effectString); //carry out onBegin messages std::vector<Parameters> beginParams = targetComponent->getEffect(effectName)->getOnBegin(); std::vector<Parameters>::iterator iParams = beginParams.begin(); while(iParams!= beginParams.end()) { if(iParams->size()>0) { Message msg(message.getSourceId(), targetComponent->getId(), *iParams); Telegram tel(message.getSourceId(), targetComponent->getId(), 0.0, msg); std::cout << "Sending onBegin effect message to " << (*iParams)[0]<< std::endl; core_->getMessageCentre()->addTelegram(tel); } ++iParams; } } // if (mainCmd=="changeSprite") // { // targetComponent->setSprite(core_->getStore()->getImage(params[2])); //// targetComponent->setLocalDestination(Vector2d(atoi(params[2].c_str()),atoi(params[3].c_str()))); // } // // else if (mainCmd=="changeCurrBy") // { // targetComponent->setCurrent(targetComponent->getCurrent() + atoi(params[2].c_str())); // } }
void System<EffectsComp>::update(double elapsed) { std::map<ObjectId,EffectsComp>::iterator iCom = components_.begin(); while(iCom!=components_.end()) { EffectsComp* effectsComp = &iCom->second; EffectsMap* effectsMap = effectsComp->getEffects(); // std::cout << "Address of effectsMap: "<< effectsMap << std::endl; // std::cout << "copy of effects map size : "<< effectsMap->size() << std::endl; // std::cout << "orig effects map size : " << effectsComp->getEffects()->size() << std::endl; //update each effect in component as necessary EffectsMap::iterator iEffect = effectsMap->begin(); while(iEffect!=effectsMap->end()) { //update timer if necessary if(iEffect->second->hasDuration()) { iEffect->second->updateDuration(elapsed); //check if timer has expired if (iEffect->second->hasExpired()) { //do on end messages std::vector<Parameters> endParams = iEffect->second->getOnEnd(); std::vector<Parameters>::iterator iParams = endParams.begin(); while(iParams!= endParams.end()) { if(iParams->size()>0) { Message msg(effectsComp->getId(), effectsComp->getId(), *iParams); Telegram tel(effectsComp->getId(), effectsComp->getId(), 0.0, msg); core_->getMessageCentre()->addTelegram(tel); } ++iParams; } //delete params effectsMap->erase(iEffect++); continue; } } //carry out onUpdate messages std::vector<Parameters> updateParams = iEffect->second->getOnUpdate(); std::vector<Parameters>::iterator iParams = updateParams.begin(); while(iParams!= updateParams.end()) { if(iParams->size()>0) { Message msg(effectsComp->getId(), effectsComp->getId(), *iParams); Telegram tel(effectsComp->getId(), effectsComp->getId(), 0.0, msg); core_->getMessageCentre()->addTelegram(tel); } ++iParams; } ++iEffect; } ++iCom; } }
void MainDlg::OnLbnSelchangeUserList() { int curindex = _userList.GetCurSel(); if( curindex >= 0 ) { int userNo = (int)_userList.GetItemData( curindex ); UserList & userInfoList = Network::GetInstance().GetUserInfoList(); int index = Network::GetInstance().GetIndexForUserNo( userNo ); UserInfo & userInfo = userInfoList[ index ]; std::string picPath = "../Test/pic/" + userInfo._pic; CString age( userInfo._age.c_str() ); CString sex( userInfo._sex.c_str() ); CString tall( userInfo._tall.c_str() ); CString weight( userInfo._weight.c_str() ); CString blood( userInfo._blood.c_str() ); CString tel( userInfo._tel.c_str() ); CString pic( picPath.c_str() ); _userDataList.DeleteAllItems(); LV_ITEM lvItem; CString itemText; itemText = "나이"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 0; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)age; _userDataList.SetItem(&lvItem); itemText = "성별"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 1; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 1; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)sex; _userDataList.SetItem(&lvItem); itemText = "키"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 2; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 2; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)tall; _userDataList.SetItem(&lvItem); itemText = "몸무게"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 3; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 3; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)weight; _userDataList.SetItem(&lvItem); itemText = "혈액형"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 4; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 4; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)blood; _userDataList.SetItem(&lvItem); itemText = "전화"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 5; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 5; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)tel; _userDataList.SetItem(&lvItem); HBITMAP hBmp = (HBITMAP)LoadImage(NULL, pic, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); _image.SetBitmap( hBmp ); // m_wndView->SetUserNo( userNo ); // OnCbnSelchangeComboHour(); } }
int main(int argc, char* argv[], char* envp[]){ //silence warnings (void)envp; if(argc != 4){ printf("Wrong number of arguments. Usage %s <local port> <remote host> <remote port> \n", argv[0]); return 1; } int listenPort = atoi(argv[1]); //timing synchronization //apps will signal when they're all done pthread_mutex_init(&count_mutex, NULL); pthread_cond_init (&count_threshold_cv, NULL); struct timeval t1; struct timeval t2; // set up network ppETH eth(1, listenPort, argv[3], argv[2]); ppIP ip(2); ppTCP tcp(3); ppUDP udp(4); ppFTP ftp(5); ppTEL tel(6); ppRDP rdp(7); ppDNS dns(8); ftpAPP ftpApplication(5, true); telAPP telApplication(6, true); rdpAPP rdpApplication(7, true); dnsAPP dnsApplication(8, true); eth.registerHLP(ip); ip.registerHLP(tcp); ip.registerHLP(udp); tcp.registerHLP(ftp); tcp.registerHLP(tel); udp.registerHLP(rdp); udp.registerHLP(dns); dns.registerHLP(dnsApplication); ftp.registerHLP(ftpApplication); rdp.registerHLP(rdpApplication); tel.registerHLP(telApplication); ftp.registerLLP(tcp); tel.registerLLP(tcp); rdp.registerLLP(udp); dns.registerLLP(udp); tcp.registerLLP(ip); udp.registerLLP(ip); ip.registerLLP(eth); dnsApplication.registerLLP(dns); ftpApplication.registerLLP(ftp); rdpApplication.registerLLP(rdp); telApplication.registerLLP(tel); ip.start(); tcp.start(); udp.start(); ftp.start(); tel.start(); rdp.start(); dns.start(); //make sure everything is set before we start timing sleep(5); gettimeofday(&t1, NULL); // dnsApplication.startListen(); // ftpApplication.startListen(); // rdpApplication.startListen(); // telApplication.startListen(); dnsApplication.startApplication(); ftpApplication.startApplication(); rdpApplication.startApplication(); telApplication.startApplication(); //wait for apps to finish and then stop timing or whatever pthread_mutex_lock(&count_mutex); while (count<numApps*2) { pthread_cond_wait(&count_threshold_cv, &count_mutex); } pthread_mutex_unlock(&count_mutex); gettimeofday(&t2, NULL); printf("Listening on %d took %f ms\n", listenPort, diffms(t2,t1)); }