diff --git a/DataBaseLMS/interfacedatabaselms.cpp b/DataBaseLMS/interfacedatabaselms.cpp index a7cca1a..988f457 100644 --- a/DataBaseLMS/interfacedatabaselms.cpp +++ b/DataBaseLMS/interfacedatabaselms.cpp @@ -90,6 +90,11 @@ QString InterfaceDataBaseLMS::getNameInstructorByLogin(QString login) return selectInstructorNameByLogin(login); } +int InterfaceDataBaseLMS::getIdInstructorByLogin(QString login) +{ + return selectInstructorID(login); +} + QList InterfaceDataBaseLMS::getListInstructors() { return selectAllInstructors(); diff --git a/DataBaseLMS/interfacedatabaselms.h b/DataBaseLMS/interfacedatabaselms.h index a472f82..701e55e 100644 --- a/DataBaseLMS/interfacedatabaselms.h +++ b/DataBaseLMS/interfacedatabaselms.h @@ -31,6 +31,7 @@ public: bool deAuthorizationAllInstructors(); QString getNameInstructorByLogin(QString login); + int getIdInstructorByLogin(QString login); QList getListInstructors(); Instructor getInstructor(int id); diff --git a/ServerLMS/Systems/Parsers/clientanswerparser.cpp b/ServerLMS/Systems/Parsers/clientanswerparser.cpp index a9505d8..2b9e456 100644 --- a/ServerLMS/Systems/Parsers/clientanswerparser.cpp +++ b/ServerLMS/Systems/Parsers/clientanswerparser.cpp @@ -10,7 +10,7 @@ void ClientAnswerParser::initialize(DataParser *dataParser) this->dataParser = dataParser; } -QByteArray ClientAnswerParser::authorization(bool result, QString instructorName,QString clientName, QString accessType, QString login) +QByteArray ClientAnswerParser::authorization(bool result, QString instructorName,QString clientName, QString accessType, QString login, int id) { QList listTag; @@ -20,7 +20,8 @@ QByteArray ClientAnswerParser::authorization(bool result, QString instructorName SAttribute attribute3 = {"ClientName", clientName}; SAttribute attribute4 = {"AccessType", accessType}; SAttribute attribute5 = {"Login", login}; - QList listAttr = {attribute1, attribute2, attribute3, attribute4, attribute5}; + SAttribute attribute6 = {"id_client", QString::number(id)}; + QList listAttr = {attribute1, attribute2, attribute3, attribute4, attribute5, attribute6}; SXmlAnswerTag tag = {"ServerAuthorization", listAttr}; listTag.append(tag); diff --git a/ServerLMS/Systems/Parsers/clientanswerparser.h b/ServerLMS/Systems/Parsers/clientanswerparser.h index 141e5d8..a395099 100644 --- a/ServerLMS/Systems/Parsers/clientanswerparser.h +++ b/ServerLMS/Systems/Parsers/clientanswerparser.h @@ -14,7 +14,7 @@ public: explicit ClientAnswerParser(QObject *parent = nullptr); void initialize(DataParser *dataParser); - QByteArray authorization(bool result, QString instructorName, QString clientName, QString accessType, QString login); + QByteArray authorization(bool result, QString instructorName, QString clientName, QString accessType, QString login, int id); QByteArray deAuthorization(bool result, QString login); QByteArray message(QString text, QString login = ""); QByteArray task(QString text); diff --git a/ServerLMS/Systems/processingsystem.cpp b/ServerLMS/Systems/processingsystem.cpp index 9ec3333..ab52f47 100644 --- a/ServerLMS/Systems/processingsystem.cpp +++ b/ServerLMS/Systems/processingsystem.cpp @@ -51,6 +51,7 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien QString instructorName; QString traineeName; QByteArray arrayAnswer; + int clientID = 0; if(providerDBLMS->authorizationInstructor(clientAutorization.Login, clientAutorization.Password)) @@ -61,8 +62,9 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien emit sigUpdateListClients(); instructorName = providerDBLMS->getNameInstructorByLogin(clientAutorization.Login); + clientID = providerDBLMS->getIdInstructorByLogin(clientAutorization.Login); - arrayAnswer = dataParser->ClientAnswer()->authorization(true, instructorName, instructorName, "instructor", clientAutorization.Login); + arrayAnswer = dataParser->ClientAnswer()->authorization(true, instructorName, instructorName, "instructor", clientAutorization.Login, clientID); } else if(clientAutorization.TypeClient != TypeClientAutorization::TYPE_GUI) { @@ -75,17 +77,18 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien //KAV redact instructorName = providerDBLMS->getMainInstructorName(); traineeName = providerDBLMS->getNameTraineeByLogin(clientAutorization.Login); + clientID = providerDBLMS->getIdTraineeByLogin(clientAutorization.Login); - arrayAnswer = dataParser->ClientAnswer()->authorization(true, instructorName, traineeName, "trainee", clientAutorization.Login); + arrayAnswer = dataParser->ClientAnswer()->authorization(true, instructorName, traineeName, "trainee", clientAutorization.Login, clientID); } else {//Никто не авторизовался - arrayAnswer = dataParser->ClientAnswer()->authorization(false, "", "", "", ""); + arrayAnswer = dataParser->ClientAnswer()->authorization(false, "", "", "", "", 0); } } else {//Никто не авторизовался - arrayAnswer = dataParser->ClientAnswer()->authorization(false, "", "", "", ""); + arrayAnswer = dataParser->ClientAnswer()->authorization(false, "", "", "", "", 0); } client->sendXmlAnswer(arrayAnswer); client->sendVersion(); diff --git a/ServerLMS/providerdblms.cpp b/ServerLMS/providerdblms.cpp index 787d317..bc98394 100644 --- a/ServerLMS/providerdblms.cpp +++ b/ServerLMS/providerdblms.cpp @@ -240,6 +240,24 @@ int ProviderDBLMS::getIdTraineeByLogin(QString login) return id_trainee; } +int ProviderDBLMS::getIdInstructorByLogin(QString login) +{ + int id_instructor = 0; + qDebug() << "ProviderDBLMS " << QThread::currentThreadId(); + mtxAccess.lock(); + + if(! dbLMS->DBisConnected()) + { + mtxAccess.unlock(); + return id_instructor; + } + + id_instructor = dbLMS->getIdInstructorByLogin(login); + + mtxAccess.unlock(); + return id_instructor; +} + QString ProviderDBLMS::getLoginTraineeById(int id_trainee) { QString login = ""; diff --git a/ServerLMS/providerdblms.h b/ServerLMS/providerdblms.h index 671e5df..cd081df 100644 --- a/ServerLMS/providerdblms.h +++ b/ServerLMS/providerdblms.h @@ -30,6 +30,7 @@ public: // int getIdTraineeByLogin(QString login); + int getIdInstructorByLogin(QString login); QString getLoginTraineeById(int id_trainee); QList GetListAllInstructors();