feat: add send scenario

This commit is contained in:
semenov
2025-11-18 12:04:31 +03:00
parent b706de2961
commit 4829647e98
17 changed files with 15980 additions and 6952 deletions

View File

@@ -25,11 +25,12 @@ void UpdateController::calculateCommonHash()
QElapsedTimer timer;
timer.start();
qDebug() << "Start calculate... ";
//appDataList = calculateHash(applicationFolderPath,"StreamingAssets");
hashCalculator->calculateHashes(applicationFolderPath,"StreamingAssets");
appDataList = *hashCalculator->getHashList();
calculateStreamingHash();
appDataList.append(streamingDataList);
qDebug() << "Hash count: " << appDataList.count() ;
dataParserOut->createFileDataList(appDataList,fullStaticDataFolderName + hashFilename);
qDebug() << "UpdateController threadID " << QThread::currentThreadId();
@@ -39,10 +40,8 @@ void UpdateController::calculateCommonHash()
void UpdateController::calculateStreamingHash()
{
streamingDataList.clear();
//streamingDataList = calculateHash(QDir::currentPath() + streamingAssetsPath,"");
hashCalculator->calculateHashes(QDir::currentPath() + streamingAssetsPath,"");
streamingDataList = *hashCalculator->getHashList();
//std::sort(streamingDataList.begin(),streamingDataList.end());
dataParserOut->createFileDataList(streamingDataList,streamingHashFilename);
}
@@ -147,8 +146,8 @@ void UpdateController::updateFilesOnServer(QList<FileData> *fileSendList){
}
calculateCommonHash();
sendSystem->sendFinish();
sendSystem->sendPacketType(PacketType::TYPE_FINISH);
sendSystem->sendPacketType(PacketType::RECALCULATE_DOCS);
emit sigUpdateComplete(true);
}
catch (...)

View File

@@ -20,6 +20,7 @@ void FastHashCalculator::calculateHashes(const QString& path, const QString& ign
QList<FileData> *folders = new QList<FileData>;
fullSize = Tools::convertFileSize(getDirectorySize(path),false);
//только папки
QDirIterator dirIterator(path,filter, QDir::AllEntries, QDirIterator::Subdirectories);
while (dirIterator.hasNext())
@@ -38,7 +39,7 @@ void FastHashCalculator::calculateHashes(const QString& path, const QString& ign
}
}
//только файлы
QDirIterator fileIterator(path,filter,QDir::Files | QDir::NoDotAndDotDot,QDirIterator::Subdirectories);
QList<QString> files;
@@ -67,6 +68,7 @@ void FastHashCalculator::calculateHashes(const QString& path, const QString& ign
currentFile.path = Tools::createLocalPath(filePath);
currentFile.hash = hash.toHex();
hashList->append(currentFile);
}).waitForFinished();

View File

@@ -25,6 +25,7 @@ void HashComparer::CompareDeltas(QList<FileData> *serverStreamingHash, QList<Fil
{
if(!serverStreamingHash->contains(item))
{
if (item.path.contains("docs.xml")) continue; //фильтр на docs
files->append(item);
}
}

View File

@@ -252,7 +252,6 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
if(packetType == PacketType::HASH_READY)
{
emit sigCheckUpdate();
//mainWindow->checkUpdate();
}
if(packetType == PacketType::HASH_CALCULATE_START)
@@ -270,6 +269,10 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
emit sigAnimationActivated(false);
}
if(packetType == PacketType::TYPE_XMLANSWER_DOCS_CHANGED)
{
emit sigSendPacketType(PacketType::GET_DOCS);
}
packetType = PacketType::TYPE_NONE;
}
}

View File

@@ -30,6 +30,7 @@ signals:
void sigAnimationActivated(bool flag);
void sigCheckUpdate();
void sigdRecalculateHashOnServerState();
void sigSendPacketType(PacketType packetType);
private:
VersionContainer *versionContainer;

View File

@@ -157,16 +157,6 @@ void SendSystem::sendXMLAnswer(const QByteArray& array)
qDebug() << "Send XML answer in byte";
}
void SendSystem::sendFinish()
{
socket->waitForReadyRead(100);
QDataStream stream(socket);
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
stream << PacketType::TYPE_FINISH;
socket->waitForReadyRead(100);
}
void SendSystem::sendPacketType(PacketType packetType)
{
QDataStream stream(socket);

View File

@@ -12,12 +12,12 @@ QString Tools::getTime()
QString Tools::createLocalPath(QString path)
{
qDebug() << "Full path: " << path;
//qDebug() << "Full path: " << path;
qint8 pos = path.indexOf("Application");
QString localPath = path.remove(0,--pos);
qDebug() << "Local path: " << localPath;
//qDebug() << "Local path: " << localPath;
return localPath;
}

View File

@@ -47,13 +47,17 @@ enum PacketType{
TYPE_UPDATE = 12,
TYPE_CHECK_VERSION = 13,
TYPE_XMLANSWER_DOCS_CHANGED = 132,
HASH_READY = 150,
CHANGE_DATA_VERSION = 151,
COPY_VERSION = 152,
DELETE_DATA_VERSION = 153,
BUSY = 154,
FREE = 155,
HASH_CALCULATE_START = 156
HASH_CALCULATE_START = 156,
RECALCULATE_DOCS = 157,
GET_DOCS = 158
};

View File

@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<AuthData Login="O1" Password="b59c67bf196a4758191e42f76670ceba" InstructorName="" ClientName="Коровин А.В." AccessType="trainee"/>
<AuthData Login="I1" Password="b59c67bf196a4758191e42f76670ceba" InstructorName="Петрушкин А.А." ClientName="Петрушкин А.А." AccessType="instructor"/>

File diff suppressed because it is too large Load Diff

8925
StaticData/serverHash.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<ServerSettingsContainer>
<ServerSettings Address="192.168.100.134" Port="6000" Language="RUS" AutoStart="0" DestPortMath="18003" LocalPortMath="18004" UseMathModel="1"/>
<VersionData Version="base" isChangable="1"/>
<ServerSettings AutoStart="0" DestPortMath="18003" Language="RUS" UseMathModel="1" Port="6000" Address="192.168.100.83" LocalPortMath="18004"/>
<VersionData Created="Пн ноя 17 15:59:34 2025" isChangable="1" Version="custom"/>
</ServerSettingsContainer>

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<ClientAutorization Login="O1" Password="b59c67bf196a4758191e42f76670ceba"/>
<ClientNotify Code="DISABLE"/>

View File

@@ -66,10 +66,11 @@ void CoreManager::binding()
connect(this,&CoreManager::sigInitializeClient,client,&TCPClient::initialize,Qt::AutoConnection);
connect(this,&CoreManager::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection);
connect(this,&CoreManager::sigSendCommand,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
connect(this,&CoreManager::sigSendPacketType,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
connect(this,&CoreManager::sigSendCheckUpdate,sendSystem,&SendSystem::sendCheckHash,Qt::AutoConnection);
connect(this,&CoreManager::sigSendXMLAnswer,sendSystem,&SendSystem::xmlAnswer,Qt::AutoConnection);
connect(this,&CoreManager::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
connect(this,&CoreManager::sigSendUpdateToServer,updateController,&UpdateController::checkCanUpdate,Qt::AutoConnection);
connect(this,&CoreManager::sigGetConnected,client,&TCPClient::getIsConnected);
connect(this,&CoreManager::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
@@ -89,6 +90,7 @@ void CoreManager::binding()
connect(recognizeSystem,&RecognizeSystem::sigNeedUpdate,this,&CoreManager::checkNeedUpdate,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigCheckUpdate,this,&CoreManager::checkUpdate,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigdRecalculateHashOnServerState,this,&CoreManager::recalculateState,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigSendPacketType,this,&CoreManager::sendPacketType,Qt::AutoConnection);
connect(hashComparer,&HashComparer::sigCallCheck,this,&CoreManager::checkUpdate);
connect(hashComparer,&HashComparer::sigHaveDelta,this,&CoreManager::checkUpdateInfo);
@@ -323,7 +325,7 @@ void CoreManager::undoCurrentChanges()
isRecovery = true;
widgetManager->setUndoCurrentChangesState();
emit sigSendCheckUpdate();
emit sigSendCommand(PacketType::TYPE_UPDATE);
emit sigSendPacketType(PacketType::TYPE_UPDATE);
//тут был таймер
isRecovery = false;
@@ -339,6 +341,11 @@ void CoreManager::startOffline()
startUnityClient();
}
void CoreManager::sendPacketType(PacketType packetType)
{
emit sigSendPacketType(packetType);
}
void CoreManager::saveServerSettingsWithConnect()
{
widgetManager->activateLoadingAnimation(true);

View File

@@ -39,6 +39,7 @@ public:
void startUnityClient();
void tryLogin();
void startOffline();
void sendPacketType(PacketType packetType);
void saveServerSettingsWithConnect();
@@ -50,7 +51,7 @@ public:
void recalculateState();
signals:
void sigInitializeClient(RecognizeSystem *recognize,SendSystem *sendSystem);
void sigSendCommand(PacketType packetType);
void sigSendPacketType(PacketType packetType);
void sigSendXMLAnswer(QString answer);
void sigSetConnect(ServerSettings* serverSettings);
void sigCalculateHash();
@@ -59,6 +60,7 @@ signals:
bool sigGetConnected();
void sigSendUpdateToServer();
void sigSetLoadSettings(ServerSettings *serverSettings);
private:

2
mathModelConfig.xml Normal file
View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<MathModelSettings SendIP="10.100.7.255" SendPortMath="18004" ListenIP="10.100.7.1" LocalPortMath="18003" />