mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
hotfix: updateVersion
This commit is contained in:
@@ -57,6 +57,8 @@ add_library(ServerLMS SHARED
|
||||
Systems/Parsers/clientanswerparser.h
|
||||
Systems/Parsers/dbanswerparser.cpp
|
||||
Systems/Parsers/dbanswerparser.h
|
||||
Systems/Parsers/processparser.cpp
|
||||
Systems/Parsers/processparser.h
|
||||
Systems/processingsystem.cpp
|
||||
Systems/processingsystem.h
|
||||
Systems/sendsystem.cpp
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
void setLogin(QString login)
|
||||
{
|
||||
this->login = login;
|
||||
isLoggedIn = true;
|
||||
fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login;
|
||||
}
|
||||
QString getLogin()
|
||||
|
||||
@@ -11,9 +11,13 @@ QObject(parent)
|
||||
|
||||
clientAnswer = new ClientAnswerParser;
|
||||
clientAnswer->initialize(this);
|
||||
|
||||
dbAnswer = new DBAnswerParser;
|
||||
dbAnswer->initialize(this);
|
||||
|
||||
processParser = new ProcessParser;
|
||||
processParser->initialize(processingSystem);
|
||||
|
||||
mutex = new QMutex;
|
||||
|
||||
if (!QDir(staticDataFolderName).exists()){
|
||||
@@ -22,223 +26,7 @@ QObject(parent)
|
||||
qDebug() << "ParserThread: " << QThread::currentThreadId();
|
||||
}
|
||||
|
||||
void DataParser::xmlParser(ClientHandler *client, QByteArray array)
|
||||
{
|
||||
QXmlStreamReader xmlReader(array);
|
||||
|
||||
xmlReader.readNext(); // Переходим к первому элементу в файле
|
||||
|
||||
//Крутимся в цикле до тех пор, пока не достигнем конца документа
|
||||
while(!xmlReader.atEnd())
|
||||
{
|
||||
//Проверяем, является ли элемент началом тега
|
||||
if(xmlReader.isStartElement())
|
||||
{
|
||||
//Анализируем теги
|
||||
if(xmlReader.name() == "ClientAutorization")
|
||||
{//Запрос авторизации от клиента
|
||||
|
||||
ClientAutorization clientAutorization;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "Login")
|
||||
clientAutorization.Login = value;
|
||||
else if(name == "Password")
|
||||
clientAutorization.Password = value;
|
||||
else if(name == "NumberOfScreen")
|
||||
clientAutorization.NumberOfScreen = value.toInt();
|
||||
else if(name == "TypeClient")
|
||||
clientAutorization.TypeClient = (TypeClientAutorization)value.toInt();
|
||||
}
|
||||
|
||||
processingSystem->processingClientAutorization(client, clientAutorization);
|
||||
}
|
||||
else if(xmlReader.name() == "ClientDeAutorization")
|
||||
{//Запрос ДеАвторизации от клиента
|
||||
|
||||
ClientDeAutorization clientDeAutorization;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "Login")
|
||||
clientDeAutorization.Login = value;
|
||||
}
|
||||
|
||||
processingSystem->processingClientDeAutorization(client, clientDeAutorization);
|
||||
}
|
||||
else if(xmlReader.name() == "ToClientMessage")
|
||||
{//Отправка сообщения Клиенту
|
||||
|
||||
ToClientMessage toClientMessage;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "id")
|
||||
toClientMessage.id = value.toInt();
|
||||
else if(name == "Text")
|
||||
toClientMessage.Text = value;
|
||||
else if(name == "Login")
|
||||
toClientMessage.Login = value;
|
||||
}
|
||||
|
||||
processingSystem->processingToClientMessage(client, toClientMessage);
|
||||
}
|
||||
else if(xmlReader.name() == "QueryToDB")
|
||||
{//Запрос к базе данных от клиента
|
||||
|
||||
ClientQueryToDB queryToDB;
|
||||
int id = 0;
|
||||
Instructor instructor;
|
||||
Trainee trainee;
|
||||
Group group;
|
||||
void* data = nullptr;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "TypeQuery")
|
||||
queryToDB.typeQuery = (TypeQueryToDB)value.toInt();
|
||||
else if(name == "id")
|
||||
id = value.toInt();
|
||||
else
|
||||
{
|
||||
switch (queryToDB.typeQuery)
|
||||
{
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_INSTRUCTOR:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_INSTRUCTOR:
|
||||
if(name == "instructor_id")
|
||||
instructor.setID(value.toInt());
|
||||
else if(name == "name")
|
||||
instructor.setName(value);
|
||||
else if(name == "login")
|
||||
instructor.setLogin(value);
|
||||
else if(name == "password")
|
||||
instructor.setPassword(value);
|
||||
else if(name == "is_admin")
|
||||
instructor.setIsAdmin(value.toInt());
|
||||
else if(name == "archived")
|
||||
instructor.setArchived(value.toInt());
|
||||
else if(name == "logged_in")
|
||||
instructor.setLoggedIn(value.toInt());
|
||||
break;
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE:
|
||||
if(name == "trainee_id")
|
||||
trainee.setID(value.toInt());
|
||||
else if(name == "name")
|
||||
trainee.setName(value);
|
||||
else if(name == "login")
|
||||
trainee.setLogin(value);
|
||||
else if(name == "password")
|
||||
trainee.setPassword(value);
|
||||
else if(name == "archived")
|
||||
trainee.setArchived(value.toInt());
|
||||
else if(name == "logged_in")
|
||||
trainee.setLoggedIn(value.toInt());
|
||||
else if(name == "group_trainee")
|
||||
{
|
||||
Group group(value.toInt(), "");
|
||||
trainee.setGroup(group);
|
||||
}
|
||||
else if(name == "computer_trainee")
|
||||
{
|
||||
Computer computer(value.toInt(), "", "", Classroom());
|
||||
trainee.setComputer(computer);
|
||||
}
|
||||
break;
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_GROUP:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_GROUP:
|
||||
if(name == "group_id")
|
||||
group.setID(value.toInt());
|
||||
else if(name == "name")
|
||||
group.setName(value);
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
switch (queryToDB.typeQuery)
|
||||
{
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_INSTRUCTOR:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_INSTRUCTOR:
|
||||
data = &instructor;
|
||||
break;
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE:
|
||||
data = &trainee;
|
||||
break;
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_GROUP:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_GROUP:
|
||||
data = &group;
|
||||
break;
|
||||
};
|
||||
|
||||
processingSystem->processingClientQueryToDB(client, queryToDB, id, data);
|
||||
}
|
||||
else if(xmlReader.name() == "ClientMessage")
|
||||
{//Сообщение от клиента
|
||||
|
||||
ClientMessage clientMessage;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "Text")
|
||||
clientMessage.Text = value;
|
||||
}
|
||||
|
||||
processingSystem->processingFromClientMessage(client, clientMessage);
|
||||
}
|
||||
else if(xmlReader.name() == "ClientNotify")
|
||||
{//Уведомление от клиента
|
||||
|
||||
ClientNotify clientNotify;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
|
||||
if(name == "Code")
|
||||
clientNotify.Code = value;
|
||||
}
|
||||
|
||||
processingSystem->processingClientNotify(client, clientNotify);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit sigLogMessage("XmlParser: unrecognized tag");
|
||||
}
|
||||
|
||||
}
|
||||
xmlReader.readNext(); // Переходим к следующему элементу файла
|
||||
}//while(!xmlReader.atEnd())
|
||||
}
|
||||
|
||||
QByteArray DataParser::xmlAnswer(QList<SXmlAnswerTag> listTag, QString elemUp1, QString elemUp2)
|
||||
{
|
||||
@@ -334,8 +122,6 @@ bool DataParser::saveDOMtoXML(QString nameFile, QDomDocument *commonDOM)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QByteArray DataParser::readTempFile()
|
||||
{
|
||||
QByteArray array;
|
||||
@@ -354,11 +140,6 @@ QByteArray DataParser::readTempFile()
|
||||
return array;
|
||||
}
|
||||
|
||||
DataParser::~DataParser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ClientAnswerParser *DataParser::ClientAnswer() const
|
||||
{
|
||||
return clientAnswer;
|
||||
@@ -368,3 +149,15 @@ DBAnswerParser *DataParser::DbAnswer() const
|
||||
{
|
||||
return dbAnswer;
|
||||
}
|
||||
|
||||
ProcessParser *DataParser::getProcessParser() const
|
||||
{
|
||||
return processParser;
|
||||
}
|
||||
|
||||
DataParser::~DataParser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Systems/logger.h"
|
||||
#include "Systems/Parsers/clientanswerparser.h"
|
||||
#include "dbanswerparser.h"
|
||||
#include "processparser.h"
|
||||
#include "serverlmswidget.h"
|
||||
|
||||
#include <QByteArray>
|
||||
@@ -22,6 +23,7 @@ class ClientHandler;
|
||||
class AssetsManager;
|
||||
class ClientAnswerParser;
|
||||
class DBAnswerParser;
|
||||
class ProcessParser;
|
||||
|
||||
class DataParser : public QObject
|
||||
{
|
||||
@@ -40,6 +42,7 @@ public:
|
||||
|
||||
ClientAnswerParser *ClientAnswer() const;
|
||||
DBAnswerParser *DbAnswer() const;
|
||||
ProcessParser *getProcessParser() const;
|
||||
|
||||
signals:
|
||||
void sigLogMessage(QString log);
|
||||
@@ -52,6 +55,7 @@ private:
|
||||
AssetsManager *assetsManager;
|
||||
ClientAnswerParser *clientAnswer;
|
||||
DBAnswerParser *dbAnswer;
|
||||
ProcessParser *processParser;
|
||||
QByteArray readTempFile();
|
||||
};
|
||||
|
||||
|
||||
261
ServerLMS/ServerLMS/Systems/Parsers/processparser.cpp
Normal file
261
ServerLMS/ServerLMS/Systems/Parsers/processparser.cpp
Normal file
@@ -0,0 +1,261 @@
|
||||
#include "processparser.h"
|
||||
|
||||
ProcessParser::ProcessParser(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ProcessParser::initialize(ProcessingSystem *processingSystem)
|
||||
{
|
||||
this->processingSystem = processingSystem;
|
||||
}
|
||||
|
||||
void ProcessParser::read(ClientHandler *client, QByteArray array)
|
||||
{
|
||||
QXmlStreamReader xmlReader(array);
|
||||
|
||||
xmlReader.readNext(); // Переходим к первому элементу в файле
|
||||
|
||||
//Крутимся в цикле до тех пор, пока не достигнем конца документа
|
||||
while(!xmlReader.atEnd())
|
||||
{
|
||||
//Проверяем, является ли элемент началом тега
|
||||
if(xmlReader.isStartElement())
|
||||
{
|
||||
//Анализируем теги
|
||||
if(xmlReader.name() == "ClientAutorization")
|
||||
{//Запрос авторизации от клиента
|
||||
|
||||
clientAuth(xmlReader,client);
|
||||
}
|
||||
else if(xmlReader.name() == "ClientDeAutorization")
|
||||
{//Запрос ДеАвторизации от клиента
|
||||
|
||||
clientDeAuth(xmlReader,client);
|
||||
}
|
||||
else if(xmlReader.name() == "ToClientMessage")
|
||||
{//Отправка сообщения Клиенту
|
||||
|
||||
toClientMessage(xmlReader,client);
|
||||
}
|
||||
else if(xmlReader.name() == "QueryToDB")
|
||||
{//Запрос к базе данных от клиента
|
||||
|
||||
queryToDb(xmlReader,client);
|
||||
}
|
||||
else if(xmlReader.name() == "ClientMessage")
|
||||
{//Сообщение от клиента
|
||||
|
||||
clientMessage(xmlReader,client);
|
||||
}
|
||||
else if(xmlReader.name() == "ClientNotify")
|
||||
{//Уведомление от клиента
|
||||
|
||||
clientNotify(xmlReader,client);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit sigLogMessage("XmlParser: unrecognized tag");
|
||||
}
|
||||
|
||||
}
|
||||
xmlReader.readNext(); // Переходим к следующему элементу файла
|
||||
}//while(!xmlReader.atEnd())
|
||||
}
|
||||
|
||||
void ProcessParser::clientAuth(QXmlStreamReader &xmlReader,ClientHandler *client)
|
||||
{
|
||||
ClientAutorization clientAutorization;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "Login")
|
||||
clientAutorization.Login = value;
|
||||
else if(name == "Password")
|
||||
clientAutorization.Password = value;
|
||||
else if(name == "NumberOfScreen")
|
||||
clientAutorization.NumberOfScreen = value.toInt();
|
||||
else if(name == "TypeClient")
|
||||
clientAutorization.TypeClient = (TypeClientAutorization)value.toInt();
|
||||
}
|
||||
|
||||
processingSystem->processingClientAutorization(client, clientAutorization);
|
||||
}
|
||||
|
||||
void ProcessParser::clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *client)
|
||||
{
|
||||
ClientDeAutorization clientDeAutorization;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "Login")
|
||||
clientDeAutorization.Login = value;
|
||||
}
|
||||
|
||||
processingSystem->processingClientDeAutorization(client, clientDeAutorization);
|
||||
}
|
||||
|
||||
void ProcessParser::toClientMessage(QXmlStreamReader &xmlReader,ClientHandler *client)
|
||||
{
|
||||
ToClientMessage toClientMessage;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "id")
|
||||
toClientMessage.id = value.toInt();
|
||||
else if(name == "Text")
|
||||
toClientMessage.Text = value;
|
||||
else if(name == "Login")
|
||||
toClientMessage.Login = value;
|
||||
}
|
||||
|
||||
processingSystem->processingToClientMessage(client, toClientMessage);
|
||||
}
|
||||
|
||||
void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client)
|
||||
{
|
||||
ClientQueryToDB queryToDB;
|
||||
int id = 0;
|
||||
Instructor instructor;
|
||||
Trainee trainee;
|
||||
Group group;
|
||||
void* data = nullptr;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "TypeQuery")
|
||||
queryToDB.typeQuery = (TypeQueryToDB)value.toInt();
|
||||
else if(name == "id")
|
||||
id = value.toInt();
|
||||
else
|
||||
{
|
||||
switch (queryToDB.typeQuery)
|
||||
{
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_INSTRUCTOR:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_INSTRUCTOR:
|
||||
if(name == "instructor_id")
|
||||
instructor.setID(value.toInt());
|
||||
else if(name == "name")
|
||||
instructor.setName(value);
|
||||
else if(name == "login")
|
||||
instructor.setLogin(value);
|
||||
else if(name == "password")
|
||||
instructor.setPassword(value);
|
||||
else if(name == "is_admin")
|
||||
instructor.setIsAdmin(value.toInt());
|
||||
else if(name == "archived")
|
||||
instructor.setArchived(value.toInt());
|
||||
else if(name == "logged_in")
|
||||
instructor.setLoggedIn(value.toInt());
|
||||
break;
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE:
|
||||
if(name == "trainee_id")
|
||||
trainee.setID(value.toInt());
|
||||
else if(name == "name")
|
||||
trainee.setName(value);
|
||||
else if(name == "login")
|
||||
trainee.setLogin(value);
|
||||
else if(name == "password")
|
||||
trainee.setPassword(value);
|
||||
else if(name == "archived")
|
||||
trainee.setArchived(value.toInt());
|
||||
else if(name == "logged_in")
|
||||
trainee.setLoggedIn(value.toInt());
|
||||
else if(name == "group_trainee")
|
||||
{
|
||||
Group group(value.toInt(), "");
|
||||
trainee.setGroup(group);
|
||||
}
|
||||
else if(name == "computer_trainee")
|
||||
{
|
||||
Computer computer(value.toInt(), "", "", Classroom());
|
||||
trainee.setComputer(computer);
|
||||
}
|
||||
break;
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_GROUP:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_GROUP:
|
||||
if(name == "group_id")
|
||||
group.setID(value.toInt());
|
||||
else if(name == "name")
|
||||
group.setName(value);
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
switch (queryToDB.typeQuery)
|
||||
{
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_INSTRUCTOR:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_INSTRUCTOR:
|
||||
data = &instructor;
|
||||
break;
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE:
|
||||
data = &trainee;
|
||||
break;
|
||||
case TypeQueryToDB::TYPE_QUERY_NEW_GROUP:
|
||||
case TypeQueryToDB::TYPE_QUERY_EDIT_GROUP:
|
||||
data = &group;
|
||||
break;
|
||||
};
|
||||
|
||||
processingSystem->processingClientQueryToDB(client, queryToDB, id, data);
|
||||
}
|
||||
|
||||
void ProcessParser::clientMessage(QXmlStreamReader &xmlReader,ClientHandler *client)
|
||||
{
|
||||
ClientMessage clientMessage;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
//addTextToLogger(name + ": " + value);
|
||||
|
||||
if(name == "Text")
|
||||
clientMessage.Text = value;
|
||||
}
|
||||
|
||||
processingSystem->processingFromClientMessage(client, clientMessage);
|
||||
}
|
||||
|
||||
void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *client)
|
||||
{
|
||||
ClientNotify clientNotify;
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
|
||||
if(name == "Code")
|
||||
clientNotify.Code = value;
|
||||
}
|
||||
|
||||
processingSystem->processingClientNotify(client, clientNotify);
|
||||
}
|
||||
|
||||
|
||||
30
ServerLMS/ServerLMS/Systems/Parsers/processparser.h
Normal file
30
ServerLMS/ServerLMS/Systems/Parsers/processparser.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef PROCESSPARSER_H
|
||||
#define PROCESSPARSER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <Data/typesDataServerClient.h>
|
||||
#include <qxmlstream.h>
|
||||
#include <clienthandler.h>
|
||||
|
||||
class ProcessParser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProcessParser(QObject *parent = nullptr);
|
||||
void initialize(ProcessingSystem *processingSystem);
|
||||
void read(ClientHandler *client, QByteArray array);
|
||||
|
||||
|
||||
signals:
|
||||
void sigLogMessage(QString text);
|
||||
private:
|
||||
ProcessingSystem *processingSystem;
|
||||
void clientAuth(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void toClientMessage(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void clientMessage(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
void clientNotify(QXmlStreamReader &xmlReader,ClientHandler *client);
|
||||
};
|
||||
|
||||
#endif // PROCESSPARSER_H
|
||||
@@ -28,7 +28,7 @@ void RecognizeSystem::initialize(UpdateController *updateController,DataParser*
|
||||
connect(this,&RecognizeSystem::sigChangeVersion,updateController,&UpdateController::changeAssetVersion,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigDeleteVersion,updateController,&UpdateController::deleteAssetVersion,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigCopyVersion,updateController,&UpdateController::createCopyVersion,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigXmlParser,dataParser,&DataParser::xmlParser,Qt::DirectConnection);
|
||||
connect(this,&RecognizeSystem::sigXmlParser,dataParser->getProcessParser(),&ProcessParser::read,Qt::DirectConnection);
|
||||
|
||||
qDebug() << "Recognize init thread ID " << QThread::currentThreadId();
|
||||
}
|
||||
|
||||
@@ -12,29 +12,29 @@
|
||||
|
||||
#define TCP_READ_TIMEOUT 5000
|
||||
|
||||
static QString staticDataFolderName = "StaticData";
|
||||
static QString applicationFolderName = "Application";
|
||||
static QString sharedDataFolderName = "SharedData";
|
||||
static QString streamingAssetsFolderName = "StreamingAssets";
|
||||
static QString tempFile = staticDataFolderName + "/save.xml";
|
||||
static QString version = staticDataFolderName + "/version.xml";
|
||||
static QString versionListFile = staticDataFolderName + "/versionList.xml";
|
||||
static QString hashFileName = staticDataFolderName + "/serverHash.xml";
|
||||
static QString buildHashName = staticDataFolderName + "/buildHash.xml";
|
||||
static QString buildDataPath = "/Application/RRJLoader/RRJ_Data/";
|
||||
static const QString staticDataFolderName = "StaticData";
|
||||
static const QString applicationFolderName = "Application";
|
||||
static const QString sharedDataFolderName = "SharedData";
|
||||
static const QString streamingAssetsFolderName = "StreamingAssets";
|
||||
static const QString tempFile = staticDataFolderName + "/save.xml";
|
||||
static const QString version = staticDataFolderName + "/version.xml";
|
||||
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 QString baseNameVersion = "base";//может вынести комманды куда нибудь?
|
||||
static const QString baseNameVersion = "base";//может вынести комманды куда нибудь?
|
||||
|
||||
static QString commandTryBaseDelete = "BASEDELETETRY";
|
||||
static QString commandTryActiveDelete = "TRYACTIVEDELETE";
|
||||
static QString commandTryCopyWithSameNames = "SAMENAMES";
|
||||
static QString commandGetServerDataList = "GETSERVERDATALIST";
|
||||
static QString commandCheckVersionList = "CHECKVERSIONLIST";
|
||||
static QString commandReadyClient = "READY";
|
||||
static QString commandDisableClient = "DISABLE";
|
||||
static QString commandDuplicateVerName = "DUPLICATEVERNAME";
|
||||
static QString commandHashCompleteClient = "HASHSENDCOMPLETE";
|
||||
static QString commandUpdateFilesClient = "update";
|
||||
static const QString commandTryBaseDelete = "BASEDELETETRY";
|
||||
static const QString commandTryActiveDelete = "TRYACTIVEDELETE";
|
||||
static const QString commandTryCopyWithSameNames = "SAMENAMES";
|
||||
static const QString commandGetServerDataList = "GETSERVERDATALIST";
|
||||
static const QString commandCheckVersionList = "CHECKVERSIONLIST";
|
||||
static const QString commandReadyClient = "READY";
|
||||
static const QString commandDisableClient = "DISABLE";
|
||||
static const QString commandDuplicateVerName = "DUPLICATEVERNAME";
|
||||
static const QString commandHashCompleteClient = "HASHSENDCOMPLETE";
|
||||
static const QString commandUpdateFilesClient = "update";
|
||||
|
||||
class Tools {
|
||||
public:
|
||||
|
||||
@@ -10,7 +10,7 @@ UpdateController::UpdateController(QObject *parent) :
|
||||
qDebug() << hashFileName;
|
||||
}
|
||||
|
||||
void UpdateController::initialize(CommonClientHandler *commonClientHandler,DataParser *dataParser,AssetsManager *assetManager)
|
||||
void UpdateController::initialize(CommonClientHandler *commonClientHandler,DataParser *dataParser,AssetsManager *assetManager,Logger *logger)
|
||||
{
|
||||
this->commonClientHandler = commonClientHandler;
|
||||
this->dataParser = dataParser;
|
||||
@@ -19,6 +19,8 @@ void UpdateController::initialize(CommonClientHandler *commonClientHandler,DataP
|
||||
sizeToSend = 0;
|
||||
assetManager->initialize(this,dataParser);
|
||||
|
||||
connect(this,&UpdateController::sigLogMessage,logger,&Logger::addTextToLogger,Qt::AutoConnection);
|
||||
|
||||
calculateFullHash();
|
||||
currentStreamingPath = assetManager->setVersion("base");
|
||||
setUpCurrentServerHash();
|
||||
@@ -244,7 +246,7 @@ bool UpdateController::checkNeedUpdate(ClientHandler *handler)
|
||||
fileSendList = *forSend;
|
||||
|
||||
emit sigLogMessage(log);
|
||||
printFileList(*forSend);
|
||||
//printFileList(*forSend);
|
||||
|
||||
handler->sendMessageBlock(log);
|
||||
needUpdate = true;
|
||||
@@ -270,7 +272,7 @@ bool UpdateController::checkNeedUpdate(ClientHandler *handler)
|
||||
fileDeleteList = *forDelete;
|
||||
|
||||
emit sigLogMessage(log);
|
||||
printFileList(*forDelete);
|
||||
//printFileList(*forDelete);
|
||||
handler->sendMessageBlock(log);
|
||||
needUpdate = true;
|
||||
}
|
||||
@@ -558,17 +560,17 @@ QList<FileData> UpdateController::getClientDataList() const
|
||||
return clientDataList;
|
||||
}
|
||||
|
||||
DataInfo *UpdateController::getCurrentDataInfo() //TODO: переименовать и перебросить в AssetManager
|
||||
DataInfo *UpdateController::getCurrentDataInfo()
|
||||
{
|
||||
return dataInfo;
|
||||
}
|
||||
|
||||
QList<FileData> *UpdateController::getDatas() const //TODO: переименовать и перебросить в AssetManager
|
||||
QList<FileData> *UpdateController::getDatas() const
|
||||
{
|
||||
return datas;
|
||||
}
|
||||
|
||||
void UpdateController::clearCurrentDataInfo() //TODO: переименовать и перебросить в AssetManager
|
||||
void UpdateController::clearCurrentDataInfo()
|
||||
{
|
||||
delete dataInfo;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ class ClientHandler;
|
||||
class AssetsManager;
|
||||
class ServerLMSWidget;
|
||||
class CommonClientHandler;
|
||||
class Logger;
|
||||
|
||||
class UpdateController : public QObject
|
||||
{
|
||||
@@ -29,7 +30,7 @@ class UpdateController : public QObject
|
||||
public:
|
||||
|
||||
explicit UpdateController(QObject *parent = 0);
|
||||
void initialize(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
|
||||
void initialize(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager,Logger *logger);
|
||||
void compareFiles(ClientHandler* handler, QByteArray array);
|
||||
void showHash();
|
||||
void calculateFullHash();
|
||||
|
||||
@@ -72,14 +72,14 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
||||
|
||||
logger->setTypeLog("widget");
|
||||
|
||||
connect(updateController,&UpdateController::sigLogMessage,logger,&Logger::addTextToLogger);
|
||||
|
||||
connect(dataParser,&DataParser::sigLogMessage,logger,&Logger::addTextToLogger);
|
||||
|
||||
connect(this,&ServerLMSWidget::sigUpdateController,updateController,&UpdateController::initialize,Qt::DirectConnection);
|
||||
connect(this,&ServerLMSWidget::sigLog,logger,&Logger::addTextToLogger,Qt::AutoConnection);
|
||||
connect(this,&ServerLMSWidget::sigCalculateFullHash,updateController,&UpdateController::calculateFullHash,Qt::AutoConnection);
|
||||
|
||||
emit sigUpdateController(commonClientHandler,dataParser,assetsManager);
|
||||
emit sigUpdateController(commonClientHandler,dataParser,assetsManager,logger);
|
||||
on_btnStartServer_clicked();
|
||||
|
||||
first = true;
|
||||
|
||||
@@ -59,7 +59,7 @@ signals:
|
||||
void sigRecognize();
|
||||
void sigLog(QString log);
|
||||
void sigCalculateFullHash();
|
||||
void sigUpdateController(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
|
||||
void sigUpdateController(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager,Logger *logger);
|
||||
|
||||
QTcpSocket* sigGetSocket();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user