From a70c8b5be16428603b041b3e892fb95bb4b10f72 Mon Sep 17 00:00:00 2001 From: krivoshein Date: Thu, 2 Oct 2025 18:36:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=BB=D0=BE=D0=BA=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=90=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BF=D1=80=D0=B8=20=D0=A0=D0=B5?= =?UTF-8?q?=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B2=20=D0=93=D0=A3=D0=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../connectorToServer/Core/dataparser.cpp | 18 +++++++++++++++ .../connectorToServer/Core/dataparser.h | 2 ++ .../connectorToServer/connectortoserver.cpp | 13 +++++++++++ .../connectorToServer/connectortoserver.h | 1 + .../instructors/viewerinstructors.cpp | 4 ++-- .../instructors/viewerinstructors.h | 2 +- .../instructorsandtraineeswidget.cpp | 4 ++-- .../instructorsandtraineeswidget.h | 2 +- .../trainees/viewertrainees.cpp | 4 ++-- .../trainees/viewertrainees.h | 2 +- ServerLMS/Systems/Parsers/processparser.cpp | 23 +++++++++++++++++++ ServerLMS/Systems/Parsers/processparser.h | 1 + ServerLMS/Systems/processingsystem.cpp | 7 ++++++ ServerLMS/Systems/processingsystem.h | 1 + 14 files changed, 75 insertions(+), 9 deletions(-) diff --git a/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp b/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp index d3b1319..f5a2428 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp +++ b/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp @@ -263,6 +263,24 @@ QByteArray DataParser::createDeAuthMessage(ClientDeAutorization *deAuth) return array; } +QByteArray DataParser::createQueryBlockAuth(bool block) +{ + QByteArray array; + QXmlStreamWriter xmlWriter(&array); + + xmlWriter.setAutoFormatting(true); + xmlWriter.writeStartDocument(); + xmlWriter.writeStartElement("BlockAuth"); + + xmlWriter.writeAttribute("Block", block ? "1" : "0"); + + xmlWriter.writeEndElement(); + xmlWriter.writeEndElement(); + xmlWriter.writeEndDocument(); + + return array; +} + void DataParser::createServerSettings(QString address, QString port) diff --git a/InstructorsAndTrainees/connectorToServer/Core/dataparser.h b/InstructorsAndTrainees/connectorToServer/Core/dataparser.h index 42bbfac..aad94ca 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/dataparser.h +++ b/InstructorsAndTrainees/connectorToServer/Core/dataparser.h @@ -28,6 +28,8 @@ public: QByteArray createQueryTasksXMLMessage(QString type); QByteArray createDeAuthMessage(ClientDeAutorization *deAuth); + QByteArray createQueryBlockAuth(bool block); + void createAuthData(ServerAuthorization *serverAuth); void createAuthDataOffline(QString username,QString pass); void addRunData(QList displays); diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp index d7f118d..4dfd8f8 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp @@ -113,6 +113,19 @@ bool ConnectorToServer::sendQueryTasksXML(QString type) return true; } +bool ConnectorToServer::sendQueryBlockAuth(bool block) +{ + if (!client->getIsConnected()) + { + return false; + } + + QByteArray array = dataParser->createQueryBlockAuth(block); + emit sigSendAnswerToServer(array); + + return true; +} + void ConnectorToServer::setLoginName(QString name) { versionSelectWidget->setAuthor(name); diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.h b/InstructorsAndTrainees/connectorToServer/connectortoserver.h index 779b42b..0b28001 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.h +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.h @@ -30,6 +30,7 @@ public: bool sendMessage(ClientMessage clientMessage); bool sendQueryTasksXML(QString type); + bool sendQueryBlockAuth(bool block); void SetConnectToServer(); void StopConnectToServer(); diff --git a/InstructorsAndTrainees/instructors/viewerinstructors.cpp b/InstructorsAndTrainees/instructors/viewerinstructors.cpp index 7d5b231..58499e8 100644 --- a/InstructorsAndTrainees/instructors/viewerinstructors.cpp +++ b/InstructorsAndTrainees/instructors/viewerinstructors.cpp @@ -58,7 +58,7 @@ void ViewerInstructors::changeEvent(QEvent *event) void ViewerInstructors::on_btnEditorInstructors_clicked() { - Q_EMIT signal_BlockAutorization(true); + connectorToServer->sendQueryBlockAuth(true); dlgRedactor = new DialogRedactorInstructors(connectorToServer, adminMode, this); dlgRedactor->exec(); @@ -72,7 +72,7 @@ void ViewerInstructors::on_btnEditorInstructors_clicked() if(authComplited) loadInstructorsFromDB(); - Q_EMIT signal_BlockAutorization(false); + connectorToServer->sendQueryBlockAuth(false); } void ViewerInstructors::on_treeWidgetItemClicked(QTreeWidgetItem *item, int column) diff --git a/InstructorsAndTrainees/instructors/viewerinstructors.h b/InstructorsAndTrainees/instructors/viewerinstructors.h index 7b101e9..f08be2d 100644 --- a/InstructorsAndTrainees/instructors/viewerinstructors.h +++ b/InstructorsAndTrainees/instructors/viewerinstructors.h @@ -28,7 +28,7 @@ protected: Q_SIGNALS: //сигнал о блокировке авторизации - void signal_BlockAutorization(bool block); + //void signal_BlockAutorization(bool block); public Q_SLOTS: void on_btnEditorInstructors_clicked(); diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index 1b1c115..3ac42e1 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -48,8 +48,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) : viewerInstructors = new ViewerInstructors(connectorToServer, this); connect(this, &InstructorsAndTraineesWidget::signal_NeedUpdateUI, viewerTrainees, &ViewerTrainees::slot_NeedUpdateUI); connect(this, &InstructorsAndTraineesWidget::signal_NeedUpdateUI, viewerInstructors, &ViewerInstructors::slot_NeedUpdateUI); - connect(viewerInstructors, &ViewerInstructors::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization); - connect(viewerTrainees, &ViewerTrainees::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization); + //connect(viewerInstructors, &ViewerInstructors::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization); + //connect(viewerTrainees, &ViewerTrainees::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization); connect(connectorToServer, &ConnectorToServer::signal_ConnectedToServer, this, &InstructorsAndTraineesWidget::slot_ConnectedToServer); diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.h b/InstructorsAndTrainees/instructorsandtraineeswidget.h index 9faef79..4afbd6a 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.h +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.h @@ -60,7 +60,7 @@ Q_SIGNALS: //сигнал о необходимости обновления интерфейса void signal_NeedUpdateUI(bool treeInstructor, bool treeTrainee); //сигнал о блокировке авторизации - void signal_BlockAutorization(bool block); + //void signal_BlockAutorization(bool block); private Q_SLOTS: void on_btnConnectionToServer_clicked(); diff --git a/InstructorsAndTrainees/trainees/viewertrainees.cpp b/InstructorsAndTrainees/trainees/viewertrainees.cpp index 71f15f7..cf9303a 100644 --- a/InstructorsAndTrainees/trainees/viewertrainees.cpp +++ b/InstructorsAndTrainees/trainees/viewertrainees.cpp @@ -92,7 +92,7 @@ void ViewerTrainees::changeEvent(QEvent *event) void ViewerTrainees::on_btnEditorTrainees_clicked() { - Q_EMIT signal_BlockAutorization(true); + connectorToServer->sendQueryBlockAuth(true); dlgRedactor = new DialogRedactorTrainees(connectorToServer, adminMode, this); dlgRedactor->exec(); @@ -106,7 +106,7 @@ void ViewerTrainees::on_btnEditorTrainees_clicked() if(authComplited) loadTraineesFromDB(); - Q_EMIT signal_BlockAutorization(false); + connectorToServer->sendQueryBlockAuth(false); } void ViewerTrainees::on_itemDoubleClicked(QTreeWidgetItem *item, int column) diff --git a/InstructorsAndTrainees/trainees/viewertrainees.h b/InstructorsAndTrainees/trainees/viewertrainees.h index c474eab..1b42a68 100644 --- a/InstructorsAndTrainees/trainees/viewertrainees.h +++ b/InstructorsAndTrainees/trainees/viewertrainees.h @@ -32,7 +32,7 @@ protected: Q_SIGNALS: //сигнал о блокировке авторизации - void signal_BlockAutorization(bool block); + //void signal_BlockAutorization(bool block); public Q_SLOTS: //void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column); diff --git a/ServerLMS/Systems/Parsers/processparser.cpp b/ServerLMS/Systems/Parsers/processparser.cpp index 3926e56..68f58ee 100644 --- a/ServerLMS/Systems/Parsers/processparser.cpp +++ b/ServerLMS/Systems/Parsers/processparser.cpp @@ -72,6 +72,11 @@ void ProcessParser::slot_read(ClientHandler *client, QByteArray array) clientUnityTaskFIMreport(xmlReader,client, array); } } + else if(xmlReader.name() == "BlockAuth") + {//Запрос Блокировки Авторизации от клиента ГУИ + + clientBlockAuth(xmlReader,client); + } else { emit sigLogMessage("XmlParser: unrecognized tag"); @@ -334,6 +339,24 @@ void ProcessParser::clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *clie processingSystem->processingClientDeAutorization(client, clientDeAutorization); } +void ProcessParser::clientBlockAuth(QXmlStreamReader &xmlReader, ClientHandler *client) +{ + bool block = false; + + /*Перебираем все атрибуты тега*/ + foreach(const QXmlStreamAttribute &attr, xmlReader.attributes()) + { + QString name = attr.name().toString(); + QString value = attr.value().toString(); + //addTextToLogger(name + ": " + value); + + if(name == "Block") + block = (value == "1") ? true : false; + } + + processingSystem->processingClientBlockAuth(client, block); +} + void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, QByteArray array) { ClientQueryToDB queryToDB; diff --git a/ServerLMS/Systems/Parsers/processparser.h b/ServerLMS/Systems/Parsers/processparser.h index 01a39b4..570d378 100644 --- a/ServerLMS/Systems/Parsers/processparser.h +++ b/ServerLMS/Systems/Parsers/processparser.h @@ -25,6 +25,7 @@ private: ProcessingSystem *processingSystem; void clientAuth(QXmlStreamReader &xmlReader,ClientHandler *client); void clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *client); + void clientBlockAuth(QXmlStreamReader &xmlReader,ClientHandler *client); void toClientMessage(QXmlStreamReader &xmlReader,ClientHandler *client); void queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, QByteArray array = QByteArray()); void queryTasksXML(QXmlStreamReader &xmlReader,ClientHandler *client); diff --git a/ServerLMS/Systems/processingsystem.cpp b/ServerLMS/Systems/processingsystem.cpp index e80e9c2..580e83c 100644 --- a/ServerLMS/Systems/processingsystem.cpp +++ b/ServerLMS/Systems/processingsystem.cpp @@ -101,6 +101,7 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization) { + /* if(server->getStateBlockAutorization() == blocked) { QByteArray arrayAnswer = dataParser->ClientAnswer()->notify(NOTIFY_SERVER_BLOCKED); @@ -111,6 +112,7 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli return; } + */ //Попытка ДеАвторизации клиента (проверка по БД) QByteArray arrayAnswer; @@ -148,6 +150,11 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli emit sigListsInstructorsTraineesChanged(); } +void ProcessingSystem::processingClientBlockAuth(ClientHandler *client, bool block) +{ + emit providerDBLMS->signal_BlockAutorization(block); +} + //упращенная деавторизация при выключении сервера void ProcessingSystem::processingClientDeAutorization(QString login) { diff --git a/ServerLMS/Systems/processingsystem.h b/ServerLMS/Systems/processingsystem.h index e0ff3f2..9527d0b 100644 --- a/ServerLMS/Systems/processingsystem.h +++ b/ServerLMS/Systems/processingsystem.h @@ -34,6 +34,7 @@ public: void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization); void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization); + void processingClientBlockAuth(ClientHandler *client, bool block); void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr); void processingClientQueryTasksXML(ClientHandler *client, ClientQueryTasksXML clientQueryTasksXML);