From adbd8395cac3b98dc776f874462aac9f7390e542 Mon Sep 17 00:00:00 2001 From: semenov Date: Wed, 15 Jan 2025 16:13:55 +0300 Subject: [PATCH 1/8] hotfix: updateController --- ServerLMS/Systems/recognizesystem.cpp | 20 ++-- ServerLMS/Systems/tools.h | 1 + ServerLMS/Systems/updatecontroller.cpp | 144 +++++++++++++++++-------- ServerLMS/Systems/updatecontroller.h | 2 - 4 files changed, 109 insertions(+), 58 deletions(-) diff --git a/ServerLMS/Systems/recognizesystem.cpp b/ServerLMS/Systems/recognizesystem.cpp index 8e30805..2389ca6 100644 --- a/ServerLMS/Systems/recognizesystem.cpp +++ b/ServerLMS/Systems/recognizesystem.cpp @@ -90,13 +90,23 @@ void RecognizeSystem::recognize() if (command == commandUpdateFilesClient) //запускает процесс оновления { sendSystem->updateFiles(updateController->getFileSendList(), - updateController->getClientDataList()); + updateController->getFileDeleteList()); qDebug()<< "Call update"; packetType = PacketType::TYPE_NONE; command = ""; } + if(command == "check") + { + command = ""; + QFile checkFile(clientHash); + checkFile.open(QIODevice::ReadOnly); + updateController->compareFiles(clientHandler,checkFile.readAll()); + checkFile.close(); + + } + if (packetType == PacketType::TYPE_XMLANSWER) { @@ -280,14 +290,6 @@ void RecognizeSystem::recognize() file.close(); - if(command == "check") - { - QFile checkFile(filePath); - checkFile.open(QIODevice::ReadOnly); - updateController->compareFiles(clientHandler,checkFile.readAll()); - checkFile.close(); - } - filePath.clear(); fileSize = 0; tmpBlock.clear(); diff --git a/ServerLMS/Systems/tools.h b/ServerLMS/Systems/tools.h index f78fff9..e896664 100644 --- a/ServerLMS/Systems/tools.h +++ b/ServerLMS/Systems/tools.h @@ -22,6 +22,7 @@ static const QString versionListFile = staticDataFolderName + "/versionList.xml" static const QString hashFileName = staticDataFolderName + "/serverHash.xml"; static const QString buildHashName = staticDataFolderName + "/buildHash.xml"; static const QString buildDataPath = "/Application/RRJLoader/RRJ_Data/"; +static const QString clientHash = staticDataFolderName + "/clientHash.xml"; static const QString baseNameVersion = "base";//может вынести комманды куда нибудь? diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 7a548c1..088337f 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -59,7 +59,6 @@ void UpdateController::compareFiles(ClientHandler* handler, QByteArray array) loadHash(); clientDataList.clear(); xmlFileDataParse(array); - clientDataList.append(*datas); checkNeedUpdate(handler); mutex->unlock(); } @@ -182,8 +181,6 @@ QString UpdateController::getCommands() } - - void UpdateController::setUpCurrentServerHash() { QList *fileList = new QList; @@ -296,62 +293,121 @@ QList* UpdateController::calculateHash(QString path) { serverDataList.clear(); - QDirIterator iterator(path,QDirIterator::Subdirectories); if(!QDir(path).exists()){ QDir().mkdir(path); } - QDir dir(path); - dir.setFilter(QDir::NoDotAndDotDot); QString hashString; + QStringList filter; + filter << "*"; QList *files = new QList; - while (iterator.hasNext()) + QDirIterator dirIterator(path,filter, QDir::AllEntries | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + + while (dirIterator.hasNext()) { - iterator.next(); - QFileInfo fileInfo = iterator.fileInfo(); + QFileInfo fileInfo(dirIterator.next()); FileData currentFile; - QFile file(fileInfo.absoluteFilePath()); - - quint64 fileSize = file.size(); - const quint64 bufferSize = 10240; - - if (fileInfo.isHidden()) continue; - - if(fileInfo.isFile() && file.open(QIODevice::ReadOnly) && !fileInfo.fileName().contains(".meta")) + if(fileInfo.isDir() && !fileInfo.fileName().startsWith(".") && fileInfo.fileName() != "RRJLoader") { - char buffer[bufferSize]; - int bytesRead; - int readSize = qMin(fileSize,bufferSize); - - QCryptographicHash hash(QCryptographicHash::Md5); - while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0){ - fileSize -= bytesRead; - hash.addData(buffer,bytesRead); - readSize = qMin(fileSize,bufferSize); - } - - hashString = QString(hash.result().toHex()); - currentFile.hash = hashString; currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); - - files->push_back(currentFile); - file.close(); - - } - else if(fileInfo.isDir() && fileInfo.fileName() != ".." && !fileInfo.isRoot()) - { currentFile.hash = "FOLDER"; - currentFile.path = Tools::createLocalPath(fileInfo.path()); - if(!files->contains(currentFile)){ + if(!files->contains(currentFile)) + { files->push_back(currentFile); } } } - std::sort(files->begin(),files->end()); + QDirIterator fileIterator(path,filter,QDir::Files | QDir::NoDotAndDotDot,QDirIterator::Subdirectories); + + while (fileIterator.hasNext()) + { + fileIterator.next(); + QFileInfo fileInfo = fileIterator.fileInfo(); + FileData currentFile; + QFile file(fileInfo.absoluteFilePath()); + + quint64 fileSize = file.size(); //буффер для хэширования крупных файлов + const quint64 bufferSize = 10240; + + if(fileInfo.isHidden()) continue; + + if(fileInfo.isFile() && file.open(QIODevice::ReadOnly) && !fileInfo.fileName().contains(".meta")) + { + char buffer[bufferSize]; + int bytesRead; + int readSize = qMin(fileSize,bufferSize); + + QCryptographicHash hash(QCryptographicHash::Md5); + + while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0) + { + fileSize -= bytesRead; + hash.addData(buffer,bytesRead); + readSize = qMin(fileSize,bufferSize); + } + + hashString = QString(hash.result().toHex()); + currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); + currentFile.hash = hashString; + files->push_back(currentFile); + file.close(); + } + } serverDataList.append(*files); + +// QDirIterator iterator(path,QDirIterator::Subdirectories); +// QDir dir(path); +// dir.setFilter(QDir::NoDotAndDotDot); + +// while (iterator.hasNext()) +// { +// iterator.next(); +// QFileInfo fileInfo = iterator.fileInfo(); +// FileData currentFile; +// QFile file(fileInfo.absoluteFilePath()); + +// quint64 fileSize = file.size(); +// const quint64 bufferSize = 10240; + +// if (fileInfo.isHidden()) continue; + +// if(fileInfo.isFile() && file.open(QIODevice::ReadOnly) && !fileInfo.fileName().contains(".meta")) +// { +// char buffer[bufferSize]; +// int bytesRead; +// int readSize = qMin(fileSize,bufferSize); + +// QCryptographicHash hash(QCryptographicHash::Md5); +// while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0){ +// fileSize -= bytesRead; +// hash.addData(buffer,bytesRead); +// readSize = qMin(fileSize,bufferSize); +// } + +// hashString = QString(hash.result().toHex()); +// currentFile.hash = hashString; +// currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); + +// files->push_back(currentFile); +// file.close(); + +// } +// else if(fileInfo.isDir() && fileInfo.fileName() != ".." && !fileInfo.isRoot()) +// { +// currentFile.hash = "FOLDER"; +// currentFile.path = Tools::createLocalPath(fileInfo.path()); + +// if(!files->contains(currentFile)){ +// files->push_back(currentFile); +// } +// } +// } + +// std::sort(files->begin(),files->end()); +// return files; } @@ -499,7 +555,6 @@ bool UpdateController::checkDuplicate(QString versionName) void UpdateController::xmlFileDataParse(QByteArray array) { QXmlStreamReader xmlReader(array); - datas = new QList; xmlReader.readNext(); //Крутимся в цикле до тех пор, пока не достигнем конца документа @@ -523,7 +578,7 @@ void UpdateController::xmlFileDataParse(QByteArray array) data.hash = value; } - datas->append(data); + clientDataList.append(data); } } @@ -565,11 +620,6 @@ DataInfo *UpdateController::getCurrentDataInfo() return dataInfo; } -QList *UpdateController::getDatas() const -{ - return datas; -} - void UpdateController::clearCurrentDataInfo() { delete dataInfo; diff --git a/ServerLMS/Systems/updatecontroller.h b/ServerLMS/Systems/updatecontroller.h index 611ef2f..efe3aee 100644 --- a/ServerLMS/Systems/updatecontroller.h +++ b/ServerLMS/Systems/updatecontroller.h @@ -51,7 +51,6 @@ public: DataInfo *getCurrentDataInfo(); void clearCurrentDataInfo(); - QList *getDatas() const; void createVersionListXmlAnswer(QList version); void saveVersionToFile(StreamingVersionData *streamingVersion); void xmlFileDataParse(QByteArray array); @@ -71,7 +70,6 @@ private: QList fileSendList; QList fileDeleteList; - QList *datas; DataInfo *dataInfo; QString buildPath; From e7b13f4ec436e96c3dc9fd40b7573078495d032c Mon Sep 17 00:00:00 2001 From: semenov Date: Thu, 16 Jan 2025 11:12:46 +0300 Subject: [PATCH 2/8] bugfix: loading process disable --- DOCS/Алексей/Board.md | 11 ++++- ServerLMS/Systems/commonclienthandler.cpp | 9 ++-- ServerLMS/Systems/commonclienthandler.h | 2 +- ServerLMS/Systems/sendsystem.cpp | 37 +++++++++------- ServerLMS/Systems/updatecontroller.cpp | 51 ----------------------- ServerLMS/clienthandler.cpp | 7 +++- ServerLMS/clienthandler.h | 1 + ServerLMS/multithreadserver.cpp | 9 ++-- ServerLMS/multithreadserver.h | 1 + ServerLMS/serverlmswidget.cpp | 10 +++-- 10 files changed, 54 insertions(+), 84 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 102b856..2be5125 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -12,6 +12,11 @@ kanban-plugin: board ## bugs +- [ ] QT сервер замерзает после выхода пользователя во время скачивания +- [ ] QT клиент, если обновление в режиме инструктора доступно, кнопку запуск отключать +- [ ] QT сервер При изменении версии правильный списке с файлами прилетает со второго раза +- [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором +- [ ] QT клиент: device not open после прерывания загрузки ## feature client Unity @@ -30,9 +35,8 @@ kanban-plugin: board ## feature server -- [ ] Прибраться в Server -- [ ] рефакторинг - [ ] добавить генерацию пустых файлов, если shared не найден +- [ ] добавить подключение без DB ## NOW @@ -42,6 +46,9 @@ kanban-plugin: board ## Complete +- [ ] рефакторинг +- [ ] Прибраться в Server +- [ ] не работает восстановление файлов - [ ] запрет на удаление base - [ ] None hash - [ ] сверстать окно создания новой версии diff --git a/ServerLMS/Systems/commonclienthandler.cpp b/ServerLMS/Systems/commonclienthandler.cpp index 6012e3e..e7e769d 100644 --- a/ServerLMS/Systems/commonclienthandler.cpp +++ b/ServerLMS/Systems/commonclienthandler.cpp @@ -11,6 +11,8 @@ void CommonClientHandler::initialize(QMap *clientsMap, Pro this->processingSystem = processingSystem; this->dataParser = dataParser; this->logger = logger; + + connect(this,&CommonClientHandler::sigSendToLogger,logger,&Logger::addTextToLogger,Qt::AutoConnection); } void CommonClientHandler::sendNewVersionListToAllClient() @@ -85,7 +87,8 @@ void CommonClientHandler::slot_msgToClientFromGUI(QString login, QString text) QString str = "Msg To Client [" + peerAddress + ":" + peerPort + "] : " + textMsg; - logger->addTextToLogger(str); + emit sigSendToLogger(str); + break; } } @@ -111,7 +114,7 @@ void CommonClientHandler::slot_msgToGUIfromClient(QString login, QString text) QString str = "Msg From Client [" + peerAddress + ":" + peerPort + "] : " + textMsg; - logger->addTextToLogger(str); + emit sigSendToLogger(str); break; } } @@ -134,7 +137,7 @@ void CommonClientHandler::slot_sendTaskToClient(QString fullNameClient,QString t QString peerPort = QString::number(handler->getSocket()->peerPort()); QString str = "Task To Client [" + peerAddress + ":" + peerPort + "] : " + textTask; - logger->addTextToLogger(str); + emit sigSendToLogger(str); } } } diff --git a/ServerLMS/Systems/commonclienthandler.h b/ServerLMS/Systems/commonclienthandler.h index a6e471b..1abf5b8 100644 --- a/ServerLMS/Systems/commonclienthandler.h +++ b/ServerLMS/Systems/commonclienthandler.h @@ -27,7 +27,7 @@ public: void slot_msgToGUIfromClient(QString login, QString text); void slot_sendTaskToClient(QString fullNameClient, QString textTask); signals: - + void sigSendToLogger(QString text); private: QMap *clientsMap; ProcessingSystem *processingSystem; diff --git a/ServerLMS/Systems/sendsystem.cpp b/ServerLMS/Systems/sendsystem.cpp index 29b2324..65caacd 100644 --- a/ServerLMS/Systems/sendsystem.cpp +++ b/ServerLMS/Systems/sendsystem.cpp @@ -35,14 +35,22 @@ void SendSystem::sendMessageBlock(QString message) void SendSystem::sendFileBlock(QString path) { - qDebug() << "sendFileBlock thread: " << QThread::currentThreadId(); + QFile file(path); + QFileInfo fileInfo(file); + + if(isSendStopped) + { //Поведение на случай отключения клиента + + file.close(); + return; + } + QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); - QFile file(path); - QFileInfo fileInfo(file); + fileSize = fileInfo.size(); if(fileSize == 0){ @@ -55,20 +63,19 @@ void SendSystem::sendFileBlock(QString path) stream << path << fileSize; - if(isSendStopped) { //Поведение на случай отключения клиента - - file.close(); - return; - } - socket->waitForBytesWritten(); + socket->waitForBytesWritten(10); - if(file.open(QFile::ReadOnly)){ - while(!file.atEnd()){ + if(file.open(QFile::ReadOnly)) + { + while(!file.atEnd()) + { QByteArray data = file.read(1025*250); stream << data; - socket->waitForBytesWritten(); + socket->waitForBytesWritten(10); + + if(socket->state() == QAbstractSocket::UnconnectedState) break; countSend++; } @@ -77,7 +84,7 @@ void SendSystem::sendFileBlock(QString path) file.close(); countSend = 0; - socket->waitForBytesWritten(); + socket->waitForBytesWritten(10); socket->waitForReadyRead(100); } @@ -237,11 +244,9 @@ void SendSystem::updateFiles(QList fileSendList, QList delet socket->waitForReadyRead(100); } - if(getIsSendStopped()) return; + if(isSendStopped) return; } - - emit sigLoadHash(); sendPacketType(PacketType::TYPE_FINISH); diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 088337f..f83fd53 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -357,57 +357,6 @@ QList* UpdateController::calculateHash(QString path) } } serverDataList.append(*files); - -// QDirIterator iterator(path,QDirIterator::Subdirectories); -// QDir dir(path); -// dir.setFilter(QDir::NoDotAndDotDot); - -// while (iterator.hasNext()) -// { -// iterator.next(); -// QFileInfo fileInfo = iterator.fileInfo(); -// FileData currentFile; -// QFile file(fileInfo.absoluteFilePath()); - -// quint64 fileSize = file.size(); -// const quint64 bufferSize = 10240; - -// if (fileInfo.isHidden()) continue; - -// if(fileInfo.isFile() && file.open(QIODevice::ReadOnly) && !fileInfo.fileName().contains(".meta")) -// { -// char buffer[bufferSize]; -// int bytesRead; -// int readSize = qMin(fileSize,bufferSize); - -// QCryptographicHash hash(QCryptographicHash::Md5); -// while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0){ -// fileSize -= bytesRead; -// hash.addData(buffer,bytesRead); -// readSize = qMin(fileSize,bufferSize); -// } - -// hashString = QString(hash.result().toHex()); -// currentFile.hash = hashString; -// currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); - -// files->push_back(currentFile); -// file.close(); - -// } -// else if(fileInfo.isDir() && fileInfo.fileName() != ".." && !fileInfo.isRoot()) -// { -// currentFile.hash = "FOLDER"; -// currentFile.path = Tools::createLocalPath(fileInfo.path()); - -// if(!files->contains(currentFile)){ -// files->push_back(currentFile); -// } -// } -// } - -// std::sort(files->begin(),files->end()); -// return files; } diff --git a/ServerLMS/clienthandler.cpp b/ServerLMS/clienthandler.cpp index 2ab918e..30c8448 100644 --- a/ServerLMS/clienthandler.cpp +++ b/ServerLMS/clienthandler.cpp @@ -54,6 +54,7 @@ void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget, connect(this,&ClientHandler::sigSocketClose,sendSystem,&SendSystem::socketClose,Qt::AutoConnection); connect(this,&ClientHandler::sigSocketFlush,sendSystem,&SendSystem::socketFlush,Qt::AutoConnection); connect(this,&ClientHandler::sigSendPacketType,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection); + connect(this,&ClientHandler::sigSendStop,sendSystem,&SendSystem::sendStop,Qt::DirectConnection); connect(socket,&QTcpSocket::readyRead,recognizeSystem,&RecognizeSystem::recognize,Qt::AutoConnection); connect(socket, &QTcpSocket::disconnected, this, &ClientHandler::sendDisable,Qt::AutoConnection); @@ -129,8 +130,10 @@ void ClientHandler::sendNeedUpdate(bool flag, quint64 size, quint64 fileCount,qu void ClientHandler::sendDisable() { - thread->exit(); - thread->wait(); +// thread->exit(); +// thread->wait(); + thread->quit(); + emit sigSendStop(); emit sigClientDisconnected(client->getAddress(),client->getPort()); } diff --git a/ServerLMS/clienthandler.h b/ServerLMS/clienthandler.h index 7e035b8..7f840db 100644 --- a/ServerLMS/clienthandler.h +++ b/ServerLMS/clienthandler.h @@ -67,6 +67,7 @@ signals: bool sigSocketFlush(); void sigSendVersion(); void sigSendPacketType(PacketType packetType); + void sigSendStop(); public : QThread *thread; diff --git a/ServerLMS/multithreadserver.cpp b/ServerLMS/multithreadserver.cpp index 1ac463d..50a0217 100644 --- a/ServerLMS/multithreadserver.cpp +++ b/ServerLMS/multithreadserver.cpp @@ -8,7 +8,7 @@ MultiThreadServer::MultiThreadServer(ServerLMSWidget *widget,UpdateController *u dataParser(dataParser), logger(logger) { - + connect(this,&MultiThreadServer::sigSendToLogger,logger,&Logger::addTextToLogger); } void MultiThreadServer::incomingConnection(qintptr socketDesriptor) @@ -16,14 +16,14 @@ void MultiThreadServer::incomingConnection(qintptr socketDesriptor) ClientHandler* newClient = new ClientHandler; connect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize,Qt::AutoConnection); - connect(newClient,&ClientHandler::sigClientDisconnected,this,&MultiThreadServer::slotDisconnectClient,Qt::QueuedConnection); + connect(newClient,&ClientHandler::sigClientDisconnected,this,&MultiThreadServer::slotDisconnectClient,Qt::AutoConnection); emit sigInitClient(socketDesriptor,serverLmsWidget,updateController,dataParser,logger); disconnect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize); serverLmsWidget->addClient(socketDesriptor,newClient); - logger->addTextToLogger("To Client: " + QString(SERVER_HELLO)); + emit sigSendToLogger("To Client: " + QString(SERVER_HELLO)); } void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPort) @@ -53,8 +53,7 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo } emit signalStopSendFile(); - - logger->addTextToLogger("SERVER: Client " + login + " disconnected"); + emit sigSendToLogger("SERVER: Client " + login + " disconnected"); serverLmsWidget->slotUpdateListClients(); serverLmsWidget->autorizationHandler(login); diff --git a/ServerLMS/multithreadserver.h b/ServerLMS/multithreadserver.h index 13a4c50..eb12f80 100644 --- a/ServerLMS/multithreadserver.h +++ b/ServerLMS/multithreadserver.h @@ -18,6 +18,7 @@ signals: void sigInitClient(int descriptor, ServerLMSWidget *serverWidget, UpdateController *updateController, DataParser *dataParser,Logger *logger); void signalStopSendFile(); + void sigSendToLogger(QString text); public slots: void slotDisconnectClient(QString peerAddress, QString peerPort); diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index f52eb00..b90a0c3 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -14,7 +14,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : tcpServer(nullptr), hostPort(6000), stateServer(stoped), - stateBlockAutorization(blocked), + stateBlockAutorization(unblocked), updateThread(nullptr), loggerThread(nullptr), dataParser(nullptr), @@ -44,11 +44,13 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : loggerThread = new QThread; providerDBLMS = new ProviderDBLMS(this); - connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization); providerDBLMS->ConnectionToDB(); logger = new Logger(ui->listWidgetLogger); - connect(logger,&Logger::sigSendTextToLogger,this,&ServerLMSWidget::slotAddToLog,Qt::QueuedConnection); + + connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization); + connect(logger,&Logger::sigSendTextToLogger,this,&ServerLMSWidget::slotAddToLog,Qt::AutoConnection); + logger->moveToThread(loggerThread); assetsManager = new AssetsManager; @@ -194,7 +196,7 @@ void ServerLMSWidget::slotUpdateListClients() } int countClients = clientsMap.count(); - logger->addTextToLogger("SERVER: countClients = " + QString::number(countClients)); + emit sigLog("SERVER: countClients = " + QString::number(countClients)); } void ServerLMSWidget::slot_BlockAutorization(bool block) From 13c83e29908043484eef180c738bd19b62760b0e Mon Sep 17 00:00:00 2001 From: semenov Date: Thu, 16 Jan 2025 13:26:28 +0300 Subject: [PATCH 3/8] bugfix: create sharedData folder --- DOCS/Алексей/Board.md | 16 +++++++++------- DOCS/Алексей/ТЕСТ-КЕЙСЫ.md | 12 +++++++++++- ServerLMS/Systems/updatecontroller.cpp | 8 ++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 2be5125..b0760b5 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -6,17 +6,11 @@ kanban-plugin: board ## backLog -- [ ] выписать все варианты взаимодействия между всеми клиентами и сервером -- [ ] sendSystem::sendXmlAnswer новый вариант отпарвки XML пакетов ## bugs -- [ ] QT сервер замерзает после выхода пользователя во время скачивания -- [ ] QT клиент, если обновление в режиме инструктора доступно, кнопку запуск отключать -- [ ] QT сервер При изменении версии правильный списке с файлами прилетает со второго раза - [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором -- [ ] QT клиент: device not open после прерывания загрузки ## feature client Unity @@ -37,15 +31,19 @@ kanban-plugin: board - [ ] добавить генерацию пустых файлов, если shared не найден - [ ] добавить подключение без DB +- [ ] ПЕРЕВЕСТИ все действия под операции и формировать процент из них ## NOW -- [ ] добавить автоматическое выключение после создания копии ## Complete +- [ ] добавить автоматическое выключение после создания копии +- [ ] sendSystem::sendXmlAnswer новый вариант отпарвки XML пакетов +- [ ] выписать все варианты взаимодействия между всеми клиентами и сервером +- [ ] QT клиента: Не показывает блокировка, если версия удаляется - [ ] рефакторинг - [ ] Прибраться в Server - [ ] не работает восстановление файлов @@ -272,6 +270,10 @@ kanban-plugin: board ## BUGFIX Complete +- [ ] QT клиент: device not open после прерывания загрузки +- [ ] QT сервер При изменении версии правильный списке с файлами прилетает со второго раза +- [ ] QT клиент, если обновление в режиме инструктора доступно, кнопку запуск отключать +- [ ] QT сервер замерзает после выхода пользователя во время скачивания - [ ] Клиент QT выводить инфу если клиент не подключен - [ ] Клиент QT не подключатся повторно, если соединение уже установлено - [ ] Клиент QT Неправильное отображение количества загруженных файлов diff --git a/DOCS/Алексей/ТЕСТ-КЕЙСЫ.md b/DOCS/Алексей/ТЕСТ-КЕЙСЫ.md index 2443d6c..e0bf81b 100644 --- a/DOCS/Алексей/ТЕСТ-КЕЙСЫ.md +++ b/DOCS/Алексей/ТЕСТ-КЕЙСЫ.md @@ -29,4 +29,14 @@ 5. Обновление с клиента на сервер - ЕСТЬ 6. Проверка с перезапуском клиента - ХЭШ КОРРЕКТНЫЙ 7. Восстановление версии с сервера на клиент -8. Проверка с перезапуском клиента \ No newline at end of file +8. Проверка с перезапуском клиента + +Работа с версиями +1. QT клиент: Копирование версии +2. QT клиент: Копирование версии с указанием существующего имени -> ошибка +3. QT клиент: Удаление версии +4. QT клиент: Удаление базовой версии -> ошибка +5. QT клиент: Удаление версии которая выбрана -> ошибка +6. QT клиент: переключении версии +7. Unity: отправка в базовую версию +8. \ No newline at end of file diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index f83fd53..7b0247a 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -50,7 +50,9 @@ void UpdateController::createCopyVersion(QString versionName,QString newVersionN void UpdateController::deleteAssetVersion(QString versionName) { + commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY); assetManager->deleteVersion(versionName); + commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE); } void UpdateController::compareFiles(ClientHandler* handler, QByteArray array) @@ -403,6 +405,12 @@ void UpdateController::CalculateSizeToSend(QList diffList) void UpdateController::calculateSharedHash() { QDir sharedDir(sharedDataPath); + + if(!QDir(sharedDataPath).exists()) + { + QDir().mkdir(sharedDataPath); + } + QDirIterator dirIterator(sharedDir); QList *fileList = new QList; QList *versionList = new QList; From 4b9ee1738ac6942733d309a078f22a02b80032bb Mon Sep 17 00:00:00 2001 From: semenov Date: Fri, 17 Jan 2025 11:10:34 +0300 Subject: [PATCH 4/8] bugfix: diff update --- DOCS/Алексей/Board.md | 6 ++++-- ServerLMS/Data/PacketType.h | 2 ++ ServerLMS/Data/StreamingVersionData.h | 14 ++++++++++++++ ServerLMS/Systems/recognizesystem.cpp | 8 +++----- ServerLMS/Systems/updatecontroller.cpp | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index b0760b5..55eae26 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -10,7 +10,7 @@ kanban-plugin: board ## bugs -- [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором +- [ ] При старт стопе не сканится шэред дата ## feature client Unity @@ -24,7 +24,6 @@ kanban-plugin: board - [ ] Иерархия проекта - папка application, папка updater и линк на основной экзешник - [ ] на старте все мониторы должны быть активны - [ ] Нужен ли дополнительный выбор для загрузки с мат моделью или нет? -- [ ] при создании копии переключение сервера и переключения клиента ## feature server @@ -32,6 +31,7 @@ kanban-plugin: board - [ ] добавить генерацию пустых файлов, если shared не найден - [ ] добавить подключение без DB - [ ] ПЕРЕВЕСТИ все действия под операции и формировать процент из них +- [ ] блокировать выгрузку под инструктором, если режим версия base ## NOW @@ -270,6 +270,8 @@ kanban-plugin: board ## BUGFIX Complete +- [ ] при создании копии переключение сервера и переключения клиента +- [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором - [ ] QT клиент: device not open после прерывания загрузки - [ ] QT сервер При изменении версии правильный списке с файлами прилетает со второго раза - [ ] QT клиент, если обновление в режиме инструктора доступно, кнопку запуск отключать diff --git a/ServerLMS/Data/PacketType.h b/ServerLMS/Data/PacketType.h index 2b54672..326dda7 100644 --- a/ServerLMS/Data/PacketType.h +++ b/ServerLMS/Data/PacketType.h @@ -14,6 +14,8 @@ enum PacketType TYPE_XMLANSWER = 8, TYPE_QT = 9, TYPE_DISABLE = 11, + TYPE_UPDATE = 12, + TYPE_CHECK_VERSION = 13, TYPE_FILESIZE = 20, TYPE_XMLANSWER_MESSAGE_FOR_GUI = 90, diff --git a/ServerLMS/Data/StreamingVersionData.h b/ServerLMS/Data/StreamingVersionData.h index 3746bd7..007b368 100644 --- a/ServerLMS/Data/StreamingVersionData.h +++ b/ServerLMS/Data/StreamingVersionData.h @@ -36,11 +36,25 @@ public: return size; } + bool getIsChangeable() const; + void setIsChangeable(bool value); + private: QString absolutePath; QString viewName; QDateTime createData; + bool isChangeable; qint32 size; }; #endif // STREAMINGVERSIONDATA_H + +bool StreamingVersionData::getIsChangeable() const +{ +return isChangeable; +} + +void StreamingVersionData::setIsChangeable(bool value) +{ +isChangeable = value; +} diff --git a/ServerLMS/Systems/recognizesystem.cpp b/ServerLMS/Systems/recognizesystem.cpp index 2389ca6..46e929d 100644 --- a/ServerLMS/Systems/recognizesystem.cpp +++ b/ServerLMS/Systems/recognizesystem.cpp @@ -87,24 +87,22 @@ void RecognizeSystem::recognize() if (!stream.commitTransaction()) continue; } - if (command == commandUpdateFilesClient) //запускает процесс оновления + if (packetType == PacketType::TYPE_UPDATE) { + sendSystem->updateFiles(updateController->getFileSendList(), updateController->getFileDeleteList()); qDebug()<< "Call update"; packetType = PacketType::TYPE_NONE; - command = ""; } - if(command == "check") + if(packetType == PacketType::TYPE_CHECK_VERSION) { - command = ""; QFile checkFile(clientHash); checkFile.open(QIODevice::ReadOnly); updateController->compareFiles(clientHandler,checkFile.readAll()); checkFile.close(); - } if (packetType == PacketType::TYPE_XMLANSWER) diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 7b0247a..08c7e9c 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -479,6 +479,7 @@ void UpdateController::createVersionListXmlAnswer(QList xmlWriter.writeEndDocument(); file.close(); } + void UpdateController::saveVersionToFile(StreamingVersionData *streamingVersion) //TODO: переименовать и перебросить в AssetManager { QFile file(version); @@ -498,7 +499,6 @@ void UpdateController::saveVersionToFile(StreamingVersionData *streamingVersion) file.close(); } - void UpdateController::sendNewVersionList() { commonClientHandler->sendNewVersionListToAllClient(); From 91a4b04f05a01883f4cce276554ca57b8837370c Mon Sep 17 00:00:00 2001 From: semenov Date: Fri, 17 Jan 2025 16:47:22 +0300 Subject: [PATCH 5/8] feat: load to server block --- DOCS/Алексей/Board.md | 3 ++ ServerLMS/Data/StreamingVersionData.h | 22 +++++++------- ServerLMS/Systems/Parsers/processparser.cpp | 3 ++ ServerLMS/Systems/processingsystem.cpp | 19 +++++++++++- ServerLMS/Systems/processingsystem.h | 9 ++++-- ServerLMS/Systems/recognizesystem.cpp | 33 +++++++++++++++++++++ ServerLMS/Systems/recognizesystem.h | 2 ++ ServerLMS/Systems/tools.h | 4 +++ ServerLMS/Systems/updatecontroller.cpp | 18 ++++++++++- ServerLMS/Systems/updatecontroller.h | 1 + ServerLMS/serverlmswidget.cpp | 2 +- 11 files changed, 99 insertions(+), 17 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 55eae26..5507615 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -6,6 +6,8 @@ kanban-plugin: board ## backLog +- [ ] окошко с выбором перенести в GUI +- [ ] Клиент НЕ СМОЖЕТ ВЫБИРАТЬ ВЕРСИИ ## bugs @@ -24,6 +26,7 @@ kanban-plugin: board - [ ] Иерархия проекта - папка application, папка updater и линк на основной экзешник - [ ] на старте все мониторы должны быть активны - [ ] Нужен ли дополнительный выбор для загрузки с мат моделью или нет? +- [ ] передавать полную версию в StreaminVerData ## feature server diff --git a/ServerLMS/Data/StreamingVersionData.h b/ServerLMS/Data/StreamingVersionData.h index 007b368..5cd2ffc 100644 --- a/ServerLMS/Data/StreamingVersionData.h +++ b/ServerLMS/Data/StreamingVersionData.h @@ -13,6 +13,7 @@ public: this->viewName = viewName; this->createData = data; this->size = size; + this->isChangeable = true; } ~StreamingVersionData(); @@ -36,8 +37,15 @@ public: return size; } - bool getIsChangeable() const; - void setIsChangeable(bool value); + bool getIsChangeable() const + { + return isChangeable; + } + + void setIsChangeable(bool value) + { + isChangeable = value; + } private: QString absolutePath; @@ -48,13 +56,3 @@ private: }; #endif // STREAMINGVERSIONDATA_H - -bool StreamingVersionData::getIsChangeable() const -{ -return isChangeable; -} - -void StreamingVersionData::setIsChangeable(bool value) -{ -isChangeable = value; -} diff --git a/ServerLMS/Systems/Parsers/processparser.cpp b/ServerLMS/Systems/Parsers/processparser.cpp index 7a94451..314d84a 100644 --- a/ServerLMS/Systems/Parsers/processparser.cpp +++ b/ServerLMS/Systems/Parsers/processparser.cpp @@ -239,6 +239,7 @@ void ProcessParser::clientMessage(QXmlStreamReader &xmlReader,ClientHandler *cli } processingSystem->processingFromClientMessage(client, clientMessage); + } void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *client) @@ -255,6 +256,8 @@ void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *clie clientNotify.Code = value; } + + processingSystem->processingClientNotify(client, clientNotify); } diff --git a/ServerLMS/Systems/processingsystem.cpp b/ServerLMS/Systems/processingsystem.cpp index ae055ab..87ee13c 100644 --- a/ServerLMS/Systems/processingsystem.cpp +++ b/ServerLMS/Systems/processingsystem.cpp @@ -8,11 +8,16 @@ ProcessingSystem::ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent this->providerDBLMS = providerDBLMS; } -void ProcessingSystem::initialize(ServerLMSWidget *server, DataParser *dataParser, CommonClientHandler *commonClientHandler,Logger *logger) +void ProcessingSystem::initialize(ServerLMSWidget *server, + DataParser *dataParser, + CommonClientHandler *commonClientHandler, + Logger *logger, + UpdateController *updateController) { this->commonClientServer = commonClientHandler; this->dataParser = dataParser; this->server = server; + this->updateController = updateController; connect(this,&ProcessingSystem::sigAuthChanged,commonClientHandler, &CommonClientHandler::slot_AuthChanged,Qt::AutoConnection); connect(this,&ProcessingSystem::sigUpdateListClients,server, &ServerLMSWidget::slotUpdateListClients,Qt::AutoConnection); @@ -278,6 +283,18 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif { client->sendVersionList(); } + else if(clientNotify.Code == commandCanChangeVersion) + { + if (updateController->getCurrentVersion()->getIsChangeable()) + { + client->sigSendNotify(commandChangable); + } + else + { + client->sigSendNotify(commandUnchangable); + } + + } } diff --git a/ServerLMS/Systems/processingsystem.h b/ServerLMS/Systems/processingsystem.h index 22dc00d..d5b82fb 100644 --- a/ServerLMS/Systems/processingsystem.h +++ b/ServerLMS/Systems/processingsystem.h @@ -23,7 +23,12 @@ class ProcessingSystem : public QObject public: explicit ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent = nullptr); - void initialize(ServerLMSWidget *server,DataParser* dataParser,CommonClientHandler *commonClientServer,Logger *logger); + void initialize(ServerLMSWidget *server, + DataParser* dataParser, + CommonClientHandler *commonClientServer, + Logger *logger, + UpdateController *updateComtroller); + void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization); void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization); void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr); @@ -44,7 +49,7 @@ private: CommonClientHandler *commonClientServer; ServerLMSWidget *server; DataParser *dataParser; - //InstructorsAndTraineesWidget *pInstructorsAndTrainees; + UpdateController *updateController; ProviderDBLMS* providerDBLMS; }; diff --git a/ServerLMS/Systems/recognizesystem.cpp b/ServerLMS/Systems/recognizesystem.cpp index 46e929d..be2e1d9 100644 --- a/ServerLMS/Systems/recognizesystem.cpp +++ b/ServerLMS/Systems/recognizesystem.cpp @@ -168,6 +168,16 @@ void RecognizeSystem::recognize() QFile file(filePath); +// //ПРОВЕРКА НА ИЗМЕНЕНИЕ БАЗОВОЙ ВЕРСИИ +// bool check = checkIsChangeable(); +// bool check2 = checkNonStaticData(filePath); +// if(!check && check2) +// { +// packetType = PacketType::TYPE_NONE; +// sendSystem->sendNotify(commandTryBaseChange); +// mutex->unlock(); +// return; +// } if (file.exists()) { @@ -239,6 +249,17 @@ void RecognizeSystem::recognize() break; } +// //ПРОВЕРКА НА ИЗМЕНЕНИЕ БАЗОВОЙ ВЕРСИИ +// bool check = checkIsChangeable(); +// bool check2 = checkNonStaticData(filePath); +// if(!check && check2) +// { +// sendSystem->sendNotify(commandTryBaseChange); +// packetType = PacketType::TYPE_NONE; +// mutex->unlock(); +// return; +// } + QFile file(filePath); QFileInfo fileInfo(file); @@ -412,6 +433,18 @@ QString RecognizeSystem::createFullPath(QString path) return fullPath; } +bool RecognizeSystem::checkIsChangeable() +{ + return updateController->getCurrentVersion()->getIsChangeable(); +} + +bool RecognizeSystem::checkNonStaticData(QString path) +{ + if(path.contains(sharedDataFolderName)) return true; + + return false; +} + RecognizeSystem::~RecognizeSystem() { diff --git a/ServerLMS/Systems/recognizesystem.h b/ServerLMS/Systems/recognizesystem.h index 7d5c97c..29a2b24 100644 --- a/ServerLMS/Systems/recognizesystem.h +++ b/ServerLMS/Systems/recognizesystem.h @@ -61,5 +61,7 @@ private: void packetTypeInit(PacketType packet,Client *client); void packetTypeInit(PacketType type); QString createFullPath(QString path); + bool checkIsChangeable(); + bool checkNonStaticData(QString path); }; #endif // RECOGNIZESYSTEM_H diff --git a/ServerLMS/Systems/tools.h b/ServerLMS/Systems/tools.h index e896664..1b9199d 100644 --- a/ServerLMS/Systems/tools.h +++ b/ServerLMS/Systems/tools.h @@ -27,6 +27,7 @@ static const QString clientHash = staticDataFolderName + "/clientHash.xml"; static const QString baseNameVersion = "base";//может вынести комманды куда нибудь? static const QString commandTryBaseDelete = "BASEDELETETRY"; +static const QString commandTryBaseChange = "TRYBASECHANGE"; static const QString commandTryActiveDelete = "TRYACTIVEDELETE"; static const QString commandTryCopyWithSameNames = "SAMENAMES"; static const QString commandGetServerDataList = "GETSERVERDATALIST"; @@ -35,6 +36,9 @@ static const QString commandReadyClient = "READY"; static const QString commandDisableClient = "DISABLE"; static const QString commandDuplicateVerName = "DUPLICATEVERNAME"; static const QString commandHashCompleteClient = "HASHSENDCOMPLETE"; +static const QString commandCanChangeVersion = "CANCHANGE"; +static const QString commandChangable = "CHANGEABLE"; +static const QString commandUnchangable = "UNCHANGEABLE"; static const QString commandUpdateFilesClient = "update"; class Tools { diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 08c7e9c..2b66318 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -431,6 +431,15 @@ void UpdateController::calculateSharedHash() fileInfo.absoluteFilePath(),fileInfo.fileName(), fileInfo.birthTime(),fileInfo.size()); + if(fileInfo.fileName() == baseNameVersion) + { + version->setIsChangeable(false); + } + else + { + version->setIsChangeable(true); + } + versionList->append(version); } @@ -447,8 +456,9 @@ void UpdateController::createVersionListXmlAnswer(QList { SAttribute attribute1 = {"Version", ver->getViewName()}; SAttribute attribute2 = {"Created", ver->getCreateData().toString()}; + SAttribute attribute3 = {"isChangeable",QString::number(ver->getIsChangeable())}; - QList listAttr = {attribute1, attribute2}; + QList listAttr = {attribute1, attribute2,attribute3}; SXmlAnswerTag tag = {"VersionData", listAttr}; listTag.append(tag); @@ -492,6 +502,7 @@ void UpdateController::saveVersionToFile(StreamingVersionData *streamingVersion) xmlWriter.writeStartElement("VersionData"); xmlWriter.writeAttribute("Version",streamingVersion->getViewName()); xmlWriter.writeAttribute("Created",streamingVersion->getCreateData().toString()); + xmlWriter.writeAttribute("isChangeable",QString::number(streamingVersion->getIsChangeable())); xmlWriter.writeEndElement(); xmlWriter.writeEndDocument(); @@ -543,6 +554,11 @@ void UpdateController::xmlFileDataParse(QByteArray array) } } +StreamingVersionData* UpdateController::getCurrentVersion() +{ + return assetManager->getCurrentVersionData(); +} + void UpdateController::printFileList(QList fileData) { QListIterator iterator(fileData); diff --git a/ServerLMS/Systems/updatecontroller.h b/ServerLMS/Systems/updatecontroller.h index efe3aee..6932588 100644 --- a/ServerLMS/Systems/updatecontroller.h +++ b/ServerLMS/Systems/updatecontroller.h @@ -54,6 +54,7 @@ public: void createVersionListXmlAnswer(QList version); void saveVersionToFile(StreamingVersionData *streamingVersion); void xmlFileDataParse(QByteArray array); + StreamingVersionData *getCurrentVersion(); public slots: void changeAssetVersion(QString versionName); void createCopyVersion(QString versionName,QString newVersionName); diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index b90a0c3..4f8c27f 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -70,7 +70,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : updateThread->start(); commonClientHandler->initialize(&clientsMap,processingSystem,dataParser,logger); - processingSystem->initialize(this,dataParser,commonClientHandler,logger); + processingSystem->initialize(this,dataParser,commonClientHandler,logger,updateController); logger->setTypeLog("widget"); From 97fee998bbe3ae3dec805f4e0e8d74c9e1186be1 Mon Sep 17 00:00:00 2001 From: semenov Date: Mon, 20 Jan 2025 10:44:01 +0300 Subject: [PATCH 6/8] feat: change path --- ServerLMS/Systems/processingsystem.h | 1 - ServerLMS/Systems/tools.h | 6 ++---- ServerLMS/Systems/updatecontroller.cpp | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ServerLMS/Systems/processingsystem.h b/ServerLMS/Systems/processingsystem.h index febb29d..d412e7a 100644 --- a/ServerLMS/Systems/processingsystem.h +++ b/ServerLMS/Systems/processingsystem.h @@ -52,7 +52,6 @@ private: DataParser *dataParser; UpdateController *updateController; ProviderDBLMS* providerDBLMS; - UpdateController* updateController; }; #endif // PROCESSINGSYSTEM_H diff --git a/ServerLMS/Systems/tools.h b/ServerLMS/Systems/tools.h index b554bbc..cf5fd3e 100644 --- a/ServerLMS/Systems/tools.h +++ b/ServerLMS/Systems/tools.h @@ -15,8 +15,9 @@ static const QString staticDataFolderName = "StaticData"; static const QString applicationFolderName = "Application"; static const QString sharedDataFolderName = "SharedData"; -static const QString additionalFilesFolderName = "AdditionalFiles"; +static const QString additionalFilesFolderName = "RRJ-95NEW-100"; static const QString streamingAssetsFolderName = "StreamingAssets"; +static const QString versionFolderName = "StreamingVersion"; static const QString tempFile = staticDataFolderName + "/save.xml"; static const QString version = staticDataFolderName + "/version.xml"; static const QString versionListFile = staticDataFolderName + "/versionList.xml"; @@ -26,9 +27,6 @@ static const QString buildDataPath = "/Application/RRJLoader/RRJ_Data/"; static const QString tasksAMMfileName = "/tasksAmm.xml"; static const QString tasksFIMfileName = "/tasksFIM.xml"; static const QString clientHash = staticDataFolderName + "/clientHash.xml"; -static const QString tasksAMMfileName = "/tasksAmm.xml"; -static const QString tasksFIMfileName = "/tasksFIM.xml"; -static const QString clientHash = staticDataFolderName + "/clientHash.xml"; static const QString baseNameVersion = "base";//может вынести комманды куда нибудь? diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index e850c77..8225da9 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -364,7 +364,7 @@ QList* UpdateController::calculateHash(QString path) QByteArray UpdateController::getAdditionalFile(QString name) { - QString path = Tools::createSharedPath("/" + assetManager->getCurrentVersionData()->getViewName() + "/AdditionalFiles" + name); + QString path = Tools::createSharedPath("/" + assetManager->getCurrentVersionData()->getViewName() + "/" + additionalFilesFolderName + name); QFile addFile(path); QByteArray array; if(addFile.open(QIODevice::ReadOnly)){ From 3e95be4447fc35dab20ad2b23d18603b40628729 Mon Sep 17 00:00:00 2001 From: semenov Date: Tue, 21 Jan 2025 11:33:51 +0300 Subject: [PATCH 7/8] feat: add versionChanger for GUI --- DOCS/Алексей/Board.md | 1 + InstructorsAndTrainees/CMakeLists.txt | 15 ++ .../connectorToServer/Core/dataparser.cpp | 4 +- .../Core/notifycontroller.cpp | 16 ++ .../connectorToServer/Core/notifycontroller.h | 18 ++ .../Core/recognizesystem.cpp | 94 +++++++ .../connectorToServer/Core/recognizesystem.h | 6 +- .../connectorToServer/Core/sendsystem.cpp | 37 +++ .../connectorToServer/Core/sendsystem.h | 7 + .../connectorToServer/Core/tools.h | 12 +- .../Core/versioncontainer.cpp | 42 +++ .../connectorToServer/Core/versioncontainer.h | 30 +++ .../connectorToServer/connectortoserver.cpp | 55 +++- .../connectorToServer/connectortoserver.h | 11 + .../connectorToServer/streamingversiondata.h | 74 ++++++ .../instructorsandtraineeswidget.cpp | 12 +- .../instructorsandtraineeswidget.h | 2 + .../instructorsandtraineeswidget.ui | 13 + InstructorsAndTrainees/resources.qrc | 1 + .../resources/icons/762.gif | Bin 0 -> 9842 bytes .../widgets/newversionwidget.cpp | 37 +++ .../widgets/newversionwidget.h | 31 +++ .../widgets/newversionwidget.ui | 219 ++++++++++++++++ .../widgets/versionselectwidget.cpp | 107 ++++++++ .../widgets/versionselectwidget.h | 50 ++++ .../widgets/versionselectwidget.ui | 239 ++++++++++++++++++ .../widgets/waitanimationwidget.cpp | 35 +++ .../widgets/waitanimationwidget.h | 27 ++ .../widgets/waitanimationwidget.ui | 73 ++++++ 29 files changed, 1259 insertions(+), 9 deletions(-) create mode 100644 InstructorsAndTrainees/connectorToServer/Core/notifycontroller.cpp create mode 100644 InstructorsAndTrainees/connectorToServer/Core/notifycontroller.h create mode 100644 InstructorsAndTrainees/connectorToServer/Core/versioncontainer.cpp create mode 100644 InstructorsAndTrainees/connectorToServer/Core/versioncontainer.h create mode 100644 InstructorsAndTrainees/connectorToServer/streamingversiondata.h create mode 100644 InstructorsAndTrainees/resources/icons/762.gif create mode 100644 InstructorsAndTrainees/widgets/newversionwidget.cpp create mode 100644 InstructorsAndTrainees/widgets/newversionwidget.h create mode 100644 InstructorsAndTrainees/widgets/newversionwidget.ui create mode 100644 InstructorsAndTrainees/widgets/versionselectwidget.cpp create mode 100644 InstructorsAndTrainees/widgets/versionselectwidget.h create mode 100644 InstructorsAndTrainees/widgets/versionselectwidget.ui create mode 100644 InstructorsAndTrainees/widgets/waitanimationwidget.cpp create mode 100644 InstructorsAndTrainees/widgets/waitanimationwidget.h create mode 100644 InstructorsAndTrainees/widgets/waitanimationwidget.ui diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 5507615..59fe3b9 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -13,6 +13,7 @@ kanban-plugin: board ## bugs - [ ] При старт стопе не сканится шэред дата +- [ ] GUI server: при неподключенном сервере, отключать попытку изменить версию ## feature client Unity diff --git a/InstructorsAndTrainees/CMakeLists.txt b/InstructorsAndTrainees/CMakeLists.txt index 8e13872..bb9f9f3 100644 --- a/InstructorsAndTrainees/CMakeLists.txt +++ b/InstructorsAndTrainees/CMakeLists.txt @@ -60,7 +60,12 @@ add_library(InstructorsAndTrainees SHARED connectorToServer/Core/tools.cpp connectorToServer/Core/tools.h connectorToServer/Core/FileData.h + connectorToServer/Core/notifycontroller.cpp + connectorToServer/Core/notifycontroller.h + connectorToServer/Core/versioncontainer.cpp + connectorToServer/Core/versioncontainer.h connectorToServer/Datas.h + connectorToServer/streamingversiondata.h messanger/messangerwidget.cpp messanger/messangerwidget.h messanger/messangerwidget.ui @@ -74,6 +79,16 @@ add_library(InstructorsAndTrainees SHARED docTasks/fimtaskswidget.ui docTasks/tasksAmmFim.cpp docTasks/tasksAmmFim.h + widgets/newversionwidget.cpp + widgets/newversionwidget.h + widgets/newversionwidget.ui + widgets/versionselectwidget.cpp + widgets/versionselectwidget.h + widgets/versionselectwidget.ui + widgets/waitanimationwidget.cpp + widgets/waitanimationwidget.h + widgets/waitanimationwidget.ui + resources.qrc ) diff --git a/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp b/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp index 1a1a735..82ebfbf 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp +++ b/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp @@ -6,6 +6,7 @@ #include "instructor.h" #include "trainee.h" #include "group.h" +#include "streamingversiondata.h" #include @@ -327,7 +328,8 @@ ServerSettings *DataParser::getServerSettings() if(xmlReader.isStartElement()){ - if(xmlReader.name() == "ServerSettings"){ + if(xmlReader.name() == "ServerSettings") + { foreach(const QXmlStreamAttribute &attr, xmlReader.attributes()){ QString name = attr.name().toString(); diff --git a/InstructorsAndTrainees/connectorToServer/Core/notifycontroller.cpp b/InstructorsAndTrainees/connectorToServer/Core/notifycontroller.cpp new file mode 100644 index 0000000..7c09e24 --- /dev/null +++ b/InstructorsAndTrainees/connectorToServer/Core/notifycontroller.cpp @@ -0,0 +1,16 @@ +#include "notifycontroller.h" + +NotifyController::NotifyController(QObject *parent) : QObject(parent) +{ + +} + +void NotifyController::showWarning(QString text) +{ + QMessageBox warning; + warning.setText(text); + + warning.setIcon(QMessageBox::Warning); + warning.setWindowTitle(tr("Ошибка")); + warning.exec(); +} diff --git a/InstructorsAndTrainees/connectorToServer/Core/notifycontroller.h b/InstructorsAndTrainees/connectorToServer/Core/notifycontroller.h new file mode 100644 index 0000000..1b08ef9 --- /dev/null +++ b/InstructorsAndTrainees/connectorToServer/Core/notifycontroller.h @@ -0,0 +1,18 @@ +#ifndef NOTIFYCONTROLLER_H +#define NOTIFYCONTROLLER_H + +#include +#include + +class NotifyController : public QObject +{ + Q_OBJECT +public: + explicit NotifyController(QObject *parent = nullptr); + + void showWarning(QString text); +signals: + +}; + +#endif // NOTIFYCONTROLLER_H diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp index 05adfa5..4764af1 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp +++ b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp @@ -254,6 +254,17 @@ void RecognizeSystem::recognize(QTcpSocket *socket) packetType = PacketType::TYPE_NONE; } + + if(packetType == PacketType::BUSY) + { + emit sigAnimationActivated(true); + } + + if(packetType == PacketType::FREE) + { + emit sigAnimationActivated(false); + } + //xml-ответы на запросы к БД switch(packetType) { @@ -337,6 +348,21 @@ void RecognizeSystem::xmlParser(QByteArray array) { emit sigStartCompare(); } + + if (value == "BASEDELETETRY") + { + emit sigNotify(tr("Нельзя удалять базовую версию")); + } + + if (value == "TRYACTIVEDELETE") + { + emit sigNotify(tr("Нельзя удалять активную версию")); + } + + if (value == "DUPLICATEVERNAME") + { + emit sigNotify(tr("Такое имя уже существет")); + } } } } @@ -414,6 +440,74 @@ void RecognizeSystem::xmlParser(QByteArray array) } emit sigDeAuth(serverDeAuth); + + } + + + if(xmlReader.name() == "VersionList") + { + QList *serverStreamingVersionDataList = new QList; + xmlReader.readNext(); + + while (!xmlReader.atEnd()) + { + if(xmlReader.isStartElement()) + { + if(xmlReader.name() == "VersionData") + { + StreamingVersionData *data = new StreamingVersionData; + + foreach(const QXmlStreamAttribute &attr,xmlReader.attributes()) + { + QString name = attr.name().toString(); + QString value = attr.value().toString(); + + if(name == "Version") + data->setName(value); + else if(name == "Created") + data->setCreateData(QDateTime::fromString(value)); + else if(name == "isChangeable") + { + data->setIsChangeable(value.toInt()); + } + } + + serverStreamingVersionDataList->append(data); + } + } + + xmlReader.readNext(); + } + + emit sigShowServerDataList(serverStreamingVersionDataList); + } + + if(xmlReader.name() == "VersionData") + { + StreamingVersionData *serverVersion = new StreamingVersionData; + foreach(const QXmlStreamAttribute &attr,xmlReader.attributes()) + { + QString name = attr.name().toString(); + QString value = attr.value().toString(); + + if (name == "Version") + { + serverVersion->setName(value); + } + + if (name == "Created") + { + serverVersion->setCreateData(QDateTime::fromString(value)); + } + + if (name == "isChangeable") + { + serverVersion->setIsChangeable(value.toInt()); + } + + } + + emit sigSetVersion(serverVersion); } xmlReader.readNext(); diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h index a01e22d..961f334 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h +++ b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h @@ -4,6 +4,7 @@ #include #include #include +#include //#include #include #include "dataparser.h" @@ -48,9 +49,12 @@ signals: void sigAnswerQueryToDB_ListComputers(QList listComputers); void sigAnswerQueryToDB_ListClassrooms(QList listClassrooms); void sigAnswerQueryToDB_ListTasks(QList listTasks); - void sigAnswerQueryTasksXML_FIM(QList listTaskFim); void sigAnswerQueryTasksXML_AMM(QList listTaskAmm); + void sigShowServerDataList(QList *versions); + void sigSetVersion(StreamingVersionData* serverVersion); + void sigNotify(QString text); + void sigAnimationActivated(bool flag); private: QList *folderList; diff --git a/InstructorsAndTrainees/connectorToServer/Core/sendsystem.cpp b/InstructorsAndTrainees/connectorToServer/Core/sendsystem.cpp index 051dbf2..dadaaf7 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/sendsystem.cpp +++ b/InstructorsAndTrainees/connectorToServer/Core/sendsystem.cpp @@ -129,6 +129,43 @@ void SendSystem::sendFinish() socket->waitForReadyRead(100); } +void SendSystem::sendChangeVersion(StreamingVersionData *streamingVersion) +{ + QDataStream stream(socket); + stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); + stream << PacketType::CHANGE_DATA_VERSION; + stream << streamingVersion->getViewName(); + + socket->waitForReadyRead(100); +} + +void SendSystem::sendDeleteVersion(StreamingVersionData *streamingVersion) +{ + QDataStream stream(socket); + stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); + stream << PacketType::DELETE_DATA_VERSION; + stream << streamingVersion->getViewName(); + + socket->waitForReadyRead(100); +} + +void SendSystem::sendCopyVersion(QString versionName) +{ + QDataStream stream(socket); + stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); + stream << PacketType::COPY_VERSION; + + stream << versionName; +} + +void SendSystem::sendPacketType(PacketType packetType) +{ + QDataStream stream(socket); + QByteArray data; + stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); + + stream << packetType; +} SendSystem::~SendSystem() { diff --git a/InstructorsAndTrainees/connectorToServer/Core/sendsystem.h b/InstructorsAndTrainees/connectorToServer/Core/sendsystem.h index b260776..1e22eef 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/sendsystem.h +++ b/InstructorsAndTrainees/connectorToServer/Core/sendsystem.h @@ -5,6 +5,9 @@ #include #include +#include +#include "Core/tools.h" + class SendSystem :public QObject { Q_OBJECT @@ -19,6 +22,10 @@ public: void sendXMLAnswer(QByteArray array); ~SendSystem(); void sendFinish(); + void sendChangeVersion(StreamingVersionData *streamingVersion); + void sendDeleteVersion(StreamingVersionData *streamingVersion); + void sendCopyVersion(QString versionName); + void sendPacketType(PacketType packetType); signals: void sigSend(); diff --git a/InstructorsAndTrainees/connectorToServer/Core/tools.h b/InstructorsAndTrainees/connectorToServer/Core/tools.h index d64b155..cb040f0 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/tools.h +++ b/InstructorsAndTrainees/connectorToServer/Core/tools.h @@ -19,6 +19,8 @@ static QString displayTemp = staticDataFolderName + "/displayData.xml"; static QString streamingHashFilename = staticDataFolderName + "/streamingHash.xml"; static QString serverHash = staticDataFolderName + "/serverHash.xml"; +static QString cmd_CheckVersionList = "CHECKVERSIONLIST"; + enum PacketType{ TYPE_NONE = 0, TYPE_UNITY = 1, @@ -31,6 +33,7 @@ enum PacketType{ TYPE_XMLANSWER = 8, TYPE_QT = 9, TYPE_DISABLE = 11, + TYPE_CHECKVERSION = 13, TYPE_XMLANSWER_MESSAGE_FOR_GUI = 90, @@ -44,7 +47,14 @@ enum PacketType{ //xml-ответы на запросы AdditionalFiles TYPE_XMLANSWER_QUERY_TASKS_XML_FIM = 130, - TYPE_XMLANSWER_QUERY_TASKS_XML_AMM = 131 + TYPE_XMLANSWER_QUERY_TASKS_XML_AMM = 131, + + HASH_READY = 150, + CHANGE_DATA_VERSION = 151, + COPY_VERSION = 152, + DELETE_DATA_VERSION = 153, + BUSY = 154, + FREE = 155 }; Q_DECLARE_METATYPE(PacketType) diff --git a/InstructorsAndTrainees/connectorToServer/Core/versioncontainer.cpp b/InstructorsAndTrainees/connectorToServer/Core/versioncontainer.cpp new file mode 100644 index 0000000..1c8bd1c --- /dev/null +++ b/InstructorsAndTrainees/connectorToServer/Core/versioncontainer.cpp @@ -0,0 +1,42 @@ +#include "versioncontainer.h" + +VersionContainer::VersionContainer(QObject *parent) : + QObject(parent) +{ + +} + +VersionContainer::~VersionContainer() +{ + +} + +QString VersionContainer::getServerVersion() const +{ + return serverVersionData->getViewName(); +} + +QString VersionContainer::getLocalVersion() const +{ + return localVersionData->getViewName(); +} + +StreamingVersionData *VersionContainer::getLocalVersionData() const +{ + return localVersionData; +} + +void VersionContainer::setLocalVersionData(StreamingVersionData *value) +{ + localVersionData = value; +} + +StreamingVersionData *VersionContainer::getServerVersionData() const +{ + return serverVersionData; +} + +void VersionContainer::setServerVersionData(StreamingVersionData *value) +{ + serverVersionData = value; +} diff --git a/InstructorsAndTrainees/connectorToServer/Core/versioncontainer.h b/InstructorsAndTrainees/connectorToServer/Core/versioncontainer.h new file mode 100644 index 0000000..8b12c77 --- /dev/null +++ b/InstructorsAndTrainees/connectorToServer/Core/versioncontainer.h @@ -0,0 +1,30 @@ +#ifndef VERSIONCONTAINER_H +#define VERSIONCONTAINER_H + +#include +#include "connectorToServer/streamingversiondata.h" + +class VersionContainer : public QObject +{ + Q_OBJECT +public: + explicit VersionContainer(QObject *parent = nullptr); + ~VersionContainer(); + + QString getServerVersion() const; + QString getLocalVersion() const; + + + StreamingVersionData *getLocalVersionData() const; + void setLocalVersionData(StreamingVersionData *value); + + StreamingVersionData *getServerVersionData() const; + void setServerVersionData(StreamingVersionData *value); + +private: + StreamingVersionData *localVersionData; + StreamingVersionData *serverVersionData; + +}; + +#endif // VERSIONCONTAINER_H diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp index de0f798..7742ca5 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp @@ -7,7 +7,11 @@ ConnectorToServer::ConnectorToServer(QObject *parent) : client(nullptr), dataParser(nullptr), sendSystem(nullptr), - recognizeSystem(nullptr) + recognizeSystem(nullptr), + versionSelectWidget(nullptr), + versionContainer(nullptr), + notifyController(nullptr), + waitAnimationWidget(nullptr) { initialize(); } @@ -96,6 +100,7 @@ bool ConnectorToServer::sendQueryTasksXML(QString type) void ConnectorToServer::SetConnectToServer() { emit sigSetConnect(dataParser->getServerSettings(),connectionThread); + } QList ConnectorToServer::getListTaskFim() @@ -249,6 +254,12 @@ int ConnectorToServer::getIdTraineeByLogin(QString login) return 0; } +void ConnectorToServer::showVersionSelect() +{ + QByteArray answer = dataParser->xmlAnswer_notify(cmd_CheckVersionList); + emit sigSendAnswerToServer(answer); +} + /* void ConnectorToServer::slot_AnswerQueryToDB(QList* listInstructors, QList* listTrainees, @@ -316,6 +327,11 @@ void ConnectorToServer::slot_msgToClientReady(QString login, QString text) sendMessageForClient(id, login, text); } +void ConnectorToServer::showServerList(QList *serverList) +{ + versionSelectWidget->fillView(serverList); +} + void ConnectorToServer::initialize() { createObjects(); @@ -325,6 +341,22 @@ void ConnectorToServer::initialize() emit sigInitializeClient(recognizeSystem,sendSystem,connectionThread); emit sigSetConnect(dataParser->getServerSettings(),connectionThread); + +// QByteArray answer = dataParser->xmlAnswer_notify() +// sendSystem->sendXMLAnswer() + +} + +void ConnectorToServer::activateLoadAnimation(bool flag) +{ + if (flag) + { + waitAnimationWidget->showWithPlay(); + } + else + { + waitAnimationWidget->hideWithStop(); + } } void ConnectorToServer::bindConnection() @@ -332,10 +364,13 @@ void ConnectorToServer::bindConnection() connect(this,&ConnectorToServer::sigInitializeClient,client,&TCPClient::initialize,Qt::AutoConnection); connect(this,&ConnectorToServer::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection); connect(this,&ConnectorToServer::signal_sendXMLmsgGUItoServer,sendSystem,&SendSystem::sendXMLmsgGUItoServer); + connect(this,&ConnectorToServer::sigSendAnswerToServer,sendSystem,&SendSystem::sendXMLAnswer,Qt::AutoConnection); connect(recognizeSystem,&RecognizeSystem::sigAuth,this,&ConnectorToServer::sigLoginResult); connect(recognizeSystem,&RecognizeSystem::sigDeAuth,this,&ConnectorToServer::sigDeLoginResult); connect(recognizeSystem,&RecognizeSystem::signal_MessageForGUI,this,&ConnectorToServer::signal_msgFromClientReady); + connect(recognizeSystem,&RecognizeSystem::sigShowServerDataList,this,&ConnectorToServer::showServerList); + connect (recognizeSystem,&RecognizeSystem::sigSetVersion,versionContainer,&VersionContainer::setServerVersionData); //connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB,this,&ConnectorToServer::slot_AnswerQueryToDB); connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListInstructors,this,&ConnectorToServer::slot_AnswerQueryToDB_ListInstructors); @@ -347,8 +382,11 @@ void ConnectorToServer::bindConnection() connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryTasksXML_FIM,this,&ConnectorToServer::slot_AnswerQueryTasksXML_FIM); connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryTasksXML_AMM,this,&ConnectorToServer::slot_AnswerQueryTasksXML_AMM); + connect(recognizeSystem,&RecognizeSystem::sigAnimationActivated,this,&ConnectorToServer::activateLoadAnimation,Qt::AutoConnection); - connect(client,&TCPClient::signal_ConnectedToServer,this,&ConnectorToServer::signal_ConnectedToServer); + connect(client,&TCPClient::signal_ConnectedToServer,this,&ConnectorToServer::signal_ConnectedToServer,Qt::AutoConnection); + + connect(recognizeSystem,&RecognizeSystem::sigNotify,notifyController,&NotifyController::showWarning,Qt::AutoConnection); } void ConnectorToServer::createObjects() @@ -360,12 +398,25 @@ void ConnectorToServer::createObjects() dataParser = new DataParser; + waitAnimationWidget = new WaitAnimationWidget; + sendSystem = new SendSystem; sendSystem->moveToThread(connectionThread); recognizeSystem = new RecognizeSystem; recognizeSystem->moveToThread(connectionThread); + notifyController = new NotifyController; + versionContainer = new VersionContainer; + versionSelectWidget = new VersionSelectWidget; + versionSelectWidget->initialize(sendSystem,versionContainer,notifyController); + + QMovie *movie = new QMovie(":/resources/icons/762.gif"); + + waitAnimationWidget->setParent(versionSelectWidget); + waitAnimationWidget->initialize(movie,versionSelectWidget); + waitAnimationWidget->moveToThread(connectionThread); + connectionThread->start(); connectionThread->setPriority(QThread::HighestPriority); } diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.h b/InstructorsAndTrainees/connectorToServer/connectortoserver.h index 9f158c7..5167542 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.h +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.h @@ -2,6 +2,8 @@ #define CONNECTORTOSERVER_H #include +#include +#include #include "Core\tcpclient.h" #include "Core\dataparser.h" #include "Core\sendsystem.h" @@ -12,6 +14,7 @@ #include "computer.h" #include "classroom.h" #include "task.h" +#include "streamingversiondata.h" class ConnectorToServer : public QObject { @@ -54,7 +57,9 @@ public: Group getGroup(int id); int getIdTraineeByLogin(QString login); + void showVersionSelect(); + void activateLoadAnimation(bool flag); public slots: /*void slot_AnswerQueryToDB(QList* listInstructors, QList* listTrainees, @@ -71,6 +76,7 @@ public slots: void slot_AnswerQueryTasksXML_AMM(QList listTaskAmm); void slot_msgToClientReady(QString login, QString text); + void showServerList(QList *serverList); signals: void sigSetConnect(ServerSettings* serverSettings,QThread *thread); @@ -93,6 +99,7 @@ signals: void signal_InitMessanger(QList listTrainees); void signal_msgFromClientReady(QString login, QString text); + void sigSendAnswerToServer(QByteArray array); private: @@ -106,6 +113,10 @@ private: DataParser *dataParser; SendSystem *sendSystem; RecognizeSystem *recognizeSystem; + VersionSelectWidget *versionSelectWidget; + VersionContainer *versionContainer; + NotifyController *notifyController; + WaitAnimationWidget *waitAnimationWidget; //Списочная модель БД СУО QList listInstructors; diff --git a/InstructorsAndTrainees/connectorToServer/streamingversiondata.h b/InstructorsAndTrainees/connectorToServer/streamingversiondata.h new file mode 100644 index 0000000..d190385 --- /dev/null +++ b/InstructorsAndTrainees/connectorToServer/streamingversiondata.h @@ -0,0 +1,74 @@ +#ifndef STREAMINGVERSIONDATA_H +#define STREAMINGVERSIONDATA_H + +#include +#include + +class StreamingVersionData +{ +public: + + StreamingVersionData(){} + + StreamingVersionData(QString absoltePath,QString viewName,QDateTime data,qint32 size) + { + this->absolutePath = absoltePath; + this->viewName = viewName; + this->createData = data; + this->size = size; + } + + void setName(QString viewName) + { + this->viewName = viewName; + } + + void setCreateData(QDateTime data) + { + this->createData = data; + } + + ~StreamingVersionData(); + + QString getAbsolutPath() const + { + return absolutePath; + } + + QString getViewName() const + { + return viewName; + } + + QDateTime getCreateData() const + { + return createData; + } + + qint32 getSize() const + { + return size; + } + + bool getIsChangeable() const + { + return isChangeable; + } + void setIsChangeable(bool value) + { + isChangeable = value; + } + + +private: + QString absolutePath; + QString viewName; + QDateTime createData; + bool isChangeable; + qint32 size; +}; + +#endif // STREAMINGVERSIONDATA_H + + + diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index d849704..42bda85 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -68,7 +68,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) : ui->verticalLayout_1->addWidget(viewerInstructors); ui->verticalLayout_2->addWidget(docTasksWidget); ui->verticalLayout_2->addWidget(fIMtasksWidget); - + ui->btnSetVersion->hide(); viewerTrainees->setMinimumHeight(800); viewerInstructors->setMinimumSize(1800, 300); messangerWidget->setMinimumSize(500, 600); @@ -170,7 +170,7 @@ void InstructorsAndTraineesWidget::checkLoginResult(ServerAuthorization *serverA viewerTrainees->setAuthComplited(true); Q_EMIT signal_NeedUpdateUI(true, true); - + ui->btnSetVersion->show(); ui->btnAuthorizationInstructor->setText(tr("Deauthorization Instructor")); updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName); @@ -200,7 +200,6 @@ void InstructorsAndTraineesWidget::checkDeLoginResult(ServerDeAuthorization *ser Q_EMIT signal_NeedUpdateUI(true, false); ui->btnAuthorizationInstructor->setText(tr("Authorization Instructor")); - updateLabelLoggedInInstructor("",""); QMessageBox::information(this, tr("Instructor deauthorization"), tr("Successfully!")); @@ -225,7 +224,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state) {//Сервер отключен ui->btnConnectionToServer->setEnabled(true); ui->btnAuthorizationInstructor->setEnabled(false); - + ui->btnSetVersion->hide(); ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png"))); } } @@ -325,3 +324,8 @@ void InstructorsAndTraineesWidget::on_btnUpdateStyleSheet_clicked() { updateMyStyleSheet(); } + +void InstructorsAndTraineesWidget::on_btnSetVersion_clicked() +{ + connectorToServer->showVersionSelect(); +} diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.h b/InstructorsAndTrainees/instructorsandtraineeswidget.h index 5f0beaa..29e524d 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.h +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.h @@ -63,6 +63,8 @@ private Q_SLOTS: void on_btnAuthorizationInstructor_clicked(); void on_btnUpdateStyleSheet_clicked(); + void on_btnSetVersion_clicked(); + private: //Авторизация инструктора локальная bool authorizationInstructorDialog(QWidget* parent = nullptr); diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.ui b/InstructorsAndTrainees/instructorsandtraineeswidget.ui index 164f714..7b72e42 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.ui +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.ui @@ -203,6 +203,19 @@ + + + + + 58 + 58 + + + + ChangeVersion + + + diff --git a/InstructorsAndTrainees/resources.qrc b/InstructorsAndTrainees/resources.qrc index 56c11bf..d15df9e 100644 --- a/InstructorsAndTrainees/resources.qrc +++ b/InstructorsAndTrainees/resources.qrc @@ -40,5 +40,6 @@ resources/icons/task.png resources/icons/procedure.png resources/icons/malfunction.png + resources/icons/762.gif diff --git a/InstructorsAndTrainees/resources/icons/762.gif b/InstructorsAndTrainees/resources/icons/762.gif new file mode 100644 index 0000000000000000000000000000000000000000..d1a1bca8b7856ad73866ccb7f064d5ce0d1a9eed GIT binary patch literal 9842 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 Jl48`K{XgQexzGRr literal 0 HcmV?d00001 diff --git a/InstructorsAndTrainees/widgets/newversionwidget.cpp b/InstructorsAndTrainees/widgets/newversionwidget.cpp new file mode 100644 index 0000000..980781e --- /dev/null +++ b/InstructorsAndTrainees/widgets/newversionwidget.cpp @@ -0,0 +1,37 @@ +#include "newversionwidget.h" +#include "ui_newversionwidget.h" + +NewVersionWidget::NewVersionWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::NewVersionWidget) +{ + ui->setupUi(this); + setWindowFlags(Qt::SubWindow); + setAttribute(Qt::WA_ShowModal,true); +} + +void NewVersionWidget::initialize(VersionSelectWidget *versionSelectWidget, QString prevName) +{ + this->versionSelectWidget = versionSelectWidget; + ui->prevVerValue->setText(prevName); +} + + +void NewVersionWidget::on_createButton_clicked() +{ + if(ui->lineEdit->text() != "") + { + versionSelectWidget->sendCopyEmit(ui->lineEdit->text()); + hide(); + } +} + +void NewVersionWidget::on_cancelButton_clicked() +{ + hide(); +} + +NewVersionWidget::~NewVersionWidget() +{ + delete ui; +} diff --git a/InstructorsAndTrainees/widgets/newversionwidget.h b/InstructorsAndTrainees/widgets/newversionwidget.h new file mode 100644 index 0000000..dbc62e5 --- /dev/null +++ b/InstructorsAndTrainees/widgets/newversionwidget.h @@ -0,0 +1,31 @@ +#ifndef NEWVERSIONWIDGET_H +#define NEWVERSIONWIDGET_H + +#include +#include + +namespace Ui { +class NewVersionWidget; +} + +class VersionSelectWidget; +class NewVersionWidget : public QWidget +{ + Q_OBJECT + +public: + explicit NewVersionWidget(QWidget *parent = nullptr); + void initialize(VersionSelectWidget *versionSelectWidget,QString prevName); + ~NewVersionWidget(); + +private slots: + void on_createButton_clicked(); + + void on_cancelButton_clicked(); + +private: + Ui::NewVersionWidget *ui; + VersionSelectWidget *versionSelectWidget; +}; + +#endif // NEWVERSIONWIDGET_H diff --git a/InstructorsAndTrainees/widgets/newversionwidget.ui b/InstructorsAndTrainees/widgets/newversionwidget.ui new file mode 100644 index 0000000..9ba102e --- /dev/null +++ b/InstructorsAndTrainees/widgets/newversionwidget.ui @@ -0,0 +1,219 @@ + + + NewVersionWidget + + + + 0 + 0 + 325 + 200 + + + + + 0 + 0 + + + + Создать копию... + + + true + + + + + + + + + true + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + Базовая версия: + + + + + + + TextLabel + + + + + + + + + 6 + + + 5 + + + 5 + + + 20 + + + 5 + + + + + Новое название: + + + + + + + + 0 + 0 + + + + + 150 + 30 + + + + + 60 + 30 + + + + + + + + + + 6 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Создать + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Отмена + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + + + + + + + diff --git a/InstructorsAndTrainees/widgets/versionselectwidget.cpp b/InstructorsAndTrainees/widgets/versionselectwidget.cpp new file mode 100644 index 0000000..2f76f3c --- /dev/null +++ b/InstructorsAndTrainees/widgets/versionselectwidget.cpp @@ -0,0 +1,107 @@ +#include "versionselectwidget.h" +#include "ui_versionselectwidget.h" +#include "ui_versionselectwidget.h" + +#include + +VersionSelectWidget::VersionSelectWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::VersionSelectWidget), + selectedVersion(nullptr) +{ + ui->setupUi(this); + setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); + setAttribute(Qt::WA_ShowModal,true); +} + +void VersionSelectWidget::initialize(SendSystem *sendSystem,VersionContainer *versionContainer,NotifyController *notifyController) +{ + connect(this,&VersionSelectWidget::sigSendSwitchVersion,sendSystem,&SendSystem::sendChangeVersion,Qt::AutoConnection); + connect(this,&VersionSelectWidget::sigSendCopyVersion,sendSystem,&SendSystem::sendCopyVersion,Qt::AutoConnection); + connect(this,&VersionSelectWidget::sigSendDeleteVersion,sendSystem,&SendSystem::sendDeleteVersion,Qt::AutoConnection); + connect(this,&VersionSelectWidget::sigSendNotify,notifyController,&NotifyController::showWarning,Qt::AutoConnection); + this->versionContainer = versionContainer; + hide(); + setWindowTitle(tr("Управление версиями")); +} + +void VersionSelectWidget::fillView(QList *serverData) +{ + show(); + ui->verListView->clear(); + serverDataList = serverData; + ui->verValue->setText(versionContainer->getServerVersionData()->getViewName()); + + foreach(StreamingVersionData *data,*serverData) + { + ui->verListView->addItem(data->getViewName()); + } +} + +void VersionSelectWidget::on_verListView_itemDoubleClicked(QListWidgetItem *item) +{ + foreach(StreamingVersionData *data,*serverDataList) + { + if(data->getViewName() == item->text()) + { + QString info = "Имя версии: " + data->getViewName() + "\n"; + info.append("Создан: " + data->getCreateData().toString()); + ui->infoValue->setText(info); + selectedVersion = data; + } + } +} + + +void VersionSelectWidget::on_createDuplicateButton_clicked() +{ + NewVersionWidget *newVersionWidget = new NewVersionWidget; + newVersionWidget->initialize(this,selectedVersion->getViewName()); + newVersionWidget->show(); +} + +void VersionSelectWidget::sendCopyEmit(QString newName) +{ + QString result = selectedVersion->getViewName() + ";" + newName; + + if (selectedVersion == nullptr) + { + sigSendNotify(tr("Версия не выбрана")); + return; + } + + //versionContainer->setLocalVersionData(selectedVersion); + emit sigSendCopyVersion(result); +} + +void VersionSelectWidget::on_DeleteVersionButton_clicked() +{ + if (selectedVersion == nullptr) + { + sigSendNotify(tr("Версия не выбрана")); + return; + } + + emit sigSendDeleteVersion(selectedVersion); +} + +void VersionSelectWidget::on_switchServerVersionButton_clicked() +{ + if (selectedVersion == nullptr) + { + sigSendNotify(tr("Версия не выбрана")); + return; + } + + versionContainer->setServerVersionData(selectedVersion); + ui->verValue->setText(selectedVersion->getViewName()); + emit sigSendSwitchVersion(selectedVersion); +} + + + +VersionSelectWidget::~VersionSelectWidget() +{ + delete ui; +} + diff --git a/InstructorsAndTrainees/widgets/versionselectwidget.h b/InstructorsAndTrainees/widgets/versionselectwidget.h new file mode 100644 index 0000000..b2dedb7 --- /dev/null +++ b/InstructorsAndTrainees/widgets/versionselectwidget.h @@ -0,0 +1,50 @@ +#ifndef VERSIONSELECTWIDGET_H +#define VERSIONSELECTWIDGET_H + +#include +#include + +#include +#include +#include +#include +#include + +namespace Ui { +class VersionSelectWidget; +} + +class VersionSelectWidget : public QWidget +{ + Q_OBJECT + +public: + explicit VersionSelectWidget(QWidget *parent = nullptr); + + void initialize(SendSystem *sendSystem,VersionContainer *versionContainer,NotifyController *notifyController); + void fillView(QList *serverData); + void sendCopyEmit(QString newName); + + ~VersionSelectWidget(); +private slots: + void on_verListView_itemDoubleClicked(QListWidgetItem *item); + void on_createDuplicateButton_clicked(); + void on_DeleteVersionButton_clicked(); + void on_switchServerVersionButton_clicked(); + +signals: + void sigSendDeleteVersion(StreamingVersionData *streaming); + void sigSendSwitchVersion(StreamingVersionData *selectVersion); + void sigSendCopyVersion(QString versionPair); + void sigSendNotify(QString message); + +private: + Ui::VersionSelectWidget *ui; + SendSystem *sendSystem; + QList *serverDataList; + VersionContainer *versionContainer; + NotifyController *notifyController; + StreamingVersionData *selectedVersion; +}; + +#endif // VERSIONSELECTWIDGET_H diff --git a/InstructorsAndTrainees/widgets/versionselectwidget.ui b/InstructorsAndTrainees/widgets/versionselectwidget.ui new file mode 100644 index 0000000..6dbca69 --- /dev/null +++ b/InstructorsAndTrainees/widgets/versionselectwidget.ui @@ -0,0 +1,239 @@ + + + VersionSelectWidget + + + + 0 + 0 + 606 + 229 + + + + + 0 + 0 + + + + Form + + + false + + + + + 0 + 0 + 301 + 171 + + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + Calibri + 12 + + + + Qt::PreventContextMenu + + + Доступные версии на сервере + + + + + + + + + + + + 0 + 180 + 601 + 41 + + + + + 6 + + + + + QLayout::SetMinimumSize + + + 5 + + + 0 + + + + + + 0 + 0 + + + + + 9 + + + + Создать копию + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 9 + + + + Удалить + + + + + + + + + + 0 + 0 + + + + + 9 + + + + Переключить версию сервера + + + + + + + + + 310 + 0 + 291 + 131 + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + Информация: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Тут будет информация о версии... + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 310 + 140 + 291 + 31 + + + + + + + Текущая версия сервера: + + + + + + + none + + + + + + + + + diff --git a/InstructorsAndTrainees/widgets/waitanimationwidget.cpp b/InstructorsAndTrainees/widgets/waitanimationwidget.cpp new file mode 100644 index 0000000..547a79f --- /dev/null +++ b/InstructorsAndTrainees/widgets/waitanimationwidget.cpp @@ -0,0 +1,35 @@ +#include "waitanimationwidget.h" +#include "ui_waitanimationwidget.h" + +WaitAnimationWidget::WaitAnimationWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::WaitAnimationWidget), + loadingMovie(nullptr) +{ + ui->setupUi(this); +} + +void WaitAnimationWidget::initialize(QMovie *movie,QWidget *parent) +{ + ui->MovieLabel->setMovie(movie); + loadingMovie = movie; + setFixedSize(parent->width(),parent->height()); + hide(); +} + +void WaitAnimationWidget::showWithPlay() +{ + show(); + loadingMovie->start(); +} + +void WaitAnimationWidget::hideWithStop() +{ + hide(); + loadingMovie->stop(); +} + +WaitAnimationWidget::~WaitAnimationWidget() +{ + delete ui; +} diff --git a/InstructorsAndTrainees/widgets/waitanimationwidget.h b/InstructorsAndTrainees/widgets/waitanimationwidget.h new file mode 100644 index 0000000..e9ea6a9 --- /dev/null +++ b/InstructorsAndTrainees/widgets/waitanimationwidget.h @@ -0,0 +1,27 @@ +#ifndef WAITANIMATIONWIDGET_H +#define WAITANIMATIONWIDGET_H + +#include +#include + +namespace Ui { +class WaitAnimationWidget; +} + +class WaitAnimationWidget : public QWidget +{ + Q_OBJECT + +public: + explicit WaitAnimationWidget(QWidget *parent = nullptr); + void initialize(QMovie *movie,QWidget *parent); + void showWithPlay(); + void hideWithStop(); + ~WaitAnimationWidget(); + +private: + Ui::WaitAnimationWidget *ui; + QMovie *loadingMovie; +}; + +#endif // WAITANIMATIONWIDGET_H diff --git a/InstructorsAndTrainees/widgets/waitanimationwidget.ui b/InstructorsAndTrainees/widgets/waitanimationwidget.ui new file mode 100644 index 0000000..4819a89 --- /dev/null +++ b/InstructorsAndTrainees/widgets/waitanimationwidget.ui @@ -0,0 +1,73 @@ + + + WaitAnimationWidget + + + + 0 + 0 + 635 + 293 + + + + + 0 + 0 + + + + Form + + + false + + + background-color:rgba(0,0,0,50%); + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + 0 + 0 + + + + background-color:rgba(0,0,0,50%) + + + + + + :/resources/icons/762.gif + + + Qt::AlignCenter + + + + + + + + + + + + From 079a36a76d0fcfeaba14302ab9e91780196cd538 Mon Sep 17 00:00:00 2001 From: semenov Date: Tue, 21 Jan 2025 15:43:30 +0300 Subject: [PATCH 8/8] feat:draft version change --- DOCS/Алексей/Board.md | 7 +- .../Core/recognizesystem.cpp | 5 +- .../connectorToServer/connectortoserver.cpp | 5 + .../connectorToServer/connectortoserver.h | 1 + .../connectorToServer/streamingversiondata.h | 14 ++ .../instructorsandtraineeswidget.cpp | 2 +- .../widgets/versionselectwidget.cpp | 17 +- .../widgets/versionselectwidget.h | 4 + ServerLMS/Data/StreamingVersionData.h | 36 ++++ ServerLMS/Systems/assetsmanager.cpp | 188 +++++++++++++++++- ServerLMS/Systems/assetsmanager.h | 7 +- ServerLMS/Systems/recognizesystem.cpp | 2 +- ServerLMS/Systems/recognizesystem.h | 2 +- ServerLMS/Systems/updatecontroller.cpp | 87 ++------ ServerLMS/Systems/updatecontroller.h | 4 +- ServerLMS/serverlmswidget.cpp | 1 - 16 files changed, 287 insertions(+), 95 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 59fe3b9..9378343 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -13,13 +13,12 @@ kanban-plugin: board ## bugs - [ ] При старт стопе не сканится шэред дата -- [ ] GUI server: при неподключенном сервере, отключать попытку изменить версию ## feature client Unity -- [ ] отправлять сигнал на пересчет хэша с саб частью - [ ] Добавить обновление инструктора, если он перелогинился +- [ ] убрать функционал смены версии с клиента ## feature client QT @@ -27,7 +26,6 @@ kanban-plugin: board - [ ] Иерархия проекта - папка application, папка updater и линк на основной экзешник - [ ] на старте все мониторы должны быть активны - [ ] Нужен ли дополнительный выбор для загрузки с мат моделью или нет? -- [ ] передавать полную версию в StreaminVerData ## feature server @@ -40,10 +38,13 @@ kanban-plugin: board ## NOW +- [ ] добавить информацию Авторе и изменяемая версия или нет ## Complete +- [ ] отправлять сигнал на пересчет хэша с саб частью +- [ ] GUI server: при неподключенном сервере, отключать попытку изменить версию - [ ] добавить автоматическое выключение после создания копии - [ ] sendSystem::sendXmlAnswer новый вариант отпарвки XML пакетов - [ ] выписать все варианты взаимодействия между всеми клиентами и сервером diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp index 4764af1..ce76408 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp +++ b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp @@ -467,9 +467,10 @@ void RecognizeSystem::xmlParser(QByteArray array) else if(name == "Created") data->setCreateData(QDateTime::fromString(value)); else if(name == "isChangeable") - { data->setIsChangeable(value.toInt()); - } + else if(name == "author") + data->setAuthor(value); + } serverStreamingVersionDataList->append(data); diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp index 7742ca5..3e6f697 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp @@ -97,6 +97,11 @@ bool ConnectorToServer::sendQueryTasksXML(QString type) return true; } +void ConnectorToServer::setLoginName(QString name) +{ + versionSelectWidget->setAuthor(name); +} + void ConnectorToServer::SetConnectToServer() { emit sigSetConnect(dataParser->getServerSettings(),connectionThread); diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.h b/InstructorsAndTrainees/connectorToServer/connectortoserver.h index 5167542..a393e3d 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.h +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.h @@ -60,6 +60,7 @@ public: void showVersionSelect(); void activateLoadAnimation(bool flag); + void setLoginName(QString name); public slots: /*void slot_AnswerQueryToDB(QList* listInstructors, QList* listTrainees, diff --git a/InstructorsAndTrainees/connectorToServer/streamingversiondata.h b/InstructorsAndTrainees/connectorToServer/streamingversiondata.h index d190385..45c8f4d 100644 --- a/InstructorsAndTrainees/connectorToServer/streamingversiondata.h +++ b/InstructorsAndTrainees/connectorToServer/streamingversiondata.h @@ -16,6 +16,7 @@ public: this->viewName = viewName; this->createData = data; this->size = size; + this->author = ""; } void setName(QString viewName) @@ -54,15 +55,26 @@ public: { return isChangeable; } + void setIsChangeable(bool value) { isChangeable = value; } + QString getAuthor() const + { + return author; + } + + void setAuthor(const QString &value) + { + author = value; + } private: QString absolutePath; QString viewName; + QString author; QDateTime createData; bool isChangeable; qint32 size; @@ -72,3 +84,5 @@ private: + + diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index 42bda85..06ce766 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -174,7 +174,7 @@ void InstructorsAndTraineesWidget::checkLoginResult(ServerAuthorization *serverA ui->btnAuthorizationInstructor->setText(tr("Deauthorization Instructor")); updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName); - + connectorToServer->setLoginName(loginInstructorLoggedInLocal); QMessageBox::information(this, tr("Instructor authorization"), tr("Successfully!")); } else diff --git a/InstructorsAndTrainees/widgets/versionselectwidget.cpp b/InstructorsAndTrainees/widgets/versionselectwidget.cpp index 2f76f3c..60c15be 100644 --- a/InstructorsAndTrainees/widgets/versionselectwidget.cpp +++ b/InstructorsAndTrainees/widgets/versionselectwidget.cpp @@ -45,13 +45,21 @@ void VersionSelectWidget::on_verListView_itemDoubleClicked(QListWidgetItem *item if(data->getViewName() == item->text()) { QString info = "Имя версии: " + data->getViewName() + "\n"; - info.append("Создан: " + data->getCreateData().toString()); + info.append("Создан: " + data->getCreateData().toString() + "\n"); + info.append("Изменяемый: " + changableText(data->getIsChangeable()) + "\n"); + info.append("Автор: " + data->getAuthor()); ui->infoValue->setText(info); selectedVersion = data; } } } +QString VersionSelectWidget::changableText(bool flag) +{ + if(flag) return tr("Да"); + else return tr("Нет"); +} + void VersionSelectWidget::on_createDuplicateButton_clicked() { @@ -62,7 +70,7 @@ void VersionSelectWidget::on_createDuplicateButton_clicked() void VersionSelectWidget::sendCopyEmit(QString newName) { - QString result = selectedVersion->getViewName() + ";" + newName; + QString result = selectedVersion->getViewName() + ";" + newName + ";" + authorName; if (selectedVersion == nullptr) { @@ -98,7 +106,10 @@ void VersionSelectWidget::on_switchServerVersionButton_clicked() emit sigSendSwitchVersion(selectedVersion); } - +void VersionSelectWidget::setAuthor(QString name) +{ + authorName = name; +} VersionSelectWidget::~VersionSelectWidget() { diff --git a/InstructorsAndTrainees/widgets/versionselectwidget.h b/InstructorsAndTrainees/widgets/versionselectwidget.h index b2dedb7..5b6a9c8 100644 --- a/InstructorsAndTrainees/widgets/versionselectwidget.h +++ b/InstructorsAndTrainees/widgets/versionselectwidget.h @@ -24,6 +24,7 @@ public: void initialize(SendSystem *sendSystem,VersionContainer *versionContainer,NotifyController *notifyController); void fillView(QList *serverData); void sendCopyEmit(QString newName); + void setAuthor(QString name); ~VersionSelectWidget(); private slots: @@ -45,6 +46,9 @@ private: VersionContainer *versionContainer; NotifyController *notifyController; StreamingVersionData *selectedVersion; + + QString authorName; + QString changableText(bool flag); }; #endif // VERSIONSELECTWIDGET_H diff --git a/ServerLMS/Data/StreamingVersionData.h b/ServerLMS/Data/StreamingVersionData.h index 5cd2ffc..752aecc 100644 --- a/ServerLMS/Data/StreamingVersionData.h +++ b/ServerLMS/Data/StreamingVersionData.h @@ -14,7 +14,10 @@ public: this->createData = data; this->size = size; this->isChangeable = true; + this->author = ""; } + StreamingVersionData(){}; + ~StreamingVersionData(); QString getAbsolutPath() const @@ -47,12 +50,45 @@ public: isChangeable = value; } + QString getAuthor() const + { + return author; + } + + void setAuthor(const QString &value) + { + author = value; + } + + void setViewName(const QString &value) + { + viewName = value; + } + + void setCreateData(const QDateTime &value) + { + createData = value; + } + + void setAbsolutePath(const QString &value) + { + absolutePath = value; + } + private: QString absolutePath; QString viewName; + QString author; QDateTime createData; bool isChangeable; qint32 size; }; #endif // STREAMINGVERSIONDATA_H + + + + + + + diff --git a/ServerLMS/Systems/assetsmanager.cpp b/ServerLMS/Systems/assetsmanager.cpp index ee883e2..4f75ebb 100644 --- a/ServerLMS/Systems/assetsmanager.cpp +++ b/ServerLMS/Systems/assetsmanager.cpp @@ -8,10 +8,76 @@ AssetsManager::AssetsManager(QObject *parent) : QObject(parent) void AssetsManager::initialize(UpdateController* updateContoller,DataParser *dataParser) { this->updateController = updateContoller; - connect(this,&AssetsManager::sigSaveVersion,updateContoller,&UpdateController::saveVersionToFile); + //connect(this,&AssetsManager::sigSaveVersion,updateContoller,&UpdateController::saveVersionToFile); datas = new QList; } +void AssetsManager::fillDatas() +{ + QByteArray array; + QFile file(versionListFile); + + if(!file.exists()) + { + return; + } + + datas->clear(); + + file.open(QIODevice::ReadOnly); + array = file.readAll(); + file.close(); + QXmlStreamReader xmlReader(array); + + xmlReader.readNext(); + QString name = xmlReader.name().toString(); + + while(!xmlReader.atEnd()) + { + name = xmlReader.name().toString(); + + if(!xmlReader.isStartElement()) { + xmlReader.readNext(); + continue; + } + + if(xmlReader.name() == "VersionList") + { + xmlReader.readNext(); + + while (!xmlReader.atEnd()) + { + if(xmlReader.isStartElement()) + { + if(xmlReader.name() == "VersionData") + { + StreamingVersionData *data = new StreamingVersionData(); + + foreach(const QXmlStreamAttribute &attr,xmlReader.attributes()) + { + QString name = attr.name().toString(); + QString value = attr.value().toString(); + + if(name == "Version") + data->setViewName(value); + else if(name == "Created") + data->setCreateData(QDateTime::fromString(value)); + else if(name == "isChangeable") + data->setIsChangeable(value.toInt()); + else if(name == "author") + data->setAuthor(value); + + } + + datas->append(data); + } + } + + xmlReader.readNext(); + } + } + } +} void AssetsManager::setVersionList(QList *streamingVersion) { datas->clear(); @@ -41,7 +107,7 @@ QString AssetsManager::setVersion(QString versionName) if (version->getViewName() == versionName) { currentVersionData = version; - emit sigSaveVersion(currentVersionData); + saveVersionToFile(currentVersionData); return version->getAbsolutPath(); } @@ -101,11 +167,11 @@ void AssetsManager::addVersion(StreamingVersionData *data) datas->push_back(data); } -void AssetsManager::createCopyVersion(QString versionName,QString newVersionName) +void AssetsManager::createCopyVersion(QString versionName,QString newVersionName,QString author) { qDebug() << "assetManager thread ID " << QThread::currentThreadId(); QListIterator iterator(*datas); - StreamingVersionData* data; + StreamingVersionData* data = new StreamingVersionData; while (iterator.hasNext()) { @@ -113,10 +179,15 @@ void AssetsManager::createCopyVersion(QString versionName,QString newVersionName if (version->getViewName() == versionName) { - data = version; + data->setAbsolutePath(version->getAbsolutPath()); } } + data->setAuthor(author); + data->setIsChangeable(true); + data->setViewName(newVersionName); + datas->append(data); + qDebug() << "Version for copy " << versionName; qDebug() << "New version name " << newVersionName; @@ -208,6 +279,113 @@ void AssetsManager::copyAllRecurse(QString source,QString destination) } } +void AssetsManager::writeVersionsToFile(QList version,bool isFirst) +{ + QList listTag; + + QFile file(versionListFile); + + foreach(StreamingVersionData* ver,version) + { + SAttribute attribute1 = {"Version", ver->getViewName()}; + SAttribute attribute2 = {"Created", ver->getCreateData().toString()}; + SAttribute attribute3; + SAttribute attribute4; + + if(isFirst) + { + attribute3 = {"isChangeable",QString::number(false)}; + attribute4 = {"author",tr("Константа-дизайн")}; + }else + { + attribute3 ={"isChangeable",QString::number(ver->getIsChangeable())}; + attribute4 = {"author",ver->getAuthor()}; + } + + + QList listAttr = {attribute1, attribute2,attribute3,attribute4}; + SXmlAnswerTag tag = {"VersionData", listAttr}; + + listTag.append(tag); + datas->append(ver); + } + + file.open(QIODevice::WriteOnly); + + QXmlStreamWriter xmlWriter(&file); + xmlWriter.setAutoFormatting(true); + xmlWriter.writeStartDocument(); + xmlWriter.writeStartElement("VersionList"); + + foreach(SXmlAnswerTag tag,listTag) + { + xmlWriter.writeStartElement(tag.elementName); + + foreach(SAttribute attribute,tag.attr) + { + xmlWriter.writeAttribute(attribute.name,attribute.value); + } + + xmlWriter.writeEndElement(); + } + + xmlWriter.writeEndElement(); + xmlWriter.writeEndDocument(); + file.close(); +} + +void AssetsManager::createFirstVersionListXML(QList version) //TODO: переименовать и перебросить в AssetManager +{ + QFile file(versionListFile); + + if(!file.exists()) + { + writeVersionsToFile(version,true); + } + else + { + + if(datas->count() == 0) fillDatas(); + + foreach(StreamingVersionData* ver,version) + { + foreach(StreamingVersionData* data,*datas) + { + if(ver->getViewName() == data->getViewName()) + { + data->setAbsolutePath(ver->getAbsolutPath()); + break; + } + } + } + + writeVersionsToFile(*datas,false); + } + + +} + +void AssetsManager::saveVersionToFile(StreamingVersionData *streamingVersion) //TODO: переименовать и перебросить в AssetManager +{ + QFile file(version); + file.open(QFile::WriteOnly); + + QXmlStreamWriter xmlWriter(&file); + xmlWriter.setAutoFormatting(true); + xmlWriter.writeStartDocument(); + + xmlWriter.writeStartElement("VersionData"); + xmlWriter.writeAttribute("Version",streamingVersion->getViewName()); + xmlWriter.writeAttribute("Created",streamingVersion->getCreateData().toString()); + xmlWriter.writeAttribute("isChangeable",QString::number(streamingVersion->getIsChangeable())); + xmlWriter.writeAttribute("author",streamingVersion->getAuthor()); + + xmlWriter.writeEndElement(); + xmlWriter.writeEndDocument(); + + file.close(); +} + AssetsManager::~AssetsManager() { diff --git a/ServerLMS/Systems/assetsmanager.h b/ServerLMS/Systems/assetsmanager.h index 559a0f7..dec309c 100644 --- a/ServerLMS/Systems/assetsmanager.h +++ b/ServerLMS/Systems/assetsmanager.h @@ -13,10 +13,11 @@ public: explicit AssetsManager(QObject *parent = nullptr); void initialize(UpdateController* updateContoller,DataParser *dataParser); void addVersion(StreamingVersionData *data); - void createCopyVersion(QString versionName,QString newName); + void createCopyVersion(QString versionName,QString newName,QString author); void deleteVersion(QString version); void setVersionList(QList *streamingVersion); bool findDuplicate(QString name); + void createFirstVersionListXML(QList assets); QString setVersion(QString versionName); QList *prepareLocalPathList(QList*fileData); @@ -27,6 +28,9 @@ public: StreamingVersionData *getCurrentVersionData() const; + void saveVersionToFile(StreamingVersionData *streamingVersion); + void writeVersionsToFile(QList version,bool isFirst); + signals: void sigSaveVersion(StreamingVersionData *versionData); @@ -36,6 +40,7 @@ private: StreamingVersionData* currentVersionData; void copyAllRecurse(QString source, QString destination); + void fillDatas(); }; #endif // ASSETSMANAGER_H diff --git a/ServerLMS/Systems/recognizesystem.cpp b/ServerLMS/Systems/recognizesystem.cpp index be2e1d9..65e28ef 100644 --- a/ServerLMS/Systems/recognizesystem.cpp +++ b/ServerLMS/Systems/recognizesystem.cpp @@ -366,7 +366,7 @@ void RecognizeSystem::recognize() break; } - emit sigCopyVersion(result[0],result[1]); + emit sigCopyVersion(result[0],result[1],result[2]); sendSystem->sendPacketType(PacketType::BUSY); } diff --git a/ServerLMS/Systems/recognizesystem.h b/ServerLMS/Systems/recognizesystem.h index 29a2b24..a28a893 100644 --- a/ServerLMS/Systems/recognizesystem.h +++ b/ServerLMS/Systems/recognizesystem.h @@ -36,7 +36,7 @@ signals: void sigXmlParser(ClientHandler *clientHandler,QByteArray data); void sigChangeVersion(QString versionName); void sigDeleteVersion(QString versionName); - void sigCopyVersion(QString versionName,QString newVersionName); + void sigCopyVersion(QString versionName,QString newVersionName,QString author); private: UpdateController *updateController; diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 8225da9..faacac7 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -41,10 +41,10 @@ void UpdateController::changeAssetVersion(QString versionName) commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE); } -void UpdateController::createCopyVersion(QString versionName,QString newVersionName) +void UpdateController::createCopyVersion(QString versionName,QString newVersionName,QString author) { commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY); - assetManager->createCopyVersion(versionName,newVersionName); + assetManager->createCopyVersion(versionName,newVersionName,author); commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE); } @@ -444,83 +444,22 @@ void UpdateController::calculateSharedHash() fileInfo.absoluteFilePath(),fileInfo.fileName(), fileInfo.birthTime(),fileInfo.size()); - if(fileInfo.fileName() == baseNameVersion) - { - version->setIsChangeable(false); - } - else - { - version->setIsChangeable(true); - } +// if(fileInfo.fileName() == baseNameVersion) +// { +// version->setIsChangeable(false); +// version->setAuthor(tr("Константа-дизайн")); +// } +// else +// { +// version->setIsChangeable(true); +// } versionList->append(version); } - createVersionListXmlAnswer(*versionList); - assetManager->setVersionList(versionList); -} - -void UpdateController::createVersionListXmlAnswer(QList version) //TODO: переименовать и перебросить в AssetManager -{ - QList listTag; - - foreach(StreamingVersionData* ver,version) - { - SAttribute attribute1 = {"Version", ver->getViewName()}; - SAttribute attribute2 = {"Created", ver->getCreateData().toString()}; - SAttribute attribute3 = {"isChangeable",QString::number(ver->getIsChangeable())}; - - QList listAttr = {attribute1, attribute2,attribute3}; - SXmlAnswerTag tag = {"VersionData", listAttr}; - - listTag.append(tag); - } - - - QFile file(versionListFile); - file.open(QIODevice::WriteOnly); - - QXmlStreamWriter xmlWriter(&file); - xmlWriter.setAutoFormatting(true); - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("VersionList"); - - foreach(SXmlAnswerTag tag,listTag) - { - xmlWriter.writeStartElement(tag.elementName); - - foreach(SAttribute attribute,tag.attr) - { - xmlWriter.writeAttribute(attribute.name,attribute.value); - } - - xmlWriter.writeEndElement(); - } - - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - file.close(); -} - -void UpdateController::saveVersionToFile(StreamingVersionData *streamingVersion) //TODO: переименовать и перебросить в AssetManager -{ - QFile file(version); - file.open(QFile::WriteOnly); - - QXmlStreamWriter xmlWriter(&file); - xmlWriter.setAutoFormatting(true); - xmlWriter.writeStartDocument(); - - xmlWriter.writeStartElement("VersionData"); - xmlWriter.writeAttribute("Version",streamingVersion->getViewName()); - xmlWriter.writeAttribute("Created",streamingVersion->getCreateData().toString()); - xmlWriter.writeAttribute("isChangeable",QString::number(streamingVersion->getIsChangeable())); - - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - - file.close(); + assetManager->createFirstVersionListXML(*versionList); + //assetManager->setVersionList(versionList); } void UpdateController::sendNewVersionList() diff --git a/ServerLMS/Systems/updatecontroller.h b/ServerLMS/Systems/updatecontroller.h index 8178144..919190a 100644 --- a/ServerLMS/Systems/updatecontroller.h +++ b/ServerLMS/Systems/updatecontroller.h @@ -51,8 +51,6 @@ public: DataInfo *getCurrentDataInfo(); void clearCurrentDataInfo(); - void createVersionListXmlAnswer(QList version); - void saveVersionToFile(StreamingVersionData *streamingVersion); void xmlFileDataParse(QByteArray array); QByteArray getAdditionalFile(QString name); @@ -60,7 +58,7 @@ public: public slots: void changeAssetVersion(QString versionName); - void createCopyVersion(QString versionName,QString newVersionName); + void createCopyVersion(QString versionName,QString newVersionName,QString author); void deleteAssetVersion(QString versionName); void setUpCurrentServerHash(); diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index 9502213..e3539ef 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -246,7 +246,6 @@ void ServerLMSWidget::on_btnStartServer_clicked() if(startServer()) { QApplication::setOverrideCursor(Qt::WaitCursor); - emit sigCalculateFullHash(); QApplication::restoreOverrideCursor(); ui->btnStartServer->setEnabled(false);