feat: load to server block

This commit is contained in:
semenov
2025-01-17 16:47:22 +03:00
parent 4b9ee1738a
commit 91a4b04f05
11 changed files with 99 additions and 17 deletions

View File

@@ -6,6 +6,8 @@ kanban-plugin: board
## backLog ## backLog
- [ ] окошко с выбором перенести в GUI
- [ ] Клиент НЕ СМОЖЕТ ВЫБИРАТЬ ВЕРСИИ
## bugs ## bugs
@@ -24,6 +26,7 @@ kanban-plugin: board
- [ ] Иерархия проекта - папка application, папка updater и линк на основной экзешник - [ ] Иерархия проекта - папка application, папка updater и линк на основной экзешник
- [ ] на старте все мониторы должны быть активны - [ ] на старте все мониторы должны быть активны
- [ ] Нужен ли дополнительный выбор для загрузки с мат моделью или нет? - [ ] Нужен ли дополнительный выбор для загрузки с мат моделью или нет?
- [ ] передавать полную версию в StreaminVerData
## feature server ## feature server

View File

@@ -13,6 +13,7 @@ public:
this->viewName = viewName; this->viewName = viewName;
this->createData = data; this->createData = data;
this->size = size; this->size = size;
this->isChangeable = true;
} }
~StreamingVersionData(); ~StreamingVersionData();
@@ -36,8 +37,15 @@ public:
return size; return size;
} }
bool getIsChangeable() const; bool getIsChangeable() const
void setIsChangeable(bool value); {
return isChangeable;
}
void setIsChangeable(bool value)
{
isChangeable = value;
}
private: private:
QString absolutePath; QString absolutePath;
@@ -48,13 +56,3 @@ private:
}; };
#endif // STREAMINGVERSIONDATA_H #endif // STREAMINGVERSIONDATA_H
bool StreamingVersionData::getIsChangeable() const
{
return isChangeable;
}
void StreamingVersionData::setIsChangeable(bool value)
{
isChangeable = value;
}

View File

@@ -239,6 +239,7 @@ void ProcessParser::clientMessage(QXmlStreamReader &xmlReader,ClientHandler *cli
} }
processingSystem->processingFromClientMessage(client, clientMessage); processingSystem->processingFromClientMessage(client, clientMessage);
} }
void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *client) void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *client)
@@ -255,6 +256,8 @@ void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *clie
clientNotify.Code = value; clientNotify.Code = value;
} }
processingSystem->processingClientNotify(client, clientNotify); processingSystem->processingClientNotify(client, clientNotify);
} }

View File

@@ -8,11 +8,16 @@ ProcessingSystem::ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent
this->providerDBLMS = providerDBLMS; this->providerDBLMS = providerDBLMS;
} }
void ProcessingSystem::initialize(ServerLMSWidget *server, DataParser *dataParser, CommonClientHandler *commonClientHandler,Logger *logger) void ProcessingSystem::initialize(ServerLMSWidget *server,
DataParser *dataParser,
CommonClientHandler *commonClientHandler,
Logger *logger,
UpdateController *updateController)
{ {
this->commonClientServer = commonClientHandler; this->commonClientServer = commonClientHandler;
this->dataParser = dataParser; this->dataParser = dataParser;
this->server = server; this->server = server;
this->updateController = updateController;
connect(this,&ProcessingSystem::sigAuthChanged,commonClientHandler, &CommonClientHandler::slot_AuthChanged,Qt::AutoConnection); connect(this,&ProcessingSystem::sigAuthChanged,commonClientHandler, &CommonClientHandler::slot_AuthChanged,Qt::AutoConnection);
connect(this,&ProcessingSystem::sigUpdateListClients,server, &ServerLMSWidget::slotUpdateListClients,Qt::AutoConnection); connect(this,&ProcessingSystem::sigUpdateListClients,server, &ServerLMSWidget::slotUpdateListClients,Qt::AutoConnection);
@@ -278,6 +283,18 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif
{ {
client->sendVersionList(); client->sendVersionList();
} }
else if(clientNotify.Code == commandCanChangeVersion)
{
if (updateController->getCurrentVersion()->getIsChangeable())
{
client->sigSendNotify(commandChangable);
}
else
{
client->sigSendNotify(commandUnchangable);
}
}
} }

View File

@@ -23,7 +23,12 @@ class ProcessingSystem : public QObject
public: public:
explicit ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent = nullptr); explicit ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent = nullptr);
void initialize(ServerLMSWidget *server,DataParser* dataParser,CommonClientHandler *commonClientServer,Logger *logger); void initialize(ServerLMSWidget *server,
DataParser* dataParser,
CommonClientHandler *commonClientServer,
Logger *logger,
UpdateController *updateComtroller);
void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization); void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization);
void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization); void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization);
void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr); void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr);
@@ -44,7 +49,7 @@ private:
CommonClientHandler *commonClientServer; CommonClientHandler *commonClientServer;
ServerLMSWidget *server; ServerLMSWidget *server;
DataParser *dataParser; DataParser *dataParser;
//InstructorsAndTraineesWidget *pInstructorsAndTrainees; UpdateController *updateController;
ProviderDBLMS* providerDBLMS; ProviderDBLMS* providerDBLMS;
}; };

View File

@@ -168,6 +168,16 @@ void RecognizeSystem::recognize()
QFile file(filePath); QFile file(filePath);
// //ПРОВЕРКА НА ИЗМЕНЕНИЕ БАЗОВОЙ ВЕРСИИ
// bool check = checkIsChangeable();
// bool check2 = checkNonStaticData(filePath);
// if(!check && check2)
// {
// packetType = PacketType::TYPE_NONE;
// sendSystem->sendNotify(commandTryBaseChange);
// mutex->unlock();
// return;
// }
if (file.exists()) if (file.exists())
{ {
@@ -239,6 +249,17 @@ void RecognizeSystem::recognize()
break; break;
} }
// //ПРОВЕРКА НА ИЗМЕНЕНИЕ БАЗОВОЙ ВЕРСИИ
// bool check = checkIsChangeable();
// bool check2 = checkNonStaticData(filePath);
// if(!check && check2)
// {
// sendSystem->sendNotify(commandTryBaseChange);
// packetType = PacketType::TYPE_NONE;
// mutex->unlock();
// return;
// }
QFile file(filePath); QFile file(filePath);
QFileInfo fileInfo(file); QFileInfo fileInfo(file);
@@ -412,6 +433,18 @@ QString RecognizeSystem::createFullPath(QString path)
return fullPath; return fullPath;
} }
bool RecognizeSystem::checkIsChangeable()
{
return updateController->getCurrentVersion()->getIsChangeable();
}
bool RecognizeSystem::checkNonStaticData(QString path)
{
if(path.contains(sharedDataFolderName)) return true;
return false;
}
RecognizeSystem::~RecognizeSystem() RecognizeSystem::~RecognizeSystem()
{ {

View File

@@ -61,5 +61,7 @@ private:
void packetTypeInit(PacketType packet,Client *client); void packetTypeInit(PacketType packet,Client *client);
void packetTypeInit(PacketType type); void packetTypeInit(PacketType type);
QString createFullPath(QString path); QString createFullPath(QString path);
bool checkIsChangeable();
bool checkNonStaticData(QString path);
}; };
#endif // RECOGNIZESYSTEM_H #endif // RECOGNIZESYSTEM_H

View File

@@ -27,6 +27,7 @@ static const QString clientHash = staticDataFolderName + "/clientHash.xml";
static const QString baseNameVersion = "base";//может вынести комманды куда нибудь? static const QString baseNameVersion = "base";//может вынести комманды куда нибудь?
static const QString commandTryBaseDelete = "BASEDELETETRY"; static const QString commandTryBaseDelete = "BASEDELETETRY";
static const QString commandTryBaseChange = "TRYBASECHANGE";
static const QString commandTryActiveDelete = "TRYACTIVEDELETE"; static const QString commandTryActiveDelete = "TRYACTIVEDELETE";
static const QString commandTryCopyWithSameNames = "SAMENAMES"; static const QString commandTryCopyWithSameNames = "SAMENAMES";
static const QString commandGetServerDataList = "GETSERVERDATALIST"; static const QString commandGetServerDataList = "GETSERVERDATALIST";
@@ -35,6 +36,9 @@ static const QString commandReadyClient = "READY";
static const QString commandDisableClient = "DISABLE"; static const QString commandDisableClient = "DISABLE";
static const QString commandDuplicateVerName = "DUPLICATEVERNAME"; static const QString commandDuplicateVerName = "DUPLICATEVERNAME";
static const QString commandHashCompleteClient = "HASHSENDCOMPLETE"; static const QString commandHashCompleteClient = "HASHSENDCOMPLETE";
static const QString commandCanChangeVersion = "CANCHANGE";
static const QString commandChangable = "CHANGEABLE";
static const QString commandUnchangable = "UNCHANGEABLE";
static const QString commandUpdateFilesClient = "update"; static const QString commandUpdateFilesClient = "update";
class Tools { class Tools {

View File

@@ -431,6 +431,15 @@ void UpdateController::calculateSharedHash()
fileInfo.absoluteFilePath(),fileInfo.fileName(), fileInfo.absoluteFilePath(),fileInfo.fileName(),
fileInfo.birthTime(),fileInfo.size()); fileInfo.birthTime(),fileInfo.size());
if(fileInfo.fileName() == baseNameVersion)
{
version->setIsChangeable(false);
}
else
{
version->setIsChangeable(true);
}
versionList->append(version); versionList->append(version);
} }
@@ -447,8 +456,9 @@ void UpdateController::createVersionListXmlAnswer(QList<StreamingVersionData *>
{ {
SAttribute attribute1 = {"Version", ver->getViewName()}; SAttribute attribute1 = {"Version", ver->getViewName()};
SAttribute attribute2 = {"Created", ver->getCreateData().toString()}; SAttribute attribute2 = {"Created", ver->getCreateData().toString()};
SAttribute attribute3 = {"isChangeable",QString::number(ver->getIsChangeable())};
QList<SAttribute> listAttr = {attribute1, attribute2}; QList<SAttribute> listAttr = {attribute1, attribute2,attribute3};
SXmlAnswerTag tag = {"VersionData", listAttr}; SXmlAnswerTag tag = {"VersionData", listAttr};
listTag.append(tag); listTag.append(tag);
@@ -492,6 +502,7 @@ void UpdateController::saveVersionToFile(StreamingVersionData *streamingVersion)
xmlWriter.writeStartElement("VersionData"); xmlWriter.writeStartElement("VersionData");
xmlWriter.writeAttribute("Version",streamingVersion->getViewName()); xmlWriter.writeAttribute("Version",streamingVersion->getViewName());
xmlWriter.writeAttribute("Created",streamingVersion->getCreateData().toString()); xmlWriter.writeAttribute("Created",streamingVersion->getCreateData().toString());
xmlWriter.writeAttribute("isChangeable",QString::number(streamingVersion->getIsChangeable()));
xmlWriter.writeEndElement(); xmlWriter.writeEndElement();
xmlWriter.writeEndDocument(); xmlWriter.writeEndDocument();
@@ -543,6 +554,11 @@ void UpdateController::xmlFileDataParse(QByteArray array)
} }
} }
StreamingVersionData* UpdateController::getCurrentVersion()
{
return assetManager->getCurrentVersionData();
}
void UpdateController::printFileList(QList<FileData> fileData) void UpdateController::printFileList(QList<FileData> fileData)
{ {
QListIterator<FileData> iterator(fileData); QListIterator<FileData> iterator(fileData);

View File

@@ -54,6 +54,7 @@ public:
void createVersionListXmlAnswer(QList<StreamingVersionData *> version); void createVersionListXmlAnswer(QList<StreamingVersionData *> version);
void saveVersionToFile(StreamingVersionData *streamingVersion); void saveVersionToFile(StreamingVersionData *streamingVersion);
void xmlFileDataParse(QByteArray array); void xmlFileDataParse(QByteArray array);
StreamingVersionData *getCurrentVersion();
public slots: public slots:
void changeAssetVersion(QString versionName); void changeAssetVersion(QString versionName);
void createCopyVersion(QString versionName,QString newVersionName); void createCopyVersion(QString versionName,QString newVersionName);

View File

@@ -70,7 +70,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
updateThread->start(); updateThread->start();
commonClientHandler->initialize(&clientsMap,processingSystem,dataParser,logger); commonClientHandler->initialize(&clientsMap,processingSystem,dataParser,logger);
processingSystem->initialize(this,dataParser,commonClientHandler,logger); processingSystem->initialize(this,dataParser,commonClientHandler,logger,updateController);
logger->setTypeLog("widget"); logger->setTypeLog("widget");