Пример #1
0
int main(int numArgs, char ** args)
{
    bool doOrder = true;
    if (numArgs == 2)
    {
        if (!strcmp(args[1], "order"))
            doOrder = true;
        else if (!strcmp(args[1], "rmse"))
            doOrder = false;
        else
        {
            qDebug() << "Argument" << args[1] << "not recognized" << endl;
            qDebug() << "Defaulting to ordering error" << endl;
            doOrder = true;
        } 
    }

    DataBase db;
    db.load();
    Probe probe(&db);
    SvdOrder alg(&db);
    QFile f("Features.dat");

    if (f.exists())
        alg.loadFeatures("Features.dat");
    else
        alg.calculateFeaturesByOrder();

    if (doOrder)
        probe.runProbeOrdering(&alg, "probe");
    else
        probe.runProbe(&alg, "probe");

    alg.saveFeatures("Features.dat");
}
Пример #2
0
void EvictionWindow::on_showAllBtn_clicked()
{
    DataBase db;
    db.connectionOpen();

    QSqlQuery query;
    query.prepare("select * from clients");
    query.exec();

    QSqlQueryModel * model = new QSqlQueryModel();
    model->setQuery(query);
    model->QSqlQueryModel::setHeaderData(0, Qt::Horizontal, "ID");
    model->QSqlQueryModel::setHeaderData(1, Qt::Horizontal, "Имя");
    model->QSqlQueryModel::setHeaderData(2, Qt::Horizontal, "Фамилия");
    model->QSqlQueryModel::setHeaderData(3, Qt::Horizontal, "Паспорт");
    model->QSqlQueryModel::setHeaderData(4, Qt::Horizontal, "Количество дней");
    model->QSqlQueryModel::setHeaderData(5, Qt::Horizontal, "Дата посления");
    model->QSqlQueryModel::setHeaderData(6, Qt::Horizontal, "№ комнаты");
    model->QSqlQueryModel::setHeaderData(7, Qt::Horizontal, "Тип комнаты");
    ui->tableView->setModel(model);
    ui->tableView->resizeColumnToContents(4);
    ui->tableView->resizeColumnToContents(5);

    db.connectionClose();
}
Пример #3
0
void CTestPage::freshSphLib()
{
	DataBase db;
	BOOL bTraining = FALSE;
	db.ResetTable(_T("SpeechLib"),bTraining);

	//CStringArray* idArray = db.GetAllUserInfo(_T("UserId"));

	CString SpeechDir = _T("F:\\SpeechDirectory");
	CString UserId,WavName,SphPath;
	CFileFind finder;
	
	UserId = _T("Test");
	SphPath = SpeechDir + _T("\\") + UserId + _T("\\") + _T("*.wav");
	BOOL res = finder.FindFile(SphPath);
	while(res){
		res = finder.FindNextFile();
		if(finder.IsDots()||finder.IsDirectory())  
			continue;
		WavName = finder.GetFileName();
		db.InsertSpeechLib(UserId,WavName);		
	}
	
	finder.Close();
	
}
Пример #4
0
// I added this code as a one time fix to update all the Instrument Data tables after I made sure that the
// Sipper file definitions were correct.
void  ReFreshInstrumentData (RunLog&  log)
{
  DataBase dbConn (log);

  InstrumentDataFileManager::InitializePush ();
  SipperFileListPtr  sipperFiles = dbConn.SipperFileLoad ("ETP2008", "", "");

  SipperFileList::iterator  idx;

  bool   cancelFlag = false;
  char   msgBuff[1024];

  for  (idx = sipperFiles->begin ();  idx != sipperFiles->end ();  idx++)
  {
    SipperFilePtr sf = *idx;

    cout << "Sipper File [" << sf->SipperFileName () << "]" << std::endl;

    dbConn.InstrumentDataReFreshSipperFile (sf->SipperFileName (), cancelFlag, msgBuff, sizeof (msgBuff));
  }

  InstrumentDataFileManager::InitializePop ();
  InstrumentData::FinalCleanUp ();

  exit (-1);

}  /* ReFreshInstrumentData */
Пример #5
0
Construction::Construction(MyWindow& window)
	:target(window)
	, stats(DATABASE.getStats())
	, cursorVector(0, 0, 1)
	, cursor(arus::Textures::cursor)
	, kafelki()
	, elementy()
	, backShape()
	, stillBuildingMap(true)
	, itSaved(false)
	, nextElement()
{
	for (int i = 0; i < 13; i++)
		for (int j = 0; j < 13; j++)
			kafelkiID[i][j] = 0;

	next.setFont(DATABASE.get(arus::Font::DisposableDroid));
	next.setString("Next");
	next.setPosition(770, 450);
	next.setCharacterSize(30);
	next.setFillColor(sf::Color::Black);

	mapPos.x = 30;
	mapPos.y = 25;
	backShape.setSize(sf::Vector2f(13 * 54, 13 * 48));
	backShape.setFillColor(sf::Color::Black);
	backShape.setPosition(mapPos.x, mapPos.y);
	backShape.setScale(1, 1);

	backShapeNext.setSize(sf::Vector2f(54, 48));
	backShapeNext.setFillColor(sf::Color::Black);
	backShapeNext.setPosition(mapPos.x, mapPos.y);
	backShapeNext.setScale(1, 1);
	backShapeNext.setPosition(770, 500);

	cursor.setPosition(mapPos.x + 27, mapPos.y + 24);
	underCursor = elementy[0];

	//mapTexture.loadFromFile("/Data/Textures/MapTextures.jpg");
	//brick
	elementy[1].setTextureAndRect(arus::Textures::brick, sf::IntRect(0, 0, 54, 48));
	elementy[2].setTextureAndRect(arus::Textures::brick, sf::IntRect(0, 0, 27, 48));
	elementy[3].setTextureAndRect(arus::Textures::brick, sf::IntRect(27, 0, 27, 48));
	elementy[4].setTextureAndRect(arus::Textures::brick, sf::IntRect(0, 0, 54, 24));
	elementy[5].setTextureAndRect(arus::Textures::brick, sf::IntRect(0, 24, 54, 24));
	//steel
	elementy[6].setTextureAndRect(arus::Textures::steel, sf::IntRect(0, 0, 54, 48));
	elementy[7].setTextureAndRect(arus::Textures::steel, sf::IntRect(0, 0, 27, 48));
	elementy[8].setTextureAndRect(arus::Textures::steel, sf::IntRect(27, 0, 27, 48));
	elementy[9].setTextureAndRect(arus::Textures::steel, sf::IntRect(0, 0, 54, 24));
	elementy[10].setTextureAndRect(arus::Textures::steel, sf::IntRect(0, 24, 54, 24));
	//reszta
	elementy[11].setTexture(arus::Textures::water); //water
	elementy[12].setTexture(arus::Textures::ice); //ice
	elementy[13].setTexture(arus::Textures::grass); //grass
	elementy[14].setTexture(arus::Textures::eagle); //orzel

	mapPos.x += 27;
	mapPos.y += 24;
}
Пример #6
0
void Registration::on_registerButton_clicked()
{
    DataBase* db = new DataBase();
    db->connectToDataBase();

    if (isCorrectData()){
        if(ui->passwordEdit->text() ==  ui->passwordEdit_2->text()){
            if(db->isUnique(ui->loginEdit->text())){
                if(db->registration(ui->loginEdit->text(),ui->passwordEdit->text(),ui->nameEdit->text(),ui->surnameEdit->text(),ui->phoneEdit->text())){
                   MainWindow* w = new MainWindow();
                   this->close();
                   w->show();
                }
            } else {
                QMessageBox::warning(this, tr("Error") ,tr("Это имя уже занято. Попробуйте другое."));
            }
         } else {
            QMessageBox::warning(this, tr("Error") ,tr("Пароли не совпадают. Повторите попытку."));
            ui->passwordEdit->setText("");
            ui->passwordEdit_2->setText("");
          }
    } else {
        QMessageBox::warning(this, tr("Error") ,tr("Неккоректные данные!"));
    }

    db->closeDataBase();
}
Пример #7
0
void
PlotWidget::saveMarkers (DataBase &db)
{
  // save plot markers
  QHashIterator<QString, Plot *> pit(_plots);
  while (pit.hasNext())
  {
    pit.next();
    Plot *p = pit.value();
    
    QHash<QString, Marker *> markers = p->markers();
    QHashIterator<QString, Marker *> mit(markers);
    while (mit.hasNext())
    {
      mit.next();
      Marker *m = mit.value();
    
      if (m->readOnly())
        continue;
      
      if (! m->modified())
        continue;
      
      Entity *e = m->settings();
      e->setName(mit.key());
      
      db.transaction();
      db.set(e);
      db.commit();
      
      m->setModified(FALSE);
    }
  }
}
void Test::user()
{
    DataBase db;
    QVERIFY(db.load());
    QFETCH(int, user);
    QFETCH(int, id);

    QList<int> movies;
    QList<int> votes;
    Movie m_movie(&db);
    for (int i = 0; i < db.totalMovies(); ++i) {
        m_movie.setId(i + 1);
        int x = m_movie.findVote(user);
        if (x >= 0) {
            movies.append(i + 1);
            votes.append(m_movie.score(x));
        }
    }
    User userObject(&db, user);
    QCOMPARE(userObject.id(), id);
    QCOMPARE(userObject.votes(), votes.count());
    userObject.setId(id);
    QCOMPARE(userObject.votes(), votes.count());

    for (int i = 0; i < votes.count(); ++i) {
        int movie = userObject.movie(i);
        QVERIFY((bool)(movies.contains(movie)));
        int score = userObject.score(i);
        QCOMPARE(votes[movies.indexOf(movie)], score);
    }
}
Пример #9
0
int main(int args, char* argv[]) {
    if (args!=2){
        usage();
        return -1;
    }

    //parameter
    int coarse_k=1024;

    DataSet* ds = new DataSet();
    ds->initDataSet(argv[1]);
    ds->readData(argv[1]);

    PqModel model;
    model.setCoarseK(coarse_k);
    char* centroid_file=NULL;
    DataBase* db = model.trainModel(ds,centroid_file);
    char* model_file = "model.dat";
    model.saveModel(model_file);
    char* database_file = "database.dat";
    db->saveDataBase(database_file);

    delete db;
    delete ds;
    return 0;
}
Пример #10
0
/**
 * Iteratively train each feature on the entire data set
 * Once sufficient progress has been made, move on
 */
void SvdOrder::calculateFeatures()
{
    qDebug() << "Training";

    // Keep looping until you have passed the maximum number
    // of epochs or have stopped making significant progress
    double prevRMSE = 1e8;
    double RMSE     = 1e7;
    Movie movie(currDb);
    double averageRating = currDb->getAverageRating();
    for (unsigned int i = 0;
         i < MIN_EPOCHS || 
            (i < MAX_EPOCHS && (prevRMSE - RMSE) > MIN_IMPROVEMENT);
         i++)
    {
        prevRMSE = RMSE;
        RMSE = 0;

        User user(currDb,6);
        int numUsers = currDb->totalUsers();
        int totalSamples = 0; 

        for (int j = 0; j < numUsers; j++)
        {   
            for (int k = 0; k < user.votes(); k++)
            {
                int movieId = user.movie(k);
                float rating = user.score(k) - averageRating;

                int userIndex = j;
                int movieIndex = movieId - 1;

                float predict = predictRating(movieIndex, userIndex);

                float diff = predict - rating;
                RMSE += diff * diff;

                // Update all the feature vectors here
                for (unsigned int l = 0; l < NUM_FEATURES; l++)
                {
                    float oldUF = userFeatures[userIndex][l];
                    float oldMF = movieFeatures[movieIndex][l];

                    userFeatures[userIndex][l] -= LRATE * 
                                        (diff * oldMF * 2 + REGULARIZE * oldUF);
                    movieFeatures[movieIndex][l] -= LRATE * 
                                        (diff * oldUF * 2 + REGULARIZE * oldMF);
                }
                totalSamples++;
            }
            user.next();
        }

        RMSE = sqrt(RMSE / totalSamples);
        qDebug() << "Epoch" << i + 1 << "RMSE: " << RMSE;
    }                

    qDebug() << "Done with training";
}
Пример #11
0
int main(int argc, char *argv[]){
	string cycleListFileName,dataDir;
	int cycleBegin,cycleEnd;
	

	//checking argv input
	if(argc > 6){//too many arguments
		cerr<<"Too many arguments.\n";
		system("pause");
		return -1;
	}

	else if(argc < 6){//too few arguments
		cerr<<"Too few arguments.\n";
		system("pause");
		return -1;
	}
	else{
	//data DIR
	cycleListFileName = argv[1];
	dataDir = argv[2];
	//Set cycle range
	if(atoi(argv[3])!='\0')
	cycleBegin = atoi(argv[3]);
	else{
	cerr << "Cyclr brgin number error!";
	system("pause");
	return 1;
	}
	if(atoi(argv[4])!='\0')
	cycleEnd = atoi(argv[4]);
	else{
	cerr << "Cycle end number error!";
	system("pause");
	return 1;
	}
	//set Segmentation number 
	segNum = atoi(argv[5]);
	if (segNum == 1)
		seg = disable;
	else 
		seg = enable;
	}

	//Start File IO	
 	// database
    DataBase db;

    db.init(dataDir, cycleListFileName);   // use filtered files directory as working directory

    if(!db.valid()){
        cerr << "Database initializing failed." << endl;
        system("pause");
        return 1;
    }
    cout<<endl;
    runFeatureExtraction(db,argv[3],argv[4]);
	return 0;
}
Пример #12
0
int main(int argc, char* argv[]){
    if(argc!=2) {
        usage();
        return 0;
    }

    //parameter
    int bucket_neig=16;
    int sift_neighbor_num=5000;
    int pic_neigh_num = 50;

    PqModel* model = new PqModel();
    char* model_file = "model.dat";
    model->loadModel(model_file);

    DataBase* db = new DataBase();
    char* database_file = "database.dat";
    db->loadDataBase(database_file);

    PqSearchEngine se;
    se.setBuckNeigNum(bucket_neig);
    se.setSiftNeigNum(sift_neighbor_num);
    se.setPicNeigNum(pic_neigh_num);
    se.setDataBase(db);
    se.setModel(model);

    /* first check if this two file exits.
     * if search_engine exits, load engine;
     * else if centorid_file exits, load centorid_file
     * else train model
     */
    //char *engine_file="search_engine.txt";
    //char *centorid_file="centroids.txt";

    //ifstream ifile(engine_file);
    //if(ifile.good()){
    //    ifile.close();
    //    se.loadEngine(engine_file);
    //}
    //else {
    //    ifile.close();
    //    /* argv[1] base pic_ftr dir */
    //    se.init(argv[1],coarse_k,centorid_file,engine_file);
    //}

    struct stat info;
    stat(argv[1],&info);
    if(S_ISDIR(info.st_mode)) {
        search_withdir(&se,argv[1]);
    }
    else {
        search_withfile(&se,argv[1]);
    }
    return 0;
}
Пример #13
0
int main(int argc, char **argv)
{
    Q_UNUSED(argc);
    Q_UNUSED(argv);

    DataBase db;
    db.load();

    QFile file("../../download/test.txt");
    if (!file.open(QFile::ReadOnly)) {
        qWarning() << "Unable to open test file";
        return 1;
    }

    //Probe probe(&db);

    Svd *svd = new Svd(&db);
    svd->calculateFeatures();

    QFile result("../../results.txt");
    if (!result.open(QFile::WriteOnly)) {
        qWarning() << "can't write";
        return 1;
    }
    QTextStream out(&result);
    QTextStream stream(&file);
    while (!stream.atEnd()) {
        QString line = stream.readLine();
        int userid = line.toInt();
        User user(&db, userid);

        QList<RowAndCount> list;
        for (int i = 0; i < db.totalMovies(); ++i) {
            //Movie movie(&db, i);
            svd->setMovie(i);
            double guess = 1.0;
            if (/*movie.findVote(userid) != -1) {//*/user.seenMovie(i) == -1) {
                guess = svd->determine(userid);
                //qDebug() << userid << i << guess;
            }
            list.append(RowAndCount(i, guess));
        }
        qSort(list);
        list = list.mid(0, 10);
        QStringList top10;
        foreach(RowAndCount rowAndCount, list) {
            int sourceRow = rowAndCount.row;
            top10.append(QString("%1").arg(sourceRow));
            Q_ASSERT(rowAndCount.count >= 1 && rowAndCount.count <= 5);
            //qDebug() << rowAndCount.count;
        }

        out << /*list[0].count << ":" <<*/ userid << ":" << top10.join(",") << endl;
    }
Пример #14
0
void Test::userNext()
{
    QFETCH(int, start);
    QFETCH(int, next);

    DataBase db;
    QVERIFY(db.load());
    User user(&db, start);
    user.next();
    QCOMPARE(user.id(), next);
}
Пример #15
0
void MainWindow::login()
{
    if (appSettings->values.value("Interface/showLoginDialog").toBool()) {
        LoginDialog *dlg = new LoginDialog;

#ifdef APP_EDITION_DEMO
        dlg->setDriver(DataBase::SQLite);
        dlg->setDbName(":memory:");
        dlg->setDemoMode();
#endif

#ifdef APP_EDITION_BASE
        dlg->setDriver(DataBase::SQLite);
        dlg->setDbName("/tmp/test.db");
        // TODO
        // recent db
#endif

#ifdef APP_EDITION_PRO
        dlg->setDriver(DataBase::PostgreSQL);
        // TODO
        // ip, port etc.
#endif
        if (dlg->exec() == QDialog::Accepted) {
            DataBase *db = new DataBase;
            db->setDriver(dlg->driver);
            db->setDbName(dlg->dbName);
            appSettings->values.setValue("Interface/showLoginDialog", dlg->showOnStartup->isChecked());

            if (!db->openConnection()) {
                QMessageBox::critical(0, qApp->tr("Ошибка соединения"),
                                      qApp->tr("Невозможно установить соединение с базой данных."), QMessageBox::Ok);
                return;
            }

#ifdef APP_EDITION_DEMO
            db->createDemo();
#endif
            this->loadData(db);
        }

        dlg->deleteLater();
    }
    else {
#ifdef APP_EDITION_DEMO
        DataBase *db = new DataBase;
        db->setDriver(DataBase::SQLite);
        db->setDbName(":memory:");
        db->openConnection();
        db->createDemo();
        this->loadData(db);
#endif
    }
}
Пример #16
0
DataBase* PqModel::getDataBase(DataSet* ds ){
    DataBase* db = new DataBase();
    db->setFtrNum(ds->getFeatureNum());
    db->setCoarseK(m_coarse_k);
    coarseIdx(ds,db);
    pq(ds,db);

    db->setFtrFileName(ds->m_vfilename);
    int* ftrFileIdx= ivec_new_0(ds->getFeatureNum());
    memcpy(ftrFileIdx,ds->m_featureFileIdx,ds->getFeatureNum());
    db->setFtrFileIdx(ftrFileIdx);
    return db;
}
Пример #17
0
/*
 *brief: 首先检查用户出入解析结果是否正确,
 *       检查数据空间中, 是否有对应的键
 *              有对应的键, 如果类型正确, 修改键值
 *              如果类型错误, 返回出错
 *       无对应的键, 设置值, 返回成功
 *
 */
int SetCommand::operator()(Client *client) const {
    ServerClient *serverClient = (ServerClient *)client;
    //check user resolved input
    const vector<string> &argv = client->getReceiveArgv();
    if (argv.size() != (unsigned int)(this->commandArgc() + 1)) {
        logWarning("set command receive error number of argv! argv_len[%d]", argv.size());
        client->initReplyHead(1);
        client->appendReplyBody(string("set no complete yet"));
        return CABINET_ERR;
    }

    const string &keyName = argv[1];
    const string &newValue = argv[2];
    //check key existence
    DataBase *db = serverClient->getDataBase();
    ValueObj *value = nullptr;
    //1. key exist
    if ((value = db->getValue(keyName)) != nullptr) {
        logDebug("set exist key, key[%s]", keyName.c_str());
        //check key type
        if (value->getValueType() != ValueObj::STRING_TYPE) {
            logDebug("set command execute in wrong type of value, key[%s] value_type[%d]", keyName.c_str(), value->getValueType());
            client->initReplyHead(1);
            client->appendReplyBody(string("I'm not string type."));
            return CABINET_OK;
        }
        logDebug("set string value, key[%s], new_value[%s]", keyName.c_str(), newValue.c_str());
        ((StringObj *)value)->set(newValue);
        client->initReplyHead(1);
        client->appendReplyBody(string("ok"));
        return CABINET_OK;
    }
    //2. key does not exist
    else {
        logDebug("set no-exist key, key[%s]", keyName.c_str());
        //to-do, insert new thing in dataspace
        ValueObj *newObj = new StringObj(newValue);
        if (db->insertKey(keyName, newObj) == CABINET_ERR) {
            logWarning("set command, insert key into dataspace error, key[%s]", keyName.c_str());
            client->initReplyHead(1);
            client->appendReplyBody(string("Set Error"));
            return CABINET_ERR;
        }
        client->initReplyHead(1);
        client->appendReplyBody(string("ok"));
        return CABINET_OK;
    }
}
Пример #18
0
void SendStuffToShop::set_DB(DataBase db)
{
    db.openDataBase();
    DB = db;
    model1->setQuery("select Name from StuffList");
    ui->comboBox->setModel(model1);
    model2->setQuery("select Name from Store");
    ui->comboBox_2->setModel(model2);
}
Пример #19
0
void Test::movie()
{
    DataBase db;
    db.load();
    Movie m(&db);
    QFETCH(int, id);
    QFETCH(int, votes);
    QFETCH(int, user);
    QFETCH(int, score);
    m.setId(id);
    QCOMPARE(m.id(), (uint)id);
    QCOMPARE(m.votes(), (uint)votes);
    int voteId = m.findVote(user);
    QVERIFY(voteId != -1);
    QCOMPARE(m.user(voteId), user);
    QCOMPARE(m.score(voteId), score);

}
Пример #20
0
void Test::dataBase()
{
    DataBase db;
    QCOMPARE(db.rootPath(), QLatin1String("../"));
    QCOMPARE(db.isLoaded(), false);
    QVERIFY(db.totalVotes() == 0);
    QCOMPARE(db.load(), true);
    QCOMPARE(db.isLoaded(), true);
    QVERIFY(db.totalMovies() > 0);
    QVERIFY(db.totalVotes() > 0);
}
Пример #21
0
void CRecorderPage::OnCbnDropdown()
{
	// TODO: Add your control notification handler code here
	DataBase db;
	CStringArray* idArray = db.GetAllUserInfo(_T("UserId"));

	cbx_SpeechSrc.ResetContent();

	for(int i=0;i<idArray->GetCount();i++){
		cbx_SpeechSrc.AddString(idArray->GetAt(i));
	}
	
	UpdateData(FALSE);//or UpdateData(false);
	
	if(idArray!=NULL){
		delete(idArray);
		idArray = NULL;
	}
}
Пример #22
0
void
PlotWidget::loadMarkers (DataBase &db)
{
  // load marker names
  QStringList names;
  db.getTypes(QString("marker"), names);
  
  for (int pos = 0; pos < names.size(); pos++)
  {
    Entity te;
    te.setName(names.at(pos));
    te.set(QString("plugin"), new QVariant(QString()));
    te.set(QString("plot"), new QVariant(QString()));
    te.set(QString("symbol"), new QVariant(QString()));
    
    if (! db.get(&te))
      continue;

    QVariant *tset = te.get(QString("symbol"));
    if (tset->toString() != g_symbol->symbol())
      continue;
    
    tset = te.get(QString("plot"));
    Plot *p = _plots.value(tset->toString());
    if (! p)
    {
      qDebug() << "PlotWidget::loadMarkers: plot not found" << tset->toString();
      continue;
    }
    
    tset = te.get(QString("plugin"));
    
    Marker *m = new Marker(tset->toString());
    m->setID(names.at(pos));
    
    Entity *e = m->settings();
    
    e->setName(names.at(pos));
    db.get(e);

    p->setMarker(m);
  }
}
Пример #23
0
void Laberinto::InicializarArtefacto(DataBase &data){
    for(int i=0;i<this->M;i++){
        for(int j=0;j<this->N;j++){
            if(this->matriz[i][j].GetTipo()==5){
                Artefacto* art = data.devuelve_artefacto(this->nivelesArtefacto);
                art->setCoordX(i); art->setCoordY(j);
                this->artefactos.push_back(art);
            }
        }
    }
}
Пример #24
0
void Laberinto::InicializarMonstruo(DataBase &data){
    for(int i=0;i<this->M;i++){
        for(int j=0;j<this->N;j++){
            if(this->matriz[i][j].GetTipo()==6){
                Monstruo mon = data.devuelve_monstruo(this->nivelesMonstruo);
                mon.SetPosX(i); mon.SetPosY(j);
                this->monstruos.push_back(mon);
            }
        }
    }
}
Пример #25
0
void EvictionWindow::on_deleteBtn_clicked()
{
    bool ok;
    int id = ui->deleteEdit->text().toInt(&ok);
    if(ok){
        DataBase db;
        db.connectionOpen();

        QSqlQuery query;
        query.prepare("delete from clients where id='"+QString::number(id)+"'");
        if(query.exec())
        {
            QMessageBox::information(this, "Успех!", "Клиент успешно удален!");
        } else {
            QMessageBox::warning(this, "Ошибка!", query.lastError().text());
        }

        db.connectionClose();
        this->close();
    }
}
Пример #26
0
void SvdOrder :: saveFeatures(QString filename)
{
    QFile out(filename);
    out.open(QFile :: WriteOnly);

    for (int i = 0; i < currDb->totalMovies(); i++)
    {
        for (unsigned int j = 0; j < NUM_FEATURES; j++)
        {
            out.write((char*)&movieFeatures[i][j], sizeof(float)); 
        }
    }

    for (int i = 0; i < currDb->totalUsers(); i++)
    {
        for (unsigned int j = 0; j < NUM_FEATURES; j++)
        {
            out.write((char*)&userFeatures[i][j], sizeof(float)); 
        }
    }
}
Пример #27
0
void SvdOrder :: loadFeatures(QString filename)
{
    QFile in(filename);
    in.open(QFile :: ReadOnly);

    for (int i = 0; i < currDb->totalMovies(); i++)
    {
        for (unsigned int j = 0; j < NUM_FEATURES; j++)
        {
            in.read((char*)&movieFeatures[i][j], sizeof(float)); 
        }
    }

    for (int i = 0; i < currDb->totalUsers(); i++)
    {
        for (unsigned int j = 0; j < NUM_FEATURES; j++)
        {
            in.read((char*)&userFeatures[i][j], sizeof(float)); 
        }
    }
}
Пример #28
0
WalletFacade::WalletFacade
(
    const Settings &settings, 
    Ethereum::Connector::Provider &provider, 
    DataBase &database, 
    Notifier &notifier, 
    Synchronizer &synchronizer,
    Invoker<Notifier> &invoker
) :
    _settings(settings),
    _invoker(invoker),
    _provider(provider),
    _database(database),
    _notifier(notifier),
    _synchronizer(synchronizer)
{
    QObject::connect(&synchronizer.getBalanceObserver(), &BalanceObserver::Update, this, &WalletFacade::emitBalance);
    QObject::connect(&database.getEthereumKeys(), &EthereumKeyStore::Key, this, &WalletFacade::emitEthereumKey);
    QObject::connect(&database.getStealthKeys(), &StealthKeyStore::Key, this, &WalletFacade::emitStealthKey);
    QObject::connect(&database.getStealthPayments(), &StealthPaymentStore::NewItem, this, &WalletFacade::emitStealthPayment);
    QObject::connect(&database.getTransactions(), &TransactionStore::NewItem, this, &WalletFacade::emitTransaction);
}
Пример #29
0
void CTestPage::OnCbnTestsph()
{
	// TODO: Add your control notification handler code here

	CString SpeakerId = _T("Test");
	//m_SpeakerId = SpeakerId;

	DataBase db;
	CStringArray* idArray = db.GetAllUserSpeech(SpeakerId);

	cbx_TestSph.ResetContent();
	for(int i=0;i<idArray->GetCount();i++){
		cbx_TestSph.AddString(idArray->GetAt(i));
	}
	
	UpdateData(FALSE);//or UpdateData(false);
	
	if(idArray!=NULL){
		delete(idArray);
		idArray = NULL;
	}
}
Пример #30
0
int main(){
	int nrec = 500000;
	clock_t begin, end;
	string data_filename = "1.dat";
	DataBase mydb;
	srand((int)time(NULL));
	int num = 0;
	ofstream ofs(data_filename.c_str(), ios::binary);
	for (int i = 0; i < nrec; i++){
		char  c_name[NAMESIZE];
		char c_content[CONTSIZE];
 		int n = i + 1; 
		sprintf(c_name, "name %d", n);
		sprintf(c_content, "content %d, 1.0", n);
		ofs.write((char *)&n, sizeof(int));
		ofs.write(c_name, NAMESIZE);
		ofs.write(c_content, CONTSIZE);
	}
	ofs.close();
	mydb.db_open(data_filename, "2.dat");
	begin = clock();
	int n = 0;
	while (n < 2000){
		int x = rand()%nrec + 1;
		if (mydb.db_find(x)) n++;
	}
 	end = clock();
	cout<<end - begin<<endl;
	int c; cin>>c;
	begin = clock();
	n = 0;
	while (n < 2000){
		int x = rand()%nrec + 1;
		if (mydb.naive_find(x)) n++;
	}
	end = clock();
	cout<<end - begin <<endl;
}