mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Merge branch 'scenario-updater' into DEV
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;
|
||||
}
|
||||
|
||||
@@ -594,8 +592,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,13 +28,15 @@ 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();
|
||||
}
|
||||
|
||||
void RecognizeSystem::recognize()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
QMutexLocker locker(mutex);
|
||||
qDebug() << "Recognize thread ID " << QThread::currentThreadId();
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
@@ -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")
|
||||
@@ -107,20 +108,17 @@ void RecognizeSystem::recognize()
|
||||
|
||||
if (packetType == PacketType::TYPE_UPDATE)
|
||||
{
|
||||
QList<FileData> sendList = updateController->prepareRealPathList(client->getFileSendList());
|
||||
sendSystem->updateFiles(sendList,
|
||||
client->getFileDeleteList());
|
||||
|
||||
sendSystem->updateFiles(updateController->getFileSendList(),
|
||||
updateController->getFileDeleteList());
|
||||
|
||||
qDebug()<< "Call update";
|
||||
qDebug()<< "Call update no docs";
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
if(packetType == PacketType::TYPE_CHECK_VERSION)
|
||||
{
|
||||
QFile checkFile(clientHash);
|
||||
checkFile.open(QIODevice::ReadOnly);
|
||||
updateController->compareFiles(clientHandler,checkFile.readAll());
|
||||
checkFile.close();
|
||||
updateController->compareFiles(clientHandler,client->getClientHash());
|
||||
}
|
||||
|
||||
if (packetType == PacketType::TYPE_XMLANSWER)
|
||||
@@ -140,6 +138,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 +372,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 +440,71 @@ 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::SEND_HASH)
|
||||
{
|
||||
QByteArray hash;
|
||||
|
||||
forever
|
||||
{
|
||||
stream.startTransaction();
|
||||
stream >> fileSize;
|
||||
|
||||
if(!stream.commitTransaction()) continue;
|
||||
socket->waitForReadyRead(100);
|
||||
break;
|
||||
}
|
||||
|
||||
forever
|
||||
{
|
||||
stream.startTransaction();
|
||||
stream >> tmpBlock;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
|
||||
if(socket->state() == QAbstractSocket::UnconnectedState){
|
||||
qDebug() << "UNCONNECT";
|
||||
//mutex->unlock();
|
||||
return;
|
||||
}
|
||||
if(socket->waitForReadyRead(100)){
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
hash += tmpBlock;
|
||||
sizeReceiveData += tmpBlock.length();
|
||||
countSend++;
|
||||
|
||||
tmpBlock.clear();
|
||||
|
||||
if(sizeReceiveData == fileSize) break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
QString logMessage = "Load from " + client->getLogin() + " ";
|
||||
|
||||
filePath.clear();
|
||||
fileSize = 0;
|
||||
tmpBlock.clear();
|
||||
sizeReceiveData = 0;
|
||||
countSend = 0;
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
client->setClientHash(hash);
|
||||
}
|
||||
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)
|
||||
@@ -311,10 +311,10 @@ void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> delet
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sendPacketType(PacketType::TYPE_FINISH);
|
||||
sendPacketType(PacketType::UPDATE_FILES_COMPLETE);
|
||||
}
|
||||
|
||||
|
||||
void SendSystem::socketClose()
|
||||
{
|
||||
socket->close();
|
||||
@@ -330,6 +330,11 @@ void SendSystem::sendStop()
|
||||
isSendStopped = true;
|
||||
}
|
||||
|
||||
void SendSystem::sendDocs(QString docsPath)
|
||||
{
|
||||
sendFileBlock(docsPath);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@@ -29,7 +29,7 @@ static const QString buildHashName = staticDataFolderName + "/buildHash.xml";
|
||||
static const QString buildDataPath = "/Application/" + projectFolderName + "/RRJ_Data/";
|
||||
static const QString tasksAMMfileName = "/docs.xml"; //"/tasksAmm.xml";
|
||||
static const QString tasksFIMfileName = "/tasksFIM.xml";
|
||||
static const QString clientHash = staticDataFolderName + "/clientHash.xml";
|
||||
//static const QString clientHash = staticDataFolderName + "/clientHash.xml";
|
||||
static const QString logFolderPath = "log";
|
||||
|
||||
static const QString configFolderName = "config";
|
||||
|
||||
@@ -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);
|
||||
@@ -240,6 +241,11 @@ QString UpdateController::getCurrentStreamingPath() const
|
||||
return currentStreamingPath;
|
||||
}
|
||||
|
||||
QList<FileData> UpdateController::prepareRealPathList(QList<FileData> fileData)
|
||||
{
|
||||
return *assetManager->prepareRealPathList(&fileData);
|
||||
}
|
||||
|
||||
void UpdateController::setLocalFileData(QList<FileData> dataList)
|
||||
{
|
||||
serverDataList.append(dataList);
|
||||
@@ -249,9 +255,8 @@ bool UpdateController::checkNeedUpdate(ClientHandler *handler)
|
||||
{
|
||||
QList<FileData> *forSend = new QList<FileData>;
|
||||
QList<FileData> *forDelete = new QList<FileData>;
|
||||
Client *client = handler->getClient();
|
||||
|
||||
fileSendList.clear();
|
||||
fileDeleteList.clear();
|
||||
sizeToSend = 0;
|
||||
|
||||
bool needUpdate = false;
|
||||
@@ -259,6 +264,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 +275,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))
|
||||
{
|
||||
@@ -279,45 +286,38 @@ bool UpdateController::checkNeedUpdate(ClientHandler *handler)
|
||||
if(forSend->length() > 0) //формирование сообщения об обновлении
|
||||
{
|
||||
QString log;
|
||||
log.append(" Client: " + handler->getClient()->getLogin());
|
||||
log.append(" Client: " + client->getLogin());
|
||||
log.append(" Need updates: ");
|
||||
log.append(QString::number(forSend->length()));
|
||||
log.append(" objects");
|
||||
fileSendList = *forSend;
|
||||
|
||||
client->setFileSendList(*forSend);
|
||||
Logger::instance().log(log);
|
||||
//printFileList(*forSend);
|
||||
|
||||
//handler->sendMessageBlock(log);
|
||||
needUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString log;
|
||||
log.append(" Client: " + handler->getClient()->getLogin());
|
||||
log.append(" Client: " + client->getLogin());
|
||||
log.append(" no update required");
|
||||
Logger::instance().log(log);
|
||||
//handler->sendMessageBlock(log);
|
||||
}
|
||||
|
||||
if(forDelete->length() > 0){
|
||||
QString log;
|
||||
log.append(" Client: " + handler->getClient()->getLogin());
|
||||
log.append(" Client: " + client->getLogin());
|
||||
|
||||
log.append(" Need delete: ");
|
||||
log.append(QString::number(forDelete->length()));
|
||||
log.append(" objects");
|
||||
fileDeleteList = *forDelete;
|
||||
client->setFileDeleteList(*forDelete);
|
||||
|
||||
Logger::instance().log(log);
|
||||
//printFileList(*forDelete);
|
||||
//handler->sendMessageBlock(log);
|
||||
needUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString log;
|
||||
log.append(" Client: " + handler->getClient()->getLogin());
|
||||
log.append(" Client: " + client->getLogin());
|
||||
log.append(" no delete required");
|
||||
|
||||
Logger::instance().log(log);
|
||||
@@ -326,6 +326,7 @@ bool UpdateController::checkNeedUpdate(ClientHandler *handler)
|
||||
|
||||
CalculateSizeToSend(*forSend);
|
||||
handler->sendNeedUpdate(needUpdate,sizeToSend,forSend->length(),forDelete->length());
|
||||
|
||||
return needUpdate;
|
||||
}
|
||||
|
||||
@@ -547,6 +548,8 @@ void UpdateController::xmlFileDataParse(QByteArray array)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
StreamingVersionData* UpdateController::getCurrentVersion()
|
||||
{
|
||||
return assetManager->getCurrentVersionData();
|
||||
@@ -563,18 +566,6 @@ void UpdateController::printFileList(QList<FileData> fileData)
|
||||
}
|
||||
}
|
||||
|
||||
QList<FileData> UpdateController::getFileDeleteList() const
|
||||
{
|
||||
return fileDeleteList;
|
||||
}
|
||||
|
||||
QList<FileData> UpdateController::getFileSendList()
|
||||
{
|
||||
QList<FileData> *copy = new QList<FileData>(fileSendList);
|
||||
QList<FileData> sendList = *assetManager->prepareRealPathList(copy);
|
||||
return sendList;
|
||||
}
|
||||
|
||||
QList<FileData> UpdateController::getClientDataList() const
|
||||
{
|
||||
return clientDataList;
|
||||
|
||||
@@ -43,10 +43,9 @@ public:
|
||||
QByteArray getLocalHash();
|
||||
|
||||
QString getCurrentVersionName();
|
||||
QList<FileData> getFileSendList();
|
||||
QList<FileData> getClientDataList() const;
|
||||
QList<FileData> getFileDeleteList() const;
|
||||
QString getCurrentStreamingPath() const;
|
||||
QList<FileData> prepareRealPathList(QList<FileData> fileData);
|
||||
|
||||
~UpdateController();
|
||||
|
||||
@@ -68,14 +67,12 @@ public slots:
|
||||
|
||||
signals:
|
||||
void sigErrorRequired(int code);
|
||||
void sigUpdateDocs();
|
||||
|
||||
private:
|
||||
QList<FileData> clientDataList;
|
||||
QList<FileData> serverDataList;
|
||||
|
||||
QList<FileData> fileSendList;
|
||||
QList<FileData> fileDeleteList;
|
||||
|
||||
DataInfo *dataInfo;
|
||||
|
||||
QString buildPath;
|
||||
|
||||
Reference in New Issue
Block a user