mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Settings DB
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QFile>
|
||||
#include <QResizeEvent>
|
||||
#include "specialmessagebox.h"
|
||||
#include "dialogcheckdb.h"
|
||||
#include "ui_dialogcheckdb.h"
|
||||
@@ -8,33 +9,78 @@
|
||||
DialogCheckDB::DialogCheckDB(ProviderDBLMS* providerDBLMS, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogCheckDB),
|
||||
providerDBLMS(providerDBLMS),
|
||||
resDriver(false),
|
||||
resUser(false),
|
||||
resDB(false)
|
||||
waitAnimationWidget(nullptr),
|
||||
providerDBLMS(providerDBLMS)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(this, &DialogCheckDB::signal_CheckDB, providerDBLMS, &ProviderDBLMS::slot_CheckDB);
|
||||
connect(providerDBLMS, &ProviderDBLMS::signal_CheckDBResult, this, &DialogCheckDB::slot_CheckDBResult);
|
||||
|
||||
connect(this, &DialogCheckDB::signal_RepareDB, providerDBLMS, &ProviderDBLMS::slot_RepareDB);
|
||||
connect(providerDBLMS, &ProviderDBLMS::signal_RepareDBResult, this, &DialogCheckDB::slot_RepareDBResult);
|
||||
|
||||
|
||||
waitAnimationWidget = new WaitAnimationWidget;
|
||||
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
||||
waitAnimationWidget->setParent(this);
|
||||
waitAnimationWidget->initialize(movie,this);
|
||||
|
||||
ui->btnRepare->setObjectName("btnRepare");
|
||||
|
||||
ui->btnRepare->setEnabled(false);
|
||||
|
||||
check();
|
||||
ui->btnRepare->setEnabled(false);
|
||||
}
|
||||
|
||||
DialogCheckDB::~DialogCheckDB()
|
||||
{
|
||||
if(waitAnimationWidget)
|
||||
{
|
||||
waitAnimationWidget->hideWithStop();
|
||||
delete waitAnimationWidget;
|
||||
}
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DialogCheckDB::initialize()
|
||||
{
|
||||
check();
|
||||
}
|
||||
|
||||
void DialogCheckDB::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QSize size = event->size();
|
||||
waitAnimationWidget->resize(size);
|
||||
}
|
||||
|
||||
void DialogCheckDB::check()
|
||||
{
|
||||
resDriver = false;
|
||||
resUser = false;
|
||||
resDB = false;
|
||||
waitAnimationWidget->showWithPlay();
|
||||
|
||||
resDriver = providerDBLMS->checkDriverQPSQLavailable();
|
||||
if(resDriver)
|
||||
emit signal_CheckDB();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void DialogCheckDB::on_btnRepare_clicked()
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
|
||||
if(!checkResult.resDriver)
|
||||
{
|
||||
SpecMsgBox::CriticalClose(this, tr("Install PostgreSQL."));
|
||||
this->reject();
|
||||
return;
|
||||
}
|
||||
|
||||
emit signal_RepareDB(checkResult);
|
||||
}
|
||||
|
||||
void DialogCheckDB::slot_CheckDBResult(CheckResult result)
|
||||
{
|
||||
checkResult = result;
|
||||
|
||||
if(result.resDriver)
|
||||
{
|
||||
ui->lblDriverRes->setText(tr("Installed"));
|
||||
ui->lblDriverResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
@@ -45,8 +91,7 @@ void DialogCheckDB::check()
|
||||
ui->lblDriverResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
||||
}
|
||||
|
||||
resUser = providerDBLMS->checkUserLMSexist();
|
||||
if(resUser)
|
||||
if(result.resUser)
|
||||
{
|
||||
ui->lblUserRes->setText(tr("Exist"));
|
||||
ui->lblUserResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
@@ -57,8 +102,7 @@ void DialogCheckDB::check()
|
||||
ui->lblUserResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
||||
}
|
||||
|
||||
resDB = providerDBLMS->checkDataBaseLMSexist();
|
||||
if(resDB)
|
||||
if(result.resDB)
|
||||
{
|
||||
ui->lblDBRes->setText(tr("Exist"));
|
||||
ui->lblDBResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
@@ -69,48 +113,39 @@ void DialogCheckDB::check()
|
||||
ui->lblDBResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
||||
}
|
||||
|
||||
if(!resDriver || !resUser || !resDB)
|
||||
if(!result.resDriver || !result.resUser || !result.resDB)
|
||||
{
|
||||
ui->btnRepare->setEnabled(true);
|
||||
}
|
||||
else
|
||||
ui->btnRepare->setEnabled(false);
|
||||
|
||||
waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
|
||||
void DialogCheckDB::on_btnRepare_clicked()
|
||||
void DialogCheckDB::slot_RepareDBResult(CheckResult result)
|
||||
{
|
||||
if(!resDriver)
|
||||
checkResult = result;
|
||||
|
||||
if(!checkResult.resUser)
|
||||
{
|
||||
SpecMsgBox::CriticalClose(this, tr("Install PostgreSQL."));
|
||||
slot_CheckDBResult(checkResult);
|
||||
SpecMsgBox::CriticalClose(this, tr("Failed to create user!"));
|
||||
this->reject();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!resUser)
|
||||
if(!checkResult.resDB)
|
||||
{
|
||||
if(!providerDBLMS->createUser())
|
||||
{
|
||||
check();
|
||||
SpecMsgBox::CriticalClose(this, tr("Failed to create user!"));
|
||||
this->reject();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!resDB)
|
||||
{
|
||||
if(!providerDBLMS->createDB())
|
||||
{
|
||||
check();
|
||||
SpecMsgBox::CriticalClose(this, tr("Failed to create Database!"));
|
||||
this->reject();
|
||||
return;
|
||||
}
|
||||
slot_CheckDBResult(checkResult);
|
||||
SpecMsgBox::CriticalClose(this, tr("Failed to create Database!"));
|
||||
this->reject();
|
||||
return;
|
||||
}
|
||||
|
||||
check();
|
||||
|
||||
if(resDriver && resUser && resDB)
|
||||
if(checkResult.resDriver && checkResult.resUser && checkResult.resDB)
|
||||
{
|
||||
SpecMsgBox::InfoOk(this, tr("The database has been successfully restored!"));
|
||||
this->accept();
|
||||
|
||||
Reference in New Issue
Block a user