Сделал залогинивание, разлогинивание полностью рабочее

This commit is contained in:
krivoshein
2024-12-04 15:29:01 +03:00
parent 56eff211ce
commit 53b37240eb
56 changed files with 1140 additions and 826 deletions

Binary file not shown.

View File

@@ -26,3 +26,46 @@
1284 2596 7548532028126673 CMakeFiles/ServerLMS.dir/Systems/logger.cpp.obj 68e3223fc0caab27
1226 1269 7548532014896390 D:/LMS/ServerLMS/Debug64/ServerLMS_autogen/EWIEGA46WW/qrc_resources.cpp 9bce64f5ef0262e2
741 3823 7549118088405427 CMakeFiles/ServerLMS.dir/Systems/sendsystem.cpp.obj d73c57350f364b58
8 620 0 CMakeFiles/ServerLMS_autogen a1ba014d73005738
8 620 0 ServerLMS_autogen/mocs_compilation.cpp a1ba014d73005738
8 620 0 ServerLMS_autogen/include/ui_serverlmswidget.h a1ba014d73005738
8 620 0 D:/LMS/ServerLMS/Debug64/CMakeFiles/ServerLMS_autogen a1ba014d73005738
8 620 0 D:/LMS/ServerLMS/Debug64/ServerLMS_autogen/mocs_compilation.cpp a1ba014d73005738
8 620 0 D:/LMS/ServerLMS/Debug64/ServerLMS_autogen/include/ui_serverlmswidget.h a1ba014d73005738
631 3169 7550042169912346 CMakeFiles/ServerLMS.dir/Systems/recognizesystem.cpp.obj f698d155fbad3bd2
628 3224 7550042170483312 CMakeFiles/ServerLMS.dir/multithreadserver.cpp.obj 8ac2c4a8e2ef203c
640 3276 7550042171011162 CMakeFiles/ServerLMS.dir/Systems/processingsystem.cpp.obj 64946e3309bfc754
633 3299 7550042171170749 CMakeFiles/ServerLMS.dir/Systems/updatecontroller.cpp.obj c4c12bda48d8fa92
643 3330 7550042171563312 CMakeFiles/ServerLMS.dir/Systems/sendsystem.cpp.obj d73c57350f364b58
636 3529 7550042173541128 CMakeFiles/ServerLMS.dir/Systems/dataparser.cpp.obj b273ef6b79a34bf
623 3530 7550042173551107 CMakeFiles/ServerLMS.dir/serverlmswidget.cpp.obj 12010b53b3caa3fc
626 3612 7550042174342071 CMakeFiles/ServerLMS.dir/clienthandler.cpp.obj 6c16bf194fe85608
620 3965 7550042177904480 CMakeFiles/ServerLMS.dir/ServerLMS_autogen/mocs_compilation.cpp.obj 40e4c8c7d98890e8
3965 4463 7550042182866266 libServerLMS.dll fec6fbb0697e8d71
3965 4463 7550042182866266 libServerLMS.dll.a fec6fbb0697e8d71
19 549 0 CMakeFiles/ServerLMS_autogen a1ba014d73005738
19 549 0 ServerLMS_autogen/mocs_compilation.cpp a1ba014d73005738
19 549 0 ServerLMS_autogen/include/ui_serverlmswidget.h a1ba014d73005738
19 549 0 D:/LMS/ServerLMS/Debug64/CMakeFiles/ServerLMS_autogen a1ba014d73005738
19 549 0 D:/LMS/ServerLMS/Debug64/ServerLMS_autogen/mocs_compilation.cpp a1ba014d73005738
19 549 0 D:/LMS/ServerLMS/Debug64/ServerLMS_autogen/include/ui_serverlmswidget.h a1ba014d73005738
569 3070 7550109271713645 CMakeFiles/ServerLMS.dir/Systems/processingsystem.cpp.obj 64946e3309bfc754
559 3181 7550109272813721 CMakeFiles/ServerLMS.dir/Systems/recognizesystem.cpp.obj f698d155fbad3bd2
562 3281 7550109273823126 CMakeFiles/ServerLMS.dir/Systems/updatecontroller.cpp.obj c4c12bda48d8fa92
572 3326 7550109274281903 CMakeFiles/ServerLMS.dir/Systems/sendsystem.cpp.obj d73c57350f364b58
555 3385 7550109274862336 CMakeFiles/ServerLMS.dir/clienthandler.cpp.obj 6c16bf194fe85608
550 3438 7550109275395266 CMakeFiles/ServerLMS.dir/ServerLMS_autogen/mocs_compilation.cpp.obj 40e4c8c7d98890e8
566 3508 7550109276093391 CMakeFiles/ServerLMS.dir/Systems/dataparser.cpp.obj b273ef6b79a34bf
557 3559 7550109276602373 CMakeFiles/ServerLMS.dir/multithreadserver.cpp.obj 8ac2c4a8e2ef203c
552 3692 7550109277923319 CMakeFiles/ServerLMS.dir/serverlmswidget.cpp.obj 12010b53b3caa3fc
3692 4166 7550109282652827 libServerLMS.dll fec6fbb0697e8d71
3692 4166 7550109282652827 libServerLMS.dll.a fec6fbb0697e8d71
19 60 0 CMakeFiles/ServerLMS_autogen a1ba014d73005738
19 60 0 ServerLMS_autogen/mocs_compilation.cpp a1ba014d73005738
19 60 0 ServerLMS_autogen/include/ui_serverlmswidget.h a1ba014d73005738
19 60 0 D:/LMS/ServerLMS/Debug64/CMakeFiles/ServerLMS_autogen a1ba014d73005738
19 60 0 D:/LMS/ServerLMS/Debug64/ServerLMS_autogen/mocs_compilation.cpp a1ba014d73005738
19 60 0 D:/LMS/ServerLMS/Debug64/ServerLMS_autogen/include/ui_serverlmswidget.h a1ba014d73005738
60 2213 7550153358132948 CMakeFiles/ServerLMS.dir/Systems/dataparser.cpp.obj b273ef6b79a34bf
2213 2674 7550153362733864 libServerLMS.dll fec6fbb0697e8d71
2213 2674 7550153362733864 libServerLMS.dll.a fec6fbb0697e8d71

View File

@@ -1,21 +1,7 @@
# Generated by CMake. Changes will be overwritten.
D:/LMS/ServerLMS/ServerLMS/Systems/dataparser.cpp
D:/LMS/ServerLMS/ServerLMS/serverlmswidget.h
mmc:Q_OBJECT
D:/LMS/ServerLMS/ServerLMS/Systems/dataparser.cpp
D:/LMS/ServerLMS/ServerLMS/Systems/updatecontroller.cpp
D:/LMS/ServerLMS/ServerLMS/multithreadserver.cpp
D:/LMS/ServerLMS/ServerLMS/Systems/sendsystem.cpp
D:/LMS/ServerLMS/ServerLMS/Systems/logger.cpp
D:/LMS/ServerLMS/ServerLMS/Systems/recognizesystem.cpp
D:/LMS/ServerLMS/ServerLMS/providerdblms.cpp
D:/LMS/ServerLMS/ServerLMS/Systems/processingsystem.cpp
D:/LMS/ServerLMS/ServerLMS/typesDataServerClient.h
D:/LMS/ServerLMS/ServerLMS/Client.h
D:/LMS/ServerLMS/ServerLMS/multithreadserver.h
mmc:Q_OBJECT
D:/LMS/ServerLMS/ServerLMS/Systems/sendsystem.h
mmc:Q_OBJECT
D:/LMS/ServerLMS/ServerLMS/ServerLMS_global.h
D:/LMS/ServerLMS/ServerLMS/Systems/dataparser.h
mmc:Q_OBJECT
D:/LMS/ServerLMS/ServerLMS/serverlmswidget.cpp
@@ -32,6 +18,20 @@ D:/LMS/ServerLMS/ServerLMS/Systems/updatecontroller.h
D:/LMS/ServerLMS/ServerLMS/Systems/tools.h
D:/LMS/ServerLMS/ServerLMS/clienthandler.h
mmc:Q_OBJECT
D:/LMS/ServerLMS/ServerLMS/typesDataServerClient.h
D:/LMS/ServerLMS/ServerLMS/Systems/processingsystem.cpp
D:/LMS/ServerLMS/ServerLMS/multithreadserver.h
mmc:Q_OBJECT
D:/LMS/ServerLMS/ServerLMS/Client.h
D:/LMS/ServerLMS/ServerLMS/Systems/sendsystem.h
mmc:Q_OBJECT
D:/LMS/ServerLMS/ServerLMS/ServerLMS_global.h
D:/LMS/ServerLMS/ServerLMS/providerdblms.cpp
D:/LMS/ServerLMS/ServerLMS/Systems/recognizesystem.cpp
D:/LMS/ServerLMS/ServerLMS/Systems/logger.cpp
D:/LMS/ServerLMS/ServerLMS/Systems/sendsystem.cpp
D:/LMS/ServerLMS/ServerLMS/multithreadserver.cpp
D:/LMS/ServerLMS/ServerLMS/Systems/updatecontroller.cpp
D:/LMS/ServerLMS/ServerLMS/providerdblms.h
mmc:Q_OBJECT
D:/LMS/ServerLMS/ServerLMS/clienthandler.cpp

Binary file not shown.

Binary file not shown.

View File

@@ -49,6 +49,24 @@ void DataParser::xmlParser(ClientHandler *client, QByteArray array)
processingSystem->processingClientAutorization(client, clientAutorization);
}
else if(xmlReader.name() == "ClientDeAutorization")
{//Запрос ДеАвторизации от клиента
ClientDeAutorization clientDeAutorization;
/*Перебираем все атрибуты тега*/
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
{
QString name = attr.name().toString();
QString value = attr.value().toString();
//addTextToLogger(name + ": " + value);
if(name == "Login")
clientDeAutorization.Login = value;
}
processingSystem->processingClientDeAutorization(client, clientDeAutorization);
}
else if(xmlReader.name() == "ClientMessage")
{//Сообщение от клиента
@@ -220,7 +238,7 @@ QByteArray DataParser::xmlAnswer(QList<SXmlAnswerTag> listTag, QString elemUp1,
}
QByteArray DataParser::xmlAnswer_authorization(bool result, QString instructorName,QString clientName, QString accessType)
QByteArray DataParser::xmlAnswer_authorization(bool result, QString instructorName,QString clientName, QString accessType, QString login)
{
QList<SXmlAnswerTag> listTag;
@@ -229,7 +247,8 @@ QByteArray DataParser::xmlAnswer_authorization(bool result, QString instructorNa
SAttribute attribute2 = {"InstructorName", instructorName};
SAttribute attribute3 = {"ClientName", clientName};
SAttribute attribute4 = {"AccessType", accessType};
QList<SAttribute> listAttr = {attribute1, attribute2, attribute3, attribute4};
SAttribute attribute5 = {"Login", login};
QList<SAttribute> listAttr = {attribute1, attribute2, attribute3, attribute4, attribute5};
SXmlAnswerTag tag = {"ServerAuthorization", listAttr};
listTag.append(tag);
@@ -237,6 +256,20 @@ QByteArray DataParser::xmlAnswer_authorization(bool result, QString instructorNa
return xmlAnswer(listTag);
}
QByteArray DataParser::xmlAnswer_deAuthorization(bool result, QString login)
{
QList<SXmlAnswerTag> listTag;
SAttribute attribute1 = {"Result", result? "true" : "false"};
SAttribute attribute2 = {"Login", login};
QList<SAttribute> listAttr = {attribute1, attribute2};
SXmlAnswerTag tag = {"ServerDeAuthorization", listAttr};
listTag.append(tag);
return xmlAnswer(listTag);
}
QByteArray DataParser::xmlAnswer_message(QString text)
{
QList<SXmlAnswerTag> listTag;

View File

@@ -25,7 +25,8 @@ public:
void xmlFileDataParse(QByteArray array);
QByteArray xmlAnswer(QList<SXmlAnswerTag> listTag,QString elemUp1 = "", QString elemUp2 = "");
QByteArray xmlAnswer_authorization(bool result, QString instructorName, QString clientName, QString accessType);
QByteArray xmlAnswer_authorization(bool result, QString instructorName, QString clientName, QString accessType, QString login);
QByteArray xmlAnswer_deAuthorization(bool result, QString login);
QByteArray xmlAnswer_message(QString text);
QByteArray xmlAnswer_task(QString text);
QByteArray xmlAnswer_notify(QString code);

View File

@@ -42,7 +42,7 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien
instructorName = providerDBLMS->getMainInstructorName();
traineeName = providerDBLMS->getNameTraineeByLogin(clientAutorization.Login);
arrayAnswer = dataParser->xmlAnswer_authorization(true, instructorName, traineeName, "trainee");
arrayAnswer = dataParser->xmlAnswer_authorization(true, instructorName, traineeName, "trainee", clientAutorization.Login);
}
else if(providerDBLMS->authorizationInstructor(clientAutorization.Login, clientAutorization.Password))
{//Авторизуется инструктор
@@ -52,11 +52,56 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien
instructorName = providerDBLMS->getNameInstructorByLogin(clientAutorization.Login);
arrayAnswer = dataParser->xmlAnswer_authorization(true, instructorName, instructorName, "instructor");
arrayAnswer = dataParser->xmlAnswer_authorization(true, instructorName, instructorName, "instructor", clientAutorization.Login);
}
else
{//Никто не авторизовался
arrayAnswer = dataParser->xmlAnswer_authorization(false, "", "", "");
arrayAnswer = dataParser->xmlAnswer_authorization(false, "", "", "", "");
}
client->sendXmlAnswer(arrayAnswer);
QString str = QString(arrayAnswer);
//logger->addTextToLogger("To Client: " + str);
//Извещаем об изменениях в авторизации
emit sigAuthChanged();
}
void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization)
{
if(server->getStateBlockAutorization() == blocked)
{
QByteArray arrayAnswer = dataParser->xmlAnswer_notify(NOTIFY_SERVER_BLOCKED);
client->sendXmlAnswer(arrayAnswer);
QString str = QString(arrayAnswer);
emit sigLogMessage("To Client: " + str);
return;
}
//Попытка ДеАвторизации клиента (проверка по БД)
QByteArray arrayAnswer;
if(providerDBLMS->deAuthorizationTrainee(clientDeAutorization.Login))
{//ДеАвторизуется обучаемый
client->getClient()->setLogin("");
emit sigUpdateListClients();
arrayAnswer = dataParser->xmlAnswer_deAuthorization(true, clientDeAutorization.Login);
}
else if(providerDBLMS->deAuthorizationInstructor(clientDeAutorization.Login))
{//ДеАвторизуется инструктор
client->getClient()->setLogin("");
emit sigUpdateListClients();
arrayAnswer = dataParser->xmlAnswer_deAuthorization(true, clientDeAutorization.Login);
}
else
{//Никто не ДеАвторизовался
arrayAnswer = dataParser->xmlAnswer_deAuthorization(false, "");
}
client->sendXmlAnswer(arrayAnswer);

View File

@@ -24,6 +24,7 @@ public:
void initialize(DataParser* dataParser,ServerLMSWidget *server);
void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization);
void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization);
void processingClientMessage(ClientHandler *client, ClientMessage clientMessage);
void processingClientNotify(ClientHandler *client, ClientNotify clientNotify);

View File

@@ -44,6 +44,11 @@ public:
QString Password;
int NumberOfScreen;
};
class ClientDeAutorization
{
public:
QString Login;
};
class ServerMessage
{