mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
bugfix: versions
* refactoring call update after update from client * refactoring common client deAuth * add packet for notify hash calculate start * bugfix update static data
This commit is contained in:
@@ -41,7 +41,8 @@ enum PacketType
|
||||
COPY_VERSION = 152,
|
||||
DELETE_DATA_VERSION = 153,
|
||||
BUSY = 154,
|
||||
FREE = 155
|
||||
FREE = 155,
|
||||
HASH_CALCULATE_START = 156
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -20,9 +20,6 @@ QObject(parent)
|
||||
|
||||
mutex = new QMutex;
|
||||
|
||||
if (!QDir(staticDataFolderName).exists()){
|
||||
QDir().mkdir(staticDataFolderName);
|
||||
}
|
||||
qDebug() << "ParserThread: " << QThread::currentThreadId();
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ void AssetsManager::fillDatas()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AssetsManager::setVersionList(QList<StreamingVersionData*> *streamingVersion)
|
||||
{
|
||||
datas->clear();
|
||||
@@ -327,7 +328,7 @@ void AssetsManager::writeVersionsToFile(QList<StreamingVersionData*> version,boo
|
||||
file.close();
|
||||
}
|
||||
|
||||
void AssetsManager::createFirstVersionListXML(QList<StreamingVersionData*> version) //TODO: переименовать и перебросить в AssetManager
|
||||
void AssetsManager::createFirstVersionListXML(QList<StreamingVersionData*> version)
|
||||
{
|
||||
QFile file(versionListFile);
|
||||
QList<StreamingVersionData*> *temp = new QList<StreamingVersionData*>();
|
||||
|
||||
@@ -142,6 +142,21 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
|
||||
emit sigListsInstructorsTraineesChanged();
|
||||
}
|
||||
|
||||
//упращенная деавторизация при выключении сервера
|
||||
void ProcessingSystem::processingClientDeAutorization(QString login)
|
||||
{
|
||||
//Отмена авторизации в БД
|
||||
|
||||
if(providerDBLMS->deAuthorizationTrainee(login))
|
||||
{//Деавторизовался обучаемый
|
||||
|
||||
}
|
||||
else if(providerDBLMS->deAuthorizationInstructor(login))
|
||||
{//Деавторизовался инструктор
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessingSystem::processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id, void* data)
|
||||
{
|
||||
qDebug() << "ProcessingQueryThread " << QThread::currentThreadId();
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
void sendListTasksAMMofTraineetoClient(ClientHandler* client, int id_trainee);
|
||||
void sendListTasksFIMofTraineetoClient(ClientHandler* client, int id_trainee);
|
||||
ClientHandler* getUnityClientById(int id);
|
||||
void processingClientDeAutorization(QString login);
|
||||
signals:
|
||||
void sigUpdateListClients();
|
||||
void sigListsInstructorsTraineesChanged();
|
||||
|
||||
@@ -23,8 +23,8 @@ void RecognizeSystem::initialize(UpdateController *updateController,DataParser*
|
||||
this->sendSystem = sendSystem;
|
||||
socket = handler->getSocket();
|
||||
|
||||
connect(this,&RecognizeSystem::sigCalculateHash,updateController,&UpdateController::calculateFullHash,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigCalculateHash,updateController,&UpdateController::setUpCurrentServerHash,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigCalculateHash,updateController,&UpdateController::calculateFullHashWithSetup,Qt::AutoConnection);
|
||||
//connect(this,&RecognizeSystem::sigCalculateHash,updateController,&UpdateController::setUpCurrentServerHash,Qt::AutoConnection);
|
||||
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);
|
||||
|
||||
@@ -29,7 +29,7 @@ void UpdateController::initialize(CommonClientHandler *commonClientHandler,DataP
|
||||
connect(this,&UpdateController::sigLogMessage,logger,&Logger::addTextToLogger,Qt::AutoConnection);
|
||||
|
||||
calculateFullHash();
|
||||
currentStreamingPath = assetManager->setVersion("base");
|
||||
currentStreamingPath = assetManager->setVersion("base"); //TODO: сохрнаять предыдущую версию и загружать ее при включении
|
||||
setUpCurrentServerHash();
|
||||
|
||||
mutex = new QMutex;
|
||||
@@ -82,18 +82,28 @@ void UpdateController::showHash()
|
||||
|
||||
void UpdateController::calculateFullHash()
|
||||
{
|
||||
qDebug() << "Calculate hash...";
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
|
||||
auto *list = calculateHash(buildPath);
|
||||
saveHash(buildHashName,list);
|
||||
calculateSharedHash();
|
||||
emit sigLogMessage("Calculate hash complete");
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||
qDebug() << "Calculate complete...";
|
||||
}
|
||||
|
||||
void UpdateController::calculateFullHashWithSetup()
|
||||
{
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_CALCULATE_START);
|
||||
calculateFullHash();
|
||||
setUpCurrentServerHash();
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY);
|
||||
}
|
||||
|
||||
void UpdateController::saveHash(QString fileName,QList<FileData> *fileList)
|
||||
{
|
||||
QFile hashFile(fileName);
|
||||
hashFile.open(QIODevice::WriteOnly);
|
||||
hashFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
QXmlStreamWriter xmlWriter(&hashFile);
|
||||
QListIterator<FileData> fileDataIterator(*fileList);
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
void compareFiles(ClientHandler* handler, QByteArray array);
|
||||
void showHash();
|
||||
void calculateFullHash();
|
||||
void calculateFullHashWithSetup();
|
||||
void calculateSharedHash();
|
||||
void sendNewVersionList();
|
||||
void setCurrentStreamingPath(QString path);
|
||||
|
||||
@@ -45,7 +45,7 @@ void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget,
|
||||
connect(this,&ClientHandler::sigFolderBlock,sendSystem,&SendSystem::sendFolderBlock,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigGetIsSendStopped,sendSystem,&SendSystem::getIsSendStopped,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigSendDeleteBlock,sendSystem,&SendSystem::sendDeleteBlock,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigSendFinish,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
|
||||
//connect(this,&ClientHandler::sigSendFinish,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigSendMessageBlock,sendSystem,&SendSystem::sendMessageBlock,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigNeedUpdate,sendSystem,&SendSystem::sendNeedUpdate,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigSendNotify,sendSystem,&SendSystem::sendNotify,Qt::AutoConnection);
|
||||
@@ -129,11 +129,6 @@ void ClientHandler::sendDeleteBlock(QString path)
|
||||
emit sigSendDeleteBlock(path);
|
||||
}
|
||||
|
||||
void ClientHandler::sendFinish()
|
||||
{
|
||||
emit sigSendFinish(PacketType::TYPE_FINISH);
|
||||
}
|
||||
|
||||
void ClientHandler::sendMessageBlock(QString text)
|
||||
{
|
||||
emit sigSendMessageBlock(text);
|
||||
|
||||
@@ -57,7 +57,6 @@ signals:
|
||||
void sigFileBlockByteArray(QByteArray array, PacketType packetType);
|
||||
bool sigGetIsSendStopped();
|
||||
void sigSendDeleteBlock(QString path);
|
||||
void sigSendFinish(PacketType packetType);
|
||||
void sigSendMessageBlock(QString text);
|
||||
void sigNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount);
|
||||
void sigClientDisconnected(QString address,QString port);
|
||||
|
||||
@@ -56,6 +56,6 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
|
||||
emit sigSendToLogger("SERVER: Client " + login + " disconnected");
|
||||
|
||||
serverLmsWidget->slotUpdateListClients();
|
||||
serverLmsWidget->autorizationHandler(login);
|
||||
serverLmsWidget->getProcessingSystem()->processingClientDeAutorization(login);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "serverlmswidget.h"
|
||||
#include "ui_serverlmswidget.h"
|
||||
|
||||
|
||||
ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ServerLMSWidget),
|
||||
@@ -84,20 +83,6 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
||||
qDebug() << "MAIN THREAD: " << QThread::currentThreadId();
|
||||
}
|
||||
|
||||
void ServerLMSWidget::autorizationHandler(QString login)
|
||||
{
|
||||
//Отмена авторизации в БД
|
||||
|
||||
if(providerDBLMS->deAuthorizationTrainee(login))
|
||||
{//Деавторизовался обучаемый
|
||||
|
||||
}
|
||||
else if(providerDBLMS->deAuthorizationInstructor(login))
|
||||
{//Деавторизовался инструктор
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ServerLMSWidget::setError(int code)
|
||||
{
|
||||
errorCode = code;
|
||||
@@ -152,7 +137,7 @@ bool ServerLMSWidget::stopServer()
|
||||
emit sigLog("To Client: " + str);
|
||||
|
||||
//slotDisconnectClient(clientsMap[idSocket]->get, QString peerPort)
|
||||
autorizationHandler(clientsMap[idSocket]->getClient()->getLogin());
|
||||
processingSystem->processingClientDeAutorization(clientsMap[idSocket]->getClient()->getLogin());
|
||||
|
||||
clientsMap[idSocket]->sigSocketClose();
|
||||
//clientsMap.remove(idSocket);
|
||||
@@ -232,7 +217,6 @@ void ServerLMSWidget::slotAddToLog(QString msg)
|
||||
ui->listWidgetLogger->scrollToBottom();
|
||||
}
|
||||
|
||||
|
||||
void ServerLMSWidget::on_btnStartServer_clicked()
|
||||
{
|
||||
if(startServer())
|
||||
|
||||
@@ -47,10 +47,8 @@ public:
|
||||
explicit ServerLMSWidget(QWidget *parent = nullptr);
|
||||
~ServerLMSWidget();
|
||||
|
||||
void autorizationHandler(QString login);
|
||||
void setError(int code);
|
||||
|
||||
|
||||
protected:
|
||||
// Метод получения событий
|
||||
// В нём будет производиться проверка события смены перевода приложения
|
||||
@@ -134,7 +132,6 @@ private:
|
||||
|
||||
QTranslator qtLanguageTranslator;
|
||||
int errorCode;
|
||||
|
||||
};
|
||||
|
||||
#endif // SERVERLMSWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user