карта блок-в. Блокировка правильная. Множ. доступ

This commit is contained in:
2026-01-21 15:44:01 +03:00
parent fe75f2c6ca
commit 2772c3aaba
26 changed files with 146 additions and 91 deletions

View File

@@ -294,7 +294,7 @@ QByteArray DataParser::createDeAuthMessage(ClientDeAutorization *deAuth)
return array; return array;
} }
QByteArray DataParser::createQueryBlockAuth(bool block) QByteArray DataParser::createQueryBlockAuth(bool block, QString type)
{ {
QByteArray array; QByteArray array;
QXmlStreamWriter xmlWriter(&array); QXmlStreamWriter xmlWriter(&array);
@@ -304,6 +304,7 @@ QByteArray DataParser::createQueryBlockAuth(bool block)
xmlWriter.writeStartElement("BlockAuth"); xmlWriter.writeStartElement("BlockAuth");
xmlWriter.writeAttribute("Block", block ? "1" : "0"); xmlWriter.writeAttribute("Block", block ? "1" : "0");
xmlWriter.writeAttribute("type", type);
xmlWriter.writeEndElement(); xmlWriter.writeEndElement();
xmlWriter.writeEndElement(); xmlWriter.writeEndElement();

View File

@@ -29,7 +29,7 @@ public:
QByteArray createQueryListSubProcMessage(QString dmCode); QByteArray createQueryListSubProcMessage(QString dmCode);
QByteArray createDeAuthMessage(ClientDeAutorization *deAuth); QByteArray createDeAuthMessage(ClientDeAutorization *deAuth);
QByteArray createQueryBlockAuth(bool block); QByteArray createQueryBlockAuth(bool block, QString type);
void createAuthData(ServerAuthorization *serverAuth); void createAuthData(ServerAuthorization *serverAuth);
void createAuthDataOffline(QString username,QString pass); void createAuthDataOffline(QString username,QString pass);

View File

@@ -260,12 +260,12 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
if(packetType == PacketType::BUSY) if(packetType == PacketType::BUSY)
{ {
emit sigAnimationActivated(true); //emit sigAnimationActivated(true);
} }
if(packetType == PacketType::FREE) if(packetType == PacketType::FREE)
{ {
emit sigAnimationActivated(false); //emit sigAnimationActivated(false);
} }
if(packetType == PacketType::HASH_READY) if(packetType == PacketType::HASH_READY)

View File

@@ -57,7 +57,6 @@ signals:
void sigShowServerDataList(QList<StreamingVersionData*> *versions); void sigShowServerDataList(QList<StreamingVersionData*> *versions);
void sigSetVersion(StreamingVersionData* serverVersion); void sigSetVersion(StreamingVersionData* serverVersion);
void sigNotifyVersionControl(QString text); void sigNotifyVersionControl(QString text);
void sigAnimationActivated(bool flag);
void sigHashReady(); void sigHashReady();
void sigAnswerQuerySubProc(QList<SubProc> listSubProc, QString parentTask_dmCode); void sigAnswerQuerySubProc(QList<SubProc> listSubProc, QString parentTask_dmCode);

View File

@@ -168,7 +168,6 @@ void ConnectorToServer::bindConnection()
connect(recognizeSystem,&RecognizeSystem::signal_AnswerDocsChanged,this,&ConnectorToServer::slot_AnswerDocsChanged); connect(recognizeSystem,&RecognizeSystem::signal_AnswerDocsChanged,this,&ConnectorToServer::slot_AnswerDocsChanged);
connect(recognizeSystem, &RecognizeSystem::sigSetVersion, this, &ConnectorToServer::signal_SetVersion); connect(recognizeSystem, &RecognizeSystem::sigSetVersion, this, &ConnectorToServer::signal_SetVersion);
connect(recognizeSystem, &RecognizeSystem::sigAnimationActivated, this, &ConnectorToServer::signal_AnimationActivated);
connect(this, &ConnectorToServer::signal_SendCopyVersion, sendSystem, &SendSystem::sendCopyVersion); connect(this, &ConnectorToServer::signal_SendCopyVersion, sendSystem, &SendSystem::sendCopyVersion);
connect(this, &ConnectorToServer::signal_SendDeleteVersion, sendSystem, &SendSystem::sendDeleteVersion); connect(this, &ConnectorToServer::signal_SendDeleteVersion, sendSystem, &SendSystem::sendDeleteVersion);

View File

@@ -47,7 +47,7 @@ public:
bool sendQueryTasksXML(QString type); bool sendQueryTasksXML(QString type);
bool sendQueryListSubProc(QString dmCode); bool sendQueryListSubProc(QString dmCode);
bool sendQueryBlockAuth(bool block); bool sendQueryBlockAuth(bool block, QString type);
void sendShowVersionSelect(); void sendShowVersionSelect();
bool sendClientNotify(QString command); bool sendClientNotify(QString command);
@@ -149,7 +149,6 @@ signals:
void signal_AnswerDocsChanged(); void signal_AnswerDocsChanged();
void signal_SetVersion(StreamingVersionData* serverVersion); void signal_SetVersion(StreamingVersionData* serverVersion);
void signal_AnimationActivated(bool flag);
void signal_SendDeleteVersion(StreamingVersionData *streaming); void signal_SendDeleteVersion(StreamingVersionData *streaming);
void signal_SendSwitchVersion(StreamingVersionData *selectVersion); void signal_SendSwitchVersion(StreamingVersionData *selectVersion);

View File

@@ -95,14 +95,14 @@ bool ConnectorToServer::sendQueryListSubProc(QString dmCode)
return true; return true;
} }
bool ConnectorToServer::sendQueryBlockAuth(bool block) bool ConnectorToServer::sendQueryBlockAuth(bool block, QString type)
{ {
if (!client->getIsConnected()) if (!client->getIsConnected())
{ {
return false; return false;
} }
QByteArray array = dataParser->createQueryBlockAuth(block); QByteArray array = dataParser->createQueryBlockAuth(block, type);
emit sigSendAnswerToServer(array); emit sigSendAnswerToServer(array);
return true; return true;

View File

@@ -77,7 +77,7 @@ void ViewerInstructors::slot_receiveMessage(ClientMessage clientMessage)
void ViewerInstructors::on_btnEditorInstructors_clicked() void ViewerInstructors::on_btnEditorInstructors_clicked()
{ {
connectorToServer->sendQueryBlockAuth(true); connectorToServer->sendQueryBlockAuth(true, "EditorInstructors");
dlgRedactor = new DialogRedactorInstructors(connectorToServer, adminMode, this); dlgRedactor = new DialogRedactorInstructors(connectorToServer, adminMode, this);
dlgRedactor->exec(); dlgRedactor->exec();
@@ -91,7 +91,7 @@ void ViewerInstructors::on_btnEditorInstructors_clicked()
if(authComplited) if(authComplited)
loadInstructorsFromDB(); loadInstructorsFromDB();
connectorToServer->sendQueryBlockAuth(false); connectorToServer->sendQueryBlockAuth(false, "EditorInstructors");
} }
void ViewerInstructors::on_treeWidgetCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) void ViewerInstructors::on_treeWidgetCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)

View File

@@ -214,6 +214,8 @@ void DialogSettings::on_btnSetVersion_clicked()
if(connectorToServer) if(connectorToServer)
if(connectorToServer->getIsConnected()) if(connectorToServer->getIsConnected())
{ {
connectorToServer->sendQueryBlockAuth(true, "VersionControl");
dlgVersionControl = new DialogVersionControl(connectorToServer, this); dlgVersionControl = new DialogVersionControl(connectorToServer, this);
dlgVersionControl->initialize(connectorToServer->getLoginName()); dlgVersionControl->initialize(connectorToServer->getLoginName());
dlgVersionControl->exec(); dlgVersionControl->exec();
@@ -222,7 +224,9 @@ void DialogSettings::on_btnSetVersion_clicked()
{ {
delete dlgVersionControl; delete dlgVersionControl;
dlgVersionControl = nullptr; dlgVersionControl = nullptr;
} }
connectorToServer->sendQueryBlockAuth(false, "VersionControl");
} }
} }

View File

@@ -58,7 +58,6 @@ void DialogVersionControl::initialize(QString authorName)
this->authorName = authorName; this->authorName = authorName;
connect (connectorToServer, &ConnectorToServer::signal_SetVersion, this, &DialogVersionControl::slot_SetVersion); connect (connectorToServer, &ConnectorToServer::signal_SetVersion, this, &DialogVersionControl::slot_SetVersion);
connect(connectorToServer, &ConnectorToServer::signal_AnimationActivated, this, &DialogVersionControl::slot_activateLoadAnimation);
connect(connectorToServer, &ConnectorToServer::signal_showServerList, this, &DialogVersionControl::slot_showServerList); connect(connectorToServer, &ConnectorToServer::signal_showServerList, this, &DialogVersionControl::slot_showServerList);
connect(connectorToServer, &ConnectorToServer::signal_NotifyVersionControl, this, &DialogVersionControl::slot_NotifyVersionControl); connect(connectorToServer, &ConnectorToServer::signal_NotifyVersionControl, this, &DialogVersionControl::slot_NotifyVersionControl);
@@ -69,6 +68,7 @@ void DialogVersionControl::initialize(QString authorName)
connect(this, &DialogVersionControl::signal_getVersion, connectorToServer, &ConnectorToServer::slot_getVersion); connect(this, &DialogVersionControl::signal_getVersion, connectorToServer, &ConnectorToServer::slot_getVersion);
waitAnimationWidget->showWithPlay();
emit signal_getVersion(); emit signal_getVersion();
} }
@@ -124,6 +124,7 @@ void DialogVersionControl::sendCopyEmit(QString newName)
} }
versionContainer->setLocalVersionData(selectedVersion); versionContainer->setLocalVersionData(selectedVersion);
waitAnimationWidget->showWithPlay();
emit sigSendCopyVersion(result); emit sigSendCopyVersion(result);
} }
@@ -144,6 +145,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked()
case QDialog::Accepted: case QDialog::Accepted:
{ {
QString newName = dlgNewVersion->getNewName(); QString newName = dlgNewVersion->getNewName();
waitAnimationWidget->showWithPlay();
sendCopyEmit(newName); sendCopyEmit(newName);
break; break;
} }
@@ -171,6 +173,7 @@ void DialogVersionControl::on_deleteVersionButton_clicked()
if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
{ {
waitAnimationWidget->showWithPlay();
emit sigSendDeleteVersion(selectedVersion); emit sigSendDeleteVersion(selectedVersion);
} }
} }
@@ -186,24 +189,14 @@ void DialogVersionControl::on_switchServerVersionButton_clicked()
//versionContainer->setServerVersionData(selectedVersion); //versionContainer->setServerVersionData(selectedVersion);
//ui->verValue->setText(selectedVersion->getViewName()); //ui->verValue->setText(selectedVersion->getViewName());
waitAnimationWidget->showWithPlay();
emit sigSendSwitchVersion(selectedVersion); emit sigSendSwitchVersion(selectedVersion);
} }
void DialogVersionControl::slot_activateLoadAnimation(bool flag)
{
if (flag)
{
waitAnimationWidget->showWithPlay();
}
else
{
waitAnimationWidget->hideWithStop();
}
}
void DialogVersionControl::slot_showServerList(QList<StreamingVersionData *> *serverList) void DialogVersionControl::slot_showServerList(QList<StreamingVersionData *> *serverList)
{ {
fillView(serverList); fillView(serverList);
waitAnimationWidget->hideWithStop();
} }
void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion) void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion)
@@ -215,11 +208,15 @@ void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion)
connectorToServer->sendShowVersionSelect(); connectorToServer->sendShowVersionSelect();
flGetVersion = true; flGetVersion = true;
waitAnimationWidget->hideWithStop();
} }
void DialogVersionControl::slot_NotifyVersionControl(QString text) void DialogVersionControl::slot_NotifyVersionControl(QString text)
{ {
SpecMsgBox::WarningClose(this, text); SpecMsgBox::WarningClose(this, text);
waitAnimationWidget->hideWithStop();
} }
void DialogVersionControl::resizeEvent(QResizeEvent *event) void DialogVersionControl::resizeEvent(QResizeEvent *event)

View File

@@ -36,7 +36,6 @@ private slots:
void on_verListView_itemClicked(QListWidgetItem *item); void on_verListView_itemClicked(QListWidgetItem *item);
private slots: private slots:
void slot_activateLoadAnimation(bool flag);
void slot_showServerList(QList<StreamingVersionData*> *serverList); void slot_showServerList(QList<StreamingVersionData*> *serverList);
void slot_SetVersion(StreamingVersionData* serverVersion); void slot_SetVersion(StreamingVersionData* serverVersion);
void slot_NotifyVersionControl(QString text); void slot_NotifyVersionControl(QString text);

View File

@@ -111,7 +111,7 @@ void ViewerTrainees::slot_receiveMessage(ClientMessage clientMessage)
void ViewerTrainees::on_btnEditorTrainees_clicked() void ViewerTrainees::on_btnEditorTrainees_clicked()
{ {
connectorToServer->sendQueryBlockAuth(true); connectorToServer->sendQueryBlockAuth(true, "EditorTrainees");
dlgRedactor = new DialogRedactorTrainees(connectorToServer, adminMode, this); dlgRedactor = new DialogRedactorTrainees(connectorToServer, adminMode, this);
dlgRedactor->exec(); dlgRedactor->exec();
@@ -125,7 +125,7 @@ void ViewerTrainees::on_btnEditorTrainees_clicked()
if(authComplited) if(authComplited)
loadTraineesFromDB(); loadTraineesFromDB();
connectorToServer->sendQueryBlockAuth(false); connectorToServer->sendQueryBlockAuth(false, "EditorTrainees");
} }
void ViewerTrainees::on_btnPersonalCard_clicked() void ViewerTrainees::on_btnPersonalCard_clicked()

View File

@@ -367,6 +367,7 @@ void ProcessParser::clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *clie
void ProcessParser::clientBlockAuth(QXmlStreamReader &xmlReader, ClientHandler *client) void ProcessParser::clientBlockAuth(QXmlStreamReader &xmlReader, ClientHandler *client)
{ {
bool block = false; bool block = false;
QString type = "";
/*Перебираем все атрибуты тега*/ /*Перебираем все атрибуты тега*/
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes()) foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
@@ -377,9 +378,12 @@ void ProcessParser::clientBlockAuth(QXmlStreamReader &xmlReader, ClientHandler *
if(name == "Block") if(name == "Block")
block = (value == "1") ? true : false; block = (value == "1") ? true : false;
if(name == "type")
type = value;
} }
processingSystem->processingClientBlockAuth(client, block); processingSystem->processingClientBlockAuth(client, block, type);
} }
void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, QByteArray array) void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, QByteArray array)

View File

@@ -117,7 +117,7 @@ void CommonClientHandler::slot_sendPacketToAllClients(PacketType packetType)
Logger::instance().log("AllSending " + handler->getClient()->getLogin() + " " + enumToString(packetType)); Logger::instance().log("AllSending " + handler->getClient()->getLogin() + " " + enumToString(packetType));
} }
emit sigSetServerState(packetType); //emit sigSetServerState(packetType);
} }

View File

@@ -22,13 +22,17 @@ public:
void slot_ListsInstructorsTraineesChanged(); void slot_ListsInstructorsTraineesChanged();
void slot_StatusTasksAMMofTraineeChanged(int trainee_id); void slot_StatusTasksAMMofTraineeChanged(int trainee_id);
void slot_StatusTasksFIMofTraineeChanged(int trainee_id); void slot_StatusTasksFIMofTraineeChanged(int trainee_id);
void slot_sendPacketToAllClients(PacketType packetType);
bool slotSendMessage(QString loginFrom, QString loginTo, QString text); bool slotSendMessage(QString loginFrom, QString loginTo, QString text);
void slot_sendTaskToClient(QString fullNameClient, QString textTask); void slot_sendTaskToClient(QString fullNameClient, QString textTask);
void slot_DocsChanged(); void slot_DocsChanged();
public slots:
void slot_sendPacketToAllClients(PacketType packetType);
signals: signals:
void sigSetServerState(PacketType packetType); //void sigSetServerState(PacketType packetType);
private: private:
QMap<int, ClientHandler*> *clientsMap; QMap<int, ClientHandler*> *clientsMap;
ProcessingSystem *processingSystem; ProcessingSystem *processingSystem;

View File

@@ -164,6 +164,8 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
else if(providerDBLMS->deAuthorizationInstructor(clientDeAutorization.Login)) else if(providerDBLMS->deAuthorizationInstructor(clientDeAutorization.Login))
{//ДеАвторизуется инструктор {//ДеАвторизуется инструктор
QString fullName = client->getClient()->getFullName();
client->getClient()->setLogin(""); client->getClient()->setLogin("");
client->getClient()->setAccessType(UserType::NONE); client->getClient()->setAccessType(UserType::NONE);
client->getClient()->setIsLoggedIn(false); client->getClient()->setIsLoggedIn(false);
@@ -172,6 +174,8 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
arrayAnswer = dataParser->ClientAnswer()->deAuthorization(true, clientDeAutorization.Login); arrayAnswer = dataParser->ClientAnswer()->deAuthorization(true, clientDeAutorization.Login);
client->sendXmlAnswer(arrayAnswer); client->sendXmlAnswer(arrayAnswer);
providerDBLMS->signal_BlockAutorization(false, fullName, "DeAuthorizationInstructor");
//Извещаем об изменениях в авторизации //Извещаем об изменениях в авторизации
emit sigListsInstructorsTraineesChanged(); emit sigListsInstructorsTraineesChanged();
} }
@@ -182,9 +186,9 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
} }
} }
void ProcessingSystem::processingClientBlockAuth(ClientHandler *client, bool block) void ProcessingSystem::processingClientBlockAuth(ClientHandler *client, bool block, QString type)
{ {
emit providerDBLMS->signal_BlockAutorization(block); bool res = emit providerDBLMS->signal_BlockAutorization(block, client->getClient()->getFullName(), type);
} }
//упращенная деавторизация при выключении сервера //упращенная деавторизация при выключении сервера

View File

@@ -35,7 +35,7 @@ public:
void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization); void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization);
void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization); void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization);
void processingClientBlockAuth(ClientHandler *client, bool block); void processingClientBlockAuth(ClientHandler *client, bool block, QString type);
void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr); void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr);
void processingClientQueryTasksXML(ClientHandler *client, ClientQueryTasksXML clientQueryTasksXML); void processingClientQueryTasksXML(ClientHandler *client, ClientQueryTasksXML clientQueryTasksXML);
void processingClientQueryListSubProc(ClientHandler *client, QString dmCode); void processingClientQueryListSubProc(ClientHandler *client, QString dmCode);

View File

@@ -411,7 +411,7 @@ void RecognizeSystem::recognize()
} }
emit sigCopyVersion(result[0],result[1],result[2]); emit sigCopyVersion(result[0],result[1],result[2]);
sendSystem->sendPacketType(PacketType::BUSY); //sendSystem->sendPacketType(PacketType::BUSY); //KAV Вроде, это не нужно (дублируется)?
} }
if(packetType == PacketType::DELETE_DATA_VERSION) if(packetType == PacketType::DELETE_DATA_VERSION)

View File

@@ -44,7 +44,7 @@ void UpdateController::initialize(CommonClientHandler *commonClientHandler,DataP
void UpdateController::changeAssetVersion(QString versionName) void UpdateController::changeAssetVersion(QString versionName)
{ {
commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY); //commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
qDebug() << "UpdateController thread ID " << QThread::currentThreadId(); qDebug() << "UpdateController thread ID " << QThread::currentThreadId();
currentStreamingPath = assetManager->setVersion(versionName); currentStreamingPath = assetManager->setVersion(versionName);
setUpCurrentServerHash(); setUpCurrentServerHash();
@@ -52,21 +52,21 @@ void UpdateController::changeAssetVersion(QString versionName)
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY); commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY);
commonClientHandler->sendCurrentVersionToAllClient(); commonClientHandler->sendCurrentVersionToAllClient();
commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE); //commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
} }
void UpdateController::createCopyVersion(QString versionName,QString newVersionName,QString author) void UpdateController::createCopyVersion(QString versionName,QString newVersionName,QString author)
{ {
commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY); //commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
assetManager->createCopyVersion(versionName,newVersionName,author); assetManager->createCopyVersion(versionName,newVersionName,author);
commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE); //commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
} }
void UpdateController::deleteAssetVersion(QString versionName) void UpdateController::deleteAssetVersion(QString versionName)
{ {
commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY); //commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
assetManager->deleteVersion(versionName); assetManager->deleteVersion(versionName);
commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE); //commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
} }
void UpdateController::compareFiles(ClientHandler* handler, QByteArray array) void UpdateController::compareFiles(ClientHandler* handler, QByteArray array)
@@ -94,7 +94,8 @@ void UpdateController::calculateFullHash()
QElapsedTimer timer; QElapsedTimer timer;
timer.start(); timer.start();
qDebug() << "Start calculate... "; qDebug() << "Start calculate... ";
commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY); //commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
bool res = emit signal_BlockAutorization(true, "SERVER", "CalculateFullHash");
//auto *list = calculateHash(buildPath); //auto *list = calculateHash(buildPath);
hashCalculator->calculateHashes(buildPath); hashCalculator->calculateHashes(buildPath);
@@ -104,8 +105,8 @@ void UpdateController::calculateFullHash()
calculateSharedHash(); calculateSharedHash();
Logger::instance().log("Calculate hash complete"); Logger::instance().log("Calculate hash complete");
qDebug() << "Calculate time " << timer.elapsed(); qDebug() << "Calculate time " << timer.elapsed();
commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE); //commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
res = emit signal_BlockAutorization(false, "SERVER", "CalculateFullHash");
} }
void UpdateController::calculateFullHashWithSetup() void UpdateController::calculateFullHashWithSetup()

View File

@@ -71,6 +71,9 @@ signals:
void sigInitializeFinished(); void sigInitializeFinished();
//сигнал о блокировке авторизации
bool signal_BlockAutorization(bool block, QString whoFullName, QString type);
private: private:
QList<FileData> clientDataList; QList<FileData> clientDataList;
QList<FileData> serverDataList; QList<FileData> serverDataList;

View File

@@ -35,15 +35,17 @@ bool MultiThreadServer::startServer()
//connect(tcpServer, &QTcpServer::newConnection, this, &ServerLMSWidget::slotNewConnection,Qt::AutoConnection); //connect(tcpServer, &QTcpServer::newConnection, this, &ServerLMSWidget::slotNewConnection,Qt::AutoConnection);
if(!listen(QHostAddress::Any, hostPort)) if(!listen(QHostAddress::Any, hostPort))
{ {
Logger::instance().log("SERVER: start ERROR");
stateServer = stoped; stateServer = stoped;
Logger::instance().log("SERVER: start ERROR");
return false; return false;
} }
else else
{ {
Logger::instance().log("SERVER: start OK");
stateServer = started; stateServer = started;
slot_BlockAutorization(false, "SERVER", "StartServer");
Logger::instance().log("SERVER: start OK");
return true; return true;
} }
} }
@@ -59,7 +61,8 @@ bool MultiThreadServer::stopServer()
//Закрываем сервер //Закрываем сервер
close(); close();
stateServer = stoped; stateServer = stoped;
slot_BlockAutorization(true, "SERVER", "StopServer");
Logger::instance().log("SERVER: stop OK"); Logger::instance().log("SERVER: stop OK");
return true; return true;
} }
@@ -94,8 +97,13 @@ void MultiThreadServer::disableClients()
handler->sigSendXmlAnswer(arrayAnswer, PacketType::TYPE_XMLANSWER); handler->sigSendXmlAnswer(arrayAnswer, PacketType::TYPE_XMLANSWER);
QString str = QString(arrayAnswer); QString str = QString(arrayAnswer);
QString fullName = handler->getClient()->getFullName();
processingSystem->processingClientDeAutorization(handler->getClient()->getLogin()); processingSystem->processingClientDeAutorization(handler->getClient()->getLogin());
slot_BlockAutorization(false, fullName, "DisableClient");
handler->sigSocketClose(); handler->sigSocketClose();
//clientsMap.remove(idSocket); //clientsMap.remove(idSocket);
removeClient(idSocket); removeClient(idSocket);
@@ -119,8 +127,12 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
ClientDeAutorization clientDeAutorization; ClientDeAutorization clientDeAutorization;
clientDeAutorization.Login = login; clientDeAutorization.Login = login;
//QString fullName = client->getClient()->getFullName();
processingSystem->processingClientDeAutorization(client, clientDeAutorization); processingSystem->processingClientDeAutorization(client, clientDeAutorization);
//slot_BlockAutorization(false, fullName, "DisconnectClient");
removeClient(idSocket); removeClient(idSocket);
delete client; delete client;
continue; continue;
@@ -135,6 +147,37 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
serverLmsWidget->getProcessingSystem()->processingClientDeAutorization(login); serverLmsWidget->getProcessingSystem()->processingClientDeAutorization(login);
} }
bool MultiThreadServer::slot_BlockAutorization(bool block, QString whoFullName, QString type)
{
bool res = true;
bool blockRes = false;
if(block)
{
this->blockAutorization();
blockersMap.insert(whoFullName, type);
blockRes = true;
}
else
{
blockersMap.take(whoFullName);
if(!blockersMap.count())
this->unBlockAutorization();
}
if(res)
{
if(blockRes)
emit signal_sendPacketToAllClients(PacketType::BUSY);
else
emit signal_sendPacketToAllClients(PacketType::FREE);
emit signal_BlockAutorizationIndicate(block, whoFullName, type);
}
return res;
}
void MultiThreadServer::removeClient(int idSocket) void MultiThreadServer::removeClient(int idSocket)
{ {
clientsMap->remove(idSocket); clientsMap->remove(idSocket);

View File

@@ -21,14 +21,7 @@ public:
bool startServer(); bool startServer();
bool stopServer(); bool stopServer();
void blockAutorization()
{
stateBlockAutorization = blocked;
}
void unBlockAutorization()
{
stateBlockAutorization = unblocked;
}
EStateBlockAutorization getStateBlockAutorization() const EStateBlockAutorization getStateBlockAutorization() const
{ {
return stateBlockAutorization; return stateBlockAutorization;
@@ -37,13 +30,29 @@ public:
{ {
return stateServer; return stateServer;
} }
private:
void blockAutorization()
{
stateBlockAutorization = blocked;
}
void unBlockAutorization()
{
stateBlockAutorization = unblocked;
}
signals: signals:
void sigInitClient(int descriptor, ServerLMSWidget *serverWidget, void sigInitClient(int descriptor, ServerLMSWidget *serverWidget,
UpdateController *updateController, DataParser *dataParser); UpdateController *updateController, DataParser *dataParser);
void signalStopSendFile(); void signalStopSendFile();
void signal_BlockAutorizationIndicate(bool block, QString whoFullName, QString type);
void signal_sendPacketToAllClients(PacketType packetType);
public slots: public slots:
void slotDisconnectClient(QString peerAddress, QString peerPort); void slotDisconnectClient(QString peerAddress, QString peerPort);
bool slot_BlockAutorization(bool block, QString whoFullName, QString type);
protected: protected:
void incomingConnection(qintptr handle) override; void incomingConnection(qintptr handle) override;
@@ -57,6 +66,7 @@ private:
EStateServer stateServer; EStateServer stateServer;
EStateBlockAutorization stateBlockAutorization; EStateBlockAutorization stateBlockAutorization;
QMap<QString, QString> blockersMap;
void removeClient(int idSocket); void removeClient(int idSocket);
void addClient(qintptr descriptor, ClientHandler *client); void addClient(qintptr descriptor, ClientHandler *client);

View File

@@ -24,7 +24,7 @@ bool ProviderDBLMS::ConnectionToDB()
{ {
if(dbLMS->connectionToDB()) if(dbLMS->connectionToDB())
{ {
Q_EMIT signal_BlockAutorization(false); bool res = Q_EMIT signal_BlockAutorization(false, "SERVER", "DisConnectionDB");
mtxAccess.unlock(); mtxAccess.unlock();
return true; return true;
@@ -44,7 +44,7 @@ void ProviderDBLMS::DisConnectionFromDB()
mtxAccess.lock(); mtxAccess.lock();
if(dbLMS->DBisConnected()) if(dbLMS->DBisConnected())
{ {
Q_EMIT signal_BlockAutorization(true); bool res = Q_EMIT signal_BlockAutorization(true, "SERVER", "DisConnectionDB");
dbLMS->disConnectionFromDB(); dbLMS->disConnectionFromDB();
} }
@@ -230,12 +230,12 @@ bool ProviderDBLMS::deAuthorizationAll()
return false; return false;
} }
Q_EMIT signal_BlockAutorization(true); bool res = Q_EMIT signal_BlockAutorization(true, "SERVER", "DeAuthorizationAll");
bool res1 = dbLMS->deAuthorizationAllTrainees(); bool res1 = dbLMS->deAuthorizationAllTrainees();
bool res2 = dbLMS->deAuthorizationAllInstructors(); bool res2 = dbLMS->deAuthorizationAllInstructors();
Q_EMIT signal_BlockAutorization(false); res = Q_EMIT signal_BlockAutorization(false, "SERVER", "DeAuthorizationAll");
mtxAccess.unlock(); mtxAccess.unlock();
return res1 && res2; return res1 && res2;

View File

@@ -72,7 +72,7 @@ public:
Q_SIGNALS: Q_SIGNALS:
//сигнал о блокировке авторизации //сигнал о блокировке авторизации
void signal_BlockAutorization(bool block); bool signal_BlockAutorization(bool block, QString whoFullName, QString type);
signals: signals:
void signal_ErrorPostgreSQL(QString text); void signal_ErrorPostgreSQL(QString text);

View File

@@ -191,17 +191,17 @@ void ServerLMSWidget::start()
startInitialization_step0(); startInitialization_step0();
} }
void ServerLMSWidget::slot_BlockAutorization(bool block) void ServerLMSWidget::slot_BlockAutorizationIndicate(bool block, QString whoFullName, QString type)
{ {
if(block) if(block)
{ {
server->blockAutorization(); //server->blockAutorization();
Logger::instance().log("Autorization is blocked"); Logger::instance().log(QString("Server BLOCK from: %1 [type: %2]").arg(whoFullName, type));
} }
else else
{ {
server->unBlockAutorization(); //server->unBlockAutorization();
Logger::instance().log("Autorization is unblocked"); Logger::instance().log(QString("Server UNBLOCK from: %1 [type: %2]").arg(whoFullName, type));
} }
updateStateOnlyServer(); updateStateOnlyServer();
} }
@@ -222,9 +222,9 @@ void ServerLMSWidget::on_btnStartServer_clicked()
ui->btnStartServer->setEnabled(false); ui->btnStartServer->setEnabled(false);
ui->btnStopServer->setEnabled(true); ui->btnStopServer->setEnabled(true);
slot_BlockAutorization(false); //slot_BlockAutorizationIndicate(false, "SERVER");
updateStateOnlyServer(); //updateStateOnlyServer();
emit signal_Tray_ShowMessage(tr("Server is started!")); emit signal_Tray_ShowMessage(tr("Server is started!"));
@@ -240,9 +240,9 @@ void ServerLMSWidget::on_btnStopServer_clicked()
ui->btnStopServer->setEnabled(false); ui->btnStopServer->setEnabled(false);
ui->btnStartServer->setEnabled(true); ui->btnStartServer->setEnabled(true);
slot_BlockAutorization(true); //slot_BlockAutorizationIndicate(true, "SERVER");
updateStateOnlyServer(); //updateStateOnlyServer();
emit signal_Tray_ShowMessage(tr("Server is stoped!")); emit signal_Tray_ShowMessage(tr("Server is stoped!"));
@@ -298,20 +298,6 @@ void ServerLMSWidget::on_btnSettings_clicked()
} }
} }
void ServerLMSWidget::slot_trySetServerState(PacketType packetType)
{
if (packetType == PacketType::BUSY)
{
server->blockAutorization();
updateStateOnlyServer();
}
else if (packetType == PacketType::FREE)
{
server->unBlockAutorization();
updateStateOnlyServer();
}
}
void ServerLMSWidget::setLanguageInterfase() void ServerLMSWidget::setLanguageInterfase()
{ {
ServerDBSettings settings; ServerDBSettings settings;
@@ -366,7 +352,7 @@ void ServerLMSWidget::startInitialization_step0()
providerDBLMS = new ProviderDBLMS(this); providerDBLMS = new ProviderDBLMS(this);
connect(providerDBLMS, &ProviderDBLMS::signal_ErrorPostgreSQL, this, &ServerLMSWidget::slot_ErrorPostgreSQL); connect(providerDBLMS, &ProviderDBLMS::signal_ErrorPostgreSQL, this, &ServerLMSWidget::slot_ErrorPostgreSQL);
connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization); //connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorizationIndicate);
mutex = new QMutex; mutex = new QMutex;
@@ -390,9 +376,13 @@ void ServerLMSWidget::startInitialization_step0()
commonClientHandler = new CommonClientHandler; commonClientHandler = new CommonClientHandler;
connect(this, &ServerLMSWidget::signal_DocsChanged, commonClientHandler, &CommonClientHandler::slot_DocsChanged); connect(this, &ServerLMSWidget::signal_DocsChanged, commonClientHandler, &CommonClientHandler::slot_DocsChanged);
connect(commonClientHandler, &CommonClientHandler::sigSetServerState, this, &ServerLMSWidget::slot_trySetServerState); //connect(commonClientHandler, &CommonClientHandler::sigSetServerState, this, &ServerLMSWidget::slot_trySetServerState);
server = new MultiThreadServer(this, updateController, processingSystem, dataParser, 6000); server = new MultiThreadServer(this, updateController, processingSystem, dataParser, 6000);
connect(server, &MultiThreadServer::signal_BlockAutorizationIndicate, this, &ServerLMSWidget::slot_BlockAutorizationIndicate);
connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, server, &MultiThreadServer::slot_BlockAutorization, Qt::DirectConnection);
connect(updateController, &UpdateController::signal_BlockAutorization, server, &MultiThreadServer::slot_BlockAutorization, Qt::DirectConnection);
connect(server, &MultiThreadServer::signal_sendPacketToAllClients, commonClientHandler, &CommonClientHandler::slot_sendPacketToAllClients);
loggerThread->start(); loggerThread->start();
updateThread->start(); updateThread->start();

View File

@@ -91,7 +91,7 @@ signals:
public slots: public slots:
void slot_LanguageChanged(QString language); void slot_LanguageChanged(QString language);
void slot_UpdateListClients(); void slot_UpdateListClients();
void slot_BlockAutorization(bool block); void slot_BlockAutorizationIndicate(bool block, QString whoFullName, QString type);
void slot_AddMessageToLog(QString message); void slot_AddMessageToLog(QString message);
void slot_ErrorPostgreSQL(QString text); void slot_ErrorPostgreSQL(QString text);
@@ -102,8 +102,6 @@ public slots:
void slot_setVersion(QString versionStr); void slot_setVersion(QString versionStr);
void slot_trySetServerState(PacketType packetType);
public: public:
QString getLanguage() QString getLanguage()
{ {