mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Создание БД из кода. Требуется рефакт.
This commit is contained in:
111
ServerLMS/dialogcheckdb.cpp
Normal file
111
ServerLMS/dialogcheckdb.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include "dialogcheckdb.h"
|
||||
#include "ui_dialogcheckdb.h"
|
||||
|
||||
DialogCheckDB::DialogCheckDB(ProviderDBLMS* providerDBLMS, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogCheckDB),
|
||||
providerDBLMS(providerDBLMS),
|
||||
resDriver(false),
|
||||
resUser(false),
|
||||
resDB(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->btnRepare->setEnabled(false);
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
DialogCheckDB::~DialogCheckDB()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DialogCheckDB::check()
|
||||
{
|
||||
resDriver = false;
|
||||
resUser = false;
|
||||
resDB = false;
|
||||
|
||||
resDriver = providerDBLMS->checkDriverQPSQLavailable();
|
||||
if(resDriver)
|
||||
{
|
||||
ui->lblDriverRes->setText(tr("Installed"));
|
||||
ui->lblDriverResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->lblDriverRes->setText(tr("Not installed"));
|
||||
ui->lblDriverResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
||||
}
|
||||
|
||||
resUser = providerDBLMS->checkUserLMSexist();
|
||||
if(resUser)
|
||||
{
|
||||
ui->lblUserRes->setText(tr("Exist"));
|
||||
ui->lblUserResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->lblUserRes->setText(tr("Not exist"));
|
||||
ui->lblUserResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
||||
}
|
||||
|
||||
resDB = providerDBLMS->checkDataBaseLMSexist();
|
||||
if(resDB)
|
||||
{
|
||||
ui->lblDBRes->setText(tr("Exist"));
|
||||
ui->lblDBResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->lblDBRes->setText(tr("Not exist"));
|
||||
ui->lblDBResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
||||
}
|
||||
|
||||
if(!resDriver || !resUser || !resDB)
|
||||
ui->btnRepare->setEnabled(true);
|
||||
else
|
||||
ui->btnRepare->setEnabled(false);
|
||||
}
|
||||
|
||||
void DialogCheckDB::on_btnRepare_clicked()
|
||||
{
|
||||
if(!resDriver)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Warning!"), tr("Install PostgreSQL."));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!resUser)
|
||||
{
|
||||
if(!providerDBLMS->createUser("nameUser"))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Failed to create user!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!resDB)
|
||||
{
|
||||
if(!providerDBLMS->createDB("nameDB"))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Failed to create Database!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DialogCheckDB::on_toolButton_clicked()
|
||||
{
|
||||
QProcess process;
|
||||
QString program = "cmd.exe";
|
||||
QStringList arguments;
|
||||
arguments << "/C" << "echo Hello from QProcess" << "&&" << "pause";
|
||||
process.start(program, arguments);
|
||||
process.waitForFinished();
|
||||
|
||||
int i = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user