до убирания mtxAccess из ProviderDBLMS

This commit is contained in:
2025-08-13 12:44:48 +03:00
parent 93fe4a94b2
commit 842118cbea
5 changed files with 174 additions and 185 deletions

View File

@@ -19,7 +19,7 @@ void InterfaceDataBaseLMS::slot_LanguageChanged(QString language)
QCoreApplication::installTranslator(&qtLanguageTranslator);
}
bool InterfaceDataBaseLMS::ConnectionToDB()
bool InterfaceDataBaseLMS::connectionToDB()
{
QMutexLocker mtxLocker(&mtxAccess);
if(!createConnection())
@@ -34,7 +34,7 @@ bool InterfaceDataBaseLMS::ConnectionToDB()
}
}
bool InterfaceDataBaseLMS::DisConnectionFromDB()
bool InterfaceDataBaseLMS::disConnectionFromDB()
{
QMutexLocker mtxLocker(&mtxAccess);
deleteConnection();
@@ -51,7 +51,7 @@ bool InterfaceDataBaseLMS::DBisConnected()
//Инструкторы
bool InterfaceDataBaseLMS::AuthorizationInstructor(QString login, QString password)
bool InterfaceDataBaseLMS::authorizationInstructor(QString login, QString password)
{
QMutexLocker mtxLocker(&mtxAccess);
@@ -81,7 +81,7 @@ bool InterfaceDataBaseLMS::deAuthorizationInstructor(QString login)
bool InterfaceDataBaseLMS::deAuthorizationAllInstructors()
{
QMutexLocker mtxLocker(&mtxAccess);
return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBInstructor,false);
return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBInstructor, false);
}
QString InterfaceDataBaseLMS::getNameInstructorByLogin(QString login)
@@ -125,43 +125,33 @@ int InterfaceDataBaseLMS::editInstructor(Instructor instructor)
QMutexLocker mtxLocker(&mtxAccess);
//Проверка корректности логина, имени, пароля
QList<Instructor> listInstructors = selectAllInstructors();
for(Instructor exist_instructor : listInstructors)
{
if(instructor.getName() == QStringLiteral("<instructor>"))
{//Имя не корректно!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted."));
return 0;
}
if(instructor.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted."));
return 0;
}
if(instructor.getName() == QStringLiteral("<name>"))
{//Имя не корректно!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted."));
return 0;
}
if(instructor.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted."));
return 0;
}
if(instructor.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted."));
return 0;
}
if(instructor.getName() == exist_instructor.getName() && instructor.getID() != exist_instructor.getID())
{//Имя уже существует
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("An existing instructor name has been entered."));
return 0;
}
if(instructor.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted."));
return 0;
}
if(instructor.getLogin() == exist_instructor.getLogin() && instructor.getID() != exist_instructor.getID())
{//Логин уже существует!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("An existing instructor login has been entered.\nThe changes will not be accepted."));
return 0;
}
if(selectUserID(DataBaseLMS::TypeUserDBInstructor, instructor.getLogin()) || selectUserID(DataBaseLMS::TypeUserDBTrainee, instructor.getLogin()))
{//Логин уже существует!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
return updateInstructor(instructor);
@@ -188,7 +178,7 @@ bool InterfaceDataBaseLMS::isLoggedInInstructor(int id)
//Инструкторы
bool InterfaceDataBaseLMS::AuthorizationTrainee(QString login, QString password, QString classroom_name, QString computer_name)
bool InterfaceDataBaseLMS::authorizationTrainee(QString login, QString password, QString classroom_name, QString computer_name)
{
QMutexLocker mtxLocker(&mtxAccess);
@@ -408,7 +398,6 @@ int InterfaceDataBaseLMS::newTaskFIM(TaskAmmFim task, int id_trainee)
int InterfaceDataBaseLMS::delTaskFIM(int id)
{
QMutexLocker mtxLocker(&mtxAccess);
deleteReportFIM(id);
return deleteTaskFIM(id);
}
@@ -421,15 +410,7 @@ int InterfaceDataBaseLMS::editTaskFIM(TaskAmmFim task)
int InterfaceDataBaseLMS::replaceReportFIM(TaskAmmFim task)
{
QMutexLocker mtxLocker(&mtxAccess);
deleteReportFIM(task.getID());
if(int report_id = insertReportFIM(task))
{
updateStatusTaskFIM(task.getID(), "checkup");
return report_id;
}
return 0;
return updateReportFIMforTask(task);
}
int InterfaceDataBaseLMS::changeStatusTaskFIM(int id_task, QString status)
@@ -461,43 +442,33 @@ int InterfaceDataBaseLMS::editTrainee(Trainee trainee)
QMutexLocker mtxLocker(&mtxAccess);
//Проверка корректности логина, имени, пароля
QList<Trainee> listTrainees = selectAllTrainees();
for(Trainee exist_trainee : listTrainees)
{
if(trainee.getName() == QStringLiteral("<trainee>"))
{//Имя не корректно!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
return 0;
}
if(trainee.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
if(trainee.getName() == QStringLiteral("<trainee>"))
{//Имя не корректно!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
return 0;
}
if(trainee.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
return 0;
}
if(trainee.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
if(trainee.getName() == exist_trainee.getName() && trainee.getID() != exist_trainee.getID())
{//Имя уже существует
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("An existing trainee name has been entered."));
return 0;
}
if(trainee.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
return 0;
}
if(trainee.getLogin() == exist_trainee.getLogin() && trainee.getID() != exist_trainee.getID())
{//Логин уже существует!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("An existing trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
if(selectUserID(DataBaseLMS::TypeUserDBInstructor, trainee.getLogin()) || selectUserID(DataBaseLMS::TypeUserDBTrainee, trainee.getLogin()))
{//Логин уже существует!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
return updateTrainee(trainee);