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

View File

@@ -13,6 +13,7 @@ public:
this->viewName = viewName;
this->createData = data;
this->size = size;
this->isChangeable = true;
}
~StreamingVersionData();
@@ -36,8 +37,15 @@ public:
return size;
}
bool getIsChangeable() const;
void setIsChangeable(bool value);
bool getIsChangeable() const
{
return isChangeable;
}
void setIsChangeable(bool value)
{
isChangeable = value;
}
private:
QString absolutePath;
@@ -48,13 +56,3 @@ private:
};
#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);
}
void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *client)
@@ -255,6 +256,8 @@ void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *clie
clientNotify.Code = value;
}
processingSystem->processingClientNotify(client, clientNotify);
}

View File

@@ -8,11 +8,16 @@ ProcessingSystem::ProcessingSystem(ProviderDBLMS* providerDBLMS, QObject *parent
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->dataParser = dataParser;
this->server = server;
this->updateController = updateController;
connect(this,&ProcessingSystem::sigAuthChanged,commonClientHandler, &CommonClientHandler::slot_AuthChanged,Qt::AutoConnection);
connect(this,&ProcessingSystem::sigUpdateListClients,server, &ServerLMSWidget::slotUpdateListClients,Qt::AutoConnection);
@@ -278,6 +283,18 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif
{
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:
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 processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization);
void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr);
@@ -44,7 +49,7 @@ private:
CommonClientHandler *commonClientServer;
ServerLMSWidget *server;
DataParser *dataParser;
//InstructorsAndTraineesWidget *pInstructorsAndTrainees;
UpdateController *updateController;
ProviderDBLMS* providerDBLMS;
};

View File

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

View File

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

View File

@@ -27,6 +27,7 @@ static const QString clientHash = staticDataFolderName + "/clientHash.xml";
static const QString baseNameVersion = "base";//может вынести комманды куда нибудь?
static const QString commandTryBaseDelete = "BASEDELETETRY";
static const QString commandTryBaseChange = "TRYBASECHANGE";
static const QString commandTryActiveDelete = "TRYACTIVEDELETE";
static const QString commandTryCopyWithSameNames = "SAMENAMES";
static const QString commandGetServerDataList = "GETSERVERDATALIST";
@@ -35,6 +36,9 @@ static const QString commandReadyClient = "READY";
static const QString commandDisableClient = "DISABLE";
static const QString commandDuplicateVerName = "DUPLICATEVERNAME";
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";
class Tools {

View File

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

View File

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

View File

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