Пример #1
0
void DBManager::createPlayerInfo()
{
    ValueVector data;
    loadCsvData(CSV_PLAYERINFO, data);
    
    string sql = "create table PlayerInfo(ID integer primary key autoincrement, Name, Level, Exp, RingCount, GoldCount, WoodCount, GoldCapacity, WoodCapacity)";
    executeUpdate(sql);
    
    for (int i = 1; i < data.size(); i++) {
        ValueMap& map = data.at(i).asValueMap();
        sql = "insert into PlayerInfo values("
        + map["ID"].asString() + ", '"
        + map["Name"].asString() + "', '"
        + map["Level"].asString() + "', '"
        + map["Exp"].asString() + "', '"
        + map["RingCount"].asString() + "', '"
        + map["GoldCount"].asString() + "', '"
        + map["WoodCount"].asString() + "', '"
        + map["GoldCapacity"].asString() + "', '"
        + map["WoodCapacity"].asString() + "')";
        
//        CCLOG("sql: %s", sql.c_str());
        executeUpdate(sql);
    }
}
Пример #2
0
void DBManager::createBuildingListInfo()
{
    ValueVector data;
    loadCsvData(CSV_BUILDINGLISTINFO, data);
    
    string timeStamp = GM()->getIntToStr(GM()->getTimeStamp());
    string sql = "create table BuildingListInfo(ID integer primary key autoincrement, BuildingID, PositionX, PositionY, BuildState, LastBuildTime, LastGoldHarvest, LastWoodHarvest)";
    executeUpdate(sql);
    
    for (int i = 1; i < data.size(); i++) {
        ValueMap& map = data.at(i).asValueMap();
        sql = "insert into BuildingListInfo values("
        + map["ID"].asString() + ", '"
        + map["BuildingID"].asString() + "', '"
        + map["PositionX"].asString() + "', '"
        + map["PositionY"].asString() + "', '"
        + map["BuildState"].asString() + "', '"
        + timeStamp + "', '"
        + timeStamp + "', '"
        + timeStamp + "')";
        
//        CCLOG("sql: %s", sql.c_str());
        executeUpdate(sql);
    }
}
Пример #3
0
void Cmd::handleRequest() {

    switch(getCommand()) {
		case LIST :
			prepareDb();
			executeList();
			break;
		case UPDATE :
			prepareDb();
			executeUpdate();
			break;
		case ACT :
			prepareDb();
			executeAct();
			break;
        case DEACT :
			prepareDb();
            executeDeact();
            break;
        case EXEC :
			prepareDb();
            executeExec();
            break;
        case EVENT :
			prepareDb();
            executeEvent();
            break;
        case VERSION :
        	executeVersion();
		default:
			cons.printError("no command found");
			break;
	}

}
void MySQLFactorerCommunicator::algorithmFinnished(const std::vector<std::string>& result)
{
    try
    {
        std::unique_ptr<sql::Connection>
            insert_con(driver->connect(address.c_str(), username.c_str(), password.c_str()));
        insert_con->setSchema(defaultSchema.c_str());

        std::string resStr;
        for(int i = 0; i < result.size(); ++i )
        {
            std::string singleNum = result[i];
            if(i < result.size()-1)
                singleNum.append("*");
            resStr.append(singleNum);
        }
        std::cout << "Returned: " << resStr << "\n";
        std::string cmd = std::string("UPDATE FactorerMain_task SET state = 2, result = \"");
        cmd.append(resStr);
        cmd.append("\" WHERE id = ");
        cmd.append(std::to_string(currentTaskId));
        cmd.append(";");
        std::cout << cmd << std::endl;
        executeUpdate(cmd.c_str());
    }
    catch (sql::SQLException &e)
         {
            std::string msg("ERR: ");
            msg.append( e.what());
            throw FactorerCommunicatorException(msg);
        }
}
Пример #5
0
void MaraUpdaterApplication::executeUpdate()
{
	//MaraTrace trace(__FUNCSIG__, this, __FILE__, __LINE__);
	connect(_window, SIGNAL(finished()), this, SLOT(updateFinished()));
	_window->show();
	QTimer::singleShot(1000, _window, SLOT(executeUpdate()));
}
Пример #6
0
void DBManager::createMiwuStateInfo()
{
    ValueVector data;
    loadCsvData(CSV_MIWUSTATEINFO, data);
    
    string timeStamp = GM()->getIntToStr(GM()->getTimeStamp());
    string sql = "create table MiwuStateInfo(MiwuID integer primary key autoincrement, Type)";
    executeUpdate(sql);
    
    for (int i = 1; i < data.size(); i++) {
        ValueMap& map = data.at(i).asValueMap();
        sql = "insert into MiwuStateInfo values("
        + map["MiwuID"].asString() + ", '"
        + map["Type"].asString() + "')";
        
//        CCLOG("sql: %s", sql.c_str());
        executeUpdate(sql);
    }
}
Пример #7
0
void ProjectsView::initialUpdateData()
{
    UpdateBatch* batch = new UpdateBatch( -1 );
    batch->updateSettings();
    batch->updateUsers();
    batch->updateTypes();
    batch->updateProjects();
    batch->updateStates();

    executeUpdate( batch );
}
Пример #8
0
void DBManager::createSoilderListInfo()
{
    ValueVector data;
    loadCsvData(CSV_SOILDER_LISTINFO, data);
    
    string timeStamp = GM()->getIntToStr(GM()->getTimeStamp());
    string sql = "create table SoilderListInfo(ID integer primary key autoincrement, SoilderID, Count)";
    executeUpdate(sql);
    
    for (int i = 1; i < data.size(); i++) {
        ValueMap& map = data.at(i).asValueMap();
        sql = "insert into SoilderListInfo values("
        + map["ID"].asString() + ", '"
        + map["SoilderID"].asString() + "', '"
        + map["Count"].asString() + "')";
        
//        CCLOG("sql: %s", sql.c_str());
        executeUpdate(sql);
    }
}
Пример #9
0
void DBManager::createHeroListInfo()
{
    ValueVector data;
    loadCsvData(CSV_HERO_LISTINFO, data);
    
    string timeStamp = GM()->getIntToStr(GM()->getTimeStamp());
    string sql = "create table HeroListInfo(ID integer primary key autoincrement, HeroID, Exp, State)";
    executeUpdate(sql);
    
    for (int i = 1; i < data.size(); i++) {
        ValueMap& map = data.at(i).asValueMap();
        sql = "insert into HeroListInfo values("
        + map["ID"].asString() + ", '"
        + map["HeroID"].asString() + "', '"
        + map["Exp"].asString() + "', '"
        + map["State"].asString() + "')";
        
//        CCLOG("sql: %s", sql.c_str());
        executeUpdate(sql);
    }
}
Пример #10
0
void ProjectsView::periodicUpdateData( bool full )
{
    if ( m_sessionExpired )
        return;

    UpdateBatch* batch = new UpdateBatch( -15 );
    if ( full ) {
        batch->updateUsers();
        batch->updateTypes();
    }
    batch->updateProjects();
    batch->updateStates();

    executeUpdate( batch );
}
Пример #11
0
void ProjectsView::cascadeUpdateFolders()
{
    UpdateBatch* batch = NULL;

    foreach ( const FolderEntity& folder, FolderEntity::list() ) {
        if ( dataManager->folderUpdateNeeded( folder.id() ) ) {
            if ( !batch ) {
                batch = new UpdateBatch( -20 );
                batch->setIfNeeded( true );
            }
            batch->updateFolder( folder.id() );
        }
    }

    if ( batch )
        executeUpdate( batch );
}
Пример #12
0
void Updater::run() {
    downloadUpdate();
    executeUpdate();

    emit finishedSuccesufull(updateInfo);
}
Пример #13
0
int Awstats::update(const HttpVHost * pVHost )
{
    // rotate current access log file to access.log.awstats
    const char * pLogPath;
    int ret;
    pLogPath = pVHost->getAccessLogPath();
    if ( !pLogPath )
    {
        LOG_ERR(( "Virtual host [%s] must use its own access log, "
                  "in order to use awstats", pVHost->getName() ));
        return -1;
    }

    if ( prepareAwstatsEnv( pVHost ) )
        return -1;
    
    ret = renameLogFile( pLogPath, "", ".awstats" );
    LOG4CXX_NS::LogRotate::postRotate( pVHost->getAccessLog()->getAppender(),
                        HttpGlobals::s_uid, HttpGlobals::s_gid);
    if ( ret == -1 )
    {
        return -1;
    }
    
    int pid = fork();
    if ( pid )
    {
        //parent process or error
        return (pid == -1)? pid : 0;
    }

    // child process
    // fork again
    pid = fork();
    if ( pid < 0)
        LOG_ERR(( "fork() failed" ));
    else if ( pid == 0 )
    {
        if ( HttpGlobals::s_psChroot )
        {
            chroot( HttpGlobals::s_psChroot->c_str() );
        }
        if ( pVHost->getRootContext().getSetUidMode() == UID_DOCROOT )
        {
            setuid( pVHost->getUid() );
        }
        else
            setuid( HttpGlobals::s_uid );
        executeUpdate( pVHost->getName() );
        exit( 0 );
    }
    else
        waitpid( pid, NULL, 0 );

    // rotate again and compress if required
    if ( archiveFile( pLogPath, ".awstats",
            pVHost->getAccessLog()->getCompress(),
            HttpGlobals::s_uid, HttpGlobals::s_gid ) == -1 )
    {
        char achBuf[1024];
        safe_snprintf( achBuf, 1024, "%s%s", pLogPath, ".awstats" );
        unlink( achBuf );
        LOG_ERR(( "Unable to rename [%s], remove it.", achBuf ));
    }
    exit( 0 );
}
Пример #14
0
MaraUpdaterApplication::MaraUpdaterApplication(int &argc, char **argv) : QApplication(argc, argv),
		_window(new MaraUpdaterWindow())
{
	//MaraTrace trace(__FUNCSIG__, this, __FILE__, __LINE__);

	_app = this;
	qInstallMsgHandler(qtMessageHandler);

	_executeCancelled = false;

	_autoRestart = false;
	_launchedFromTemp = false;

	QStringList args = arguments();

	for(QStringList::iterator ii = args.begin(); ii != args.end(); ++ii)
	{
		if((*ii).toLower() == "autorestart")
		{
			_autoRestart = true;
		}

		if((*ii) == "__TEMP_LAUNCHED__")
		{
			_launchedFromTemp = true;
		}
	}

	if(_launchedFromTemp)
	{
		//MaraTrace trace(__FUNCSIG__ ":TempLaunched", this, __FILE__, __LINE__);
		executeUpdate();
	}
	else
	{
		//MaraTrace trace(__FUNCSIG__ ":NotTempLaunched", this, __FILE__, __LINE__);
		QFileInfo exeFileInfo(QCoreApplication::applicationFilePath());
		QString tempPath = QDir::temp().filePath(exeFileInfo.fileName());
		QFile temp(tempPath);

		if(temp.exists() && !temp.remove())
		{
			QMessageBox::warning(0, "Error", QString("Error removing temp executable %1:\n%2\n\nUpdater will not be able to update itself.").arg(tempPath).arg(temp.errorString()));
			executeUpdate();
		}

		QFile exeFile(QCoreApplication::applicationFilePath());

		std::cout << "Copying self to " << qPrintable(tempPath) << "..." << std::flush;

		if(exeFile.copy(tempPath))
		{
			std::cout << "Success!" << std::flush;
			if(!QProcess::startDetached(tempPath, args << "__TEMP_LAUNCHED__"))
			{
				QMessageBox::critical(0, "Error", QString("Failed launching temp updater."));
			}
			_executeCancelled = true;
		}
		else
		{
			QMessageBox::warning(0, "Error", QString("Error copying to temp location %1:\n%2\n\nUpdater will not be able to update itself.").arg(tempPath).arg(exeFile.errorString()));
			executeUpdate();
		}
	}
}