From a9137cbac2b8a4cb937f4afe40b97d7c432886fc Mon Sep 17 00:00:00 2001 From: semenov Date: Tue, 3 Jun 2025 17:07:17 +0300 Subject: [PATCH 1/2] docs: add tasks --- DOCS/Алексей/Board.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index f254041..9525589 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -19,6 +19,9 @@ kanban-plugin: board ## feature client Unity - [ ] Добавить обновление инструктора, если он перелогинился +- [ ] АММ - убрать возможность отмены +- [ ] FIM разграничить кнопку и статус задачи +- [ ] FIM проверять на null задачу ## feature client QT From d75eb3ce5cb68b600081292ef6c8abf6d865a83b Mon Sep 17 00:00:00 2001 From: semenov Date: Wed, 4 Jun 2025 14:30:58 +0300 Subject: [PATCH 2/2] ref: send task list to client --- DOCS/Алексей/Board.md | 4 +- ServerLMS/Systems/processingsystem.cpp | 52 +++++++++++++------------- ServerLMS/Systems/processingsystem.h | 1 + ServerLMS/Systems/sendsystem.cpp | 3 +- ServerLMS/Systems/tools.h | 1 + ServerLMS/clienthandler.cpp | 5 +++ ServerLMS/clienthandler.h | 1 + 7 files changed, 36 insertions(+), 31 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 9525589..07a16e9 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -19,8 +19,6 @@ kanban-plugin: board ## feature client Unity - [ ] Добавить обновление инструктора, если он перелогинился -- [ ] АММ - убрать возможность отмены -- [ ] FIM разграничить кнопку и статус задачи - [ ] FIM проверять на null задачу @@ -46,6 +44,8 @@ kanban-plugin: board ## Complete +- [ ] FIM разграничить кнопку и статус задачи +- [ ] АММ - убрать возможность отмены - [ ] сохранение не отправленных задач - [ ] Unity: неправильно обновляется статус задачи - [ ] окошко с выбором перенести в GUI diff --git a/ServerLMS/Systems/processingsystem.cpp b/ServerLMS/Systems/processingsystem.cpp index d22db51..33c7883 100644 --- a/ServerLMS/Systems/processingsystem.cpp +++ b/ServerLMS/Systems/processingsystem.cpp @@ -90,23 +90,6 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien client->sendXmlAnswer(arrayAnswer); client->sendVersion(); - //Отправка списков задач клиенту Юнити - if(client->getClient()->getIsUnity()) - { - QString login = client->getClient()->getLogin(); - int id_trainee = providerDBLMS->getIdTraineeByLogin(login); - - //AMM - QList listTasksAMM = providerDBLMS->GetListTasksAMMofTrainee(id_trainee); - QByteArray arrayAnswerTasksAMM = dataParser->DbAnswer()->listTasksAMMofTrainee(true, &listTasksAMM, id_trainee); - client->sendXmlAnswer(arrayAnswerTasksAMM, PacketType::TYPE_XMLANSWER_QUERY_TASKS_AMM_OF_TRAINEE); - - //FIM - QList listTasksFIM = providerDBLMS->GetListTasksFIMofTrainee(id_trainee); - QByteArray arrayAnswerFIM = dataParser->DbAnswer()->listTasksFIMofTrainee(true, &listTasksFIM, id_trainee); - client->sendXmlAnswer(arrayAnswerFIM, PacketType::TYPE_XMLANSWER_QUERY_TASKS_FIM_OF_TRAINEE); - } - QString str = QString(arrayAnswer); //logger->addTextToLogger("To Client: " + str); @@ -423,17 +406,9 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif { if(clientNotify.Code == commandReadyClient) {//Клиент готов принять задания - client->getClient()->setReady(true); //скорее всего функции будут внутри хэндлера - - //Отправляем пакет с заданиями для Обучаемого(клиента) - + client->setReady(true); + sendTaskListToUnity(client); client->getSocket()->flush(); - - //QStringList listTasks; - //QByteArray arrayAnswer = dataParser->ClientAnswer()->tasks(listTasks); - //client->sendXmlAnswer(arrayAnswer); - //QString str = QString(arrayAnswer); - //emit sigLogMessage("To Client: " + str); } else if(clientNotify.Code == commandDisableClient) { @@ -459,6 +434,9 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif client->sigSendNotify(commandUnchangable); } + }else if(clientNotify.Code == commandGetTasks) + { + sendTaskListToUnity(client); } } @@ -481,6 +459,26 @@ void ProcessingSystem::sendListTasksFIMofTraineetoClient(ClientHandler *client, client->sendXmlAnswer(arrayAnswer, PacketType::TYPE_XMLANSWER_QUERY_TASKS_FIM_OF_TRAINEE); } +void ProcessingSystem::sendTaskListToUnity(ClientHandler *client) +{ + //Отправка списков задач клиенту Юнити + if(client->getClient()->getIsUnity()) + { + QString login = client->getClient()->getLogin(); + int id_trainee = providerDBLMS->getIdTraineeByLogin(login); + + //AMM + QList listTasksAMM = providerDBLMS->GetListTasksAMMofTrainee(id_trainee); + QByteArray arrayAnswerTasksAMM = dataParser->DbAnswer()->listTasksAMMofTrainee(true, &listTasksAMM, id_trainee); + client->sendXmlAnswer(arrayAnswerTasksAMM, PacketType::TYPE_XMLANSWER_QUERY_TASKS_AMM_OF_TRAINEE); + + //FIM + QList listTasksFIM = providerDBLMS->GetListTasksFIMofTrainee(id_trainee); + QByteArray arrayAnswerFIM = dataParser->DbAnswer()->listTasksFIMofTrainee(true, &listTasksFIM, id_trainee); + client->sendXmlAnswer(arrayAnswerFIM, PacketType::TYPE_XMLANSWER_QUERY_TASKS_FIM_OF_TRAINEE); + } +} + ClientHandler *ProcessingSystem::getUnityClientById(int id) { QString login = providerDBLMS->getLoginTraineeById(id); diff --git a/ServerLMS/Systems/processingsystem.h b/ServerLMS/Systems/processingsystem.h index d59620c..a09ecdd 100644 --- a/ServerLMS/Systems/processingsystem.h +++ b/ServerLMS/Systems/processingsystem.h @@ -60,6 +60,7 @@ private: DataParser *dataParser; UpdateController *updateController; ProviderDBLMS* providerDBLMS; + void sendTaskListToUnity(ClientHandler *client); }; #endif // PROCESSINGSYSTEM_H diff --git a/ServerLMS/Systems/sendsystem.cpp b/ServerLMS/Systems/sendsystem.cpp index 7d2140b..2c9e5d5 100644 --- a/ServerLMS/Systems/sendsystem.cpp +++ b/ServerLMS/Systems/sendsystem.cpp @@ -200,8 +200,7 @@ void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType) socket->write(array); } - - socket->waitForReadyRead(1000); + socket->waitForReadyRead(2000); } void SendSystem::sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount) diff --git a/ServerLMS/Systems/tools.h b/ServerLMS/Systems/tools.h index cd8840f..09cf2ad 100644 --- a/ServerLMS/Systems/tools.h +++ b/ServerLMS/Systems/tools.h @@ -44,6 +44,7 @@ static const QString commandCanChangeVersion = "CANCHANGE"; static const QString commandChangable = "CHANGEABLE"; static const QString commandUnchangable = "UNCHANGEABLE"; static const QString commandUpdateFilesClient = "update"; +static const QString commandGetTasks = "GETTASKS"; class Tools { public: diff --git a/ServerLMS/clienthandler.cpp b/ServerLMS/clienthandler.cpp index 5b0604f..0274c7f 100644 --- a/ServerLMS/clienthandler.cpp +++ b/ServerLMS/clienthandler.cpp @@ -83,6 +83,11 @@ void ClientHandler::sendVersion() emit sigSendVersion(); } +void ClientHandler::setReady(bool flag) +{ + getClient()->setReady(flag); +} + void ClientHandler::sendVersionList() { QFile file(versionListFile); diff --git a/ServerLMS/clienthandler.h b/ServerLMS/clienthandler.h index 7f840db..ebde3d0 100644 --- a/ServerLMS/clienthandler.h +++ b/ServerLMS/clienthandler.h @@ -39,6 +39,7 @@ public: void sendVersionList(); void sendPacketType(PacketType packetType); void sendVersion(); + void setReady(bool flag); ~ClientHandler();