mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Сделал выдачу tasksFIM.xml из сервера по запросу GUI-клиента
This commit is contained in:
@@ -179,6 +179,25 @@ void DataParser::createQueryToDBMessage(ClientQueryToDB *queryToDB, int id, void
|
||||
file.close();
|
||||
}
|
||||
|
||||
void DataParser::createQueryTasksXMLMessage(QString type)
|
||||
{
|
||||
QFile file(tempName);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
QXmlStreamWriter xmlWriter(&file);
|
||||
|
||||
xmlWriter.setAutoFormatting(true);
|
||||
xmlWriter.writeStartDocument();
|
||||
xmlWriter.writeStartElement("QueryTasksXML");
|
||||
|
||||
xmlWriter.writeAttribute("Type", type);
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndDocument();
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
void DataParser::createDeAuthMessage(ClientDeAutorization *deAuth)
|
||||
{
|
||||
QFile file(tempName);
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
void createAuthMessage(ClientAutorization *auth);
|
||||
void createToClientMessage(ToClientMessage *toClientMessage);
|
||||
void createQueryToDBMessage(ClientQueryToDB *queryToDB, int id = 0, void* data = nullptr);
|
||||
void createQueryTasksXMLMessage(QString type);
|
||||
void createDeAuthMessage(ClientDeAutorization *deAuth);
|
||||
void createAuthData(ServerAuthorization *serverAuth);
|
||||
void createAuthDataOffline(QString username,QString pass);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <QDir>
|
||||
#include <QDomDocument>
|
||||
#include "instructor.h"
|
||||
#include "tasksAmmFim.h"
|
||||
#include "fimtaskswidget.h"
|
||||
|
||||
|
||||
RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||
@@ -276,6 +278,22 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
break;
|
||||
};
|
||||
|
||||
//xml-ответы на запросы AdditionalFiles
|
||||
if(packetType == PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_FIM ||
|
||||
packetType == PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_AMM)
|
||||
{
|
||||
QByteArray array;
|
||||
stream.startTransaction();
|
||||
stream >> array;
|
||||
|
||||
if(!stream.commitTransaction())
|
||||
continue;
|
||||
|
||||
xmlParserQueryTasksXML(packetType, array);
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
}
|
||||
@@ -547,6 +565,19 @@ void RecognizeSystem::xmlParserQueryToDB(PacketType packetType, QByteArray array
|
||||
};
|
||||
}
|
||||
|
||||
void RecognizeSystem::xmlParserQueryTasksXML(PacketType packetType, QByteArray array)
|
||||
{
|
||||
QList<TaskAmmFim> listTaskAmmFim;
|
||||
|
||||
//парсинг XML
|
||||
listTaskAmmFim = FIMtasksWidget::loadTasksAmmFimFromXML(array);
|
||||
|
||||
if(packetType == TYPE_XMLANSWER_QUERY_TASKS_XML_FIM)
|
||||
emit sigAnswerQueryTasksXML_FIM(listTaskAmmFim);
|
||||
else if(packetType == TYPE_XMLANSWER_QUERY_TASKS_XML_AMM)
|
||||
emit sigAnswerQueryTasksXML_AMM(listTaskAmmFim);
|
||||
}
|
||||
|
||||
void RecognizeSystem::checkAccessType(QString type)
|
||||
{
|
||||
if(type == "instructor")
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "trainee.h"
|
||||
#include "group.h"
|
||||
#include "Datas.h"
|
||||
#include "tasksAmmFim.h"
|
||||
|
||||
|
||||
class RecognizeSystem : public QObject
|
||||
@@ -48,6 +49,9 @@ signals:
|
||||
void sigAnswerQueryToDB_ListClassrooms(QList<Classroom> listClassrooms);
|
||||
void sigAnswerQueryToDB_ListTasks(QList<Task> listTasks);
|
||||
|
||||
void sigAnswerQueryTasksXML_FIM(QList<TaskAmmFim> listTaskFim);
|
||||
void sigAnswerQueryTasksXML_AMM(QList<TaskAmmFim> listTaskAmm);
|
||||
|
||||
private:
|
||||
QList<QString> *folderList;
|
||||
//MainWindow *mainWindow;
|
||||
@@ -63,6 +67,7 @@ private:
|
||||
|
||||
void xmlParser(QByteArray array);
|
||||
void xmlParserQueryToDB(PacketType packetType, QByteArray array);
|
||||
void xmlParserQueryTasksXML(PacketType packetType, QByteArray array);
|
||||
|
||||
void checkAccessType(QString type);
|
||||
};
|
||||
|
||||
@@ -40,7 +40,11 @@ enum PacketType{
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_TRAINEES = 102,
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_COMPUTERS = 103,
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_CLASSROOMS = 104,
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_TASKS = 105
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_TASKS = 105,
|
||||
|
||||
//xml-ответы на запросы AdditionalFiles
|
||||
TYPE_XMLANSWER_QUERY_TASKS_XML_FIM = 130,
|
||||
TYPE_XMLANSWER_QUERY_TASKS_XML_AMM = 131
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(PacketType)
|
||||
|
||||
@@ -80,11 +80,34 @@ bool ConnectorToServer::sendMessageForClient(int id, QString login, QString text
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::sendQueryTasksXML(QString type)
|
||||
{
|
||||
if (!client->getIsConnected())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dataParser->createQueryTasksXMLMessage(type);
|
||||
emit signal_sendXMLmsgGUItoServer();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConnectorToServer::SetConnectToServer()
|
||||
{
|
||||
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
|
||||
}
|
||||
|
||||
QList<TaskAmmFim> ConnectorToServer::getListTaskFim()
|
||||
{
|
||||
return listTaskFim;
|
||||
}
|
||||
|
||||
QList<TaskAmmFim> ConnectorToServer::getListTaskAmm()
|
||||
{
|
||||
return listTaskAmm;
|
||||
}
|
||||
|
||||
QList<Instructor> ConnectorToServer::getListInstructors()
|
||||
{
|
||||
return listInstructors;
|
||||
@@ -274,6 +297,18 @@ void ConnectorToServer::slot_AnswerQueryToDB_ListTasks(QList<Task> listTasks)
|
||||
//emit signal_UpdateDB(false, true);
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryTasksXML_FIM(QList<TaskAmmFim> listTaskFim)
|
||||
{
|
||||
this->listTaskFim = listTaskFim;
|
||||
emit signal_UpdateTasksFIM();
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryTasksXML_AMM(QList<TaskAmmFim> listTaskAmm)
|
||||
{
|
||||
this->listTaskAmm = listTaskAmm;
|
||||
emit signal_UpdateTasksAMM();
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_msgToClientReady(QString login, QString text)
|
||||
{
|
||||
int id = getIdTraineeByLogin(login);
|
||||
@@ -310,6 +345,9 @@ void ConnectorToServer::bindConnection()
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListClassrooms,this,&ConnectorToServer::slot_AnswerQueryToDB_ListClassrooms);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListTasks,this,&ConnectorToServer::slot_AnswerQueryToDB_ListTasks);
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryTasksXML_FIM,this,&ConnectorToServer::slot_AnswerQueryTasksXML_FIM);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryTasksXML_AMM,this,&ConnectorToServer::slot_AnswerQueryTasksXML_AMM);
|
||||
|
||||
connect(client,&TCPClient::signal_ConnectedToServer,this,&ConnectorToServer::signal_ConnectedToServer);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,14 @@ public:
|
||||
bool sendQueryToDB(TypeQueryToDB typeQuery, int id = 0, void* data = nullptr);
|
||||
bool sendMessageForClient(int id, QString login, QString text);
|
||||
|
||||
bool sendQueryTasksXML(QString type);
|
||||
|
||||
void SetConnectToServer();
|
||||
|
||||
public:
|
||||
QList<TaskAmmFim> getListTaskFim();
|
||||
QList<TaskAmmFim> getListTaskAmm();
|
||||
|
||||
public:
|
||||
//Запросы к БД (локальной)
|
||||
QList<Instructor> getListInstructors();
|
||||
@@ -61,6 +67,9 @@ public slots:
|
||||
void slot_AnswerQueryToDB_ListClassrooms(QList<Classroom> listClassrooms);
|
||||
void slot_AnswerQueryToDB_ListTasks(QList<Task> listTasks);
|
||||
|
||||
void slot_AnswerQueryTasksXML_FIM(QList<TaskAmmFim> listTaskFim);
|
||||
void slot_AnswerQueryTasksXML_AMM(QList<TaskAmmFim> listTaskAmm);
|
||||
|
||||
void slot_msgToClientReady(QString login, QString text);
|
||||
|
||||
signals:
|
||||
@@ -76,6 +85,9 @@ signals:
|
||||
|
||||
void signal_UpdateDB(bool treeInstructor, bool treeTrainee);
|
||||
|
||||
void signal_UpdateTasksFIM();
|
||||
void signal_UpdateTasksAMM();
|
||||
|
||||
void signal_ConnectedToServer(bool state);
|
||||
|
||||
void signal_InitMessanger(QList<Trainee> listTrainees);
|
||||
@@ -102,6 +114,9 @@ private:
|
||||
QList<Computer> listComputers;
|
||||
QList<Classroom> listClassrooms;
|
||||
QList<Task> listTasks;
|
||||
|
||||
QList<TaskAmmFim> listTaskFim;
|
||||
QList<TaskAmmFim> listTaskAmm;
|
||||
};
|
||||
|
||||
#endif // CONNECTORTOSERVER_H
|
||||
|
||||
@@ -62,6 +62,19 @@ void DocTasksWidget::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
}
|
||||
}
|
||||
|
||||
void DocTasksWidget::slot_NeedUpdateUI()
|
||||
{
|
||||
loadTasksAMM();
|
||||
}
|
||||
|
||||
void DocTasksWidget::loadTasksAMM()
|
||||
{
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
//TODO собственно обновление дерева
|
||||
}
|
||||
|
||||
void DocTasksWidget::domElementParser(QDomElement element, Module* moduleParent)
|
||||
{
|
||||
QString name;
|
||||
|
||||
@@ -27,6 +27,10 @@ public:
|
||||
private Q_SLOTS:
|
||||
void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
||||
public Q_SLOTS:
|
||||
//Слот обработки сигнала необходимости обновления интерфейса
|
||||
void slot_NeedUpdateUI();
|
||||
|
||||
private:
|
||||
void domElementParser(QDomElement element, Module* moduleParent);
|
||||
void loadDocTasksFromXML();
|
||||
@@ -38,11 +42,14 @@ private:
|
||||
void updateTreeWidget();
|
||||
void addModuleToTreeWidget(Module* module, QTreeWidgetItem* parentItem = nullptr);
|
||||
|
||||
void loadTasksAMM();
|
||||
|
||||
private:
|
||||
Ui::DocTasksWidget *ui;
|
||||
QTreeWidget* treeWidget;
|
||||
|
||||
QList<Module*> listAllModules;
|
||||
|
||||
};
|
||||
|
||||
#endif // DOCTASKSWIDGET_H
|
||||
|
||||
@@ -6,17 +6,18 @@
|
||||
#include "ui_fimtaskswidget.h"
|
||||
#include "tasksAmmFim.h"
|
||||
|
||||
FIMtasksWidget::FIMtasksWidget(QWidget *parent) :
|
||||
FIMtasksWidget::FIMtasksWidget(ConnectorToServer* connectorToServer, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FIMtasksWidget)
|
||||
ui(new Ui::FIMtasksWidget),
|
||||
connectorToServer(connectorToServer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
loadTasksAmmFimFromXML();
|
||||
//loadTasksAmmFimFromXML();
|
||||
|
||||
preparationTreeWidget();
|
||||
|
||||
fillTree();
|
||||
//fillTree();
|
||||
}
|
||||
|
||||
FIMtasksWidget::~FIMtasksWidget()
|
||||
@@ -24,92 +25,86 @@ FIMtasksWidget::~FIMtasksWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FIMtasksWidget::loadTasksAmmFimFromXML()
|
||||
QList<TaskAmmFim> FIMtasksWidget::loadTasksAmmFimFromXML(QByteArray array)
|
||||
{
|
||||
QList<TaskAmmFim> listTaskAmmFim;
|
||||
|
||||
QDomDocument docTasksDOM;
|
||||
QString xmlFileName = "./tasksFIM.xml";
|
||||
QFile xmlInFile(xmlFileName);
|
||||
if (!xmlInFile.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
QMessageBox::critical(nullptr, tr("Attention!"), tr("The file could not be opened ") + xmlFileName);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
docTasksDOM.setContent(xmlInFile.readAll());
|
||||
xmlInFile.close();
|
||||
|
||||
QDomElement RRJTasksElement = docTasksDOM.firstChildElement("RRJTasks");
|
||||
if(RRJTasksElement.isNull())
|
||||
return;
|
||||
docTasksDOM.setContent(array);
|
||||
|
||||
QDomElement taskElement = RRJTasksElement.firstChildElement();
|
||||
if(taskElement.isNull())
|
||||
return;
|
||||
QDomElement RRJTasksElement = docTasksDOM.firstChildElement("RRJTasks");
|
||||
if(RRJTasksElement.isNull())
|
||||
return listTaskAmmFim;
|
||||
|
||||
do
|
||||
{/*task*/
|
||||
QString name = taskElement.nodeName();
|
||||
QDomNamedNodeMap nodeMap = taskElement.attributes();
|
||||
QDomElement taskElement = RRJTasksElement.firstChildElement();
|
||||
if(taskElement.isNull())
|
||||
return listTaskAmmFim;
|
||||
|
||||
if(name == "task")
|
||||
do
|
||||
{/*task*/
|
||||
QString name = taskElement.nodeName();
|
||||
QDomNamedNodeMap nodeMap = taskElement.attributes();
|
||||
|
||||
if(name == "task")
|
||||
{
|
||||
TaskAmmFim task;
|
||||
|
||||
task.initialize(nodeMap.namedItem("id").nodeValue().toInt(),
|
||||
nodeMap.namedItem("type").nodeValue(),
|
||||
nodeMap.namedItem("title").nodeValue(),
|
||||
nodeMap.namedItem("status").nodeValue(),
|
||||
nodeMap.namedItem("created").nodeValue(),
|
||||
nodeMap.namedItem("changed").nodeValue());
|
||||
|
||||
QDomElement malfunctionElement = taskElement.firstChildElement();
|
||||
if(!malfunctionElement.isNull())
|
||||
{
|
||||
TaskAmmFim task;
|
||||
do
|
||||
{/*malfunction*/
|
||||
QString name = malfunctionElement.nodeName();
|
||||
QDomNamedNodeMap nodeMap = malfunctionElement.attributes();
|
||||
|
||||
task.initialize(nodeMap.namedItem("id").nodeValue().toInt(),
|
||||
nodeMap.namedItem("type").nodeValue(),
|
||||
nodeMap.namedItem("title").nodeValue(),
|
||||
nodeMap.namedItem("status").nodeValue(),
|
||||
nodeMap.namedItem("created").nodeValue(),
|
||||
nodeMap.namedItem("changed").nodeValue());
|
||||
if(name == "malfunction")
|
||||
{
|
||||
Malfunction malfunction;
|
||||
|
||||
QDomElement malfunctionElement = taskElement.firstChildElement();
|
||||
if(!malfunctionElement.isNull())
|
||||
{
|
||||
do
|
||||
{/*malfunction*/
|
||||
QString name = malfunctionElement.nodeName();
|
||||
QDomNamedNodeMap nodeMap = malfunctionElement.attributes();
|
||||
malfunction.initialize(nodeMap.namedItem("dmCode").nodeValue(),
|
||||
nodeMap.namedItem("num").nodeValue(),
|
||||
nodeMap.namedItem("description").nodeValue());
|
||||
|
||||
if(name == "malfunction")
|
||||
QDomElement signElement = malfunctionElement.firstChildElement();
|
||||
if(!signElement.isNull())
|
||||
{
|
||||
Malfunction malfunction;
|
||||
do
|
||||
{/*malfunctionSign*/
|
||||
QString name = signElement.nodeName();
|
||||
QDomNamedNodeMap nodeMap = signElement.attributes();
|
||||
|
||||
malfunction.initialize(nodeMap.namedItem("dmCode").nodeValue(),
|
||||
nodeMap.namedItem("num").nodeValue(),
|
||||
nodeMap.namedItem("description").nodeValue());
|
||||
if(name == "malfunctionSign")
|
||||
{
|
||||
MalfunctionSign sign;
|
||||
|
||||
QDomElement signElement = malfunctionElement.firstChildElement();
|
||||
if(!signElement.isNull())
|
||||
{
|
||||
do
|
||||
{/*malfunctionSign*/
|
||||
QString name = signElement.nodeName();
|
||||
QDomNamedNodeMap nodeMap = signElement.attributes();
|
||||
sign.initialize(nodeMap.namedItem("type").nodeValue().toInt(),
|
||||
nodeMap.namedItem("description").nodeValue());
|
||||
|
||||
if(name == "malfunctionSign")
|
||||
{
|
||||
MalfunctionSign sign;
|
||||
malfunction.addMalfunctionSign(sign);
|
||||
}
|
||||
|
||||
sign.initialize(nodeMap.namedItem("type").nodeValue().toInt(),
|
||||
nodeMap.namedItem("description").nodeValue());
|
||||
|
||||
malfunction.addMalfunctionSign(sign);
|
||||
}
|
||||
|
||||
}while(! (signElement = signElement.nextSiblingElement()).isNull());
|
||||
}
|
||||
task.addMalfunction(malfunction);
|
||||
}while(! (signElement = signElement.nextSiblingElement()).isNull());
|
||||
}
|
||||
}while(! (malfunctionElement = malfunctionElement.nextSiblingElement()).isNull());
|
||||
}
|
||||
listTaskAmmFim.append(task);
|
||||
task.addMalfunction(malfunction);
|
||||
}
|
||||
}while(! (malfunctionElement = malfunctionElement.nextSiblingElement()).isNull());
|
||||
}
|
||||
}while (! (taskElement = taskElement.nextSiblingElement()).isNull());
|
||||
}
|
||||
listTaskAmmFim.append(task);
|
||||
}
|
||||
}while (! (taskElement = taskElement.nextSiblingElement()).isNull());
|
||||
|
||||
return listTaskAmmFim;
|
||||
}
|
||||
|
||||
void FIMtasksWidget::fillTree()
|
||||
void FIMtasksWidget::fillTree(QList<TaskAmmFim> listTaskAmmFim)
|
||||
{
|
||||
for(int i = 0; i < listTaskAmmFim.count(); i++)
|
||||
{/*Задачи*/
|
||||
@@ -172,3 +167,22 @@ void FIMtasksWidget::reSetHeadTreeWidget()
|
||||
QStringList listHeaders = {tr("Title"), tr("ID")};
|
||||
ui->treeWidget->setHeaderLabels(listHeaders);
|
||||
}
|
||||
|
||||
void FIMtasksWidget::slot_NeedUpdateUI()
|
||||
{
|
||||
loadTasksFIM();
|
||||
}
|
||||
|
||||
void FIMtasksWidget::loadTasksFIM()
|
||||
{
|
||||
//Обновление дерева
|
||||
ui->treeWidget->clear();
|
||||
|
||||
//собственно обновление дерева
|
||||
fillTree(connectorToServer->getListTaskFim());
|
||||
}
|
||||
|
||||
void FIMtasksWidget::on_btnUpdateTasks_clicked()
|
||||
{
|
||||
connectorToServer->sendQueryTasksXML("fim");
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include "tasksAmmFim.h"
|
||||
#include "connectortoserver.h"
|
||||
|
||||
namespace Ui {
|
||||
class FIMtasksWidget;
|
||||
@@ -19,22 +20,34 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
explicit FIMtasksWidget(QWidget *parent = nullptr);
|
||||
explicit FIMtasksWidget(ConnectorToServer* connectorToServer, QWidget *parent = nullptr);
|
||||
~FIMtasksWidget();
|
||||
|
||||
private:
|
||||
void loadTasksAmmFimFromXML();
|
||||
void fillTree();
|
||||
public:
|
||||
static QList<TaskAmmFim> loadTasksAmmFimFromXML(QByteArray array);
|
||||
|
||||
private:
|
||||
void fillTree(QList<TaskAmmFim> listTaskAmmFim);
|
||||
void preparationTreeWidget();
|
||||
void reSetHeadTreeWidget();
|
||||
|
||||
public Q_SLOTS:
|
||||
//Слот обработки сигнала необходимости обновления интерфейса
|
||||
void slot_NeedUpdateUI();
|
||||
|
||||
private:
|
||||
void loadTasksFIM();
|
||||
|
||||
public:
|
||||
QString userName;
|
||||
QList<TaskAmmFim> listTaskAmmFim;
|
||||
//QList<TaskAmmFim> listTaskAmmFim;
|
||||
|
||||
private slots:
|
||||
void on_btnUpdateTasks_clicked();
|
||||
|
||||
private:
|
||||
Ui::FIMtasksWidget *ui;
|
||||
ConnectorToServer* connectorToServer;
|
||||
};
|
||||
|
||||
#endif // FIMTASKSWIDGET_H
|
||||
|
||||
@@ -22,6 +22,13 @@
|
||||
<string>FIM</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>List of tasks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QTreeWidget" name="treeWidget">
|
||||
<column>
|
||||
@@ -31,12 +38,16 @@
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>List of tasks</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="5" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnUpdateTasks">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@@ -29,6 +29,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
qRegisterMetaType<QList<Classroom>>("QList<Classroom>");
|
||||
qRegisterMetaType<QList<Task>>("QList<Task>");
|
||||
|
||||
qRegisterMetaType<QList<TaskAmmFim>>("QList<TaskAmmFim>");
|
||||
|
||||
connectorToServer = new ConnectorToServer(this);
|
||||
connect(connectorToServer,&ConnectorToServer::sigLoginResult,this,&InstructorsAndTraineesWidget::checkLoginResult);
|
||||
connect(connectorToServer,&ConnectorToServer::sigDeLoginResult,this,&InstructorsAndTraineesWidget::checkDeLoginResult);
|
||||
@@ -55,7 +57,10 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
|
||||
|
||||
docTasksWidget = new DocTasksWidget(this);
|
||||
fIMtasksWidget = new FIMtasksWidget(this);
|
||||
fIMtasksWidget = new FIMtasksWidget(connectorToServer, this);
|
||||
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateTasksFIM, fIMtasksWidget, &FIMtasksWidget::slot_NeedUpdateUI);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateTasksAMM, docTasksWidget, &DocTasksWidget::slot_NeedUpdateUI);
|
||||
|
||||
ui->horizontalLayout_3->addWidget(viewerTrainees);
|
||||
ui->horizontalLayout_3->addWidget(messangerWidget);
|
||||
|
||||
@@ -18,6 +18,8 @@ Q_DECLARE_METATYPE(QList<Computer>)
|
||||
Q_DECLARE_METATYPE(QList<Classroom>)
|
||||
Q_DECLARE_METATYPE(QList<Task>)
|
||||
|
||||
Q_DECLARE_METATYPE(QList<TaskAmmFim>)
|
||||
|
||||
namespace Ui {
|
||||
class InstructorsAndTraineesWidget;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ enum PacketType
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_CLASSROOMS = 104,
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_TASKS = 105,
|
||||
|
||||
//xml-ответы на запросы AdditionalFiles
|
||||
TYPE_XMLANSWER_QUERY_TASKS_XML_FIM = 130,
|
||||
TYPE_XMLANSWER_QUERY_TASKS_XML_AMM = 131,
|
||||
|
||||
//ответы по обновлениям
|
||||
HASH_READY = 150,
|
||||
CHANGE_DATA_VERSION = 151,
|
||||
|
||||
@@ -79,6 +79,12 @@ public:
|
||||
TypeQueryToDB typeQuery;
|
||||
};
|
||||
|
||||
class ClientQueryTasksXML
|
||||
{
|
||||
public:
|
||||
QString Type;
|
||||
};
|
||||
|
||||
class ServerMessage
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -43,6 +43,11 @@ void ProcessParser::read(ClientHandler *client, QByteArray array)
|
||||
|
||||
queryToDb(xmlReader,client);
|
||||
}
|
||||
else if(xmlReader.name() == "QueryTasksXML")
|
||||
{//Запрос файла XML с задачами
|
||||
|
||||
queryTasksXML(xmlReader,client);
|
||||
}
|
||||
else if(xmlReader.name() == "ClientMessage")
|
||||
{//Сообщение от клиента
|
||||
|
||||
@@ -223,6 +228,24 @@ void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client)
|
||||
processingSystem->processingClientQueryToDB(client, queryToDB, id, data);
|
||||
}
|
||||
|
||||
void ProcessParser::queryTasksXML(QXmlStreamReader &xmlReader, ClientHandler *client)
|
||||
{
|
||||
ClientQueryTasksXML clientQueryTasksXML;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "Type")
|
||||
clientQueryTasksXML.Type = value;
|
||||
}
|
||||
|
||||
processingSystem->processingClientQueryTasksXML(client, clientQueryTasksXML);
|
||||
}
|
||||
|
||||
void ProcessParser::clientMessage(QXmlStreamReader &xmlReader,ClientHandler *client)
|
||||
{
|
||||
ClientMessage clientMessage;
|
||||
|
||||
@@ -23,6 +23,7 @@ private:
|
||||
void clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void toClientMessage(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void queryTasksXML(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void clientMessage(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void clientNotify(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
};
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
#include <clienthandler.h>
|
||||
|
||||
ProcessingSystem::ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent):
|
||||
QObject(parent)
|
||||
ProcessingSystem::ProcessingSystem(ProviderDBLMS* providerDBLMS, UpdateController* updateController, QObject *parent):
|
||||
QObject(parent),
|
||||
providerDBLMS(nullptr),
|
||||
updateController(nullptr)
|
||||
{
|
||||
this->providerDBLMS = providerDBLMS;
|
||||
this->updateController = updateController;
|
||||
}
|
||||
|
||||
void ProcessingSystem::initialize(ServerLMSWidget *server, DataParser *dataParser, CommonClientHandler *commonClientHandler,Logger *logger)
|
||||
@@ -226,6 +229,21 @@ void ProcessingSystem::processingClientQueryToDB(ClientHandler *client, ClientQu
|
||||
//logger->addTextToLogger("To Client: " + str);
|
||||
}
|
||||
|
||||
void ProcessingSystem::processingClientQueryTasksXML(ClientHandler *client, ClientQueryTasksXML clientQueryTasksXML)
|
||||
{
|
||||
QByteArray arrayAnswer;
|
||||
|
||||
QString nameFile = "";
|
||||
if(clientQueryTasksXML.Type == "fim")
|
||||
nameFile = tasksFIMfileName;
|
||||
else if(clientQueryTasksXML.Type == "amm")
|
||||
nameFile = tasksAMMfileName;
|
||||
|
||||
arrayAnswer = updateController->getAdditionalFile(nameFile);
|
||||
|
||||
client->sendXmlAnswer(arrayAnswer, PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_FIM);
|
||||
}
|
||||
|
||||
void ProcessingSystem::processingToClientMessage(ClientHandler *client, ToClientMessage toClientMessage)
|
||||
{
|
||||
signal_msgToClientReady(toClientMessage.Login, toClientMessage.Text);
|
||||
|
||||
@@ -21,12 +21,13 @@ class ProcessingSystem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent = nullptr);
|
||||
explicit ProcessingSystem(ProviderDBLMS* providerDBLMS, UpdateController* updateController, QObject *parent = nullptr);
|
||||
|
||||
void initialize(ServerLMSWidget *server,DataParser* dataParser,CommonClientHandler *commonClientServer,Logger *logger);
|
||||
void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization);
|
||||
void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization);
|
||||
void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr);
|
||||
void processingClientQueryTasksXML(ClientHandler *client, ClientQueryTasksXML clientQueryTasksXML);
|
||||
void processingToClientMessage(ClientHandler *client, ToClientMessage toClientMessage);
|
||||
|
||||
void processingFromClientMessage(ClientHandler *client, ClientMessage clientMessage);
|
||||
@@ -46,6 +47,7 @@ private:
|
||||
DataParser *dataParser;
|
||||
//InstructorsAndTraineesWidget *pInstructorsAndTrainees;
|
||||
ProviderDBLMS* providerDBLMS;
|
||||
UpdateController* updateController;
|
||||
};
|
||||
|
||||
#endif // PROCESSINGSYSTEM_H
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
static const QString staticDataFolderName = "StaticData";
|
||||
static const QString applicationFolderName = "Application";
|
||||
static const QString sharedDataFolderName = "SharedData";
|
||||
static const QString additionalFilesFolderName = "AdditionalFiles";
|
||||
static const QString streamingAssetsFolderName = "StreamingAssets";
|
||||
static const QString tempFile = staticDataFolderName + "/save.xml";
|
||||
static const QString version = staticDataFolderName + "/version.xml";
|
||||
@@ -22,6 +23,8 @@ 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 tasksAMMfileName = "/tasksAmm.xml";
|
||||
static const QString tasksFIMfileName = "/tasksFIM.xml";
|
||||
|
||||
static const QString baseNameVersion = "base";//может вынести комманды куда нибудь?
|
||||
|
||||
|
||||
@@ -355,6 +355,19 @@ QList<FileData>* UpdateController::calculateHash(QString path)
|
||||
return files;
|
||||
}
|
||||
|
||||
QByteArray UpdateController::getAdditionalFile(QString name)
|
||||
{
|
||||
QString path = Tools::createSharedPath("/" + assetManager->getCurrentVersionData()->getViewName() + "/AdditionalFiles" + name);
|
||||
QFile addFile(path);
|
||||
QByteArray array;
|
||||
if(addFile.open(QIODevice::ReadOnly)){
|
||||
array = addFile.readAll();
|
||||
addFile.close();
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
QByteArray UpdateController::getLocalHash()
|
||||
{
|
||||
QFile hashFile(hashFileName);
|
||||
|
||||
@@ -55,6 +55,9 @@ public:
|
||||
void createVersionListXmlAnswer(QList<StreamingVersionData *> version);
|
||||
void saveVersionToFile(StreamingVersionData *streamingVersion);
|
||||
void xmlFileDataParse(QByteArray array);
|
||||
|
||||
QByteArray getAdditionalFile(QString name);
|
||||
|
||||
public slots:
|
||||
void changeAssetVersion(QString versionName);
|
||||
void createCopyVersion(QString versionName,QString newVersionName);
|
||||
|
||||
@@ -54,14 +54,14 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
||||
assetsManager = new AssetsManager;
|
||||
assetsManager->moveToThread(updateThread);
|
||||
|
||||
processingSystem = new ProcessingSystem(providerDBLMS);
|
||||
updateController = new UpdateController;
|
||||
updateController->moveToThread(updateThread);
|
||||
|
||||
processingSystem = new ProcessingSystem(providerDBLMS, updateController);
|
||||
processingSystem->moveToThread(updateThread);
|
||||
|
||||
dataParser = new DataParser(assetsManager,processingSystem);
|
||||
|
||||
updateController = new UpdateController;
|
||||
updateController->moveToThread(updateThread);
|
||||
|
||||
commonClientHandler = new CommonClientHandler;
|
||||
|
||||
loggerThread->start();
|
||||
|
||||
Reference in New Issue
Block a user