mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Начал реализовывать обмен запросами к БД
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.11.1, 2024-12-04T10:19:38. -->
|
||||
<!-- Written by QtCreator 4.11.1, 2024-12-06T11:14:24. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
CommonView::CommonView(InterfaceDataBaseLMS* dbLMS, TypeView type, QWidget *parent):
|
||||
CommonView::CommonView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
|
||||
QWidget(parent),
|
||||
dbLMS(dbLMS),
|
||||
dbLMS(nullptr), //TODO
|
||||
connectorToServer(connectorToServer),
|
||||
treeWidget(nullptr),
|
||||
typeView(type),
|
||||
archiveVisible(false),
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QMutex>
|
||||
#include "instructorsAndTrainees_global.h"
|
||||
#include "interfacedatabaselms.h"
|
||||
#include "connectortoserver.h"
|
||||
|
||||
//Родительский класс представления БД Инструкторов/Обучаемых (самого верхнего уровня)
|
||||
|
||||
@@ -21,7 +22,7 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
CommonView(InterfaceDataBaseLMS* dbLMS, TypeView type, QWidget *parent = nullptr);
|
||||
CommonView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent = nullptr);
|
||||
|
||||
public:
|
||||
void setAdminMode(bool adminMode)
|
||||
@@ -56,6 +57,7 @@ private:
|
||||
|
||||
protected:
|
||||
InterfaceDataBaseLMS* dbLMS;
|
||||
ConnectorToServer* connectorToServer;
|
||||
QTreeWidget* treeWidget;
|
||||
QMutex mtxTreeWidget;
|
||||
TypeView typeView;
|
||||
|
||||
@@ -60,8 +60,28 @@ void DataParser::createAuthMessage(ClientAutorization *auth)
|
||||
xmlWriter.writeStartDocument();
|
||||
xmlWriter.writeStartElement("ClientAutorization");
|
||||
|
||||
xmlWriter.writeAttribute("Login",auth->Login);
|
||||
xmlWriter.writeAttribute("Password",auth->Password);
|
||||
xmlWriter.writeAttribute("Login", auth->Login);
|
||||
xmlWriter.writeAttribute("Password", auth->Password);
|
||||
xmlWriter.writeAttribute("TypeClient", QString::number(auth->TypeClient));
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndDocument();
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
void DataParser::createQueryToDBMessage(ClientQueryToDB *queryToDB)
|
||||
{
|
||||
QFile file(tempName);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
QXmlStreamWriter xmlWriter(&file);
|
||||
|
||||
xmlWriter.setAutoFormatting(true);
|
||||
xmlWriter.writeStartDocument();
|
||||
xmlWriter.writeStartElement("QueryToDB");
|
||||
|
||||
xmlWriter.writeAttribute("TypeQuery", QString::number(queryToDB->typeQuery));
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement();
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
void saveClientSettrings(QString language,bool isAutoStart);
|
||||
void createFileDataList(QList<FileData> fileDataList,QString filename);
|
||||
void createAuthMessage(ClientAutorization *auth);
|
||||
void createQueryToDBMessage(ClientQueryToDB *queryToDB);
|
||||
void createDeAuthMessage(ClientDeAutorization *deAuth);
|
||||
void createAuthData(ServerAuthorization *serverAuth);
|
||||
void createAuthDataOffline(QString username,QString pass);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Core/recognizesystem.h"
|
||||
#include <QThread>
|
||||
#include <QDir>
|
||||
#include "instructor.h"
|
||||
|
||||
|
||||
RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||
@@ -14,6 +15,8 @@ RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||
tmpBlock.clear();
|
||||
countSend = 0;
|
||||
folderList = new QList<QString>;
|
||||
|
||||
listInstructors = new QList<Instructor>;
|
||||
}
|
||||
|
||||
RecognizeSystem::~RecognizeSystem()
|
||||
@@ -25,7 +28,7 @@ void RecognizeSystem::initialize(DataParser *dataParser/*,MainWindow *mainWindow
|
||||
{
|
||||
this->dataParser = dataParser;
|
||||
//this->mainWindow = mainWindow;
|
||||
connect(this,&RecognizeSystem::sigSaveLoginData,dataParser,&DataParser::createAuthData);
|
||||
connect(this,&RecognizeSystem::sigAuth,dataParser,&DataParser::createAuthData);
|
||||
}
|
||||
|
||||
void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
@@ -259,9 +262,12 @@ void RecognizeSystem::xmlParser(QByteArray array)
|
||||
QXmlStreamReader xmlReader(array);
|
||||
|
||||
xmlReader.readNext();
|
||||
QString name = xmlReader.name().toString();
|
||||
|
||||
while(!xmlReader.atEnd())
|
||||
{
|
||||
name = xmlReader.name().toString();
|
||||
|
||||
if(!xmlReader.isStartElement()) {
|
||||
xmlReader.readNext();
|
||||
continue;
|
||||
@@ -325,7 +331,7 @@ void RecognizeSystem::xmlParser(QByteArray array)
|
||||
}
|
||||
}
|
||||
|
||||
emit sigSaveLoginData(serverAuth);
|
||||
emit sigAuth(serverAuth);
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "ServerDeAuthorization"){
|
||||
@@ -349,6 +355,71 @@ void RecognizeSystem::xmlParser(QByteArray array)
|
||||
emit sigDeAuth(serverDeAuth);
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "ListInstructors"){
|
||||
|
||||
xmlReader.readNext();
|
||||
name = xmlReader.name().toString();
|
||||
|
||||
QList<Instructor> listInstructors;
|
||||
|
||||
while(!xmlReader.atEnd())
|
||||
{
|
||||
name = xmlReader.name().toString();
|
||||
|
||||
if(!xmlReader.isStartElement()) {
|
||||
xmlReader.readNext();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "Instructor")
|
||||
{
|
||||
Instructor instructor;
|
||||
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
|
||||
if (name == "instructor_id"){
|
||||
instructor.setID(value.toInt());
|
||||
}
|
||||
if (name == "name"){
|
||||
instructor.setName(value);
|
||||
}
|
||||
if (name == "login"){
|
||||
instructor.setLogin(value);
|
||||
}
|
||||
if (name == "password"){
|
||||
instructor.setPassword(value);
|
||||
}
|
||||
if (name == "is_admin"){
|
||||
instructor.setIsAdmin(value == "true" ? true : false);
|
||||
}
|
||||
if (name == "archived"){
|
||||
instructor.setArchived(value == "true" ? true : false);
|
||||
}
|
||||
if (name == "logged_in"){
|
||||
instructor.setLoggedIn(value == "true" ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
listInstructors.append(instructor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//emit sigDeAuth(serverDeAuth);
|
||||
|
||||
xmlReader.readNext();
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
i++;
|
||||
|
||||
*this->listInstructors = listInstructors;
|
||||
emit sigAnswerQueryToDB(this->listInstructors);
|
||||
}
|
||||
|
||||
xmlReader.readNext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//#include <mainwindow.h>
|
||||
#include <Core\tools.h>
|
||||
#include "dataparser.h"
|
||||
#include "instructor.h"
|
||||
|
||||
|
||||
class RecognizeSystem : public QObject
|
||||
@@ -27,8 +28,9 @@ signals:
|
||||
void sigSendDebugLog(QString message);
|
||||
void sigSocketDisabled();
|
||||
void sigServerBlocked();
|
||||
void sigSaveLoginData(ServerAuthorization *serverAuth);
|
||||
void sigAuth(ServerAuthorization *serverAuth);
|
||||
void sigDeAuth(ServerDeAuthorization *serverDeAuth);
|
||||
void sigAnswerQueryToDB(QList<Instructor>* listInstructors);
|
||||
void sigSocketWaitForReadyRead(int waitTime);
|
||||
void sigStartCompare();
|
||||
|
||||
@@ -45,6 +47,8 @@ private:
|
||||
qint64 fileSize;
|
||||
int countSend;
|
||||
|
||||
QList<Instructor>* listInstructors;
|
||||
|
||||
void xmlParser(QByteArray array);
|
||||
|
||||
void checkAccessType(QString type);
|
||||
|
||||
@@ -129,6 +129,23 @@ void SendSystem::sendFinish()
|
||||
socket->waitForReadyRead(100);
|
||||
}
|
||||
|
||||
void SendSystem::sendClientQueryToDB()
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
|
||||
QFile file(tempName);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
|
||||
QByteArray array = file.readAll();
|
||||
|
||||
stream << PacketType::TYPE_XMLANSWER;
|
||||
stream << array;
|
||||
socket->waitForBytesWritten();
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
SendSystem::~SendSystem()
|
||||
{
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ public:
|
||||
void sendXMLAnswer(QByteArray array);
|
||||
~SendSystem();
|
||||
void sendFinish();
|
||||
|
||||
void sendClientQueryToDB();
|
||||
signals:
|
||||
void sigSend();
|
||||
QByteArray sigGetXmlAnswer(QString);
|
||||
|
||||
@@ -30,7 +30,9 @@ enum PacketType{
|
||||
TYPE_NEEDUPDATE = 7,
|
||||
TYPE_XMLANSWER = 8,
|
||||
TYPE_QT = 9,
|
||||
TYPE_DISABLE = 11
|
||||
TYPE_DISABLE = 11,
|
||||
|
||||
TYPE_GET_LIST_INSTRUCTORS = 100
|
||||
};
|
||||
|
||||
class Tools {
|
||||
|
||||
@@ -25,10 +25,16 @@ public:
|
||||
QString Login;
|
||||
};
|
||||
|
||||
enum TypeClientAutorization{
|
||||
TYPE_SIMPLE = 0,
|
||||
TYPE_GUI = 10
|
||||
};
|
||||
|
||||
class ClientAutorization{
|
||||
public:
|
||||
QString Login;
|
||||
QString Password;
|
||||
TypeClientAutorization TypeClient;
|
||||
};
|
||||
|
||||
class ClientDeAutorization{
|
||||
@@ -36,6 +42,15 @@ public:
|
||||
QString Login;
|
||||
};
|
||||
|
||||
enum TypeQueryToDB{
|
||||
TYPE_QUERY_GET_LIST_INSTRUCTORS
|
||||
};
|
||||
|
||||
class ClientQueryToDB{
|
||||
public:
|
||||
TypeQueryToDB typeQuery;
|
||||
};
|
||||
|
||||
class ServerMessage
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -22,6 +22,7 @@ bool ConnectorToServer::authorizationInstructorLocal(QString login, QString pass
|
||||
ClientAutorization *autorization = new ClientAutorization;
|
||||
autorization->Login = login;
|
||||
autorization->Password = password;
|
||||
autorization->TypeClient = TypeClientAutorization::TYPE_GUI;
|
||||
|
||||
dataParser->createAuthMessage(autorization);
|
||||
emit sigSendAutorization();
|
||||
@@ -45,6 +46,31 @@ bool ConnectorToServer::deAuthorizationInstructorLocal(QString login)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::queryGetListInstructors()
|
||||
{
|
||||
if (!client->getIsConnected())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ClientQueryToDB *queryToDB = new ClientQueryToDB;
|
||||
queryToDB->typeQuery = TypeQueryToDB::TYPE_QUERY_GET_LIST_INSTRUCTORS;
|
||||
|
||||
dataParser->createQueryToDBMessage(queryToDB);
|
||||
emit sigSendQueryToDB();
|
||||
}
|
||||
|
||||
QList<Instructor> ConnectorToServer::getListInstructors()
|
||||
{
|
||||
return listInstructors;
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB(QList<Instructor>* listInstructors)
|
||||
{
|
||||
this->listInstructors = *listInstructors;
|
||||
emit signal_UpdateDB(true, false);
|
||||
}
|
||||
|
||||
void ConnectorToServer::initialize()
|
||||
{
|
||||
createObjects();
|
||||
@@ -63,8 +89,11 @@ void ConnectorToServer::bindConnection()
|
||||
connect(this,&ConnectorToServer::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
|
||||
connect(this,&ConnectorToServer::sigSendDeAutorization,sendSystem,&SendSystem::sendClientAutorization);
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSaveLoginData,this,&ConnectorToServer::sigLoginResult);
|
||||
connect(this,&ConnectorToServer::sigSendQueryToDB,sendSystem,&SendSystem::sendClientQueryToDB);
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAuth,this,&ConnectorToServer::sigLoginResult);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigDeAuth,this,&ConnectorToServer::sigDeLoginResult);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB,this,&ConnectorToServer::slot_AnswerQueryToDB);
|
||||
}
|
||||
|
||||
void ConnectorToServer::createObjects()
|
||||
|
||||
@@ -16,7 +16,12 @@ public:
|
||||
bool authorizationInstructorLocal(QString login, QString password);
|
||||
bool deAuthorizationInstructorLocal(QString login);
|
||||
|
||||
private slots:
|
||||
bool queryGetListInstructors();
|
||||
|
||||
QList<Instructor> getListInstructors();
|
||||
|
||||
public slots:
|
||||
void slot_AnswerQueryToDB(QList<Instructor>* listInstructors);
|
||||
|
||||
signals:
|
||||
void sigSetConnect(ServerSettings* serverSettings,QThread *thread);
|
||||
@@ -25,9 +30,16 @@ signals:
|
||||
QThread *thread);
|
||||
void sigSendAutorization();
|
||||
void sigSendDeAutorization();
|
||||
|
||||
void sigSendQueryToDB();
|
||||
|
||||
|
||||
void sigLoginResult(ServerAuthorization * serverAuth);
|
||||
void sigDeLoginResult(ServerDeAuthorization * serverDeAuth);
|
||||
|
||||
void signal_UpdateDB(bool treeInstructor, bool treeTrainee);
|
||||
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
void bindConnection();
|
||||
@@ -40,6 +52,7 @@ private:
|
||||
SendSystem *sendSystem;
|
||||
RecognizeSystem *recognizeSystem;
|
||||
|
||||
QList<Instructor> listInstructors;
|
||||
};
|
||||
|
||||
#endif // CONNECTORTOSERVER_H
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "dialogeditinstructor.h"
|
||||
#include "ui_editorinstructors.h"
|
||||
|
||||
EditorInstructors::EditorInstructors(InterfaceDataBaseLMS* dbLMS, bool adminMode, QWidget *parent) :
|
||||
InstructorsView(dbLMS, CommonView::TypeView::control, parent),
|
||||
EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
|
||||
InstructorsView(connectorToServer, CommonView::TypeView::control, parent),
|
||||
ui(new Ui::EditorInstructors)
|
||||
{
|
||||
ui->setupUi((QDialog*)this);
|
||||
|
||||
@@ -16,7 +16,7 @@ class EditorInstructors : public InstructorsView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditorInstructors(InterfaceDataBaseLMS* dbLMS, bool adminMode, QWidget *parent = nullptr);
|
||||
explicit EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent = nullptr);
|
||||
~EditorInstructors();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <QTranslator>
|
||||
#include "instructorsview.h"
|
||||
|
||||
InstructorsView::InstructorsView(InterfaceDataBaseLMS* dbLMS, TypeView type, QWidget *parent):
|
||||
CommonView(dbLMS, type, parent)
|
||||
InstructorsView::InstructorsView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
|
||||
CommonView(connectorToServer, type, parent)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -99,15 +99,14 @@ void InstructorsView::loadInstructorsFromDB()
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
if(!dbLMS->DBisConnected())
|
||||
{
|
||||
mtxTreeWidget.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
//Инструкторы
|
||||
QList<Instructor> listInstructors;
|
||||
listInstructors = dbLMS->getListInstructors();
|
||||
//TODO
|
||||
//listInstructors = dbLMS->getListInstructors();
|
||||
//sendSystem->getListInstructors();
|
||||
|
||||
listInstructors = connectorToServer->getListInstructors();
|
||||
|
||||
for(Instructor instructor : listInstructors)
|
||||
{
|
||||
QTreeWidgetItem *ItemInstructor = new QTreeWidgetItem(treeWidget);
|
||||
|
||||
@@ -11,7 +11,7 @@ class InstructorsView: public CommonView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InstructorsView(InterfaceDataBaseLMS* dbLMS, TypeView type, QWidget *parent = nullptr);
|
||||
InstructorsView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
enum ColumnsTreeInsructors{
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "viewerinstructors.h"
|
||||
#include "ui_viewerinstructors.h"
|
||||
|
||||
ViewerInstructors::ViewerInstructors(InterfaceDataBaseLMS* db, QWidget *parent) :
|
||||
InstructorsView(db, CommonView::TypeView::onlyView, parent),
|
||||
ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidget *parent) :
|
||||
InstructorsView(connectorToServer, CommonView::TypeView::onlyView, parent),
|
||||
ui(new Ui::ViewerInstructors)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -39,7 +39,7 @@ void ViewerInstructors::on_btnEditorInstructors_clicked()
|
||||
{
|
||||
Q_EMIT signal_BlockAutorization(true);
|
||||
|
||||
EditorInstructors editorInstructors(dbLMS, adminMode);
|
||||
EditorInstructors editorInstructors(connectorToServer, adminMode);
|
||||
QDialog* dialog = new QDialog(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(dialog);
|
||||
layout->addWidget(&editorInstructors);
|
||||
|
||||
@@ -14,7 +14,7 @@ class ViewerInstructors : public InstructorsView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ViewerInstructors(InterfaceDataBaseLMS* db, QWidget *parent = nullptr);
|
||||
explicit ViewerInstructors(ConnectorToServer* connectorToServer, QWidget *parent = nullptr);
|
||||
~ViewerInstructors();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -14,7 +14,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
messangerWidget(nullptr),
|
||||
docTasksWidget(nullptr),
|
||||
adminMode(false),
|
||||
loginInstructorLoggedInLocal(QStringLiteral(""))
|
||||
loginInstructorLoggedInLocal(QStringLiteral("")),
|
||||
nameInstructorLoggedInLocal(QStringLiteral(""))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -25,8 +26,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
dbLMS = new InterfaceDataBaseLMS(this);
|
||||
connect(this, &InstructorsAndTraineesWidget::signal_LanguageChanged, dbLMS, &InterfaceDataBaseLMS::slot_LanguageChanged);
|
||||
|
||||
viewerTrainees = new ViewerTrainees(dbLMS);
|
||||
viewerInstructors = new ViewerInstructors(dbLMS);
|
||||
viewerTrainees = new ViewerTrainees(connectorToServer);
|
||||
viewerInstructors = new ViewerInstructors(connectorToServer);
|
||||
connect(this, &InstructorsAndTraineesWidget::signal_NeedUpdateUI, viewerTrainees, &ViewerTrainees::slot_NeedUpdateUI);
|
||||
connect(this, &InstructorsAndTraineesWidget::signal_NeedUpdateUI, viewerInstructors, &ViewerInstructors::slot_NeedUpdateUI);
|
||||
connect(viewerInstructors, &ViewerInstructors::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization);
|
||||
@@ -34,6 +35,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
connect(viewerTrainees, &ViewerTrainees::signal_traineeSelected, this, &InstructorsAndTraineesWidget::signal_traineeSelected);
|
||||
connect(this, &InstructorsAndTraineesWidget::signal_tabMessengerChanged, viewerTrainees, &ViewerTrainees::slot_tabMessengerChanged);
|
||||
|
||||
connect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerInstructors,&ViewerInstructors::slot_NeedUpdateUI);
|
||||
|
||||
messangerWidget = new MessangerWidget(this);
|
||||
|
||||
docTasksWidget = new DocTasksWidget(this);
|
||||
@@ -52,14 +55,6 @@ InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
||||
if(authorizationIsCompleted())
|
||||
deAuthorizationInstructor(loginInstructorLoggedInLocal);
|
||||
|
||||
if(dbLMS->DBisConnected())
|
||||
{
|
||||
dbLMS->deAuthorizationAllInstructors();
|
||||
dbLMS->deAuthorizationAllTrainees();
|
||||
|
||||
dbLMS->DisConnectionFromDB();
|
||||
}
|
||||
|
||||
delete docTasksWidget;
|
||||
delete messangerWidget;
|
||||
delete viewerInstructors;
|
||||
@@ -86,7 +81,7 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event)
|
||||
else
|
||||
ui->btnConnectionToDB->setText(tr("Connection DB"));
|
||||
|
||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, "???");
|
||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +98,7 @@ void InstructorsAndTraineesWidget::checkLoginResult(ServerAuthorization *serverA
|
||||
if (serverAuth->Result)
|
||||
{
|
||||
loginInstructorLoggedInLocal = serverAuth->Login;
|
||||
nameInstructorLoggedInLocal = serverAuth->ClientName;
|
||||
|
||||
if(loginInstructorLoggedInLocal == QStringLiteral("admin"))
|
||||
adminMode = true;
|
||||
@@ -120,12 +116,11 @@ void InstructorsAndTraineesWidget::checkLoginResult(ServerAuthorization *serverA
|
||||
|
||||
updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName);
|
||||
|
||||
//Q_EMIT signal_NeedUpdateUI(true, true);
|
||||
|
||||
QMessageBox::information(this, tr("Instructor authorization"), tr("Successfully!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->btnAuthorizationInstructor->setChecked(false);
|
||||
QMessageBox::warning(this, tr("Instructor authorization"), tr("Invalid login or password!"));
|
||||
}
|
||||
}
|
||||
@@ -135,6 +130,7 @@ void InstructorsAndTraineesWidget::checkDeLoginResult(ServerDeAuthorization *ser
|
||||
if (serverDeAuth->Result)
|
||||
{
|
||||
loginInstructorLoggedInLocal = QStringLiteral("");
|
||||
nameInstructorLoggedInLocal = QStringLiteral("");
|
||||
adminMode = false;
|
||||
|
||||
viewerInstructors->setAdminMode(adminMode);
|
||||
@@ -152,6 +148,7 @@ void InstructorsAndTraineesWidget::checkDeLoginResult(ServerDeAuthorization *ser
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->btnAuthorizationInstructor->setChecked(true);
|
||||
QMessageBox::warning(this, tr("Instructor deauthorization"), tr("Error!"));
|
||||
}
|
||||
}
|
||||
@@ -170,7 +167,6 @@ bool InstructorsAndTraineesWidget::authorizationInstructorDialog(QWidget* parent
|
||||
QString login = dlg.getLogin();
|
||||
QString password = dlg.getPassword();
|
||||
|
||||
//if(authorizationInstructor(login, password))
|
||||
connectorToServer->authorizationInstructorLocal(login, password);
|
||||
|
||||
return true;
|
||||
@@ -188,44 +184,8 @@ bool InstructorsAndTraineesWidget::authorizationInstructorDialog(QWidget* parent
|
||||
|
||||
bool InstructorsAndTraineesWidget::deAuthorizationInstructor(QString login)
|
||||
{
|
||||
mtxAccess.lock();
|
||||
|
||||
/*
|
||||
if(! dbLMS->DBisConnected())
|
||||
{
|
||||
mtxAccess.unlock();
|
||||
return false;
|
||||
}*/
|
||||
|
||||
//Q_EMIT signal_BlockAutorization(true);
|
||||
|
||||
//bool res = dbLMS->deAuthorizationInstructor(login);
|
||||
connectorToServer->deAuthorizationInstructorLocal(login);
|
||||
|
||||
//Q_EMIT signal_BlockAutorization(false);
|
||||
|
||||
/*
|
||||
if(res)
|
||||
{
|
||||
if(loginInstructorLoggedInLocal == login)
|
||||
{
|
||||
loginInstructorLoggedInLocal = QStringLiteral("");
|
||||
adminMode = false;
|
||||
|
||||
viewerInstructors->setAdminMode(adminMode);
|
||||
viewerTrainees->setAdminMode(adminMode);
|
||||
viewerInstructors->setAuthComplited(false);
|
||||
viewerTrainees->setAuthComplited(false);
|
||||
|
||||
Q_EMIT signal_NeedUpdateUI(true, false);
|
||||
}
|
||||
else
|
||||
Q_EMIT signal_NeedUpdateUI(true, false);
|
||||
|
||||
} */
|
||||
|
||||
mtxAccess.unlock();
|
||||
return /*res*/true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InstructorsAndTraineesWidget::authorizationIsCompleted()
|
||||
@@ -242,7 +202,7 @@ void InstructorsAndTraineesWidget::on_btnConnectionToDB_clicked()
|
||||
|
||||
if(stateIsChecked)
|
||||
{//Подключение к БД
|
||||
mtxAccess.lock();
|
||||
|
||||
if(! dbLMS->DBisConnected())
|
||||
{
|
||||
if(dbLMS->ConnectionToDB())
|
||||
@@ -259,7 +219,6 @@ void InstructorsAndTraineesWidget::on_btnConnectionToDB_clicked()
|
||||
Q_EMIT signal_InitMessanger(dbLMS->getListTrainees());
|
||||
}
|
||||
}
|
||||
mtxAccess.unlock();
|
||||
}
|
||||
else
|
||||
{//Отключение от БД
|
||||
@@ -267,7 +226,6 @@ void InstructorsAndTraineesWidget::on_btnConnectionToDB_clicked()
|
||||
if(stateIsCheckedAuthorization)
|
||||
ui->btnAuthorizationInstructor->click();
|
||||
|
||||
mtxAccess.lock();
|
||||
if(dbLMS->DBisConnected())
|
||||
{
|
||||
Q_EMIT signal_BlockAutorization(true);
|
||||
@@ -281,7 +239,6 @@ void InstructorsAndTraineesWidget::on_btnConnectionToDB_clicked()
|
||||
|
||||
Q_EMIT signal_NeedUpdateUI(true, true);
|
||||
}
|
||||
mtxAccess.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +250,6 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
|
||||
{//Авторизация Инструктора локальная (Администратора)
|
||||
if(authorizationInstructorDialog(this))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
ui->btnAuthorizationInstructor->setChecked(false);
|
||||
@@ -304,27 +260,15 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
|
||||
{
|
||||
if(deAuthorizationInstructor(loginInstructorLoggedInLocal))
|
||||
{
|
||||
//ui->btnAuthorizationInstructor->setText(tr("Authorization Instructor"));
|
||||
|
||||
//updateLabelLoggedInInstructor();
|
||||
|
||||
//Q_EMIT signal_NeedUpdateUI(true, true);
|
||||
}
|
||||
else
|
||||
ui->btnAuthorizationInstructor->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::updateLabelLoggedInInstructor(QString login, QString name)
|
||||
{
|
||||
mtxAccess.lock();
|
||||
|
||||
/*
|
||||
if(! dbLMS->DBisConnected())
|
||||
{
|
||||
mtxAccess.unlock();
|
||||
return;
|
||||
}*/
|
||||
|
||||
if(authorizationIsCompleted())
|
||||
{
|
||||
QString nameLoggedInInstructor = QString("%1 (%2)").arg(name, login);
|
||||
@@ -339,8 +283,6 @@ void InstructorsAndTraineesWidget::updateLabelLoggedInInstructor(QString login,
|
||||
ui->lblLoggedInInstructor->setText(tr("none"));
|
||||
ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/icons/circleGray.png")));
|
||||
}
|
||||
|
||||
mtxAccess.unlock();
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::on_btnUpdateStyleSheet_clicked()
|
||||
@@ -348,3 +290,8 @@ void InstructorsAndTraineesWidget::on_btnUpdateStyleSheet_clicked()
|
||||
viewerTrainees->updateMyStyleSheet();
|
||||
viewerInstructors->updateMyStyleSheet();
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::on_btnQueryGetListInstructors_clicked()
|
||||
{
|
||||
connectorToServer->queryGetListInstructors();
|
||||
}
|
||||
|
||||
@@ -31,25 +31,20 @@ public Q_SLOTS:
|
||||
void slot_LanguageChanged(QString language);
|
||||
//Слот обработки результата авторизации
|
||||
void checkLoginResult(ServerAuthorization * serverAuth);
|
||||
//Слот обработки результата авторизации
|
||||
//Слот обработки результата деавторизации
|
||||
void checkDeLoginResult(ServerDeAuthorization * serverDeAuth);
|
||||
|
||||
Q_SIGNALS:
|
||||
//сигнал об изменении языка интерфейса
|
||||
void signal_LanguageChanged(QString language);
|
||||
|
||||
//сигнал о необходимости обновления интерфейса
|
||||
void signal_NeedUpdateUI(bool treeInstructor, bool treeTrainee);
|
||||
|
||||
//сигнал о блокировке авторизации
|
||||
void signal_BlockAutorization(bool block);
|
||||
|
||||
//сигнал о выборе обучаемого (в списке)
|
||||
void signal_traineeSelected(QString login);
|
||||
|
||||
//сигнал об изменении вкладки диалога (в мессенджере)
|
||||
void signal_tabMessengerChanged(QString login);
|
||||
|
||||
//сигнал об инициализации мессенджера
|
||||
void signal_InitMessanger(QList<Trainee> listTrainees);
|
||||
|
||||
@@ -58,13 +53,14 @@ private Q_SLOTS:
|
||||
void on_btnAuthorizationInstructor_clicked();
|
||||
void on_btnUpdateStyleSheet_clicked();
|
||||
|
||||
private:
|
||||
void updateLabelLoggedInInstructor(QString login, QString name);
|
||||
void on_btnQueryGetListInstructors_clicked();
|
||||
|
||||
private:
|
||||
//Авторизация инструктора локальная
|
||||
bool authorizationInstructorDialog(QWidget* parent = nullptr);
|
||||
bool deAuthorizationInstructor(QString login);
|
||||
bool authorizationIsCompleted();
|
||||
void updateLabelLoggedInInstructor(QString login, QString name);
|
||||
|
||||
private:
|
||||
Ui::InstructorsAndTraineesWidget *ui;
|
||||
@@ -80,10 +76,9 @@ private:
|
||||
|
||||
bool adminMode;
|
||||
QString loginInstructorLoggedInLocal;
|
||||
QString nameInstructorLoggedInLocal;
|
||||
|
||||
QTranslator qtLanguageTranslator;
|
||||
|
||||
QMutex mtxAccess;
|
||||
};
|
||||
|
||||
#endif // INSTRUCTORSANDTRAINEESWIDGET_H
|
||||
|
||||
@@ -212,6 +212,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnQueryGetListInstructors">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>58</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>GET_LIST_INSTRUCTORS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "dialogeditgroup.h"
|
||||
#include "dialogedittrainee.h"
|
||||
|
||||
EditorTrainees::EditorTrainees(InterfaceDataBaseLMS* dbLMS, bool adminMode, QWidget *parent) :
|
||||
TraineesView(dbLMS, CommonView::TypeView::control, parent),
|
||||
EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
|
||||
TraineesView(connectorToServer, CommonView::TypeView::control, parent),
|
||||
ui(new Ui::EditorTrainees)
|
||||
{
|
||||
ui->setupUi((QDialog*)this);
|
||||
|
||||
@@ -17,7 +17,7 @@ class EditorTrainees : public TraineesView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditorTrainees(InterfaceDataBaseLMS* dbLMS, bool adminMode, QWidget *parent = nullptr);
|
||||
explicit EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent = nullptr);
|
||||
~EditorTrainees();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <QHeaderView>
|
||||
#include "traineesview.h"
|
||||
|
||||
TraineesView::TraineesView(InterfaceDataBaseLMS* dbLMS, TypeView type, QWidget *parent):
|
||||
CommonView(dbLMS, type, parent)
|
||||
TraineesView::TraineesView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
|
||||
CommonView(connectorToServer, type, parent)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -101,18 +101,12 @@ void TraineesView::loadTraineesFromDB()
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
if(!dbLMS->DBisConnected())
|
||||
{
|
||||
mtxTreeWidget.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
QList <Group> listGroups;
|
||||
QList <Trainee> listTrainees;
|
||||
//dbLMS->transactionBegin();
|
||||
listGroups = dbLMS->getListGroups();
|
||||
listTrainees = dbLMS->getListTrainees();
|
||||
//dbLMS->transactionEnd();
|
||||
|
||||
//TODO
|
||||
//listGroups = dbLMS->getListGroups();
|
||||
//listTrainees = dbLMS->getListTrainees();
|
||||
|
||||
for(Group group : listGroups)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ class TraineesView: public CommonView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TraineesView(InterfaceDataBaseLMS* dbLMS, TypeView type, QWidget *parent = nullptr);
|
||||
TraineesView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
enum ColumnsTreeTrainees{
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include "viewertrainees.h"
|
||||
#include "ui_viewertrainees.h"
|
||||
|
||||
ViewerTrainees::ViewerTrainees(InterfaceDataBaseLMS* db, QWidget *parent) :
|
||||
TraineesView(db, CommonView::TypeView::onlyView, parent),
|
||||
ViewerTrainees::ViewerTrainees(ConnectorToServer* connectorToServer, QWidget *parent) :
|
||||
TraineesView(connectorToServer, CommonView::TypeView::onlyView, parent),
|
||||
ui(new Ui::ViewerTrainees)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -67,7 +67,7 @@ void ViewerTrainees::on_btnEditorTrainees_clicked()
|
||||
{
|
||||
Q_EMIT signal_BlockAutorization(true);
|
||||
|
||||
EditorTrainees editorTraineesGroups(dbLMS, adminMode);
|
||||
EditorTrainees editorTraineesGroups(connectorToServer, adminMode);
|
||||
QDialog* dialog = new QDialog(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(dialog);
|
||||
layout->addWidget(&editorTraineesGroups);
|
||||
|
||||
@@ -14,7 +14,7 @@ class ViewerTrainees : public TraineesView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ViewerTrainees(InterfaceDataBaseLMS* db, QWidget *parent = nullptr);
|
||||
explicit ViewerTrainees(ConnectorToServer* connectorToServer, QWidget *parent = nullptr);
|
||||
~ViewerTrainees();
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user