mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
271 lines
8.5 KiB
C++
271 lines
8.5 KiB
C++
#include <QString>
|
|
#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<PM*>(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<PM*>(moduleParent);
|
|
PMmodulParent->addChildModule(module);
|
|
}
|
|
}
|
|
else if(name == "dm")
|
|
{
|
|
module = new DM();
|
|
DM* DMmodul = static_cast<DM*>(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<PM*>(moduleParent);
|
|
PMmodulParent->addChildModule(module);
|
|
}
|
|
}
|
|
else if(name == "rus" || name == "eng")
|
|
{
|
|
if(moduleParent)
|
|
{
|
|
if(moduleParent->getType() == ModuleType::TYPE_PM)
|
|
{//PM
|
|
PM* PMmodulParent = static_cast<PM*>(moduleParent);
|
|
|
|
if(name == "rus")
|
|
PMmodulParent->setLangStructRus(nodeMap.namedItem("title").nodeValue());
|
|
else
|
|
PMmodulParent->setLangStructEng(nodeMap.namedItem("title").nodeValue());
|
|
}
|
|
else
|
|
{//DM
|
|
DM* DMmodulParent = static_cast<DM*>(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<DM*>(module)->getLangStructRus().techName;
|
|
task->ammProcedure.dmCode = static_cast<DM*>(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<PM*>(module);
|
|
else
|
|
delete static_cast<DM*>(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;
|
|
}
|