mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
feat: add update scenario
This commit is contained in:
@@ -114,6 +114,7 @@ void CommonClientHandler::slot_sendPacketToAllClients(PacketType packetType)
|
||||
if (!handler->getClient()->getIsLoggedIn()) continue;
|
||||
|
||||
handler->sendPacketType(packetType);
|
||||
Logger::instance().log("AllSending " + handler->getClient()->getLogin() + " " + enumToString(packetType));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ bool DocsUpdater::updateDocsXML()
|
||||
{
|
||||
QMutexLocker locker(&mtxAccess);
|
||||
|
||||
QString nameDocsFile = tasksAMMfileName;
|
||||
QString nameDocsFile = tasksAMMfileName; //кручу верчу запутать хочу!
|
||||
QString pathDocsFile = updateController->getPathAdditionalFile(nameDocsFile);
|
||||
|
||||
QDomDocument docTasksDOM;
|
||||
|
||||
@@ -50,9 +50,11 @@ void FastHashCalculator::calculateHashes(QString path)
|
||||
QFileInfo fileInfo = fileIterator.fileInfo();
|
||||
QString path = fileInfo.absoluteFilePath();
|
||||
|
||||
//фильтры
|
||||
if (fileInfo.isHidden()) continue;
|
||||
if (!fileInfo.isFile()) continue;
|
||||
if (fileInfo.fileName().contains(".meta")) continue;
|
||||
if (fileInfo.fileName() == "docs.xml") continue;
|
||||
|
||||
files.append(path);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,6 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien
|
||||
client->sendXmlAnswer(arrayAnswer);
|
||||
|
||||
QString str = QString(arrayAnswer);
|
||||
Logger::instance().log("To Client: " + str);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -597,8 +595,6 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif
|
||||
{
|
||||
chatSystem->sendOldMessages(clientData->getId());
|
||||
}
|
||||
|
||||
Logger::instance().log(clientData->getLogin() + " notifyCode " + clientNotify.Code,LogLevel::DEBUG);
|
||||
}
|
||||
|
||||
void ProcessingSystem::setCurrentDataInfo(DataInfo *dataInfo)
|
||||
|
||||
@@ -28,6 +28,8 @@ void RecognizeSystem::initialize(UpdateController *updateController,DataParser*
|
||||
connect(this,&RecognizeSystem::sigDeleteVersion,updateController,&UpdateController::deleteAssetVersion,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigCopyVersion,updateController,&UpdateController::createCopyVersion,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigXmlParser,dataParser->getProcessParser(),&ProcessParser::slot_read,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigRecalculateDocs,server,&ServerLMSWidget::slot_UpdateDocs,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigSendDocs,sendSystem,&SendSystem::sendDocs,Qt::AutoConnection);
|
||||
|
||||
qDebug() << "Recognize init thread ID " << QThread::currentThreadId();
|
||||
}
|
||||
@@ -70,8 +72,7 @@ void RecognizeSystem::recognize()
|
||||
if (packetType != PacketType::TYPE_NONE)
|
||||
{
|
||||
QString result = enumToString(packetType);
|
||||
Logger::instance().log(client->getLogin() +
|
||||
" RECEIVE pack " +
|
||||
Logger::instance().log("RECEIVE FROM: " + client->getLogin() + " " +
|
||||
result ,LogLevel::DEBUG);
|
||||
//секция на случай прихода неизвестного пакета
|
||||
if(result == "Unknown")
|
||||
@@ -111,7 +112,7 @@ void RecognizeSystem::recognize()
|
||||
sendSystem->updateFiles(updateController->getFileSendList(),
|
||||
updateController->getFileDeleteList());
|
||||
|
||||
qDebug()<< "Call update";
|
||||
qDebug()<< "Call update no docs";
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
@@ -140,6 +141,7 @@ void RecognizeSystem::recognize()
|
||||
|
||||
qDebug() << data;
|
||||
emit sigXmlParser(clientHandler,data);
|
||||
Logger::instance().log(" Text " + QString(data), LogLevel::DEBUG);
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
continue;
|
||||
}
|
||||
@@ -373,12 +375,6 @@ void RecognizeSystem::recognize()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (packetType == PacketType::TYPE_FINISH)
|
||||
{
|
||||
emit sigCalculateHash();
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
if(packetType == PacketType::CHANGE_DATA_VERSION)
|
||||
{
|
||||
stream.startTransaction();
|
||||
@@ -447,6 +443,22 @@ void RecognizeSystem::recognize()
|
||||
clientHandler->sendDisable();
|
||||
}
|
||||
|
||||
if(packetType == PacketType::RECALCULATE_DOCS)
|
||||
{
|
||||
emit sigCalculateHash();
|
||||
emit sigRecalculateDocs();
|
||||
}
|
||||
|
||||
if(packetType == PacketType::GET_DOCS)
|
||||
{
|
||||
emit sigSendDocs(updateController->getPathAdditionalFile(tasksAMMfileName));
|
||||
}
|
||||
|
||||
// if(packetType == PacketType::RECALCULATE_HASH)
|
||||
// {
|
||||
// emit sigCalculateHash();
|
||||
// }
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ signals:
|
||||
void sigChangeVersion(QString versionName);
|
||||
void sigDeleteVersion(QString versionName);
|
||||
void sigCopyVersion(QString versionName,QString newVersionName,QString author);
|
||||
void sigRecalculateDocs();
|
||||
void sigSendDocs(QString docsPath);
|
||||
|
||||
private:
|
||||
UpdateController *updateController;
|
||||
|
||||
@@ -211,7 +211,7 @@ void SendSystem::sendDeleteBlock(QString path)
|
||||
|
||||
void SendSystem::sendPacketType(PacketType packetType)
|
||||
{
|
||||
Logger::instance().log("C: " + client->getLogin() + " send pack " + enumToString(packetType), LogLevel::DEBUG);
|
||||
Logger::instance().log(" SEND TO: " + client->getLogin() + " " + enumToString(packetType), LogLevel::DEBUG);
|
||||
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
||||
client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
||||
{
|
||||
@@ -238,8 +238,8 @@ void SendSystem::sendHello()
|
||||
void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType)
|
||||
{
|
||||
qDebug() << "SendSystemThread: " << QThread::currentThreadId();
|
||||
Logger::instance().log("C: " + client->getLogin() + " send pack " + enumToString(packetType) +
|
||||
" " + QString::fromUtf8(array),LogLevel::DEBUG);
|
||||
Logger::instance().log("SEND TO: "+ client->getLogin() + " " + enumToString(packetType) + "\n Text: " +
|
||||
QString(array),LogLevel::DEBUG);
|
||||
|
||||
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
||||
client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
||||
@@ -312,9 +312,10 @@ void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> delet
|
||||
}
|
||||
}
|
||||
|
||||
sendPacketType(PacketType::TYPE_FINISH);
|
||||
sendPacketType(PacketType::TYPE_LOADING_FINISH_WITHOUT_DOCS);
|
||||
}
|
||||
|
||||
|
||||
void SendSystem::socketClose()
|
||||
{
|
||||
socket->close();
|
||||
@@ -330,6 +331,12 @@ void SendSystem::sendStop()
|
||||
isSendStopped = true;
|
||||
}
|
||||
|
||||
void SendSystem::sendDocs(QString docsPath)
|
||||
{
|
||||
sendFileBlock(docsPath);
|
||||
sendPacketType(PacketType::TYPE_FULL_LOADING_FINISH);
|
||||
}
|
||||
|
||||
bool SendSystem::getIsSendStopped() const
|
||||
{
|
||||
return isSendStopped;
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
void sendHello();
|
||||
void sendNotify(QString notify);
|
||||
void sendStop();
|
||||
void sendDocs(QString docPath);
|
||||
void sendXmlAnswer(QByteArray array, PacketType packetType = PacketType::TYPE_XMLANSWER);
|
||||
void sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount);
|
||||
void updateFiles(QList<FileData> fileSendList, QList<FileData> deleteList);
|
||||
@@ -42,6 +43,7 @@ public:
|
||||
~SendSystem();
|
||||
|
||||
|
||||
void updateFilesFULL(QList<FileData> fileSendList, QList<FileData> deleteList);
|
||||
public slots:
|
||||
void socketClose();
|
||||
void sendVersion();
|
||||
|
||||
@@ -46,6 +46,7 @@ void UpdateController::changeAssetVersion(QString versionName)
|
||||
qDebug() << "UpdateController thread ID " << QThread::currentThreadId();
|
||||
currentStreamingPath = assetManager->setVersion(versionName);
|
||||
setUpCurrentServerHash();
|
||||
emit sigUpdateDocs();
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY);
|
||||
commonClientHandler->sendCurrentVersionToAllClient();
|
||||
|
||||
@@ -107,7 +108,7 @@ void UpdateController::calculateFullHash()
|
||||
|
||||
void UpdateController::calculateFullHashWithSetup()
|
||||
{
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_CALCULATE_START);
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::RECALCULATE_HASH);
|
||||
calculateCurrentSharedHash();
|
||||
setUpCurrentServerHash();
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY);
|
||||
@@ -259,6 +260,7 @@ bool UpdateController::checkNeedUpdate(ClientHandler *handler)
|
||||
for (auto &item:clientDataList) //проверка на недостающие файлы по адресам
|
||||
{
|
||||
if(item.path.contains("Temp")) continue;
|
||||
if(item.path.contains("docs.xml")) continue;
|
||||
|
||||
if (!serverDataList.contains(item))
|
||||
{
|
||||
@@ -269,6 +271,7 @@ bool UpdateController::checkNeedUpdate(ClientHandler *handler)
|
||||
for (auto &item:serverDataList)
|
||||
{
|
||||
if(item.path.contains("Temp")) continue;
|
||||
if(item.path.contains("docs.xml")) continue;
|
||||
|
||||
if (!clientDataList.contains(item))
|
||||
{
|
||||
|
||||
@@ -68,6 +68,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void sigErrorRequired(int code);
|
||||
void sigUpdateDocs();
|
||||
|
||||
private:
|
||||
QList<FileData> clientDataList;
|
||||
|
||||
Reference in New Issue
Block a user