int sendbusinessEmial() { string strConn = ServerConf::Instance()->m_dbcfg.m_dbip+ ":"+ "@" + ServerConf::Instance()->m_dbcfg.m_dbname; ConnectDb *ConnectHandle = new ConnectDb(strConn, ServerConf::Instance()->m_dbcfg.m_dbuser, ServerConf::Instance()->m_dbcfg.m_dbpwd, "gb2312"); if (!ConnectHandle->connect()) return -1; string jsonString; string ret; ServerConf::Instance()->m_sendcfg.sendtime = time(NULL); while (!g_exit) { if (onTime()) { if(ConnectHandle->execCommand(ServerConf::Instance()->m_spcfg.spname,ServerConf::Instance()->m_spcfg.numDay,jsonString)) { parseJosnString(jsonString,ret); sendQueryMail(ret); ServerConf::Instance()->m_sendcfg.sendtime = time(NULL); AC_INFO("Send business mail :%s",ret.c_str()); } else { AC_ERROR("Send business mail failed\n"); } } sleep(300); } return 0; }
void IRC::handle_msg(const string& chan, const string& nick, const string& login, const string& host, const string& omsg) { string msg = omsg; if(chan.find_first_of("#&+!") == 0) { //Channel Message onMessage(chan, nick, login, host, msg); } else { //Private Messages if(msg.find("\x001") == 0 && msg.rfind("\x001") == msg.length() - 1) { //CTCP msg = msg.substr(1, msg.length() - 2); if(msg.compare("TIME") == 0) { onTime(nick,login,host,chan); } else if(msg.compare("VERSION") == 0) { onVersion(nick,login,host,chan); } else if(msg.substr(0, 4).compare("PING") == 0) { onPing(nick,login,host,chan,msg.substr(5)); } else if(msg.compare("FINGER") == 0) { onFinger(nick,login,host,chan); } else if(msg.substr(0, 6).compare("ACTION") == 0) { onAction(nick,login,host,chan,msg.substr(7)); } return; } onPrivateMessage(nick, login, host, msg); } }
// Get the simple/primary schedule off time, as minutes after midnight [0,1439]; invalid (eg ~0) if none set. // This is based on specifed start time and some element of the current eco/comfort bias. // * which schedule number, counting from 0 uint_least16_t getSimpleScheduleOff(const uint8_t which) { const uint_least16_t startMins = getSimpleScheduleOn(which); if(startMins == (uint_least16_t)~0) { return(~0); } // Compute end from start, allowing for wrap-around at midnight. uint_least16_t endTime = startMins + PREWARM_MINS + onTime(); if(endTime >= MINS_PER_DAY) { endTime -= MINS_PER_DAY; } // Allow for wrap-around at midnight. return(endTime); }
int FileAction::onRstat(ServerContext& ctxt, FileServer& server, const char *path, file_stat_t& fs) { time_t tm; fs.fs_size = onSize(ctxt, server, path); fs.fs_blksize = 4096; fs.fs_blocks = fs.fs_size >> 12; fs.fs_uid = fs.fs_gid = 65534; fs.fs_nlink = 1; onTime(ctxt, server, path, tm); fs.fs_ctime = fs.fs_atime = fs.fs_mtime = tm; int rbits = canRead(ctxt, server, path) ? 0444 : 0; int wbits = canWrite(ctxt, server, path) ? 0222 : 0; fs.fs_mode = S_IFREG | rbits | wbits; return 0; }
void AttributeParser::parseUnitAttribute(MFnDependencyNode & node, MObject & attr) { MStatus status; MFnUnitAttribute fnAttr(attr, &status); if (!status) return; MFnUnitAttribute::Type unitType = fnAttr.unitType(&status); if (!status) return; MPlug plug = node.findPlug(attr, &status); if (!status) return; MString name = fnAttr.name(&status); if (!status) return; switch (unitType) { case MFnUnitAttribute::kAngle: { MAngle angle; status = plug.getValue(angle); if (!status) return; onAngle(plug, name, angle); } break; case MFnUnitAttribute::kDistance: { MDistance distance; status = plug.getValue(distance); if (!status) return; onDistance(plug, name, distance); } break; case MFnUnitAttribute::kTime: { MTime time; status = plug.getValue(time); if (!status) return; onTime(plug, name, time); } break; } }
/* ** =================================================================== ** Method : comparar ** Description : ** =================================================================== */ void Timer::comparar(){ bool comp; ulong cuentaTmp = baseTimer->getCuenta(); ulong nextCuentaTmp = this->next_cuenta; ulong tiempoTmp = this->tiempo; if(this->of) comp= cuentaTmp <= nextCuentaTmp; else comp= cuentaTmp >= nextCuentaTmp; if (comp ){ int error = cuentaTmp - nextCuentaTmp; error = (error<0)?-error:error; nextCuentaTmp += error + tiempoTmp; baseTimer->lockInc(); this->next_cuenta=nextCuentaTmp; baseTimer->unlockInc(); if(cuentaTmp >= nextCuentaTmp){ this->of=TRUE; } onTime(); } }
} void DepthInternalWidget::setConnection() { connect(ui->chboxDepth, SIGNAL(stateChanged(int)), this, SLOT(includeParameter(int))); connect(ui->chboxRate, SIGNAL(stateChanged(int)), this, SLOT(includeParameter(int))); connect(ui->chboxTension, SIGNAL(stateChanged(int)), this, SLOT(includeParameter(int))); connect(ui->cboxDepth, SIGNAL( currentIndexChanged(QString)), this, SLOT(changeUnits(QString))); connect(ui->cboxRate, SIGNAL( currentIndexChanged(QString)), this, SLOT(changeUnits(QString))); connect(ui->cboxTension, SIGNAL( currentIndexChanged(QString)), this, SLOT(changeUnits(QString))); connect(ui->pbtConnect, SIGNAL(toggled(bool)), this, SLOT(connectDepthMeter(bool))); connect(&timer, SIGNAL(timeout()), this, SLOT(onTime())); } void DepthInternalWidget::includeParameter(int state) { QCheckBox *chbox = (QCheckBox*)sender(); if (!chbox) return; bool flag; if (state == Qt::Checked) flag = true; else if (state == Qt::Unchecked) flag = false; if (chbox == ui->chboxDepth) { ui->ledDepth->setText(""); ui->cboxDepth->setEnabled(flag);
void GameStart::execute(HelloWorld* s) { //!清除超过屏幕的子弹 auto layer=s->playerlayer; for(auto i=layer->bullets.begin(); i!=layer->bullets.end();) { if((*i)->getPositionY()>810) { (*i)->removeFromParent(); i=layer->bullets.erase(i); } else { i++; } } //!清除超过屏幕的敌机 auto layer1=s->enemylayer; for(auto i=layer1->enemyNum.begin(); i!=layer1->enemyNum.end();) { if((*i)->getPositionY()<-15) { (*i)->removeFromParent(); i=layer1->enemyNum.erase(i); } else { i++; } } //!消灭生命值低于零的死亡敌机 for(auto i=layer1->deadEnemy.begin(); i!=layer1->deadEnemy.end();) { auto life=(int)(*i)->getUserData(); if(life<0) { (*i)->removeFromParent(); i=layer1->deadEnemy.erase(i); } else { i++; } } //!滚动背景图片 s->updateBackGround(); //// layer1->addTime(Director::getInstance()->getDeltaTime()); //!添加敌机 if(layer1->onTime()) { layer1->createEnemy(); layer1->setTime(0); } //!检测炸弹是否启动 auto goodslayer=s->goodslayer; if(goodslayer->getIsEexplosion()) { //!计算所有被消灭的敌机分数 int score1=0; for(auto i=layer1->enemyNum.begin(); i!=layer1->enemyNum.end();) { auto point1=(*i)->getPositionY(); if(point1<800) { int life=(int)(*i)->getUserData(); score1+=life; //!设置死亡敌机消失时间 life=50; (*i)->setUserData((void*)life); (*i)->stopAllActions(); (*i)->getChildByTag(1)->setVisible(true); //!将死亡的敌机放到死亡容器中 layer1->deadEnemy.pushBack(*i); i=layer1->enemyNum.erase(i); } else { i++; } } score1+=s->getScore(); s->setScore(score1); goodslayer->setExplosion(false); } //!添加子弹 layer->update(Director::getInstance()->getDeltaTime()); ///////////////////////////////////////////////////// //////////////////////////////////////////////////// //!碰撞检测 //先判断玩家是否与敌机相撞 auto es=layer1->enemyNum; for(auto i=es.begin(); i!=es.end(); ++i) { auto rect1=(*i)->getBoundingBox(); auto rect2=layer->getPlaneRect(); if(rect1.intersectsRect(rect2)) { //!跳转到游戏结束状态 layer->getPlayer()->getChildByTag(1)->setVisible(true); s->changeState(GameOver::getInstance()); return; } } //!子弹与敌机的碰撞检测 for(auto i=layer1->enemyNum.begin(); i!=layer1->enemyNum.end(); ++i) { for(auto y=layer->bullets.begin(); y!=layer->bullets.end();) { auto rect1=(*i)->getBoundingBox(); auto rect2=(*y)->getBoundingBox(); int life=(int)(*i)->getUserData(); if(rect1.intersectsRect(rect2)) { (*y)->removeFromParent(); y=layer->bullets.erase(y); life--; (*i)->setUserData((void*)life); s->scorePlus(); s->updateScore(); } else { y++; } } } //!将生命值为0的敌机添加到死亡列表里 for(auto i=layer1->enemyNum.begin(); i!=layer1->enemyNum.end();) { int life=(int)(*i)->getUserData(); if(life<=0) { life=50; (*i)->stopAllActions(); (*i)->setUserData((void*)life); (*i)->getChildByTag(1)->setVisible(true); layer1->deadEnemy.pushBack(*i); i=layer1->enemyNum.erase(i); } else { i++; } } //!更新所有死亡的敌机集合 for (auto i=layer1->deadEnemy.begin(); i!=layer1->deadEnemy.end(); ++i) { int life=(int)(*i)->getUserData(); life--; (*i)->setUserData((void*)life); } }