mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
refract Server 0
This commit is contained in:
@@ -9,12 +9,11 @@
|
|||||||
const QString DataBaseLMS::TypeUserDBInstructor = "instructor";
|
const QString DataBaseLMS::TypeUserDBInstructor = "instructor";
|
||||||
const QString DataBaseLMS::TypeUserDBTrainee = "trainee";
|
const QString DataBaseLMS::TypeUserDBTrainee = "trainee";
|
||||||
|
|
||||||
DataBaseLMS::DataBaseLMS(QWidget *ownerWidget, QObject *parent):
|
DataBaseLMS::DataBaseLMS(QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
db(nullptr),
|
db(nullptr),
|
||||||
UserNamePostgres(""),
|
UserNamePostgres(""),
|
||||||
PasswordPostgres(""),
|
PasswordPostgres("")
|
||||||
ownerWidget(ownerWidget)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class DATABASELMS_EXPORT DataBaseLMS : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataBaseLMS(QWidget *ownerWidget, QObject *parent = nullptr);
|
DataBaseLMS(QObject *parent = nullptr);
|
||||||
~DataBaseLMS();
|
~DataBaseLMS();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -132,9 +132,6 @@ protected:
|
|||||||
|
|
||||||
QString UserNamePostgres;
|
QString UserNamePostgres;
|
||||||
QString PasswordPostgres;
|
QString PasswordPostgres;
|
||||||
|
|
||||||
private:
|
|
||||||
QWidget* ownerWidget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATABASELMS_H
|
#endif // DATABASELMS_H
|
||||||
|
|||||||
@@ -4,9 +4,8 @@
|
|||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include "interfacedatabaselms.h"
|
#include "interfacedatabaselms.h"
|
||||||
|
|
||||||
InterfaceDataBaseLMS::InterfaceDataBaseLMS(QWidget *ownerWidget, QObject *parent):
|
InterfaceDataBaseLMS::InterfaceDataBaseLMS(QObject *parent):
|
||||||
DataBaseLMS(ownerWidget, parent),
|
DataBaseLMS(parent)
|
||||||
ownerWidget(ownerWidget)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
errAlreadyLogIn
|
errAlreadyLogIn
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
InterfaceDataBaseLMS(QWidget *ownerWidget, QObject *parent = nullptr);
|
InterfaceDataBaseLMS(QObject *parent = nullptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//Соединение
|
//Соединение
|
||||||
@@ -105,9 +105,6 @@ public:
|
|||||||
int replaceReportFIM(TaskAmmFim task);
|
int replaceReportFIM(TaskAmmFim task);
|
||||||
int changeStatusTaskFIM(int id_task, QString status);
|
int changeStatusTaskFIM(int id_task, QString status);
|
||||||
int changeStatusTaskAMM(int id_task, QString status);
|
int changeStatusTaskAMM(int id_task, QString status);
|
||||||
|
|
||||||
private:
|
|
||||||
QWidget* ownerWidget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTERFACEDATABASELMS_H
|
#endif // INTERFACEDATABASELMS_H
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ QString AssetsManager::setVersion(QString versionName)
|
|||||||
currentVersionData = version;
|
currentVersionData = version;
|
||||||
saveVersionToFile(currentVersionData);
|
saveVersionToFile(currentVersionData);
|
||||||
|
|
||||||
|
Logger::instance().log("Set Version of materials: " + versionName);
|
||||||
|
|
||||||
emit signal_setVersion(versionName);
|
emit signal_setVersion(versionName);
|
||||||
|
|
||||||
return version->getAbsolutPath();
|
return version->getAbsolutPath();
|
||||||
|
|||||||
@@ -13,12 +13,10 @@ QObject(parent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecognizeSystem::initialize(UpdateController *updateController,DataParser* dataParser,
|
void RecognizeSystem::initialize(UpdateController *updateController,DataParser* dataParser,SendSystem *sendSystem, ClientHandler *handler)
|
||||||
ServerLMSWidget *server,SendSystem *sendSystem, ClientHandler *handler)
|
|
||||||
{
|
{
|
||||||
this->updateController = updateController;
|
this->updateController = updateController;
|
||||||
this->dataParser = dataParser;
|
this->dataParser = dataParser;
|
||||||
this->server = server;
|
|
||||||
this->clientHandler = handler;
|
this->clientHandler = handler;
|
||||||
this->sendSystem = sendSystem;
|
this->sendSystem = sendSystem;
|
||||||
socket = handler->getSocket();
|
socket = handler->getSocket();
|
||||||
@@ -28,7 +26,7 @@ void RecognizeSystem::initialize(UpdateController *updateController,DataParser*
|
|||||||
connect(this,&RecognizeSystem::sigDeleteVersion,updateController,&UpdateController::deleteAssetVersion,Qt::AutoConnection);
|
connect(this,&RecognizeSystem::sigDeleteVersion,updateController,&UpdateController::deleteAssetVersion,Qt::AutoConnection);
|
||||||
connect(this,&RecognizeSystem::sigCopyVersion,updateController,&UpdateController::createCopyVersion,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::sigXmlParser,dataParser->getProcessParser(),&ProcessParser::slot_read,Qt::AutoConnection);
|
||||||
connect(this,&RecognizeSystem::sigRecalculateDocs,server,&ServerLMSWidget::slot_UpdateDocs,Qt::AutoConnection);
|
//connect(this,&RecognizeSystem::sigRecalculateDocs,server,&ServerLMSWidget::slot_UpdateDocs,Qt::AutoConnection);
|
||||||
connect(this,&RecognizeSystem::sigSendDocs,sendSystem,&SendSystem::sendDocs,Qt::AutoConnection);
|
connect(this,&RecognizeSystem::sigSendDocs,sendSystem,&SendSystem::sendDocs,Qt::AutoConnection);
|
||||||
|
|
||||||
qDebug() << "Recognize init thread ID " << QThread::currentThreadId();
|
qDebug() << "Recognize init thread ID " << QThread::currentThreadId();
|
||||||
@@ -448,7 +446,8 @@ void RecognizeSystem::recognize()
|
|||||||
if(packetType == PacketType::RECALCULATE_DOCS)
|
if(packetType == PacketType::RECALCULATE_DOCS)
|
||||||
{
|
{
|
||||||
emit sigCalculateHash();
|
emit sigCalculateHash();
|
||||||
emit sigRecalculateDocs();
|
//emit sigRecalculateDocs();
|
||||||
|
emit signal_updateDocsXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(packetType == PacketType::GET_DOCS)
|
if(packetType == PacketType::GET_DOCS)
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ class RecognizeSystem : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RecognizeSystem(QObject *parent = nullptr);
|
RecognizeSystem(QObject *parent = nullptr);
|
||||||
void initialize(UpdateController *updateController,DataParser *dataParser,
|
void initialize(UpdateController *updateController,DataParser *dataParser, SendSystem *sendSystem, ClientHandler *handler);
|
||||||
ServerLMSWidget *server,SendSystem *sendSystem, ClientHandler *handler);
|
|
||||||
void recognize();
|
void recognize();
|
||||||
~RecognizeSystem();
|
~RecognizeSystem();
|
||||||
|
|
||||||
@@ -37,14 +36,15 @@ signals:
|
|||||||
void sigChangeVersion(QString versionName);
|
void sigChangeVersion(QString versionName);
|
||||||
void sigDeleteVersion(QString versionName);
|
void sigDeleteVersion(QString versionName);
|
||||||
void sigCopyVersion(QString versionName,QString newVersionName,QString author);
|
void sigCopyVersion(QString versionName,QString newVersionName,QString author);
|
||||||
void sigRecalculateDocs();
|
//void sigRecalculateDocs();
|
||||||
void sigSendDocs(QString docsPath);
|
void sigSendDocs(QString docsPath);
|
||||||
|
|
||||||
|
void signal_updateDocsXML();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UpdateController *updateController;
|
UpdateController *updateController;
|
||||||
SendSystem *sendSystem;
|
SendSystem *sendSystem;
|
||||||
DataParser *dataParser;
|
DataParser *dataParser;
|
||||||
ServerLMSWidget *server;
|
|
||||||
QString command;
|
QString command;
|
||||||
PacketType packetType;
|
PacketType packetType;
|
||||||
QString filePath;
|
QString filePath;
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ ClientHandler::ClientHandler( QObject *parent):
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget,
|
void ClientHandler::initialize(int descriptor,
|
||||||
UpdateController *updateController,DataParser *dataParser)
|
UpdateController *updateController,DataParser *dataParser, QMutex *mutex)
|
||||||
{
|
{
|
||||||
this->socket = new QTcpSocket;
|
this->socket = new QTcpSocket;
|
||||||
this->thread = new QThread;
|
this->thread = new QThread;
|
||||||
@@ -30,7 +30,6 @@ void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget,
|
|||||||
recognizeSystem->moveToThread(thread);
|
recognizeSystem->moveToThread(thread);
|
||||||
|
|
||||||
this->updateController = updateController;
|
this->updateController = updateController;
|
||||||
this->server = serverWidget;
|
|
||||||
|
|
||||||
QString peerName = socket->peerName();
|
QString peerName = socket->peerName();
|
||||||
QString peerAddress = socket->peerAddress().toString();
|
QString peerAddress = socket->peerAddress().toString();
|
||||||
@@ -38,6 +37,8 @@ void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget,
|
|||||||
|
|
||||||
client = new Client(peerName,peerAddress,peerPort,socket);
|
client = new Client(peerName,peerAddress,peerPort,socket);
|
||||||
|
|
||||||
|
connect(recognizeSystem,&RecognizeSystem::signal_updateDocsXML,this,&ClientHandler::signal_updateDocsXML);
|
||||||
|
|
||||||
connect(this,&ClientHandler::sigSendXmlAnswer,sendSystem,&SendSystem::sendXmlAnswer,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendXmlAnswer,sendSystem,&SendSystem::sendXmlAnswer,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigInitSender,sendSystem,&SendSystem::initialize,Qt::AutoConnection/*Qt::DirectConnection*/);
|
connect(this,&ClientHandler::sigInitSender,sendSystem,&SendSystem::initialize,Qt::AutoConnection/*Qt::DirectConnection*/);
|
||||||
connect(this,&ClientHandler::sigFileBlock,sendSystem,&SendSystem::sendFileBlock,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigFileBlock,sendSystem,&SendSystem::sendFileBlock,Qt::AutoConnection);
|
||||||
@@ -57,9 +58,9 @@ void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget,
|
|||||||
connect(socket,&QTcpSocket::readyRead,this,&ClientHandler::initClientType,Qt::AutoConnection);
|
connect(socket,&QTcpSocket::readyRead,this,&ClientHandler::initClientType,Qt::AutoConnection);
|
||||||
initClientType();
|
initClientType();
|
||||||
|
|
||||||
recognizeSystem->initialize(updateController,dataParser,serverWidget,sendSystem, this);
|
recognizeSystem->initialize(updateController,dataParser,sendSystem, this);
|
||||||
sendSystem->setClient(client,socket);
|
sendSystem->setClient(client,socket);
|
||||||
emit sigInitSender(dataParser,serverWidget->getMutex());
|
emit sigInitSender(dataParser, mutex);
|
||||||
|
|
||||||
Logger::instance().log("SERVER: Client connected");
|
Logger::instance().log("SERVER: Client connected");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,12 +69,14 @@ signals:
|
|||||||
void sigSendPacketType(PacketType packetType);
|
void sigSendPacketType(PacketType packetType);
|
||||||
void sigSendStop();
|
void sigSendStop();
|
||||||
|
|
||||||
|
void signal_updateDocsXML();
|
||||||
|
|
||||||
public :
|
public :
|
||||||
QThread *thread;
|
QThread *thread;
|
||||||
QTcpSocket *socket;
|
QTcpSocket *socket;
|
||||||
|
|
||||||
void initialize(int descriptor, ServerLMSWidget *serverWidget,
|
void initialize(int descriptor,
|
||||||
UpdateController *updateController, DataParser *dataParser);
|
UpdateController *updateController, DataParser *dataParser, QMutex *mutex);
|
||||||
void setClient(Client *value);
|
void setClient(Client *value);
|
||||||
private:
|
private:
|
||||||
UpdateController *updateController;
|
UpdateController *updateController;
|
||||||
@@ -82,7 +84,6 @@ private:
|
|||||||
Client *client;
|
Client *client;
|
||||||
|
|
||||||
SendSystem *sendSystem;
|
SendSystem *sendSystem;
|
||||||
ServerLMSWidget *server;
|
|
||||||
|
|
||||||
void initClientType();
|
void initClientType();
|
||||||
void packetTypeInit(PacketType packet, Client *client);
|
void packetTypeInit(PacketType packet, Client *client);
|
||||||
|
|||||||
@@ -6,4 +6,9 @@ void registerMetaType()
|
|||||||
qRegisterMetaType<PacketType>("PacketType");
|
qRegisterMetaType<PacketType>("PacketType");
|
||||||
qRegisterMetaType<UserType>("UserType");
|
qRegisterMetaType<UserType>("UserType");
|
||||||
qRegisterMetaType<LogLevel>("LogLevel");
|
qRegisterMetaType<LogLevel>("LogLevel");
|
||||||
|
qRegisterMetaType<QStringList>("QStringList");
|
||||||
|
qRegisterMetaType<DataBaseSettings>("DataBaseSettings");
|
||||||
|
|
||||||
|
qRegisterMetaType<EStateServer>("EStateServer");
|
||||||
|
qRegisterMetaType<EStateBlockAutorization>("EStateBlockAutorization");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,17 @@
|
|||||||
#include "Data/PacketType.h"
|
#include "Data/PacketType.h"
|
||||||
#include "Data/typesDataServerClient.h"
|
#include "Data/typesDataServerClient.h"
|
||||||
#include "Systems/logger.h"
|
#include "Systems/logger.h"
|
||||||
|
#include "databaselms.h"
|
||||||
|
|
||||||
void registerMetaType();
|
void registerMetaType();
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(PacketType)
|
Q_DECLARE_METATYPE(PacketType)
|
||||||
Q_DECLARE_METATYPE(UserType)
|
Q_DECLARE_METATYPE(UserType)
|
||||||
Q_DECLARE_METATYPE(LogLevel)
|
Q_DECLARE_METATYPE(LogLevel)
|
||||||
|
Q_DECLARE_METATYPE(QStringList)
|
||||||
|
Q_DECLARE_METATYPE(DataBaseSettings)
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(EStateServer)
|
||||||
|
Q_DECLARE_METATYPE(EStateBlockAutorization)
|
||||||
|
|
||||||
#endif // METATYPES_H
|
#endif // METATYPES_H
|
||||||
|
|||||||
@@ -1,27 +1,39 @@
|
|||||||
#include "multithreadserver.h"
|
#include "multithreadserver.h"
|
||||||
|
|
||||||
MultiThreadServer::MultiThreadServer(ServerLMSWidget *widget,UpdateController *updateController,ProcessingSystem *processingSystem,
|
MultiThreadServer::MultiThreadServer(UpdateController *updateController, DocsUpdater *docsUpdater,ProcessingSystem *processingSystem,
|
||||||
DataParser *dataParser,qint16 hostPort, QObject *parent ):
|
DataParser *dataParser,qint16 hostPort, QObject *parent ):
|
||||||
QTcpServer(parent),
|
QTcpServer(parent),
|
||||||
serverLmsWidget(widget),
|
mutex(nullptr),
|
||||||
hostPort(hostPort),
|
hostPort(hostPort),
|
||||||
processingSystem(processingSystem),
|
processingSystem(processingSystem),
|
||||||
updateController(updateController),
|
updateController(updateController),
|
||||||
|
docsUpdater(docsUpdater),
|
||||||
dataParser(dataParser),
|
dataParser(dataParser),
|
||||||
stateServer(stoped),
|
stateServer(stoped),
|
||||||
stateBlockAutorization(blocked)
|
stateBlockAutorization(blocked)
|
||||||
{
|
{
|
||||||
clientsMap = new QMap<int,ClientHandler*>;
|
clientsMap = new QMap<int,ClientHandler*>;
|
||||||
|
mutex = new QMutex;
|
||||||
|
|
||||||
|
connect(this, &MultiThreadServer::signal_updateDocsXML, docsUpdater, &DocsUpdater::slot_updateDocsXML);
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiThreadServer::~MultiThreadServer()
|
||||||
|
{
|
||||||
|
delete mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiThreadServer::incomingConnection(qintptr socketDesriptor)
|
void MultiThreadServer::incomingConnection(qintptr socketDesriptor)
|
||||||
{
|
{
|
||||||
ClientHandler* newClient = new ClientHandler;
|
ClientHandler* newClient = new ClientHandler;
|
||||||
|
|
||||||
connect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize, Qt::AutoConnection/*Qt::DirectConnection*/);
|
connect(newClient,&ClientHandler::signal_updateDocsXML,this,&MultiThreadServer::slot_UpdateDocs);
|
||||||
|
|
||||||
|
//connect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize, Qt::AutoConnection/*Qt::DirectConnection*/);
|
||||||
connect(newClient,&ClientHandler::sigClientDisconnected,this,&MultiThreadServer::slotDisconnectClient,Qt::AutoConnection);
|
connect(newClient,&ClientHandler::sigClientDisconnected,this,&MultiThreadServer::slotDisconnectClient,Qt::AutoConnection);
|
||||||
emit sigInitClient(socketDesriptor,serverLmsWidget,updateController,dataParser);
|
//emit sigInitClient(socketDesriptor,serverLmsWidget,updateController,dataParser, getMutex());
|
||||||
disconnect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize);
|
newClient->initialize(socketDesriptor,updateController,dataParser, getMutex());
|
||||||
|
//disconnect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize);
|
||||||
|
|
||||||
addClient(socketDesriptor,newClient);
|
addClient(socketDesriptor,newClient);
|
||||||
|
|
||||||
@@ -40,19 +52,18 @@ bool MultiThreadServer::startServer()
|
|||||||
{
|
{
|
||||||
if(stateServer == stoped)
|
if(stateServer == stoped)
|
||||||
{
|
{
|
||||||
//connect(tcpServer, &QTcpServer::newConnection, this, &ServerLMSWidget::slotNewConnection,Qt::AutoConnection);
|
|
||||||
|
|
||||||
if(!listen(QHostAddress::Any, hostPort))
|
if(!listen(QHostAddress::Any, hostPort))
|
||||||
{
|
{
|
||||||
stateServer = stoped;
|
stateServer = stoped;
|
||||||
|
emit signal_StateServer(stateServer, stateBlockAutorization);
|
||||||
Logger::instance().log("SERVER: start ERROR");
|
Logger::instance().log("SERVER: start ERROR");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
stateServer = started;
|
stateServer = started;
|
||||||
slot_BlockAutorization(false, "SERVER", "StopServer");
|
slot_BlockAutorization(false, "SERVER", "StopServer");
|
||||||
|
emit signal_StateServer(stateServer, stateBlockAutorization);
|
||||||
Logger::instance().log("SERVER: start OK");
|
Logger::instance().log("SERVER: start OK");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -71,6 +82,7 @@ bool MultiThreadServer::stopServer()
|
|||||||
close();
|
close();
|
||||||
stateServer = stoped;
|
stateServer = stoped;
|
||||||
slot_BlockAutorization(true, "SERVER", "StopServer");
|
slot_BlockAutorization(true, "SERVER", "StopServer");
|
||||||
|
emit signal_StateServer(stateServer, stateBlockAutorization);
|
||||||
Logger::instance().log("SERVER: stop OK");
|
Logger::instance().log("SERVER: stop OK");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -83,9 +95,20 @@ QMap<int, ClientHandler *> *MultiThreadServer::getClientsMap() const
|
|||||||
return clientsMap;
|
return clientsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList MultiThreadServer::getClientFullNameList()
|
||||||
|
{
|
||||||
|
QStringList list;
|
||||||
|
for(ClientHandler* handler : *getClientsMap())
|
||||||
|
{
|
||||||
|
QString clientFullName = handler->getClient()->getFullName();
|
||||||
|
list.append(clientFullName);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
void MultiThreadServer::updateClientList()
|
void MultiThreadServer::updateClientList()
|
||||||
{
|
{
|
||||||
serverLmsWidget->slot_UpdateListClients();
|
emit signal_UpdateListClients(getClientFullNameList());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiThreadServer::disableClients()
|
void MultiThreadServer::disableClients()
|
||||||
@@ -151,8 +174,8 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
|
|||||||
emit signalStopSendFile();
|
emit signalStopSendFile();
|
||||||
Logger::instance().log("SERVER: Client " + login + " disconnected");
|
Logger::instance().log("SERVER: Client " + login + " disconnected");
|
||||||
|
|
||||||
serverLmsWidget->slot_UpdateListClients();
|
emit signal_UpdateListClients(getClientFullNameList());
|
||||||
serverLmsWidget->getProcessingSystem()->processingClientDeAutorization(login);
|
processingSystem->processingClientDeAutorization(login);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiThreadServer::slot_BlockAutorization(bool block, QString whoFullName, QString type)
|
bool MultiThreadServer::slot_BlockAutorization(bool block, QString whoFullName, QString type)
|
||||||
@@ -259,15 +282,30 @@ bool MultiThreadServer::slot_BlockAutorization(bool block, QString whoFullName,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiThreadServer::slot_StartServer()
|
||||||
|
{
|
||||||
|
startServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiThreadServer::slot_StopServer()
|
||||||
|
{
|
||||||
|
stopServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiThreadServer::slot_UpdateDocs()
|
||||||
|
{
|
||||||
|
emit signal_updateDocsXML();
|
||||||
|
}
|
||||||
|
|
||||||
void MultiThreadServer::removeClient(int idSocket)
|
void MultiThreadServer::removeClient(int idSocket)
|
||||||
{
|
{
|
||||||
clientsMap->remove(idSocket);
|
clientsMap->remove(idSocket);
|
||||||
serverLmsWidget->slot_UpdateListClients();
|
emit signal_UpdateListClients(getClientFullNameList());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiThreadServer::addClient(qintptr descriptor, ClientHandler *client)
|
void MultiThreadServer::addClient(qintptr descriptor, ClientHandler *client)
|
||||||
{
|
{
|
||||||
(*clientsMap)[descriptor] = client;
|
(*clientsMap)[descriptor] = client;
|
||||||
serverLmsWidget->slot_UpdateListClients();
|
emit signal_UpdateListClients(getClientFullNameList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
#ifndef MULTITHREADSERVER_H
|
#ifndef MULTITHREADSERVER_H
|
||||||
#define MULTITHREADSERVER_H
|
#define MULTITHREADSERVER_H
|
||||||
|
|
||||||
#include "serverlmswidget.h"
|
|
||||||
#include "Systems/processingsystem.h"
|
#include "Systems/processingsystem.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class ProcessingSystem;
|
class ProcessingSystem;
|
||||||
|
class DocsUpdater;
|
||||||
class MultiThreadServer : public QTcpServer
|
class MultiThreadServer : public QTcpServer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiThreadServer(ServerLMSWidget *widget,UpdateController *updateController,ProcessingSystem *processingSystem,
|
MultiThreadServer(UpdateController *updateController, DocsUpdater *docsUpdater,ProcessingSystem *processingSystem,
|
||||||
DataParser *dataParser, qint16 hostPort, QObject *parent = nullptr);
|
DataParser *dataParser, qint16 hostPort, QObject *parent = nullptr);
|
||||||
|
~MultiThreadServer();
|
||||||
|
|
||||||
|
|
||||||
QMap<int, ClientHandler *> *getClientsMap() const;
|
QMap<int, ClientHandler *> *getClientsMap() const;
|
||||||
|
QStringList getClientFullNameList();
|
||||||
void updateClientList();
|
void updateClientList();
|
||||||
void disableClients();
|
void disableClients();
|
||||||
|
|
||||||
bool startServer();
|
|
||||||
bool stopServer();
|
|
||||||
|
|
||||||
EStateBlockAutorization getStateBlockAutorization() const
|
EStateBlockAutorization getStateBlockAutorization() const
|
||||||
{
|
{
|
||||||
return stateBlockAutorization;
|
return stateBlockAutorization;
|
||||||
@@ -30,38 +29,60 @@ public:
|
|||||||
{
|
{
|
||||||
return stateServer;
|
return stateServer;
|
||||||
}
|
}
|
||||||
|
QMutex *getMutex() const
|
||||||
|
{
|
||||||
|
return mutex;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool startServer();
|
||||||
|
bool stopServer();
|
||||||
|
|
||||||
void blockAutorization()
|
void blockAutorization()
|
||||||
{
|
{
|
||||||
stateBlockAutorization = blocked;
|
stateBlockAutorization = blocked;
|
||||||
|
emit signal_StateServer(stateServer, stateBlockAutorization);
|
||||||
}
|
}
|
||||||
void unBlockAutorization()
|
void unBlockAutorization()
|
||||||
{
|
{
|
||||||
stateBlockAutorization = unblocked;
|
stateBlockAutorization = unblocked;
|
||||||
|
emit signal_StateServer(stateServer, stateBlockAutorization);
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sigInitClient(int descriptor, ServerLMSWidget *serverWidget,
|
//void sigInitClient(int descriptor, ServerLMSWidget *serverWidget,
|
||||||
UpdateController *updateController, DataParser *dataParser);
|
// UpdateController *updateController, DataParser *dataParser, QMutex *mutex);
|
||||||
void signalStopSendFile();
|
void signalStopSendFile();
|
||||||
|
|
||||||
void signal_BlockAutorizationIndicate(bool block, QString blocker, QString types);
|
void signal_BlockAutorizationIndicate(bool block, QString blocker, QString types);
|
||||||
void signal_sendPacketToAllClients(PacketType packetType, bool flOnlyGUI);
|
void signal_sendPacketToAllClients(PacketType packetType, bool flOnlyGUI);
|
||||||
|
|
||||||
|
void signal_StateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization);
|
||||||
|
|
||||||
|
void signal_UpdateListClients(QStringList listFullName);
|
||||||
|
|
||||||
|
void signal_updateDocsXML();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotDisconnectClient(QString peerAddress, QString peerPort);
|
void slotDisconnectClient(QString peerAddress, QString peerPort);
|
||||||
|
|
||||||
bool slot_BlockAutorization(bool block, QString whoFullName, QString type);
|
bool slot_BlockAutorization(bool block, QString whoFullName, QString type);
|
||||||
|
|
||||||
|
void slot_StartServer();
|
||||||
|
void slot_StopServer();
|
||||||
|
|
||||||
|
void slot_UpdateDocs();
|
||||||
protected:
|
protected:
|
||||||
void incomingConnection(qintptr handle) override;
|
void incomingConnection(qintptr handle) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ServerLMSWidget *serverLmsWidget;
|
QMutex *mutex;
|
||||||
QMap<int, ClientHandler*> *clientsMap;
|
QMap<int, ClientHandler*> *clientsMap;
|
||||||
qint16 hostPort;
|
qint16 hostPort;
|
||||||
ProcessingSystem *processingSystem;
|
ProcessingSystem *processingSystem;
|
||||||
UpdateController *updateController;
|
UpdateController *updateController;
|
||||||
|
DocsUpdater *docsUpdater;
|
||||||
DataParser *dataParser;
|
DataParser *dataParser;
|
||||||
|
|
||||||
EStateServer stateServer;
|
EStateServer stateServer;
|
||||||
|
|||||||
@@ -3,12 +3,11 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
ProviderDBLMS::ProviderDBLMS(QWidget *parentWidget, QObject *parent) :
|
ProviderDBLMS::ProviderDBLMS(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
dbLMS(nullptr),
|
dbLMS(nullptr)
|
||||||
parentWidget(parentWidget)
|
|
||||||
{
|
{
|
||||||
dbLMS = new InterfaceDataBaseLMS(parentWidget);
|
dbLMS = new InterfaceDataBaseLMS();
|
||||||
connect(dbLMS, &InterfaceDataBaseLMS::signal_ErrorPostgreSQL, this, &ProviderDBLMS::signal_ErrorPostgreSQL);
|
connect(dbLMS, &InterfaceDataBaseLMS::signal_ErrorPostgreSQL, this, &ProviderDBLMS::signal_ErrorPostgreSQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,6 +16,15 @@ ProviderDBLMS::~ProviderDBLMS()
|
|||||||
DisConnectionFromDB();
|
DisConnectionFromDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProviderDBLMS::slot_TryConnectionToDB()
|
||||||
|
{
|
||||||
|
ConnectionToDB();
|
||||||
|
}
|
||||||
|
void ProviderDBLMS::slot_TryDisConnectionFromDB()
|
||||||
|
{
|
||||||
|
DisConnectionFromDB();
|
||||||
|
}
|
||||||
|
|
||||||
bool ProviderDBLMS::ConnectionToDB()
|
bool ProviderDBLMS::ConnectionToDB()
|
||||||
{
|
{
|
||||||
mtxAccess.lock();
|
mtxAccess.lock();
|
||||||
@@ -26,15 +34,31 @@ bool ProviderDBLMS::ConnectionToDB()
|
|||||||
{
|
{
|
||||||
bool res = Q_EMIT signal_BlockAutorization(false, "SERVER", "DisConnectionDB");
|
bool res = Q_EMIT signal_BlockAutorization(false, "SERVER", "DisConnectionDB");
|
||||||
|
|
||||||
|
bool res1 = dbLMS->deAuthorizationAllTrainees();
|
||||||
|
bool res2 = dbLMS->deAuthorizationAllInstructors();
|
||||||
|
|
||||||
|
emit signal_StateConnectionToDB(true, getDBSettings());
|
||||||
|
emit signal_ResultTryConnectDb(true);
|
||||||
|
|
||||||
mtxAccess.unlock();
|
mtxAccess.unlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
emit signal_StateConnectionToDB(false, getDBSettings());
|
||||||
|
emit signal_ResultTryConnectDb(false);
|
||||||
|
|
||||||
mtxAccess.unlock();
|
mtxAccess.unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool res1 = dbLMS->deAuthorizationAllTrainees();
|
||||||
|
bool res2 = dbLMS->deAuthorizationAllInstructors();
|
||||||
|
|
||||||
|
emit signal_StateConnectionToDB(true, getDBSettings());
|
||||||
|
emit signal_ResultTryConnectDb(true);
|
||||||
|
|
||||||
mtxAccess.unlock();
|
mtxAccess.unlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -46,7 +70,19 @@ void ProviderDBLMS::DisConnectionFromDB()
|
|||||||
{
|
{
|
||||||
bool res = Q_EMIT signal_BlockAutorization(true, "SERVER", "DisConnectionDB");
|
bool res = Q_EMIT signal_BlockAutorization(true, "SERVER", "DisConnectionDB");
|
||||||
|
|
||||||
dbLMS->disConnectionFromDB();
|
bool res1 = dbLMS->deAuthorizationAllTrainees();
|
||||||
|
bool res2 = dbLMS->deAuthorizationAllInstructors();
|
||||||
|
|
||||||
|
if(dbLMS->disConnectionFromDB())
|
||||||
|
{
|
||||||
|
emit signal_ResultTryDisConnectDb(true);
|
||||||
|
emit signal_StateConnectionToDB(false, getDBSettings());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit signal_ResultTryDisConnectDb(true);
|
||||||
|
emit signal_StateConnectionToDB(false, getDBSettings());
|
||||||
}
|
}
|
||||||
mtxAccess.unlock();
|
mtxAccess.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class ProviderDBLMS : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ProviderDBLMS(QWidget *parentWidget, QObject *parent = nullptr);
|
explicit ProviderDBLMS(QObject *parent = nullptr);
|
||||||
~ProviderDBLMS();
|
~ProviderDBLMS();
|
||||||
public:
|
public:
|
||||||
QString getMainInstructorName();
|
QString getMainInstructorName();
|
||||||
@@ -75,10 +75,20 @@ Q_SIGNALS:
|
|||||||
bool signal_BlockAutorization(bool block, QString whoFullName, QString type);
|
bool signal_BlockAutorization(bool block, QString whoFullName, QString type);
|
||||||
signals:
|
signals:
|
||||||
void signal_ErrorPostgreSQL(QString text);
|
void signal_ErrorPostgreSQL(QString text);
|
||||||
|
void signal_StateConnectionToDB(bool dbIsConnected, DataBaseSettings dbSettings);
|
||||||
|
|
||||||
public:
|
void signal_ResultTryConnectDb(bool result);
|
||||||
|
void signal_ResultTryDisConnectDb(bool result);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slot_TryConnectionToDB();
|
||||||
|
void slot_TryDisConnectionFromDB();
|
||||||
|
|
||||||
|
private:
|
||||||
bool ConnectionToDB();
|
bool ConnectionToDB();
|
||||||
void DisConnectionFromDB();
|
void DisConnectionFromDB();
|
||||||
|
|
||||||
|
public:
|
||||||
bool DBisConnected();
|
bool DBisConnected();
|
||||||
DataBaseSettings getDBSettings();
|
DataBaseSettings getDBSettings();
|
||||||
|
|
||||||
@@ -94,7 +104,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
InterfaceDataBaseLMS* dbLMS;
|
InterfaceDataBaseLMS* dbLMS;
|
||||||
QMutex mtxAccess;
|
QMutex mtxAccess;
|
||||||
QWidget *parentWidget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROVIDERDBLMS_H
|
#endif // PROVIDERDBLMS_H
|
||||||
|
|||||||
@@ -4,37 +4,45 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
|
|
||||||
#include "serverlmswidget.h"
|
#include "serverlmswidget.h"
|
||||||
#include "dialogsettingstray.h"
|
#include "dialogsettingstray.h"
|
||||||
#include "specialmessagebox.h"
|
#include "specialmessagebox.h"
|
||||||
#include "ui_serverlmswidget.h"
|
|
||||||
#include "metatypes.h"
|
#include "metatypes.h"
|
||||||
|
#include "ui_serverlmswidget.h"
|
||||||
|
|
||||||
|
|
||||||
const QString ServerLMSWidget::languageENG = "en_EN";
|
const QString ServerLMSWidget::languageENG = "en_EN";
|
||||||
const QString ServerLMSWidget::languageRUS = "ru_RU";
|
const QString ServerLMSWidget::languageRUS = "ru_RU";
|
||||||
|
|
||||||
|
|
||||||
ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::ServerLMSWidget),
|
ui(new Ui::ServerLMSWidget),
|
||||||
waitAnimationWidget(nullptr),
|
waitAnimationWidget(nullptr),
|
||||||
updateThread(nullptr),
|
updateThread(nullptr),
|
||||||
loggerThread(nullptr),
|
loggerThread(nullptr),
|
||||||
mutex(nullptr),
|
serverThread(nullptr),
|
||||||
server(nullptr),
|
server(nullptr),
|
||||||
dataParser(nullptr),
|
dataParser(nullptr),
|
||||||
processingSystem(nullptr),
|
processingSystem(nullptr),
|
||||||
updateController(nullptr),
|
|
||||||
assetsManager(nullptr),
|
|
||||||
commonClientHandler(nullptr),
|
commonClientHandler(nullptr),
|
||||||
chatSystem(nullptr),
|
chatSystem(nullptr),
|
||||||
|
providerDBLMS(nullptr),
|
||||||
|
updateController(nullptr),
|
||||||
|
assetsManager(nullptr),
|
||||||
docsUpdater(nullptr),
|
docsUpdater(nullptr),
|
||||||
cfiController(nullptr),
|
cfiController(nullptr),
|
||||||
providerDBLMS(nullptr),
|
|
||||||
first(true),
|
first(true),
|
||||||
language(languageENG),
|
language(languageENG),
|
||||||
errorCode(0),
|
errorCode(0),
|
||||||
versionStr("..."),
|
stateVersionMaterials("..."),
|
||||||
flStartInitialization(false)
|
dbIsConnected(false),
|
||||||
|
stateServer(EStateServer::stoped),
|
||||||
|
stateBlockAutorization(EStateBlockAutorization::unblocked),
|
||||||
|
flStartInitialization(false),
|
||||||
|
flTryConnectionToDB(false),
|
||||||
|
flNeedReconnectDB(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@@ -49,26 +57,31 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
|||||||
|
|
||||||
updateMyStyleSheet();
|
updateMyStyleSheet();
|
||||||
|
|
||||||
setLanguageInterfase();
|
initLanguageInterfase();
|
||||||
|
|
||||||
waitAnimationWidget = new WaitAnimationWidget;
|
waitAnimationWidget = new WaitAnimationWidget;
|
||||||
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
||||||
waitAnimationWidget->setParent(this);
|
waitAnimationWidget->setParent(this);
|
||||||
waitAnimationWidget->initialize(movie,this);
|
waitAnimationWidget->initialize(movie,this);
|
||||||
|
|
||||||
updateStateOnlyVersion();
|
updateStateOnlyVersionMaterials();
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerLMSWidget::~ServerLMSWidget()
|
ServerLMSWidget::~ServerLMSWidget()
|
||||||
{
|
{
|
||||||
if(flStartInitialization)
|
if(flStartInitialization)
|
||||||
{
|
{
|
||||||
server->stopServer();
|
emit signal_StopServer();
|
||||||
|
//server->stopServer();
|
||||||
|
|
||||||
updateThread->quit();
|
updateThread->quit();
|
||||||
updateThread->wait();
|
updateThread->wait();
|
||||||
delete updateThread;
|
delete updateThread;
|
||||||
|
|
||||||
|
serverThread->quit();
|
||||||
|
serverThread->wait();
|
||||||
|
delete serverThread;
|
||||||
|
|
||||||
delete server;
|
delete server;
|
||||||
delete commonClientHandler;
|
delete commonClientHandler;
|
||||||
delete dataParser;
|
delete dataParser;
|
||||||
@@ -79,8 +92,6 @@ ServerLMSWidget::~ServerLMSWidget()
|
|||||||
delete assetsManager;
|
delete assetsManager;
|
||||||
delete chatSystem;
|
delete chatSystem;
|
||||||
|
|
||||||
delete mutex;
|
|
||||||
|
|
||||||
loggerThread->quit();
|
loggerThread->quit();
|
||||||
loggerThread->wait();
|
loggerThread->wait();
|
||||||
delete loggerThread;
|
delete loggerThread;
|
||||||
@@ -94,6 +105,16 @@ ServerLMSWidget::~ServerLMSWidget()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//INTERFACE
|
||||||
|
void ServerLMSWidget::start()
|
||||||
|
{
|
||||||
|
startInitialization_step0();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//EVENT
|
||||||
|
|
||||||
void ServerLMSWidget::changeEvent(QEvent *event)
|
void ServerLMSWidget::changeEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
// В случае получения события изменения языка приложения
|
// В случае получения события изменения языка приложения
|
||||||
@@ -103,7 +124,7 @@ void ServerLMSWidget::changeEvent(QEvent *event)
|
|||||||
|
|
||||||
updateStateOnlyServer();
|
updateStateOnlyServer();
|
||||||
updateStateOnlyDB();
|
updateStateOnlyDB();
|
||||||
updateStateOnlyVersion();
|
updateStateOnlyVersionMaterials();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,27 +134,137 @@ void ServerLMSWidget::resizeEvent(QResizeEvent *event)
|
|||||||
waitAnimationWidget->resize(size);
|
waitAnimationWidget->resize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::slot_UpdateListClients()
|
|
||||||
|
//STYLESHEET
|
||||||
|
|
||||||
|
void ServerLMSWidget::updateMyStyleSheet()
|
||||||
|
{
|
||||||
|
QString styleSheet = loadStyleSheet();
|
||||||
|
styleSheet = styleSheet.replace("\n", "");
|
||||||
|
|
||||||
|
this->setStyleSheet(styleSheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ServerLMSWidget::loadStyleSheet()
|
||||||
|
{
|
||||||
|
QString fileName = "./resources/css/styleSheetMain.css";
|
||||||
|
QFile styleSheetFile(fileName);
|
||||||
|
if (!styleSheetFile.open(QFile::ReadOnly | QFile::Text))
|
||||||
|
{
|
||||||
|
SpecMsgBox::WarningClose(this, tr("The file could not be opened ") + fileName);
|
||||||
|
return QStringLiteral("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QByteArray byteArray = styleSheetFile.readAll();
|
||||||
|
styleSheetFile.close();
|
||||||
|
|
||||||
|
QString style = byteArray;
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//LANGUAGE
|
||||||
|
|
||||||
|
void ServerLMSWidget::initLanguageInterfase()
|
||||||
|
{
|
||||||
|
ServerDBSettings settings;
|
||||||
|
DialogSettingsTray::loadSettings(&settings);
|
||||||
|
|
||||||
|
if(settings.Language == "ENG")
|
||||||
|
{
|
||||||
|
qtLanguageTranslator.load(QString("translations/RRJServer_") + languageENG, ".");
|
||||||
|
language = languageENG;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qtLanguageTranslator.load(QString("translations/RRJServer_") + languageRUS, ".");
|
||||||
|
language = languageRUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
qApp->installTranslator(&qtLanguageTranslator);
|
||||||
|
|
||||||
|
emit signal_LanguageChanged(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//UPDATE STATES
|
||||||
|
|
||||||
|
void ServerLMSWidget::updateStateOnlyServer()
|
||||||
|
{
|
||||||
|
if(stateServer == EStateServer::started)
|
||||||
|
{
|
||||||
|
if(stateBlockAutorization == EStateBlockAutorization::unblocked)
|
||||||
|
{
|
||||||
|
ui->lblOnOffText->setText(tr("started"));
|
||||||
|
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->lblOnOffText->setText(tr("started") + ", " + tr("locked"));
|
||||||
|
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->lblOnOffText->setText(tr("stoped"));
|
||||||
|
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/stoped.png")));
|
||||||
|
}
|
||||||
|
|
||||||
|
emit signal_updateStateServer(stateServer, stateBlockAutorization);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerLMSWidget::updateStateOnlyDB()
|
||||||
|
{
|
||||||
|
if(dbIsConnected)
|
||||||
|
{
|
||||||
|
//Настройки БД
|
||||||
|
QString strDBsettings = tr("connected") + QString(" [%1 (%2) %3 : %4]").arg(dbSettings.dbName,
|
||||||
|
dbSettings.dbType,
|
||||||
|
dbSettings.dbHostName,
|
||||||
|
QString::number(dbSettings.dbPort));
|
||||||
|
ui->lblDBsettings->setText(strDBsettings);
|
||||||
|
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->lblDBsettings->setText(tr("not connected"));
|
||||||
|
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||||
|
|
||||||
|
ui->btnStopServer->setEnabled(false);
|
||||||
|
ui->btnStartServer->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerLMSWidget::updateStateOnlyVersionMaterials()
|
||||||
|
{
|
||||||
|
ui->lblVersionText->setText(stateVersionMaterials);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//SLOTS
|
||||||
|
|
||||||
|
void ServerLMSWidget::slot_UpdateListClients(QStringList listFullName)
|
||||||
{
|
{
|
||||||
//Очищаем список
|
//Очищаем список
|
||||||
ui->listWidget_Clients->clear();
|
ui->listWidget_Clients->clear();
|
||||||
|
|
||||||
for (const ClientHandler *handler : server->getClientsMap()->values())
|
for (const QString clientFullName : listFullName)
|
||||||
{
|
{
|
||||||
QString strClient = handler->getClient()->getFullName();
|
//QString clientFullName = handler->getClient()->getFullName();
|
||||||
|
|
||||||
ui->listWidget_Clients->addItem(strClient);
|
ui->listWidget_Clients->addItem(clientFullName);
|
||||||
ui->listWidget_Clients->scrollToBottom();
|
ui->listWidget_Clients->scrollToBottom();
|
||||||
ui->listWidget_Clients->setCurrentRow(ui->listWidget_Clients->count() - 1);
|
ui->listWidget_Clients->setCurrentRow(ui->listWidget_Clients->count() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int countClients = (*server->getClientsMap()).count();
|
int countClients = listFullName.count();
|
||||||
Logger::instance().log("SERVER: countClients = " + QString::number(countClients));
|
Logger::instance().log("SERVER: countClients = " + QString::number(countClients));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::slot_AddMessageToLog(QString message)
|
void ServerLMSWidget::slot_AddMessageToLog(QString message)
|
||||||
{
|
{
|
||||||
//ui->loggerTextField->appendPlainText(message);
|
|
||||||
ui->loggerTextField->appendHtml(message);
|
ui->loggerTextField->appendHtml(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,61 +274,101 @@ void ServerLMSWidget::slot_ErrorPostgreSQL(QString text)
|
|||||||
SpecMsgBox::CriticalClose(this, tr("Error PostgreSQL!") + "\n" + text);
|
SpecMsgBox::CriticalClose(this, tr("Error PostgreSQL!") + "\n" + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::slot_UpdateDocs()
|
void ServerLMSWidget::slot_StateConnectionToDB(bool dbIsConnected, DataBaseSettings dbSettings)
|
||||||
{
|
{
|
||||||
//QApplication::setOverrideCursor(Qt::WaitCursor);
|
this->dbIsConnected = dbIsConnected;
|
||||||
|
this->dbSettings = dbSettings;
|
||||||
emit signal_updateDocsXML();
|
updateStateOnlyDB();
|
||||||
|
|
||||||
//if(docsUpdater->slot_updateDocsXML())
|
|
||||||
//emit signal_DocsChanged();
|
|
||||||
|
|
||||||
//QApplication::restoreOverrideCursor();
|
|
||||||
|
|
||||||
//TODO для теста
|
|
||||||
//cfiController->test();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::slot_startInitialization_step1()
|
void ServerLMSWidget::slot_StateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization)
|
||||||
|
{
|
||||||
|
if(this->stateServer != stateServer)
|
||||||
|
{
|
||||||
|
if(stateServer == EStateServer::started)
|
||||||
|
{
|
||||||
|
ui->btnStartServer->setEnabled(false);
|
||||||
|
ui->btnStopServer->setEnabled(true);
|
||||||
|
emit signal_Tray_ShowMessage(tr("Server is started!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Logger::instance().log("Update docs.xml...");
|
|
||||||
slot_UpdateDocs();
|
|
||||||
Logger::instance().log("Update docs.xml completed!");
|
|
||||||
|
|
||||||
ui->btnStopServer->setEnabled(false);
|
ui->btnStopServer->setEnabled(false);
|
||||||
ui->btnStartServer->setEnabled(true);
|
ui->btnStartServer->setEnabled(true);
|
||||||
|
emit signal_Tray_ShowMessage(tr("Server is stoped!"));
|
||||||
flStartInitialization = true;
|
}
|
||||||
|
}
|
||||||
|
this->stateServer = stateServer;
|
||||||
|
this->stateBlockAutorization = stateBlockAutorization;
|
||||||
updateStateOnlyServer();
|
updateStateOnlyServer();
|
||||||
updateStateOnlyDB();
|
}
|
||||||
updateStateOnlyVersion();
|
|
||||||
|
|
||||||
//QApplication::restoreOverrideCursor();
|
void ServerLMSWidget::slot_StateVersionMaterials(QString versionStr)
|
||||||
|
{
|
||||||
|
this->stateVersionMaterials = versionStr;
|
||||||
|
updateStateOnlyVersionMaterials();
|
||||||
|
}
|
||||||
|
|
||||||
if(hasError() == 100)
|
void ServerLMSWidget::slot_ResultTryConnectDb(bool result)
|
||||||
return;
|
{
|
||||||
|
if(flTryConnectionToDB)
|
||||||
|
{
|
||||||
|
flTryConnectionToDB = false;
|
||||||
|
|
||||||
|
if(result)
|
||||||
|
{
|
||||||
|
//Настройки БД
|
||||||
|
DataBaseSettings dbSettings = providerDBLMS->getDBSettings();
|
||||||
|
QString strDBsettings = QString("%1 (%2) %3 : %4").arg(dbSettings.dbName,
|
||||||
|
dbSettings.dbType,
|
||||||
|
dbSettings.dbHostName,
|
||||||
|
QString::number(dbSettings.dbPort));
|
||||||
|
|
||||||
|
Logger::instance().log("Connection to DB completed!");
|
||||||
|
|
||||||
|
emit signal_Tray_ShowMessage(tr("Database connection OK!") + "\n" + strDBsettings);
|
||||||
|
|
||||||
|
on_btnStartServer_clicked();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger::instance().log("Database connection error!");
|
||||||
|
|
||||||
|
emit signal_Tray_ShowMessage(tr("Database connection error!"), QSystemTrayIcon::Critical);
|
||||||
|
|
||||||
|
emit signal_Menu_ShowWindow();
|
||||||
|
|
||||||
|
SpecMsgBox::CriticalClose(this, tr("Database connection error!"));
|
||||||
|
|
||||||
|
on_btnSettings_clicked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerLMSWidget::slot_ResultTryDisConnectDb(bool result)
|
||||||
|
{
|
||||||
|
if(flNeedReconnectDB)
|
||||||
|
{
|
||||||
|
flNeedReconnectDB = false;
|
||||||
|
|
||||||
|
SpecMsgBox::WarningClose(this, tr("Database settings have been changed.\nThe server will be restarted."));
|
||||||
|
|
||||||
Logger::instance().log("Try connection to DB...");
|
|
||||||
tryConnectionToDB();
|
tryConnectionToDB();
|
||||||
|
}
|
||||||
waitAnimationWidget->hideWithStop();
|
|
||||||
|
|
||||||
emit signal_InitializeFinished();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::slot_setVersion(QString versionStr)
|
|
||||||
|
void ServerLMSWidget::slot_UpdateDocs()
|
||||||
{
|
{
|
||||||
this->versionStr = versionStr;
|
emit signal_updateDocsXML();
|
||||||
Logger::instance().log("Set Version: " + versionStr);
|
|
||||||
updateStateOnlyVersion();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::start()
|
void ServerLMSWidget::slot_UpdateControllerInitializeFinished()
|
||||||
{
|
{
|
||||||
startInitialization_step0();
|
startInitialization_step1();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ServerLMSWidget::slot_BlockAutorizationIndicate(bool block, QString blocker, QString types)
|
void ServerLMSWidget::slot_BlockAutorizationIndicate(bool block, QString blocker, QString types)
|
||||||
{
|
{
|
||||||
if(block)
|
if(block)
|
||||||
@@ -225,9 +396,13 @@ void ServerLMSWidget::slot_LanguageChanged(QString language)
|
|||||||
emit signal_LanguageChanged(language);
|
emit signal_LanguageChanged(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//ON_BTN
|
||||||
|
|
||||||
void ServerLMSWidget::on_btnStartServer_clicked()
|
void ServerLMSWidget::on_btnStartServer_clicked()
|
||||||
{
|
{
|
||||||
if(server->startServer())
|
emit signal_StartServer();
|
||||||
|
//if(server->startServer())
|
||||||
{
|
{
|
||||||
//QApplication::setOverrideCursor(Qt::WaitCursor);
|
//QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
@@ -237,7 +412,7 @@ void ServerLMSWidget::on_btnStartServer_clicked()
|
|||||||
|
|
||||||
//updateStateOnlyServer();
|
//updateStateOnlyServer();
|
||||||
|
|
||||||
emit signal_Tray_ShowMessage(tr("Server is started!"));
|
//emit signal_Tray_ShowMessage(tr("Server is started!"));
|
||||||
|
|
||||||
//QApplication::restoreOverrideCursor();
|
//QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
@@ -245,7 +420,8 @@ void ServerLMSWidget::on_btnStartServer_clicked()
|
|||||||
|
|
||||||
void ServerLMSWidget::on_btnStopServer_clicked()
|
void ServerLMSWidget::on_btnStopServer_clicked()
|
||||||
{
|
{
|
||||||
if(server->stopServer())
|
emit signal_StopServer();
|
||||||
|
//if(server->stopServer())
|
||||||
{
|
{
|
||||||
//QApplication::setOverrideCursor(Qt::WaitCursor);
|
//QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
@@ -255,7 +431,7 @@ void ServerLMSWidget::on_btnStopServer_clicked()
|
|||||||
|
|
||||||
//updateStateOnlyServer();
|
//updateStateOnlyServer();
|
||||||
|
|
||||||
emit signal_Tray_ShowMessage(tr("Server is stoped!"));
|
//emit signal_Tray_ShowMessage(tr("Server is stoped!"));
|
||||||
|
|
||||||
//QApplication::restoreOverrideCursor();
|
//QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
@@ -289,15 +465,18 @@ void ServerLMSWidget::on_btnSettings_clicked()
|
|||||||
{
|
{
|
||||||
on_btnStopServer_clicked();
|
on_btnStopServer_clicked();
|
||||||
|
|
||||||
providerDBLMS->deAuthorizationAll();
|
//providerDBLMS->deAuthorizationAll();
|
||||||
|
|
||||||
providerDBLMS->DisConnectionFromDB();
|
//providerDBLMS->DisConnectionFromDB();
|
||||||
|
|
||||||
updateStateOnlyDB();
|
flNeedReconnectDB = true;
|
||||||
|
flTryConnectionToDB = false;
|
||||||
|
|
||||||
SpecMsgBox::WarningClose(this, tr("Database settings have been changed.\nThe server will be restarted."));
|
emit signal_TryDisConnectionFromDB();
|
||||||
|
|
||||||
tryConnectionToDB();
|
//updateStateOnlyDB();
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -309,53 +488,8 @@ void ServerLMSWidget::on_btnSettings_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::setLanguageInterfase()
|
|
||||||
{
|
|
||||||
ServerDBSettings settings;
|
|
||||||
DialogSettingsTray::loadSettings(&settings);
|
|
||||||
|
|
||||||
if(settings.Language == "ENG")
|
//INIT
|
||||||
{
|
|
||||||
qtLanguageTranslator.load(QString("translations/RRJServer_") + languageENG, ".");
|
|
||||||
language = languageENG;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qtLanguageTranslator.load(QString("translations/RRJServer_") + languageRUS, ".");
|
|
||||||
language = languageRUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
qApp->installTranslator(&qtLanguageTranslator);
|
|
||||||
|
|
||||||
emit signal_LanguageChanged(language);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerLMSWidget::updateMyStyleSheet()
|
|
||||||
{
|
|
||||||
QString styleSheet = loadStyleSheet();
|
|
||||||
styleSheet = styleSheet.replace("\n", "");
|
|
||||||
|
|
||||||
this->setStyleSheet(styleSheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ServerLMSWidget::loadStyleSheet()
|
|
||||||
{
|
|
||||||
QString fileName = "./resources/css/styleSheetMain.css";
|
|
||||||
QFile styleSheetFile(fileName);
|
|
||||||
if (!styleSheetFile.open(QFile::ReadOnly | QFile::Text))
|
|
||||||
{
|
|
||||||
SpecMsgBox::WarningClose(this, tr("The file could not be opened ") + fileName);
|
|
||||||
return QStringLiteral("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QByteArray byteArray = styleSheetFile.readAll();
|
|
||||||
styleSheetFile.close();
|
|
||||||
|
|
||||||
QString style = byteArray;
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerLMSWidget::startInitialization_step0()
|
void ServerLMSWidget::startInitialization_step0()
|
||||||
{
|
{
|
||||||
@@ -363,18 +497,22 @@ void ServerLMSWidget::startInitialization_step0()
|
|||||||
|
|
||||||
waitAnimationWidget->showWithPlay();
|
waitAnimationWidget->showWithPlay();
|
||||||
|
|
||||||
//QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
||||||
|
|
||||||
providerDBLMS = new ProviderDBLMS(this);
|
|
||||||
connect(providerDBLMS, &ProviderDBLMS::signal_ErrorPostgreSQL, this, &ServerLMSWidget::slot_ErrorPostgreSQL);
|
|
||||||
//connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorizationIndicate);
|
|
||||||
|
|
||||||
mutex = new QMutex;
|
|
||||||
|
|
||||||
updateThread = new QThread;
|
updateThread = new QThread;
|
||||||
loggerThread = new QThread;
|
loggerThread = new QThread;
|
||||||
|
serverThread = new QThread;
|
||||||
|
|
||||||
|
providerDBLMS = new ProviderDBLMS();
|
||||||
|
providerDBLMS->moveToThread(serverThread);
|
||||||
|
|
||||||
|
connect(providerDBLMS, &ProviderDBLMS::signal_ErrorPostgreSQL, this, &ServerLMSWidget::slot_ErrorPostgreSQL);
|
||||||
|
connect(providerDBLMS, &ProviderDBLMS::signal_StateConnectionToDB, this, &ServerLMSWidget::slot_StateConnectionToDB);
|
||||||
|
connect(this, &ServerLMSWidget::signal_TryConnectionToDB, providerDBLMS, &ProviderDBLMS::slot_TryConnectionToDB);
|
||||||
|
connect(this, &ServerLMSWidget::signal_TryDisConnectionFromDB, providerDBLMS, &ProviderDBLMS::slot_TryDisConnectionFromDB);
|
||||||
|
connect(providerDBLMS, &ProviderDBLMS::signal_ResultTryConnectDb, this, &ServerLMSWidget::slot_ResultTryConnectDb);
|
||||||
|
connect(providerDBLMS, &ProviderDBLMS::signal_ResultTryDisConnectDb, this, &ServerLMSWidget::slot_ResultTryDisConnectDb);
|
||||||
|
|
||||||
chatSystem = new ChatSystem();
|
chatSystem = new ChatSystem();
|
||||||
|
chatSystem->moveToThread(serverThread);
|
||||||
|
|
||||||
assetsManager = new AssetsManager;
|
assetsManager = new AssetsManager;
|
||||||
assetsManager->moveToThread(updateThread);
|
assetsManager->moveToThread(updateThread);
|
||||||
@@ -389,22 +527,33 @@ void ServerLMSWidget::startInitialization_step0()
|
|||||||
cfiController->moveToThread(updateThread);
|
cfiController->moveToThread(updateThread);
|
||||||
|
|
||||||
processingSystem = new ProcessingSystem(providerDBLMS, updateController, docsUpdater, cfiController);
|
processingSystem = new ProcessingSystem(providerDBLMS, updateController, docsUpdater, cfiController);
|
||||||
|
processingSystem->moveToThread(serverThread);
|
||||||
|
|
||||||
dataParser = new DataParser(assetsManager, processingSystem);
|
dataParser = new DataParser(assetsManager, processingSystem);
|
||||||
|
dataParser->moveToThread(serverThread);
|
||||||
|
|
||||||
commonClientHandler = new CommonClientHandler;
|
commonClientHandler = new CommonClientHandler;
|
||||||
//connect(this, &ServerLMSWidget::signal_DocsChanged, commonClientHandler, &CommonClientHandler::slot_DocsChanged);
|
commonClientHandler->moveToThread(serverThread);
|
||||||
connect(docsUpdater, &DocsUpdater::signal_DocsChanged, commonClientHandler, &CommonClientHandler::slot_DocsChanged);
|
|
||||||
//connect(commonClientHandler, &CommonClientHandler::sigSetServerState, this, &ServerLMSWidget::slot_trySetServerState);
|
connect(docsUpdater, &DocsUpdater::signal_DocsChanged, commonClientHandler, &CommonClientHandler::slot_DocsChanged);
|
||||||
|
|
||||||
|
server = new MultiThreadServer(updateController, docsUpdater, processingSystem, dataParser, 6000);
|
||||||
|
server->moveToThread(serverThread);
|
||||||
|
|
||||||
|
connect(server, &MultiThreadServer::signal_StateServer, this, &ServerLMSWidget::slot_StateServer);
|
||||||
|
connect(server, &MultiThreadServer::signal_UpdateListClients, this, &ServerLMSWidget::slot_UpdateListClients);
|
||||||
|
|
||||||
|
connect(this, &ServerLMSWidget::signal_StartServer, server, &MultiThreadServer::slot_StartServer);
|
||||||
|
connect(this, &ServerLMSWidget::signal_StopServer, server, &MultiThreadServer::slot_StopServer);
|
||||||
|
|
||||||
server = new MultiThreadServer(this, updateController, processingSystem, dataParser, 6000);
|
|
||||||
connect(server, &MultiThreadServer::signal_BlockAutorizationIndicate, this, &ServerLMSWidget::slot_BlockAutorizationIndicate);
|
connect(server, &MultiThreadServer::signal_BlockAutorizationIndicate, this, &ServerLMSWidget::slot_BlockAutorizationIndicate);
|
||||||
connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, server, &MultiThreadServer::slot_BlockAutorization/*, Qt::DirectConnection*/);
|
connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, server, &MultiThreadServer::slot_BlockAutorization, Qt::DirectConnection /*Тут именно DirectConnection!*/);
|
||||||
connect(updateController, &UpdateController::signal_BlockAutorization, server, &MultiThreadServer::slot_BlockAutorization/*, Qt::DirectConnection*/);
|
connect(updateController, &UpdateController::signal_BlockAutorization, server, &MultiThreadServer::slot_BlockAutorization/*, Qt::DirectConnection*/);
|
||||||
connect(server, &MultiThreadServer::signal_sendPacketToAllClients, commonClientHandler, &CommonClientHandler::slot_sendPacketToAllClients);
|
connect(server, &MultiThreadServer::signal_sendPacketToAllClients, commonClientHandler, &CommonClientHandler::slot_sendPacketToAllClients);
|
||||||
|
|
||||||
loggerThread->start();
|
loggerThread->start();
|
||||||
updateThread->start();
|
updateThread->start();
|
||||||
|
serverThread->start();
|
||||||
|
|
||||||
commonClientHandler->initialize(server->getClientsMap(), processingSystem, dataParser);
|
commonClientHandler->initialize(server->getClientsMap(), processingSystem, dataParser);
|
||||||
processingSystem->initialize(server, dataParser, commonClientHandler, updateController, chatSystem);
|
processingSystem->initialize(server, dataParser, commonClientHandler, updateController, chatSystem);
|
||||||
@@ -415,108 +564,54 @@ void ServerLMSWidget::startInitialization_step0()
|
|||||||
Logger::instance().setLogToFile(true);
|
Logger::instance().setLogToFile(true);
|
||||||
|
|
||||||
connect(this, &ServerLMSWidget::sigUpdateControllerInitialize, updateController, &UpdateController::initialize);
|
connect(this, &ServerLMSWidget::sigUpdateControllerInitialize, updateController, &UpdateController::initialize);
|
||||||
connect(updateController, &UpdateController::sigInitializeFinished, this, &ServerLMSWidget::slot_startInitialization_step1);
|
connect(updateController, &UpdateController::sigInitializeFinished, this, &ServerLMSWidget::slot_UpdateControllerInitializeFinished);
|
||||||
connect(this, &ServerLMSWidget::sigCalculateFullHash, updateController, &UpdateController::calculateFullHash, Qt::AutoConnection);
|
connect(this, &ServerLMSWidget::sigCalculateFullHash, updateController, &UpdateController::calculateFullHash, Qt::AutoConnection);
|
||||||
connect(updateController, &UpdateController::sigErrorRequired, this, &ServerLMSWidget::setError);
|
connect(updateController, &UpdateController::sigErrorRequired, this, &ServerLMSWidget::setError);
|
||||||
connect(updateController, &UpdateController::sigUpdateDocs, this, &ServerLMSWidget::slot_UpdateDocs, Qt::AutoConnection);
|
connect(updateController, &UpdateController::sigUpdateDocs, this, &ServerLMSWidget::slot_UpdateDocs, Qt::AutoConnection);
|
||||||
connect(&Logger::instance(), &Logger::sigLogToWidget, this, &ServerLMSWidget::slot_AddMessageToLog, Qt::QueuedConnection);
|
connect(&Logger::instance(), &Logger::sigLogToWidget, this, &ServerLMSWidget::slot_AddMessageToLog, Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(assetsManager, &AssetsManager::signal_setVersion, this, &ServerLMSWidget::slot_setVersion);
|
connect(assetsManager, &AssetsManager::signal_setVersion, this, &ServerLMSWidget::slot_StateVersionMaterials);
|
||||||
|
|
||||||
connect(this, &ServerLMSWidget::signal_updateDocsXML, docsUpdater, &DocsUpdater::slot_updateDocsXML);
|
connect(this, &ServerLMSWidget::signal_updateDocsXML, docsUpdater, &DocsUpdater::slot_updateDocsXML);
|
||||||
|
|
||||||
emit sigUpdateControllerInitialize(commonClientHandler, dataParser, assetsManager);
|
emit sigUpdateControllerInitialize(commonClientHandler, dataParser, assetsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::tryConnectionToDB()
|
void ServerLMSWidget::startInitialization_step1()
|
||||||
{
|
{
|
||||||
if(! providerDBLMS->ConnectionToDB())
|
Logger::instance().log("Update docs.xml...");
|
||||||
{
|
slot_UpdateDocs();
|
||||||
Logger::instance().log("Database connection error!");
|
Logger::instance().log("Update docs.xml completed!");
|
||||||
|
|
||||||
emit signal_Tray_ShowMessage(tr("Database connection error!"), QSystemTrayIcon::Critical);
|
|
||||||
|
|
||||||
emit signal_Menu_ShowWindow();
|
|
||||||
|
|
||||||
SpecMsgBox::CriticalClose(this, tr("Database connection error!"));
|
|
||||||
|
|
||||||
on_btnSettings_clicked();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
providerDBLMS->deAuthorizationAll();
|
|
||||||
|
|
||||||
//Настройки БД
|
|
||||||
DataBaseSettings dbSettings = providerDBLMS->getDBSettings();
|
|
||||||
QString strDBsettings = QString("%1 (%2) %3 : %4").arg(dbSettings.dbName,
|
|
||||||
dbSettings.dbType,
|
|
||||||
dbSettings.dbHostName,
|
|
||||||
QString::number(dbSettings.dbPort));
|
|
||||||
|
|
||||||
Logger::instance().log("Connection to DB completed!");
|
|
||||||
|
|
||||||
emit signal_Tray_ShowMessage(tr("Database connection OK!") + "\n" + strDBsettings);
|
|
||||||
|
|
||||||
on_btnStartServer_clicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateStateOnlyDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerLMSWidget::updateStateOnlyServer()
|
|
||||||
{
|
|
||||||
if(server)
|
|
||||||
{
|
|
||||||
if(server->getStateServer() == EStateServer::started)
|
|
||||||
{
|
|
||||||
if(server->getStateBlockAutorization() == EStateBlockAutorization::unblocked)
|
|
||||||
{
|
|
||||||
ui->lblOnOffText->setText(tr("started"));
|
|
||||||
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->lblOnOffText->setText(tr("started") + ", " + tr("locked"));
|
|
||||||
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->lblOnOffText->setText(tr("stoped"));
|
|
||||||
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/stoped.png")));
|
|
||||||
}
|
|
||||||
|
|
||||||
emit signal_updateStateServer(server->getStateServer(), server->getStateBlockAutorization());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerLMSWidget::updateStateOnlyDB()
|
|
||||||
{
|
|
||||||
if(providerDBLMS)
|
|
||||||
{
|
|
||||||
if(providerDBLMS->DBisConnected())
|
|
||||||
{
|
|
||||||
//Настройки БД
|
|
||||||
DataBaseSettings dbSettings = providerDBLMS->getDBSettings();
|
|
||||||
QString strDBsettings = tr("connected") + QString(" [%1 (%2) %3 : %4]").arg(dbSettings.dbName,
|
|
||||||
dbSettings.dbType,
|
|
||||||
dbSettings.dbHostName,
|
|
||||||
QString::number(dbSettings.dbPort));
|
|
||||||
ui->lblDBsettings->setText(strDBsettings);
|
|
||||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->lblDBsettings->setText(tr("not connected"));
|
|
||||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
|
||||||
|
|
||||||
ui->btnStopServer->setEnabled(false);
|
ui->btnStopServer->setEnabled(false);
|
||||||
ui->btnStartServer->setEnabled(false);
|
ui->btnStartServer->setEnabled(true);
|
||||||
}
|
|
||||||
}
|
flStartInitialization = true;
|
||||||
|
|
||||||
|
updateStateOnlyServer();
|
||||||
|
updateStateOnlyDB();
|
||||||
|
updateStateOnlyVersionMaterials();
|
||||||
|
|
||||||
|
//QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
|
if(hasError() == 100)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Logger::instance().log("Try connection to DB...");
|
||||||
|
tryConnectionToDB();
|
||||||
|
|
||||||
|
waitAnimationWidget->hideWithStop();
|
||||||
|
|
||||||
|
emit signal_InitializeFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::updateStateOnlyVersion()
|
|
||||||
|
//CONNECT DB
|
||||||
|
|
||||||
|
void ServerLMSWidget::tryConnectionToDB()
|
||||||
{
|
{
|
||||||
ui->lblVersionText->setText(versionStr);
|
flTryConnectionToDB = true;
|
||||||
|
flNeedReconnectDB = false;
|
||||||
|
emit signal_TryConnectionToDB();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,12 @@
|
|||||||
|
|
||||||
#include <Data/typesDataServerClient.h>
|
#include <Data/typesDataServerClient.h>
|
||||||
#include <Data/Client.h>
|
#include <Data/Client.h>
|
||||||
|
|
||||||
#include "multithreadserver.h"
|
#include "multithreadserver.h"
|
||||||
#include "providerdblms.h"
|
#include "providerdblms.h"
|
||||||
#include "docsupdater.h"
|
#include "docsupdater.h"
|
||||||
|
|
||||||
#include "waitanimationwidget.h"
|
#include "waitanimationwidget.h"
|
||||||
#include "specialmessagebox.h"
|
#include "specialmessagebox.h"
|
||||||
|
|
||||||
#include "cficontroller.h"
|
#include "cficontroller.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -51,25 +50,24 @@ class ChatSystem;
|
|||||||
class DocsUpdater;
|
class DocsUpdater;
|
||||||
class CfiController;
|
class CfiController;
|
||||||
|
|
||||||
|
|
||||||
class SERVERLMS_EXPORT ServerLMSWidget : public QWidget
|
class SERVERLMS_EXPORT ServerLMSWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ServerLMSWidget(QWidget *parent = nullptr);
|
|
||||||
~ServerLMSWidget();
|
|
||||||
|
|
||||||
void start();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const QString languageENG;
|
static const QString languageENG;
|
||||||
static const QString languageRUS;
|
static const QString languageRUS;
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
// Метод получения событий
|
explicit ServerLMSWidget(QWidget *parent = nullptr);
|
||||||
// В нём будет производиться проверка события смены перевода приложения
|
~ServerLMSWidget();
|
||||||
void changeEvent(QEvent * event) override;
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
void start();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent(QEvent * event) override;
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -95,19 +93,30 @@ signals:
|
|||||||
|
|
||||||
void signal_InitializeFinished();
|
void signal_InitializeFinished();
|
||||||
|
|
||||||
|
void signal_TryConnectionToDB();
|
||||||
|
void signal_TryDisConnectionFromDB();
|
||||||
|
|
||||||
|
void signal_StartServer();
|
||||||
|
void signal_StopServer();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slot_LanguageChanged(QString language);
|
void slot_LanguageChanged(QString language);
|
||||||
void slot_UpdateListClients();
|
void slot_UpdateListClients(QStringList listFullName);
|
||||||
void slot_BlockAutorizationIndicate(bool block, QString blocker, QString types);
|
void slot_BlockAutorizationIndicate(bool block, QString blocker, QString types);
|
||||||
void slot_AddMessageToLog(QString message);
|
void slot_AddMessageToLog(QString message);
|
||||||
|
|
||||||
void slot_ErrorPostgreSQL(QString text);
|
void slot_ErrorPostgreSQL(QString text);
|
||||||
|
void slot_StateConnectionToDB(bool dbIsConnected, DataBaseSettings dbSettings);
|
||||||
|
void slot_StateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization);
|
||||||
|
|
||||||
void slot_UpdateDocs();
|
void slot_UpdateDocs();
|
||||||
|
|
||||||
void slot_startInitialization_step1();
|
void slot_UpdateControllerInitializeFinished();
|
||||||
|
|
||||||
void slot_setVersion(QString versionStr);
|
void slot_StateVersionMaterials(QString stateVersionMaterials);
|
||||||
|
|
||||||
|
void slot_ResultTryConnectDb(bool result);
|
||||||
|
void slot_ResultTryDisConnectDb(bool result);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString getLanguage()
|
QString getLanguage()
|
||||||
@@ -139,11 +148,6 @@ public:
|
|||||||
return processingSystem;
|
return processingSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutex *getMutex() const
|
|
||||||
{
|
|
||||||
return mutex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeClient(int socketId);
|
void removeClient(int socketId);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -152,17 +156,19 @@ private slots:
|
|||||||
void on_btnSettings_clicked();
|
void on_btnSettings_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setLanguageInterfase();
|
|
||||||
void updateMyStyleSheet();
|
void updateMyStyleSheet();
|
||||||
QString loadStyleSheet();
|
QString loadStyleSheet();
|
||||||
|
void initLanguageInterfase();
|
||||||
|
|
||||||
void startInitialization_step0();
|
private:
|
||||||
|
|
||||||
void tryConnectionToDB();
|
|
||||||
|
|
||||||
void updateStateOnlyServer();
|
void updateStateOnlyServer();
|
||||||
void updateStateOnlyDB();
|
void updateStateOnlyDB();
|
||||||
void updateStateOnlyVersion();
|
void updateStateOnlyVersionMaterials();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void startInitialization_step0();
|
||||||
|
void startInitialization_step1();
|
||||||
|
void tryConnectionToDB();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ServerLMSWidget *ui;
|
Ui::ServerLMSWidget *ui;
|
||||||
@@ -172,31 +178,36 @@ private:
|
|||||||
|
|
||||||
QThread *updateThread;
|
QThread *updateThread;
|
||||||
QThread *loggerThread;
|
QThread *loggerThread;
|
||||||
|
QThread *serverThread;
|
||||||
|
|
||||||
QMutex *mutex;
|
MultiThreadServer *server; //serverThread
|
||||||
|
DataParser *dataParser; //serverThread
|
||||||
|
ProcessingSystem *processingSystem; //serverThread
|
||||||
|
CommonClientHandler *commonClientHandler; //serverThread
|
||||||
|
ChatSystem *chatSystem; //serverThread
|
||||||
|
ProviderDBLMS* providerDBLMS; //serverThread
|
||||||
|
|
||||||
MultiThreadServer *server;
|
|
||||||
|
|
||||||
DataParser *dataParser;
|
|
||||||
ProcessingSystem *processingSystem;
|
|
||||||
UpdateController *updateController; //updateThread
|
UpdateController *updateController; //updateThread
|
||||||
AssetsManager *assetsManager; //updateThread
|
AssetsManager *assetsManager; //updateThread
|
||||||
CommonClientHandler *commonClientHandler;
|
|
||||||
ChatSystem *chatSystem;
|
|
||||||
|
|
||||||
DocsUpdater* docsUpdater; //updateThread
|
DocsUpdater* docsUpdater; //updateThread
|
||||||
CfiController* cfiController; //updateThread
|
CfiController* cfiController; //updateThread
|
||||||
|
|
||||||
ProviderDBLMS* providerDBLMS;
|
bool first; // для тестов Unity
|
||||||
|
|
||||||
bool first = true; // для тестов Unity
|
|
||||||
|
|
||||||
QTranslator qtLanguageTranslator;
|
QTranslator qtLanguageTranslator;
|
||||||
QString language;
|
QString language;
|
||||||
|
|
||||||
int errorCode;
|
int errorCode;
|
||||||
QString versionStr;
|
|
||||||
|
QString stateVersionMaterials;
|
||||||
|
bool dbIsConnected;
|
||||||
|
DataBaseSettings dbSettings;
|
||||||
|
EStateServer stateServer;
|
||||||
|
EStateBlockAutorization stateBlockAutorization;
|
||||||
|
|
||||||
bool flStartInitialization;
|
bool flStartInitialization;
|
||||||
|
bool flTryConnectionToDB;
|
||||||
|
bool flNeedReconnectDB;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SERVERLMSWIDGET_H
|
#endif // SERVERLMSWIDGET_H
|
||||||
|
|||||||
Reference in New Issue
Block a user