diff --git a/DOCS/Андрей/Board.md b/DOCS/Андрей/Board.md index e90059f..faa2f73 100644 --- a/DOCS/Андрей/Board.md +++ b/DOCS/Андрей/Board.md @@ -56,6 +56,7 @@ kanban-plugin: board (Так как сейчас может вызвать проблемы при смене логина юзера!!!) - [ ] Зарефакторить databaselms_PostgreSQL.cpp (возможно, нужно использовать транзакции при восстановлении БД!) +- [ ] При долгой работе загибается главное окно (предположительно из-за лога) ## GUI Messenger diff --git a/InstructorsAndTrainees/tasks/module.cpp b/InstructorsAndTrainees/tasks/module.cpp index 6a7e716..1883121 100644 --- a/InstructorsAndTrainees/tasks/module.cpp +++ b/InstructorsAndTrainees/tasks/module.cpp @@ -52,7 +52,13 @@ bool Module::getIsActive() return this->isActive; } +void Module::setModeList(ModeList modeList) +{ + this->modeList = modeList; + if(modeList.demo || modeList.train || modeList.exam || modeList.autoM) + setIsActiveTrue(); +} PM::PM(): modelIdentCode (), diff --git a/InstructorsAndTrainees/tasks/module.h b/InstructorsAndTrainees/tasks/module.h index 009a328..77455e1 100644 --- a/InstructorsAndTrainees/tasks/module.h +++ b/InstructorsAndTrainees/tasks/module.h @@ -2,6 +2,7 @@ #define MODULE_H #include #include +#include "instructorsAndTrainees_global.h" enum ModuleType { @@ -9,7 +10,15 @@ enum ModuleType TYPE_DM = 1 }; -class Module +struct ModeList +{ + bool demo = false; + bool train = false; + bool exam = false; + bool autoM = false; +}; + +class INSTRUCTORSANDTRAINEES_EXPORT Module { public: Module(); @@ -20,19 +29,26 @@ public: void setParentModule(Module* parentModule){ this->parentModule = parentModule; }; Module* getModuleByID(int id); - void setIsActiveTrue(); bool getIsActive(); + void setModeList(ModeList modeList);; + ModeList getModeList(){return modeList;}; + +protected: + void setIsActiveTrue(); + protected: ModuleType type; Module* parentModule; int ID; static int lastID; bool isActive; + + ModeList modeList; }; -class PM : public Module +class INSTRUCTORSANDTRAINEES_EXPORT PM : public Module { public: struct pmLangStruct @@ -66,7 +82,7 @@ private: }; -class DM : public Module +class INSTRUCTORSANDTRAINEES_EXPORT DM : public Module { public: struct dmLangStruct diff --git a/InstructorsAndTrainees/tasks/tasktreepreparation.cpp b/InstructorsAndTrainees/tasks/tasktreepreparation.cpp index 15e9d58..cbeeb33 100644 --- a/InstructorsAndTrainees/tasks/tasktreepreparation.cpp +++ b/InstructorsAndTrainees/tasks/tasktreepreparation.cpp @@ -356,8 +356,9 @@ void TaskAMMFIMTreePreparation::domElementParserAMM(QDomElement element, Module* //Активность QString canplay = nodeMap.namedItem("canplay").nodeValue(); - if(canplay.contains("+")) - DMmodulParent->setIsActiveTrue(); + DMmodulParent->setModeList(parseCanplay(canplay)); + //if(canplay.contains("+")) + //DMmodulParent->setIsActiveTrue(); } else DMmodulParent->setLangStructEng(nodeMap.namedItem("techName").nodeValue(), @@ -391,6 +392,45 @@ void TaskAMMFIMTreePreparation::domElementParserAMM(QDomElement element, Module* }while (! (childElement = childElement.nextSiblingElement()).isNull()); } +ModeList TaskAMMFIMTreePreparation::parseCanplay(QString canplay) +{ + ModeList modeList; + + if(canplay == "") + { + modeList.demo = false; + modeList.train = false; + modeList.exam = false; + modeList.autoM = false; + } + else + { + QStringList list = canplay.split("/"); + + if(list.at(0) == "+") + modeList.demo = true; + else + modeList.demo = false; + + if(list.at(1) == "+") + modeList.train = true; + else + modeList.train = false; + + if(list.at(2) == "+") + modeList.exam = true; + else + modeList.exam = false; + + if(list.at(3) == "+") + modeList.autoM = true; + else + modeList.autoM = false; + } + + return modeList; +} + void TaskAMMFIMTreePreparation::slot_prepareAMMListItems(QByteArray array, bool flOnlyActive, bool flRequestFirst) { qDebug() << "TaskAMMFIMTreePreparation::slot_prepareAMMListItems thread ID " << QThread::currentThreadId(); diff --git a/InstructorsAndTrainees/tasks/tasktreepreparation.h b/InstructorsAndTrainees/tasks/tasktreepreparation.h index d618dbc..13a7ef5 100644 --- a/InstructorsAndTrainees/tasks/tasktreepreparation.h +++ b/InstructorsAndTrainees/tasks/tasktreepreparation.h @@ -50,6 +50,7 @@ private: void loadAMMtasksFromXML(QByteArray array); void domElementParserAMM(QDomElement element, Module* moduleParent); void deleteAllModulsAMM(); + ModeList parseCanplay(QString canplay); void loadFIMtasksFromXML(QByteArray array); diff --git a/ServerLMS/CMakeLists.txt b/ServerLMS/CMakeLists.txt index d27b788..8dc66ea 100644 --- a/ServerLMS/CMakeLists.txt +++ b/ServerLMS/CMakeLists.txt @@ -52,6 +52,8 @@ add_library(ServerLMS SHARED Systems/chatsystem.h Systems/fasthashcalculator.cpp Systems/fasthashcalculator.h + Systems/docsupdater.cpp + Systems/docsupdater.h providerdblms/providerdblms.cpp providerdblms/providerdblms.h ServerLMS.qrc @@ -78,6 +80,7 @@ target_link_libraries(ServerLMS PRIVATE libDataBaseLMS.dll) target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees) target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/authorization) +target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/tasks) if(PROJECT_TYPE_DEBUG) target_link_directories(ServerLMS PUBLIC ${REPO_PATH}/BUILDS/Debug64/InstructorsAndTrainees) else() diff --git a/ServerLMS/Systems/Parsers/dataparser.cpp b/ServerLMS/Systems/Parsers/dataparser.cpp index b65eec1..1a8d63f 100644 --- a/ServerLMS/Systems/Parsers/dataparser.cpp +++ b/ServerLMS/Systems/Parsers/dataparser.cpp @@ -87,7 +87,7 @@ QByteArray DataParser::xmlAnswer(QList listTag, QString elemUp1, } -bool DataParser::loadBlankXML(QString nameFile, QDomDocument *commonDOM) +bool DataParser::loadXMLtoDOM(QString nameFile, QDomDocument *commonDOM) { QFile blankFile(nameFile); diff --git a/ServerLMS/Systems/Parsers/dataparser.h b/ServerLMS/Systems/Parsers/dataparser.h index f933dd8..c4b2da8 100644 --- a/ServerLMS/Systems/Parsers/dataparser.h +++ b/ServerLMS/Systems/Parsers/dataparser.h @@ -36,8 +36,8 @@ public: QByteArray xmlAnswer(QList listTag,QString elemUp1 = "", QString elemUp2 = ""); - bool loadBlankXML(QString nameFile, QDomDocument* commonDOM); - bool saveDOMtoXML(QString nameFile, QDomDocument* commonDOM); + static bool loadXMLtoDOM(QString nameFile, QDomDocument* commonDOM); + static bool saveDOMtoXML(QString nameFile, QDomDocument* commonDOM); ~DataParser(); ClientAnswerParser *ClientAnswer() const; diff --git a/ServerLMS/Systems/Parsers/dbanswerparser.cpp b/ServerLMS/Systems/Parsers/dbanswerparser.cpp index 0e2a3be..e835bd3 100644 --- a/ServerLMS/Systems/Parsers/dbanswerparser.cpp +++ b/ServerLMS/Systems/Parsers/dbanswerparser.cpp @@ -15,7 +15,7 @@ void DBAnswerParser::initialize(DataParser *dataParser) QByteArray DBAnswerParser::listInstructors(bool result, QList *listInstructors) { QDomDocument commonDOM; - if(! dataParser->loadBlankXML(":/resources/blankXML/ListInstructors.xml", &commonDOM)) + if(! dataParser->loadXMLtoDOM(":/resources/blankXML/ListInstructors.xml", &commonDOM)) return QByteArray(); QDomNode listNode = commonDOM.namedItem("ListInstructors"); @@ -42,7 +42,7 @@ QByteArray DBAnswerParser::listInstructors(bool result, QList *listI QByteArray DBAnswerParser::listGroups(bool result, QList *listGroups) { QDomDocument commonDOM; - if(! dataParser->loadBlankXML(":/resources/blankXML/ListGroups.xml", &commonDOM)) + if(! dataParser->loadXMLtoDOM(":/resources/blankXML/ListGroups.xml", &commonDOM)) return QByteArray(); QDomNode listNode = commonDOM.namedItem("ListGroups"); @@ -64,7 +64,7 @@ QByteArray DBAnswerParser::listGroups(bool result, QList *listGroups) QByteArray DBAnswerParser::listTrainees(bool result, QList *listTrainees) { QDomDocument commonDOM; - if(! dataParser->loadBlankXML(":/resources/blankXML/ListTrainees.xml", &commonDOM)) + if(! dataParser->loadXMLtoDOM(":/resources/blankXML/ListTrainees.xml", &commonDOM)) return QByteArray(); QDomNode listNode = commonDOM.namedItem("ListTrainees"); @@ -142,7 +142,7 @@ QByteArray DBAnswerParser::listContacts(bool result, QList *listCo QByteArray DBAnswerParser::listTasksAMMofTrainee(bool result, QList *listTasks, int trainee_id, bool full_list) { QDomDocument commonDOM; - if(! dataParser->loadBlankXML(":/resources/blankXML/ListTasksAMM.xml", &commonDOM)) + if(! dataParser->loadXMLtoDOM(":/resources/blankXML/ListTasksAMM.xml", &commonDOM)) return QByteArray(); QDomNode listNode = commonDOM.namedItem("ListTasksAMM"); @@ -171,7 +171,7 @@ QByteArray DBAnswerParser::listTasksAMMofTrainee(bool result, QList QByteArray DBAnswerParser::listTasksFIMofTrainee(bool result, QList *listTasks, int trainee_id, bool full_list) { QDomDocument commonDOM; - if(! dataParser->loadBlankXML(":/resources/blankXML/ListTasksFIM.xml", &commonDOM)) + if(! dataParser->loadXMLtoDOM(":/resources/blankXML/ListTasksFIM.xml", &commonDOM)) return QByteArray(); QDomNode listNode = commonDOM.namedItem("ListTasksFIM"); diff --git a/ServerLMS/Systems/docsupdater.cpp b/ServerLMS/Systems/docsupdater.cpp new file mode 100644 index 0000000..ba23e0a --- /dev/null +++ b/ServerLMS/Systems/docsupdater.cpp @@ -0,0 +1,270 @@ +#include +#include "docsupdater.h" +#include "tools.h" + + +DocsUpdater::DocsUpdater(UpdateController* updateController): + updateController(updateController), + flagStop(false) +{ + +} + +bool DocsUpdater::update() +{ + QString nameDocsFile = tasksAMMfileName; + QString pathDocsFile = updateController->getPathAdditionalFile(nameDocsFile); + + QDomDocument docTasksDOM; + if(! DataParser::loadXMLtoDOM(pathDocsFile, &docTasksDOM)) + return false; + + QDomElement manifestElement = docTasksDOM.firstChildElement("manifest"); + if(manifestElement.isNull()) + return false; + + deleteAllModulsAMM(); + listTasksAMM.clear(); + + domElementParserAMM(manifestElement, nullptr); + + if(! DataParser::saveDOMtoXML(pathDocsFile, &docTasksDOM)) + return false; + + return true; +} + +void DocsUpdater::domElementParserAMM(QDomElement element, Module* moduleParent) +{ + QString name; + + if(flagStop) + return; + + QDomElement childElement = element.firstChildElement(); + if(childElement.isNull()) + return; + + Module* module = nullptr; + + do + { + name = childElement.nodeName(); + + QDomNamedNodeMap nodeMap = childElement.attributes(); + + if(name == "doc") + { + module = new PM(); + } + else if(name == "pm") + { + module = new PM(); + PM* PMmodul = static_cast(module); + + PMmodul->initialize(nodeMap.namedItem("modelIdentCode").nodeValue(), + nodeMap.namedItem("pmIssuer").nodeValue(), + nodeMap.namedItem("pmNumber").nodeValue(), + nodeMap.namedItem("pmVolume").nodeValue()); + + if(moduleParent) + { + PMmodul->setParentModule(moduleParent); + + PM* PMmodulParent = static_cast(moduleParent); + PMmodulParent->addChildModule(module); + } + } + else if(name == "dm") + { + module = new DM(); + DM* DMmodul = static_cast(module); + + DMmodul->initialize(nodeMap.namedItem("modelIdentCode").nodeValue(), + nodeMap.namedItem("systemDiffCode").nodeValue(), + nodeMap.namedItem("systemCode").nodeValue(), + nodeMap.namedItem("subSystemCode").nodeValue(), + nodeMap.namedItem("subSubSystemCode").nodeValue(), + nodeMap.namedItem("assyCode").nodeValue(), + nodeMap.namedItem("disassyCode").nodeValue(), + nodeMap.namedItem("disassyCodeVariant").nodeValue(), + nodeMap.namedItem("infoCode").nodeValue(), + nodeMap.namedItem("infoCodeVariant").nodeValue(), + nodeMap.namedItem("itemLocationCode").nodeValue()); + + if(moduleParent) + { + DMmodul->setParentModule(moduleParent); + + PM* PMmodulParent = static_cast(moduleParent); + PMmodulParent->addChildModule(module); + } + } + else if(name == "rus" || name == "eng") + { + if(moduleParent) + { + if(moduleParent->getType() == ModuleType::TYPE_PM) + {//PM + PM* PMmodulParent = static_cast(moduleParent); + + if(name == "rus") + PMmodulParent->setLangStructRus(nodeMap.namedItem("title").nodeValue()); + else + PMmodulParent->setLangStructEng(nodeMap.namedItem("title").nodeValue()); + } + else + {//DM + DM* DMmodulParent = static_cast(moduleParent); + + if(name == "rus") + { + DMmodulParent->setLangStructRus(nodeMap.namedItem("techName").nodeValue(), + nodeMap.namedItem("infoName").nodeValue(), + nodeMap.namedItem("pdf").nodeValue(), + nodeMap.namedItem("bookmark").nodeValue(), + nodeMap.namedItem("xml").nodeValue()); + + //Активность + //QString canplay = nodeMap.namedItem("canplay").nodeValue(); + + //Обновление Активности + QString dmCode = DMmodulParent->dmCode(); + QString canplay = defineCanplayByScenXML(dmCode); + DMmodulParent->setModeList(parseCanplay(canplay)); + nodeMap.namedItem("canplay").setNodeValue(canplay); + } + else + DMmodulParent->setLangStructEng(nodeMap.namedItem("techName").nodeValue(), + nodeMap.namedItem("infoName").nodeValue(), + nodeMap.namedItem("pdf").nodeValue(), + nodeMap.namedItem("bookmark").nodeValue(), + nodeMap.namedItem("xml").nodeValue()); + } + } + + } + + domElementParserAMM(childElement, module); + + if(moduleParent == nullptr) + listAllModulesAMM.append(module); + + if(module) + if(module->getType() == ModuleType::TYPE_DM) + { + TaskAmmFim* task = nullptr; + task = new TaskAmmFim(); + task->setID(module->getID()); + task->ammProcedure.title = static_cast(module)->getLangStructRus().techName; + task->ammProcedure.dmCode = static_cast(module)->dmCode(); + + listTasksAMM.append(*task); + delete task; + } + + }while (! (childElement = childElement.nextSiblingElement()).isNull()); +} + +void DocsUpdater::deleteAllModulsAMM() +{ + for(Module* module: listAllModulesAMM) + { + if(module->getType() == ModuleType::TYPE_PM) + delete static_cast(module); + else + delete static_cast(module); + } + listAllModulesAMM.clear(); +} + +ModeList DocsUpdater::parseCanplay(QString canplay) +{ + ModeList modeList; + + if(canplay == "") + { + modeList.demo = false; + modeList.train = false; + modeList.exam = false; + modeList.autoM = false; + } + else + { + QStringList list = canplay.split("/"); + + if(list.at(0) == "+") + modeList.demo = true; + else + modeList.demo = false; + + if(list.at(1) == "+") + modeList.train = true; + else + modeList.train = false; + + if(list.at(2) == "+") + modeList.exam = true; + else + modeList.exam = false; + + if(list.at(3) == "+") + modeList.autoM = true; + else + modeList.autoM = false; + } + + return modeList; +} + +QString DocsUpdater::defineCanplayByScenXML(QString dmCode) +{ + QString canplay = ""; + QString signDemo = "-"; + QString signTrain = "-"; + QString signExam = "-"; + QString signAuto = "-"; + + QString nameScenXMLFile = dmCode + ".xml"; + QString pathScenXMLFile = updateController->getPathScensFile(nameScenXMLFile); + + QDomDocument docScenDOM; + if(! DataParser::loadXMLtoDOM(pathScenXMLFile, &docScenDOM)) + return canplay; + + QDomElement scenarioElement = docScenDOM.firstChildElement("scenario"); + if(scenarioElement.isNull()) + return canplay; + + QDomElement demoElement = scenarioElement.firstChildElement("demo"); + if(!demoElement.isNull()) + { + if(demoElement.toElement().attribute("canplay") == "True") + signDemo = "+"; + } + + QDomElement trainElement = scenarioElement.firstChildElement("train"); + if(!trainElement.isNull()) + { + if(trainElement.toElement().attribute("canplay") == "True") + signTrain = "+"; + } + + QDomElement examElement = scenarioElement.firstChildElement("exam"); + if(!examElement.isNull()) + { + if(examElement.toElement().attribute("canplay") == "True") + signExam = "+"; + } + + QDomElement autoElement = scenarioElement.firstChildElement("auto"); + if(!autoElement.isNull()) + { + if(autoElement.toElement().attribute("canplay") == "True") + signAuto = "+"; + } + + canplay = QString("%1/%2/%3/%4").arg(signDemo, signTrain, signExam, signAuto); + + return canplay; +} diff --git a/ServerLMS/Systems/docsupdater.h b/ServerLMS/Systems/docsupdater.h new file mode 100644 index 0000000..9e24598 --- /dev/null +++ b/ServerLMS/Systems/docsupdater.h @@ -0,0 +1,28 @@ +#ifndef DOCSUPDATER_H +#define DOCSUPDATER_H + +#include "updatecontroller.h" +#include "module.h" + + +class DocsUpdater +{ +public: + DocsUpdater(UpdateController* updateController); + + bool update(); + +private: + void domElementParserAMM(QDomElement element, Module* moduleParent); + void deleteAllModulsAMM(); + ModeList parseCanplay(QString canplay); + QString defineCanplayByScenXML(QString dmCode); + +private: + UpdateController* updateController; + bool flagStop; + QList listAllModulesAMM; //? + QList listTasksAMM; //? +}; + +#endif // DOCSUPDATER_H diff --git a/ServerLMS/Systems/tools.h b/ServerLMS/Systems/tools.h index b243a54..90769ef 100644 --- a/ServerLMS/Systems/tools.h +++ b/ServerLMS/Systems/tools.h @@ -17,6 +17,7 @@ static const QString applicationFolderName = "Application"; static const QString sharedDataFolderName = "SharedData"; static const QString projectFolderName = "RRJLoader"; static const QString additionalFilesFolderName = "RRJ-95NEW-100"; +static const QString rusScensFolderName = "RUS/Scens"; static const QString streamingAssetsFolderName = "StreamingAssets"; static const QString versionFolderName = "StreamingVersion"; static const QString tempFile = staticDataFolderName + "/save.xml"; diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 461c4ef..441e917 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -406,6 +406,12 @@ QString UpdateController::getPathAdditionalFile(QString name) return path; } +QString UpdateController::getPathScensFile(QString name) +{ + QString path = Tools::createSharedPath("/" + assetManager->getCurrentVersionData()->getViewName() + "/" + rusScensFolderName + name); + return path; +} + QByteArray UpdateController::getLocalHash() { QFile hashFile(hashFileName); diff --git a/ServerLMS/Systems/updatecontroller.h b/ServerLMS/Systems/updatecontroller.h index de6f087..7dc708e 100644 --- a/ServerLMS/Systems/updatecontroller.h +++ b/ServerLMS/Systems/updatecontroller.h @@ -55,6 +55,7 @@ public: void xmlFileDataParse(QByteArray array); QString getPathAdditionalFile(QString name); + QString getPathScensFile(QString name); StreamingVersionData *getCurrentVersion(); void setDataInfo(DataInfo *value);