mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
QMutexLocker
This commit is contained in:
@@ -24,8 +24,6 @@ DataBaseLMS::~DataBaseLMS()
|
|||||||
|
|
||||||
bool DataBaseLMS::createConnection()
|
bool DataBaseLMS::createConnection()
|
||||||
{
|
{
|
||||||
mtxAccess.lock();
|
|
||||||
|
|
||||||
dbSettings = getDataBaseSettings();
|
dbSettings = getDataBaseSettings();
|
||||||
|
|
||||||
dbSettings.connectionName = "Connection_" + dbSettings.dbName;
|
dbSettings.connectionName = "Connection_" + dbSettings.dbName;
|
||||||
@@ -41,7 +39,6 @@ bool DataBaseLMS::createConnection()
|
|||||||
|
|
||||||
if(!res)
|
if(!res)
|
||||||
{
|
{
|
||||||
mtxAccess.unlock();
|
|
||||||
deleteConnection();
|
deleteConnection();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -49,15 +46,12 @@ bool DataBaseLMS::createConnection()
|
|||||||
{
|
{
|
||||||
bool flHas = db->driver()->hasFeature(QSqlDriver::Transactions);
|
bool flHas = db->driver()->hasFeature(QSqlDriver::Transactions);
|
||||||
qDebug() << "db->driver()->hasFeature(QSqlDriver::Transactions): " << flHas;
|
qDebug() << "db->driver()->hasFeature(QSqlDriver::Transactions): " << flHas;
|
||||||
mtxAccess.unlock();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataBaseLMS::deleteConnection()
|
void DataBaseLMS::deleteConnection()
|
||||||
{
|
{
|
||||||
mtxAccess.lock();
|
|
||||||
|
|
||||||
if(transactionBegined)
|
if(transactionBegined)
|
||||||
QSqlDatabase::database().rollback();
|
QSqlDatabase::database().rollback();
|
||||||
|
|
||||||
@@ -69,29 +63,21 @@ void DataBaseLMS::deleteConnection()
|
|||||||
delete db;
|
delete db;
|
||||||
db = nullptr;
|
db = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
mtxAccess.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataBaseLMS::isConnected()
|
bool DataBaseLMS::isConnected()
|
||||||
{
|
{
|
||||||
mtxAccess.lock();
|
|
||||||
|
|
||||||
if(db == nullptr)
|
if(db == nullptr)
|
||||||
{
|
{
|
||||||
mtxAccess.unlock();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(db->isOpen())
|
if(db->isOpen())
|
||||||
{
|
{
|
||||||
mtxAccess.unlock();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mtxAccess.unlock();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,33 +139,6 @@ DataBaseSettings DataBaseLMS::getDataBaseSettings()
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataBaseLMS::transactionBegin()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if(transactionBegined)
|
|
||||||
{//Отмена предыдущей незаконченной
|
|
||||||
if(QSqlDatabase::database().rollback())
|
|
||||||
transactionBegined = false;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (transactionBegined = QSqlDatabase::database().transaction());
|
|
||||||
*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataBaseLMS::transactionEnd()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if(transactionBegined)
|
|
||||||
{
|
|
||||||
return !(transactionBegined = !QSqlDatabase::database().commit());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DataBaseLMS::queryExecInt(QString queryStr)
|
int DataBaseLMS::queryExecInt(QString queryStr)
|
||||||
{
|
{
|
||||||
QSqlQuery query = QSqlQuery(*db);
|
QSqlQuery query = QSqlQuery(*db);
|
||||||
@@ -222,10 +181,8 @@ bool DataBaseLMS::queryExecBool(QString queryStr)
|
|||||||
bool DataBaseLMS::queryExec(QString queryStr, QSqlQuery *query)
|
bool DataBaseLMS::queryExec(QString queryStr, QSqlQuery *query)
|
||||||
{
|
{
|
||||||
bool res = false;
|
bool res = false;
|
||||||
mtxAccess.lock();
|
|
||||||
if(! (res = query->exec(queryStr)) )
|
if(! (res = query->exec(queryStr)) )
|
||||||
messageWarningErrorQuery(queryStr, query);
|
messageWarningErrorQuery(queryStr, query);
|
||||||
mtxAccess.unlock();
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,6 @@ protected:
|
|||||||
void deleteConnection();
|
void deleteConnection();
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
|
|
||||||
//Транзакции
|
|
||||||
bool transactionBegin();
|
|
||||||
bool transactionEnd();
|
|
||||||
|
|
||||||
//Юзер
|
//Юзер
|
||||||
int selectUserID(QString type, QString login, QString password = QStringLiteral(""));
|
int selectUserID(QString type, QString login, QString password = QStringLiteral(""));
|
||||||
QString selectUserNameByLogin(QString type, QString login);
|
QString selectUserNameByLogin(QString type, QString login);
|
||||||
@@ -115,8 +111,7 @@ protected:
|
|||||||
DataBaseSettings dbSettings;
|
DataBaseSettings dbSettings;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool transactionBegined;
|
bool transactionBegined;
|
||||||
QMutex mtxAccess;
|
|
||||||
QWidget* ownerWidget;
|
QWidget* ownerWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ void InterfaceDataBaseLMS::slot_LanguageChanged(QString language)
|
|||||||
|
|
||||||
bool InterfaceDataBaseLMS::ConnectionToDB()
|
bool InterfaceDataBaseLMS::ConnectionToDB()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
if(!createConnection())
|
if(!createConnection())
|
||||||
{
|
{
|
||||||
QMessageBox::critical(ownerWidget, dbSettings.dbName, tr("Connection error: ") + db->lastError().text());
|
QMessageBox::critical(ownerWidget, dbSettings.dbName, tr("Connection error: ") + db->lastError().text());
|
||||||
@@ -34,7 +35,8 @@ bool InterfaceDataBaseLMS::ConnectionToDB()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool InterfaceDataBaseLMS::DisConnectionFromDB()
|
bool InterfaceDataBaseLMS::DisConnectionFromDB()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
deleteConnection();
|
deleteConnection();
|
||||||
//QMessageBox::information(ownerWidget, dbName, tr("Disconnection is successful!"));
|
//QMessageBox::information(ownerWidget, dbName, tr("Disconnection is successful!"));
|
||||||
return true;
|
return true;
|
||||||
@@ -42,6 +44,7 @@ bool InterfaceDataBaseLMS::DisConnectionFromDB()
|
|||||||
|
|
||||||
bool InterfaceDataBaseLMS::DBisConnected()
|
bool InterfaceDataBaseLMS::DBisConnected()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return isConnected();
|
return isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,76 +53,77 @@ bool InterfaceDataBaseLMS::DBisConnected()
|
|||||||
|
|
||||||
bool InterfaceDataBaseLMS::AuthorizationInstructor(QString login, QString password)
|
bool InterfaceDataBaseLMS::AuthorizationInstructor(QString login, QString password)
|
||||||
{
|
{
|
||||||
if(! transactionBegin())
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return false;
|
|
||||||
|
|
||||||
if(int id = selectUserID(DataBaseLMS::TypeUserDBInstructor, login, password))
|
if(int id = selectUserID(DataBaseLMS::TypeUserDBInstructor, login, password))
|
||||||
{
|
{
|
||||||
if(isArchivedInstructor(id) || isLoggedInInstructor(id))
|
if(selectUserArchived(DataBaseLMS::TypeUserDBInstructor, id) || selectUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id))
|
||||||
{
|
|
||||||
transactionEnd();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id, true))
|
|
||||||
return transactionEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
transactionEnd();
|
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id, true))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterfaceDataBaseLMS::deAuthorizationInstructor(QString login)
|
bool InterfaceDataBaseLMS::deAuthorizationInstructor(QString login)
|
||||||
{
|
{
|
||||||
if(! transactionBegin())
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return false;
|
|
||||||
|
|
||||||
if(int id = selectUserID(DataBaseLMS::TypeUserDBInstructor, login))
|
if(int id = selectUserID(DataBaseLMS::TypeUserDBInstructor, login))
|
||||||
{
|
{
|
||||||
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id, false))
|
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id, false))
|
||||||
return transactionEnd();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
transactionEnd();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterfaceDataBaseLMS::deAuthorizationAllInstructors()
|
bool InterfaceDataBaseLMS::deAuthorizationAllInstructors()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBInstructor,false);
|
return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBInstructor,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString InterfaceDataBaseLMS::getNameInstructorByLogin(QString login)
|
QString InterfaceDataBaseLMS::getNameInstructorByLogin(QString login)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectUserNameByLogin(DataBaseLMS::TypeUserDBInstructor, login);
|
return selectUserNameByLogin(DataBaseLMS::TypeUserDBInstructor, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::getIdInstructorByLogin(QString login)
|
int InterfaceDataBaseLMS::getIdInstructorByLogin(QString login)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectUserID(DataBaseLMS::TypeUserDBInstructor, login);
|
return selectUserID(DataBaseLMS::TypeUserDBInstructor, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Instructor> InterfaceDataBaseLMS::getListInstructors()
|
QList<Instructor> InterfaceDataBaseLMS::getListInstructors()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectAllInstructors();
|
return selectAllInstructors();
|
||||||
}
|
}
|
||||||
|
|
||||||
Instructor InterfaceDataBaseLMS::getInstructor(int id)
|
Instructor InterfaceDataBaseLMS::getInstructor(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectInstructor(id);
|
return selectInstructor(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::newInstructor()
|
int InterfaceDataBaseLMS::newInstructor()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return insertInstructor();
|
return insertInstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::delInstructor(int id)
|
int InterfaceDataBaseLMS::delInstructor(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return deleteInstructor(id);
|
return deleteInstructor(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::editInstructor(Instructor instructor)
|
int InterfaceDataBaseLMS::editInstructor(Instructor instructor)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
|
|
||||||
//Проверка корректности логина, имени, пароля
|
//Проверка корректности логина, имени, пароля
|
||||||
QList<Instructor> listInstructors = selectAllInstructors();
|
QList<Instructor> listInstructors = selectAllInstructors();
|
||||||
for(Instructor exist_instructor : listInstructors)
|
for(Instructor exist_instructor : listInstructors)
|
||||||
@@ -165,16 +169,19 @@ int InterfaceDataBaseLMS::editInstructor(Instructor instructor)
|
|||||||
|
|
||||||
bool InterfaceDataBaseLMS::isAdminInstructor(int id)
|
bool InterfaceDataBaseLMS::isAdminInstructor(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectInstructorIsAdmin(id);
|
return selectInstructorIsAdmin(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterfaceDataBaseLMS::isArchivedInstructor(int id)
|
bool InterfaceDataBaseLMS::isArchivedInstructor(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectUserArchived(DataBaseLMS::TypeUserDBInstructor, id);
|
return selectUserArchived(DataBaseLMS::TypeUserDBInstructor, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterfaceDataBaseLMS::isLoggedInInstructor(int id)
|
bool InterfaceDataBaseLMS::isLoggedInInstructor(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id);
|
return selectUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,46 +190,41 @@ 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)
|
||||||
{
|
{
|
||||||
if(! transactionBegin())
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return false;
|
|
||||||
|
|
||||||
if(int id = selectUserID(DataBaseLMS::TypeUserDBTrainee, login, password))
|
if(int id = selectUserID(DataBaseLMS::TypeUserDBTrainee, login, password))
|
||||||
{
|
{
|
||||||
if(isArchivedTrainee(id) || isLoggedInTrainee(id))
|
if(selectUserArchived(DataBaseLMS::TypeUserDBTrainee, id) || selectUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id))
|
||||||
{
|
|
||||||
transactionEnd();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id, true))
|
|
||||||
return transactionEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
transactionEnd();
|
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id, true))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterfaceDataBaseLMS::deAuthorizationTrainee(QString login)
|
bool InterfaceDataBaseLMS::deAuthorizationTrainee(QString login)
|
||||||
{
|
{
|
||||||
if(! transactionBegin())
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return false;
|
|
||||||
|
|
||||||
if(int id = selectUserID(DataBaseLMS::TypeUserDBTrainee, login))
|
if(int id = selectUserID(DataBaseLMS::TypeUserDBTrainee, login))
|
||||||
{
|
{
|
||||||
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id, false))
|
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id, false))
|
||||||
return transactionEnd();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
transactionEnd();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterfaceDataBaseLMS::deAuthorizationAllTrainees()
|
bool InterfaceDataBaseLMS::deAuthorizationAllTrainees()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBTrainee, false);
|
return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBTrainee, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::entryTraineeOnSimulator(int id_trainee)
|
int InterfaceDataBaseLMS::entryTraineeOnSimulator(int id_trainee)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
|
|
||||||
TimingOfTrainee timing(id_trainee);
|
TimingOfTrainee timing(id_trainee);
|
||||||
|
|
||||||
timing = selectTimingTrainee(id_trainee);
|
timing = selectTimingTrainee(id_trainee);
|
||||||
@@ -243,6 +245,8 @@ int InterfaceDataBaseLMS::entryTraineeOnSimulator(int id_trainee)
|
|||||||
|
|
||||||
int InterfaceDataBaseLMS::exitTraineeFromSimulator(int id_trainee)
|
int InterfaceDataBaseLMS::exitTraineeFromSimulator(int id_trainee)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
|
|
||||||
TimingOfTrainee timing(id_trainee);
|
TimingOfTrainee timing(id_trainee);
|
||||||
|
|
||||||
timing = selectTimingTrainee(id_trainee);
|
timing = selectTimingTrainee(id_trainee);
|
||||||
@@ -263,61 +267,74 @@ int InterfaceDataBaseLMS::exitTraineeFromSimulator(int id_trainee)
|
|||||||
|
|
||||||
QString InterfaceDataBaseLMS::getNameTraineeOnComputer(QString computer_name)
|
QString InterfaceDataBaseLMS::getNameTraineeOnComputer(QString computer_name)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectTraineeNameOnComputer(computer_name);
|
return selectTraineeNameOnComputer(computer_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Trainee InterfaceDataBaseLMS::getTraineeOnComputer(QString computer_name)
|
Trainee InterfaceDataBaseLMS::getTraineeOnComputer(QString computer_name)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectTraineeOnComputer(computer_name);
|
return selectTraineeOnComputer(computer_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString InterfaceDataBaseLMS::getNameTraineeByLogin(QString login)
|
QString InterfaceDataBaseLMS::getNameTraineeByLogin(QString login)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectUserNameByLogin(DataBaseLMS::TypeUserDBTrainee, login);
|
return selectUserNameByLogin(DataBaseLMS::TypeUserDBTrainee, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::getIdTraineeByLogin(QString login)
|
int InterfaceDataBaseLMS::getIdTraineeByLogin(QString login)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectUserID(DataBaseLMS::TypeUserDBTrainee, login);
|
return selectUserID(DataBaseLMS::TypeUserDBTrainee, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Trainee> InterfaceDataBaseLMS::getListTraineesInGroup(int id)
|
QList<Trainee> InterfaceDataBaseLMS::getListTraineesInGroup(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectAllTraineesInGroup(id);
|
return selectAllTraineesInGroup(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Group> InterfaceDataBaseLMS::getListGroups()
|
QList<Group> InterfaceDataBaseLMS::getListGroups()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectAllGroups();
|
return selectAllGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Trainee> InterfaceDataBaseLMS::getListTrainees()
|
QList<Trainee> InterfaceDataBaseLMS::getListTrainees()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectAllTrainees();
|
return selectAllTrainees();
|
||||||
}
|
}
|
||||||
|
|
||||||
Trainee InterfaceDataBaseLMS::getTrainee(int id)
|
Trainee InterfaceDataBaseLMS::getTrainee(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectTrainee(id);
|
return selectTrainee(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Group InterfaceDataBaseLMS::getGroup(int id)
|
Group InterfaceDataBaseLMS::getGroup(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectGroup(id);
|
return selectGroup(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::newGroup()
|
int InterfaceDataBaseLMS::newGroup()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return insertGroup();
|
return insertGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::delGroup(int id)
|
int InterfaceDataBaseLMS::delGroup(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return deleteGroup(id);
|
return deleteGroup(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::editGroup(Group group)
|
int InterfaceDataBaseLMS::editGroup(Group group)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
|
|
||||||
//Проверка корректности имени
|
//Проверка корректности имени
|
||||||
QList<Group> listGroups = selectAllGroups();
|
QList<Group> listGroups = selectAllGroups();
|
||||||
for(Group exist_group : listGroups)
|
for(Group exist_group : listGroups)
|
||||||
@@ -342,57 +359,68 @@ int InterfaceDataBaseLMS::editGroup(Group group)
|
|||||||
|
|
||||||
int InterfaceDataBaseLMS::newTaskAMM(TaskAmmFim task, int id_trainee)
|
int InterfaceDataBaseLMS::newTaskAMM(TaskAmmFim task, int id_trainee)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return insertTaskAMM(task, id_trainee);
|
return insertTaskAMM(task, id_trainee);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::delTaskAMM(int id)
|
int InterfaceDataBaseLMS::delTaskAMM(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return deleteTaskAMM(id);
|
return deleteTaskAMM(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::editTaskAMM(TaskAmmFim task)
|
int InterfaceDataBaseLMS::editTaskAMM(TaskAmmFim task)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return updateTaskAMM(task);
|
return updateTaskAMM(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<TaskAmmFim> InterfaceDataBaseLMS::getListTasksAMMofTrainee(int id_trainee)
|
QList<TaskAmmFim> InterfaceDataBaseLMS::getListTasksAMMofTrainee(int id_trainee)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectTasksAMMofTrainee(id_trainee);
|
return selectTasksAMMofTrainee(id_trainee);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<TaskAmmFim> InterfaceDataBaseLMS::getListTasksFIMofTrainee(int id_trainee)
|
QList<TaskAmmFim> InterfaceDataBaseLMS::getListTasksFIMofTrainee(int id_trainee)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectTasksFIMofTrainee(id_trainee);
|
return selectTasksFIMofTrainee(id_trainee);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskAmmFim InterfaceDataBaseLMS::getTaskAMMbyID(int id_task)
|
TaskAmmFim InterfaceDataBaseLMS::getTaskAMMbyID(int id_task)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectTaskAMMbyID(id_task);
|
return selectTaskAMMbyID(id_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskAmmFim InterfaceDataBaseLMS::getTaskFIMbyID(int id_task)
|
TaskAmmFim InterfaceDataBaseLMS::getTaskFIMbyID(int id_task)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectTaskFIMbyID(id_task);
|
return selectTaskFIMbyID(id_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::newTaskFIM(TaskAmmFim task, int id_trainee)
|
int InterfaceDataBaseLMS::newTaskFIM(TaskAmmFim task, int id_trainee)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return insertTaskFIM(task, id_trainee);
|
return insertTaskFIM(task, id_trainee);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::delTaskFIM(int id)
|
int InterfaceDataBaseLMS::delTaskFIM(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
deleteReportFIM(id);
|
deleteReportFIM(id);
|
||||||
return deleteTaskFIM(id);
|
return deleteTaskFIM(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::editTaskFIM(TaskAmmFim task)
|
int InterfaceDataBaseLMS::editTaskFIM(TaskAmmFim task)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return updateTaskFIM(task);
|
return updateTaskFIM(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::replaceReportFIM(TaskAmmFim task)
|
int InterfaceDataBaseLMS::replaceReportFIM(TaskAmmFim task)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
deleteReportFIM(task.getID());
|
deleteReportFIM(task.getID());
|
||||||
|
|
||||||
if(int report_id = insertReportFIM(task))
|
if(int report_id = insertReportFIM(task))
|
||||||
@@ -406,26 +434,32 @@ int InterfaceDataBaseLMS::replaceReportFIM(TaskAmmFim task)
|
|||||||
|
|
||||||
int InterfaceDataBaseLMS::changeStatusTaskFIM(int id_task, QString status)
|
int InterfaceDataBaseLMS::changeStatusTaskFIM(int id_task, QString status)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return updateStatusTaskFIM(id_task, status);
|
return updateStatusTaskFIM(id_task, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::changeStatusTaskAMM(int id_task, QString status)
|
int InterfaceDataBaseLMS::changeStatusTaskAMM(int id_task, QString status)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return updateStatusTaskAMM(id_task, status);
|
return updateStatusTaskAMM(id_task, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::newTrainee(int id_group)
|
int InterfaceDataBaseLMS::newTrainee(int id_group)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return insertTrainee(id_group);
|
return insertTrainee(id_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::delTrainee(int id)
|
int InterfaceDataBaseLMS::delTrainee(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return deleteTrainee(id);
|
return deleteTrainee(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterfaceDataBaseLMS::editTrainee(Trainee trainee)
|
int InterfaceDataBaseLMS::editTrainee(Trainee trainee)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
|
|
||||||
//Проверка корректности логина, имени, пароля
|
//Проверка корректности логина, имени, пароля
|
||||||
QList<Trainee> listTrainees = selectAllTrainees();
|
QList<Trainee> listTrainees = selectAllTrainees();
|
||||||
for(Trainee exist_trainee : listTrainees)
|
for(Trainee exist_trainee : listTrainees)
|
||||||
@@ -471,10 +505,12 @@ int InterfaceDataBaseLMS::editTrainee(Trainee trainee)
|
|||||||
|
|
||||||
bool InterfaceDataBaseLMS::isArchivedTrainee(int id)
|
bool InterfaceDataBaseLMS::isArchivedTrainee(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectUserArchived(DataBaseLMS::TypeUserDBTrainee, id);
|
return selectUserArchived(DataBaseLMS::TypeUserDBTrainee, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterfaceDataBaseLMS::isLoggedInTrainee(int id)
|
bool InterfaceDataBaseLMS::isLoggedInTrainee(int id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mtxLocker(&mtxAccess);
|
||||||
return selectUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id);
|
return selectUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QTranslator qtLanguageTranslator;
|
QTranslator qtLanguageTranslator;
|
||||||
QWidget* ownerWidget;
|
QWidget* ownerWidget;
|
||||||
|
QMutex mtxAccess;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTERFACEDATABASELMS_H
|
#endif // INTERFACEDATABASELMS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user