From ef12d4f7a9451c468b8c61c2bea02e24e088be1d Mon Sep 17 00:00:00 2001 From: krivoshein Date: Wed, 13 Aug 2025 16:15:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D0=B8=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B8=D0=BD=D1=87=20=D1=81=20=D0=BC=D1=8C=D1=8E?= =?UTF-8?q?=D1=82=D0=B5=D0=BA=D1=81=D0=BE=D0=BC=20=D0=9F=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=B9=D0=B4=D0=B5=D1=80=D0=B0=20=D0=94=D0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DataBaseLMS/databaselms_trainees.cpp | 2 +- DataBaseLMS/interfacedatabaselms.cpp | 102 ++++++++++++------------- DataBaseLMS/interfacedatabaselms.h | 2 +- ServerLMS/Systems/processingsystem.cpp | 10 ++- ServerLMS/providerdblms.cpp | 4 +- ServerLMS/serverlmswidget.cpp | 17 +++-- ServerLMS/serverlmswidget.h | 2 +- 7 files changed, 74 insertions(+), 65 deletions(-) diff --git a/DataBaseLMS/databaselms_trainees.cpp b/DataBaseLMS/databaselms_trainees.cpp index fd1ba6f..5a20583 100644 --- a/DataBaseLMS/databaselms_trainees.cpp +++ b/DataBaseLMS/databaselms_trainees.cpp @@ -62,7 +62,7 @@ Trainee DataBaseLMS::selectTrainee(int id_trainee) "LEFT OUTER JOIN public.computers ON computers.computer_id = users.fk_computer_id " "LEFT OUTER JOIN public.classrooms ON classrooms.classroom_id = computers.fk_classroom_id " "WHERE users.user_id = %1 AND users.type = '%2' " - "ORDER BY groups.name, trainees.name ASC").arg( + "ORDER BY groups.name, users.name ASC").arg( QString::number(id_trainee), TypeUserDBTrainee); diff --git a/DataBaseLMS/interfacedatabaselms.cpp b/DataBaseLMS/interfacedatabaselms.cpp index 8358187..32ee3c2 100644 --- a/DataBaseLMS/interfacedatabaselms.cpp +++ b/DataBaseLMS/interfacedatabaselms.cpp @@ -21,7 +21,7 @@ void InterfaceDataBaseLMS::slot_LanguageChanged(QString language) bool InterfaceDataBaseLMS::connectionToDB() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); if(!createConnection()) { QMessageBox::critical(ownerWidget, dbSettings.dbName, tr("Connection error: ") + db->lastError().text()); @@ -36,7 +36,7 @@ bool InterfaceDataBaseLMS::connectionToDB() bool InterfaceDataBaseLMS::disConnectionFromDB() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); deleteConnection(); //QMessageBox::information(ownerWidget, dbName, tr("Disconnection is successful!")); return true; @@ -44,7 +44,7 @@ bool InterfaceDataBaseLMS::disConnectionFromDB() bool InterfaceDataBaseLMS::DBisConnected() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return isConnected(); } @@ -53,7 +53,7 @@ bool InterfaceDataBaseLMS::DBisConnected() bool InterfaceDataBaseLMS::authorizationInstructor(QString login, QString password) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); if(int id = selectUserID(DataBaseLMS::TypeUserDBInstructor, login, password)) { @@ -68,7 +68,7 @@ bool InterfaceDataBaseLMS::authorizationInstructor(QString login, QString passwo bool InterfaceDataBaseLMS::deAuthorizationInstructor(QString login) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); if(int id = selectUserID(DataBaseLMS::TypeUserDBInstructor, login)) { @@ -80,49 +80,49 @@ bool InterfaceDataBaseLMS::deAuthorizationInstructor(QString login) bool InterfaceDataBaseLMS::deAuthorizationAllInstructors() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBInstructor, false); } QString InterfaceDataBaseLMS::getNameInstructorByLogin(QString login) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectUserNameByLogin(DataBaseLMS::TypeUserDBInstructor, login); } int InterfaceDataBaseLMS::getIdInstructorByLogin(QString login) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectUserID(DataBaseLMS::TypeUserDBInstructor, login); } QList InterfaceDataBaseLMS::getListInstructors() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectAllInstructors(); } Instructor InterfaceDataBaseLMS::getInstructor(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectInstructor(id); } int InterfaceDataBaseLMS::newInstructor() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return insertInstructor(); } int InterfaceDataBaseLMS::delInstructor(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return deleteInstructor(id); } int InterfaceDataBaseLMS::editInstructor(Instructor instructor) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); //Проверка корректности логина, имени, пароля @@ -159,19 +159,19 @@ int InterfaceDataBaseLMS::editInstructor(Instructor instructor) bool InterfaceDataBaseLMS::isAdminInstructor(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectInstructorIsAdmin(id); } bool InterfaceDataBaseLMS::isArchivedInstructor(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectUserArchived(DataBaseLMS::TypeUserDBInstructor, id); } bool InterfaceDataBaseLMS::isLoggedInInstructor(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id); } @@ -180,7 +180,7 @@ bool InterfaceDataBaseLMS::isLoggedInInstructor(int id) bool InterfaceDataBaseLMS::authorizationTrainee(QString login, QString password, QString classroom_name, QString computer_name) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); if(int id = selectUserID(DataBaseLMS::TypeUserDBTrainee, login, password)) { @@ -195,7 +195,7 @@ bool InterfaceDataBaseLMS::authorizationTrainee(QString login, QString password, bool InterfaceDataBaseLMS::deAuthorizationTrainee(QString login) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); if(int id = selectUserID(DataBaseLMS::TypeUserDBTrainee, login)) { @@ -207,13 +207,13 @@ bool InterfaceDataBaseLMS::deAuthorizationTrainee(QString login) bool InterfaceDataBaseLMS::deAuthorizationAllTrainees() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBTrainee, false); } int InterfaceDataBaseLMS::entryTraineeOnSimulator(int id_trainee) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); TimingOfTrainee timing(id_trainee); @@ -235,7 +235,7 @@ int InterfaceDataBaseLMS::entryTraineeOnSimulator(int id_trainee) int InterfaceDataBaseLMS::exitTraineeFromSimulator(int id_trainee) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); TimingOfTrainee timing(id_trainee); @@ -257,73 +257,73 @@ int InterfaceDataBaseLMS::exitTraineeFromSimulator(int id_trainee) QString InterfaceDataBaseLMS::getNameTraineeOnComputer(QString computer_name) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectTraineeNameOnComputer(computer_name); } Trainee InterfaceDataBaseLMS::getTraineeOnComputer(QString computer_name) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectTraineeOnComputer(computer_name); } QString InterfaceDataBaseLMS::getNameTraineeByLogin(QString login) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectUserNameByLogin(DataBaseLMS::TypeUserDBTrainee, login); } int InterfaceDataBaseLMS::getIdTraineeByLogin(QString login) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectUserID(DataBaseLMS::TypeUserDBTrainee, login); } QList InterfaceDataBaseLMS::getListTraineesInGroup(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectAllTraineesInGroup(id); } QList InterfaceDataBaseLMS::getListGroups() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectAllGroups(); } QList InterfaceDataBaseLMS::getListTrainees() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectAllTrainees(); } Trainee InterfaceDataBaseLMS::getTrainee(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectTrainee(id); } Group InterfaceDataBaseLMS::getGroup(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectGroup(id); } int InterfaceDataBaseLMS::newGroup() { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return insertGroup(); } int InterfaceDataBaseLMS::delGroup(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return deleteGroup(id); } int InterfaceDataBaseLMS::editGroup(Group group) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); //Проверка корректности имени QList listGroups = selectAllGroups(); @@ -349,97 +349,97 @@ int InterfaceDataBaseLMS::editGroup(Group group) int InterfaceDataBaseLMS::newTaskAMM(TaskAmmFim task, int id_trainee) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return insertTaskAMM(task, id_trainee); } int InterfaceDataBaseLMS::delTaskAMM(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return deleteTaskAMM(id); } int InterfaceDataBaseLMS::editTaskAMM(TaskAmmFim task) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return updateTaskAMM(task); } QList InterfaceDataBaseLMS::getListTasksAMMofTrainee(int id_trainee) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectTasksAMMofTrainee(id_trainee); } QList InterfaceDataBaseLMS::getListTasksFIMofTrainee(int id_trainee) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectTasksFIMofTrainee(id_trainee); } TaskAmmFim InterfaceDataBaseLMS::getTaskAMMbyID(int id_task) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectTaskAMMbyID(id_task); } TaskAmmFim InterfaceDataBaseLMS::getTaskFIMbyID(int id_task) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectTaskFIMbyID(id_task); } int InterfaceDataBaseLMS::newTaskFIM(TaskAmmFim task, int id_trainee) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return insertTaskFIM(task, id_trainee); } int InterfaceDataBaseLMS::delTaskFIM(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return deleteTaskFIM(id); } int InterfaceDataBaseLMS::editTaskFIM(TaskAmmFim task) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return updateTaskFIM(task); } int InterfaceDataBaseLMS::replaceReportFIM(TaskAmmFim task) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return updateReportFIMforTask(task); } int InterfaceDataBaseLMS::changeStatusTaskFIM(int id_task, QString status) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return updateStatusTaskFIM(id_task, status); } int InterfaceDataBaseLMS::changeStatusTaskAMM(int id_task, QString status) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return updateStatusTaskAMM(id_task, status); } int InterfaceDataBaseLMS::newTrainee(int id_group) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return insertTrainee(id_group); } int InterfaceDataBaseLMS::delTrainee(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return deleteTrainee(id); } int InterfaceDataBaseLMS::editTrainee(Trainee trainee) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); //Проверка корректности логина, имени, пароля @@ -476,12 +476,12 @@ int InterfaceDataBaseLMS::editTrainee(Trainee trainee) bool InterfaceDataBaseLMS::isArchivedTrainee(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectUserArchived(DataBaseLMS::TypeUserDBTrainee, id); } bool InterfaceDataBaseLMS::isLoggedInTrainee(int id) { - QMutexLocker mtxLocker(&mtxAccess); + //QMutexLocker mtxLocker(&mtxAccess); return selectUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id); } diff --git a/DataBaseLMS/interfacedatabaselms.h b/DataBaseLMS/interfacedatabaselms.h index 03eff5d..6668637 100644 --- a/DataBaseLMS/interfacedatabaselms.h +++ b/DataBaseLMS/interfacedatabaselms.h @@ -105,7 +105,7 @@ public: private: QTranslator qtLanguageTranslator; QWidget* ownerWidget; - QMutex mtxAccess; + //QMutex mtxAccess; }; #endif // INTERFACEDATABASELMS_H diff --git a/ServerLMS/Systems/processingsystem.cpp b/ServerLMS/Systems/processingsystem.cpp index 928428e..38083bd 100644 --- a/ServerLMS/Systems/processingsystem.cpp +++ b/ServerLMS/Systems/processingsystem.cpp @@ -1,4 +1,5 @@ #include "processingsystem.h" +#include "providerdblms.h" #include @@ -7,7 +8,10 @@ ProcessingSystem::ProcessingSystem(ProviderDBLMS* providerDBLMS, UpdateControlle updateController(nullptr), providerDBLMS(nullptr) { - this->providerDBLMS = providerDBLMS; + //this->providerDBLMS = providerDBLMS; + + + this->updateController = updateController; } @@ -16,6 +20,10 @@ void ProcessingSystem::initialize(MultiThreadServer *server, DataParser *dataPar UpdateController *updateController, ChatSystem *chatSystem) { + this->providerDBLMS = new ProviderDBLMS(/*parent*/nullptr); + this->providerDBLMS->ConnectionToDB(); + this->providerDBLMS->deAuthorizationAll(); + this->commonClientServer = commonClientHandler; this->dataParser = dataParser; this->server = server; diff --git a/ServerLMS/providerdblms.cpp b/ServerLMS/providerdblms.cpp index 31c3bd2..d851db4 100644 --- a/ServerLMS/providerdblms.cpp +++ b/ServerLMS/providerdblms.cpp @@ -17,7 +17,7 @@ ProviderDBLMS::~ProviderDBLMS() void ProviderDBLMS::ConnectionToDB() { - mtxAccess.lock(); + mtxAccess.lock(); if(! dbLMS->DBisConnected()) { if(dbLMS->connectionToDB()) @@ -31,7 +31,7 @@ void ProviderDBLMS::ConnectionToDB() void ProviderDBLMS::DisConnectionFromDB() { - mtxAccess.lock(); + mtxAccess.lock(); if(dbLMS->DBisConnected()) { Q_EMIT signal_BlockAutorization(true); diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index b5a9979..66b0236 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -16,8 +16,8 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : loggerThread(nullptr), dataParser(nullptr), processingSystem(nullptr), - updateController(nullptr), - providerDBLMS(nullptr) + updateController(nullptr)//, + //providerDBLMS(nullptr) { ui->setupUi(this); mutex = new QMutex; @@ -37,13 +37,13 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : updateThread = new QThread; loggerThread = new QThread; - providerDBLMS = new ProviderDBLMS(this); - providerDBLMS->ConnectionToDB(); - providerDBLMS->deAuthorizationAll(); + //providerDBLMS = new ProviderDBLMS(this); + //providerDBLMS->ConnectionToDB(); + //providerDBLMS->deAuthorizationAll(); chatSystem = new ChatSystem(); - connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization); + //connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization); assetsManager = new AssetsManager; assetsManager->moveToThread(updateThread); @@ -51,8 +51,9 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : updateController = new UpdateController; updateController->moveToThread(updateThread); - processingSystem = new ProcessingSystem(providerDBLMS, updateController); - processingSystem->moveToThread(updateThread); + processingSystem = new ProcessingSystem(/*providerDBLMS*/nullptr, updateController); + //processingSystem->moveToThread(updateThread); + //providerDBLMS->moveToThread(updateThread); dataParser = new DataParser(assetsManager,processingSystem); diff --git a/ServerLMS/serverlmswidget.h b/ServerLMS/serverlmswidget.h index 77b8357..789ced0 100644 --- a/ServerLMS/serverlmswidget.h +++ b/ServerLMS/serverlmswidget.h @@ -103,7 +103,7 @@ private: CommonClientHandler *commonClientHandler; ChatSystem *chatSystem; - ProviderDBLMS* providerDBLMS; + //ProviderDBLMS* providerDBLMS; bool first = true; // для тестов Unity