отклонение запроса на Управление версиями

This commit is contained in:
2026-01-22 15:18:40 +03:00
parent 2522bc6af5
commit 5415afe264
12 changed files with 156 additions and 16 deletions

View File

@@ -592,6 +592,28 @@ void RecognizeSystem::xmlParser(QByteArray array)
}
if(xmlReader.name() == "TryBlock")
{
bool result = false;
QString type = "";
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
{
QString name = attr.name().toString();
QString value = attr.value().toString();
if (name == "Result"){
result = value == "true" ? true : false;
}
if (name == "Type"){
type = value;
}
}
emit sigTryBlock(result, type);
}
if(xmlReader.name() == "VersionList")
{

View File

@@ -37,6 +37,7 @@ signals:
void sigErrorAuth(QString error);
void sigAuth(ServerAuthorization *serverAuth);
void sigDeAuth(ServerDeAuthorization *serverDeAuth);
void sigTryBlock(bool result, QString type);
void sigAnswerQueryToDB(QList<Instructor>* listInstructors,
QList<Trainee>* listTrainees,
QList<Group>* listGroups);

View File

@@ -150,6 +150,8 @@ void ConnectorToServer::bindConnection()
connect(recognizeSystem,&RecognizeSystem::sigAuth,this,&ConnectorToServer::slot_Auth);
connect(recognizeSystem,&RecognizeSystem::sigDeAuth,this,&ConnectorToServer::sigDeLoginResult);
connect(recognizeSystem,&RecognizeSystem::sigTryBlock,this,&ConnectorToServer::sigTryBlockResult);
connect(recognizeSystem,&RecognizeSystem::sigServerBlocked,this,&ConnectorToServer::slot_ServerBlocked);
connect(recognizeSystem,&RecognizeSystem::sigErrorAuth,this,&ConnectorToServer::slot_ErrorAuth);

View File

@@ -130,6 +130,9 @@ signals:
void sigLoginResult(ServerAuthorization * serverAuth);
void sigDeLoginResult(ServerDeAuthorization * serverDeAuth);
void sigTryBlockResult(bool result, QString type);
void sigServerBlocked();
void sigErrorAuth(QString error);

View File

@@ -51,6 +51,9 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
connectorToServer = new ConnectorToServer();
connect(connectorToServer, &ConnectorToServer::sigLoginResult, this, &InstructorsAndTraineesWidget::slot_checkLoginResult);
connect(connectorToServer, &ConnectorToServer::sigDeLoginResult, this, &InstructorsAndTraineesWidget::slot_checkDeLoginResult);
connect(connectorToServer, &ConnectorToServer::sigTryBlockResult, this, &InstructorsAndTraineesWidget::slot_checkTryBlockResult);
connect(connectorToServer, &ConnectorToServer::sigServerBlocked, this, &InstructorsAndTraineesWidget::slot_ServerBlocked);
connect(connectorToServer, &ConnectorToServer::sigErrorAuth, this, &InstructorsAndTraineesWidget::slot_ErrorAuth);
connect(connectorToServer, &ConnectorToServer::signal_SetVersion, this, &InstructorsAndTraineesWidget::slot_SetVersion);
@@ -289,6 +292,11 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
}
}
void InstructorsAndTraineesWidget::slot_checkTryBlockResult(bool result, QString type)
{
}
void InstructorsAndTraineesWidget::slot_ServerBlocked()
{
if(flTryLogin)
@@ -695,6 +703,8 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
connect(dlgSettings, &DialogSettings::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet);
connect(connectorToServer, &ConnectorToServer::sigTryBlockResult, dlgSettings, &DialogSettings::slot_checkTryBlockResult);
switch( dlgSettings->exec() )
{
case QDialog::Accepted:

View File

@@ -54,6 +54,8 @@ public Q_SLOTS:
//Слот обработки результата деавторизации
void slot_checkDeLoginResult(ServerDeAuthorization * serverDeAuth);
void slot_checkTryBlockResult(bool result, QString type);
void slot_ServerBlocked();
void slot_ErrorAuth(QString error);
void slot_SetVersion(StreamingVersionData* serverVersion);

View File

@@ -5,6 +5,7 @@
#include <QXmlStreamReader>
#include <QRegExpValidator>
#include "dialogversioncontrol.h"
#include "specialmessagebox.h"
DialogSettings::DialogSettings(ConnectorToServer* connectorToServer, bool instructorIsLogged, QWidget *parent) :
QDialog(parent),
@@ -12,7 +13,8 @@ DialogSettings::DialogSettings(ConnectorToServer* connectorToServer, bool instru
settings(nullptr),
connectorToServer(nullptr),
dlgVersionControl(nullptr),
flSettingsServerChanged(false)
flSettingsServerChanged(false),
flTryVersionControl(false)
{
ui->setupUi(this);
@@ -214,19 +216,12 @@ void DialogSettings::on_btnSetVersion_clicked()
if(connectorToServer)
if(connectorToServer->getIsConnected())
{
flTryVersionControl = true;
connectorToServer->sendQueryBlockAuth(true, "VersionControl");
dlgVersionControl = new DialogVersionControl(connectorToServer, this);
dlgVersionControl->initialize(connectorToServer->getLoginName());
dlgVersionControl->exec();
if(dlgVersionControl)
{
delete dlgVersionControl;
dlgVersionControl = nullptr;
}
connectorToServer->sendQueryBlockAuth(false, "VersionControl");
//TODO пока сразу
//slot_VersionControl();
}
}
@@ -258,3 +253,38 @@ void DialogSettings::on_DialogSettings_accepted()
emit signal_LanguageChanged(language);
}
void DialogSettings::slot_VersionControl()
{
dlgVersionControl = new DialogVersionControl(connectorToServer, this);
dlgVersionControl->initialize(connectorToServer->getLoginName());
dlgVersionControl->exec();
if(dlgVersionControl)
{
delete dlgVersionControl;
dlgVersionControl = nullptr;
}
connectorToServer->sendQueryBlockAuth(false, "VersionControl");
}
void DialogSettings::slot_checkTryBlockResult(bool result, QString type)
{
if(flTryVersionControl)
{
if(type == "VersionControl")
{
if(result)
{//Одобрено
slot_VersionControl();
}
else
{//Отказ
SpecMsgBox::WarningClose(this, tr("The server rejected your request to access version control.\nAnother instructor is managing versions.\nPlease try again later."));
}
flTryVersionControl = false;
}
}
}

View File

@@ -46,6 +46,11 @@ private slots:
void on_editPort_textChanged(const QString &arg1);
void on_DialogSettings_accepted();
public slots:
void slot_VersionControl();
void slot_checkTryBlockResult(bool result, QString type);
private:
bool saveSettings();
@@ -59,6 +64,8 @@ private:
DialogVersionControl *dlgVersionControl;
bool flSettingsServerChanged;
bool flTryVersionControl;
};
#endif // DIALOGSETTINGS_H

View File

@@ -43,6 +43,20 @@ QByteArray ClientAnswerParser::deAuthorization(bool result, QString login)
return dataParser->xmlAnswer(listTag);
}
QByteArray ClientAnswerParser::tryBlock(bool result, QString type)
{
QList<SXmlAnswerTag> listTag;
SAttribute attribute1 = {"Result", result? "true" : "false"};
SAttribute attribute2 = {"Type", type};
QList<SAttribute> listAttr = {attribute1, attribute2};
SXmlAnswerTag tag = {"TryBlock", listAttr};
listTag.append(tag);
return dataParser->xmlAnswer(listTag);
}
QByteArray ClientAnswerParser::message(QString loginFrom,QString loginTo,QString text)
{
QList<SXmlAnswerTag> listTag;

View File

@@ -16,6 +16,7 @@ public:
QByteArray authorization(bool result, QString instructorName, QString clientName, QString accessType, QString login, int id);
QByteArray deAuthorization(bool result, QString login);
QByteArray tryBlock(bool result, QString type);
QByteArray message(QString loginFrom,QString loginTo,QString text);
QByteArray task(QString text);
QByteArray notify(QString code);

View File

@@ -188,7 +188,19 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
void ProcessingSystem::processingClientBlockAuth(ClientHandler *client, bool block, QString type)
{
QByteArray arrayAnswer;
bool res = emit providerDBLMS->signal_BlockAutorization(block, client->getClient()->getFullName(), type);
if(res)
{//Блокировка одобрена
arrayAnswer = dataParser->ClientAnswer()->tryBlock(true, type);
}
else
{//Отказ
arrayAnswer = dataParser->ClientAnswer()->tryBlock(false, type);
}
client->sendXmlAnswer(arrayAnswer);
}
//упращенная деавторизация при выключении сервера

View File

@@ -149,16 +149,50 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
bool MultiThreadServer::slot_BlockAutorization(bool block, QString whoFullName, QString type)
{
bool res = true;
bool res = false;
bool blockRes = false;
QString key = whoFullName + " [type:" + type + "]";
QString strTypes = "";
if(block)
{
if(whoFullName == "SERVER")
{
this->blockAutorization();
blockersMap.insert(key, type);
blockRes = true;
res = true;
}
else
{
bool flExist = false;
foreach(QString keyLocal, blockersMap.keys())
{
if(blockersMap[keyLocal] == type)
{
flExist = true;
break;
}
}
if(!flExist)
{
this->blockAutorization();
blockersMap.insert(key, type);
blockRes = true;
res = true;
}
else
{
if(!blockersMap.count())
blockRes = false;
else
blockRes = true;
res = false;
}
}
}
else
{
@@ -170,6 +204,8 @@ bool MultiThreadServer::slot_BlockAutorization(bool block, QString whoFullName,
}
else
blockRes = true;
res = true;
}
if(res)