mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
сделал newInstructor
This commit is contained in:
@@ -114,4 +114,11 @@ endif()
|
||||
target_link_libraries(InstructorsAndTrainees PRIVATE libDataBaseLMS.dll)
|
||||
|
||||
|
||||
add_custom_command(TARGET InstructorsAndTrainees
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
d:/LMS/DB_IaT/Debug64/libInstructorsAndTrainees.dll
|
||||
d:/LMS/GUIdataBaseLMS/Debug64)
|
||||
|
||||
|
||||
#install(TARGETS InstructorsAndTrainees DESTINATION ${VEYON_LIB_DIR})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.11.1, 2024-12-09T17:51:46. -->
|
||||
<!-- Written by QtCreator 4.11.1, 2024-12-10T17:52:46. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -16,10 +16,6 @@ RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||
tmpBlock.clear();
|
||||
countSend = 0;
|
||||
folderList = new QList<QString>;
|
||||
|
||||
listInstructors = new QList<Instructor>;
|
||||
listTrainees = new QList<Trainee>;
|
||||
listGroups = new QList<Group>;
|
||||
}
|
||||
|
||||
RecognizeSystem::~RecognizeSystem()
|
||||
@@ -256,19 +252,29 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
if(packetType == PacketType::TYPE_XMLANSWER_ON_QUERY_TO_DB){ //ответы формата XML на запросы к БД
|
||||
QByteArray array;
|
||||
stream.startTransaction();
|
||||
stream >> array;
|
||||
//xml-ответы на запросы к БД
|
||||
switch(packetType)
|
||||
{
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_INSTRUCTORS:
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_GROUPS:
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_TRAINEES:
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_COMPUTERS:
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_CLASSROOMS:
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_TASKS:
|
||||
{
|
||||
QByteArray array;
|
||||
stream.startTransaction();
|
||||
stream >> array;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
continue;
|
||||
if(!stream.commitTransaction())
|
||||
continue;
|
||||
|
||||
xmlParserQueryToDB(packetType, array);
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
xmlParserQueryToDB(array);
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
break;
|
||||
};
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
@@ -372,168 +378,153 @@ void RecognizeSystem::xmlParser(QByteArray array)
|
||||
emit sigDeAuth(serverDeAuth);
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "AllLists"){
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
void RecognizeSystem::xmlParserQueryToDB(QByteArray array)
|
||||
void RecognizeSystem::xmlParserQueryToDB(PacketType packetType, QByteArray array)
|
||||
{
|
||||
QDomDocument groupsTraineesDOM;
|
||||
QDomDocument commonDOM;
|
||||
commonDOM.setContent(array);
|
||||
|
||||
/*
|
||||
QString xmlFileName = appDirPath + "/groupsTrainees.xml";
|
||||
QFile xmlInFile(xmlFileName);
|
||||
if (!xmlInFile.open(QFile::ReadOnly | QFile::Text))
|
||||
switch(packetType)
|
||||
{
|
||||
qDebug() << "LoadTraineesGroupsXML: Не удалось открыть файл " + xmlFileName;
|
||||
return;
|
||||
}
|
||||
else*/
|
||||
{
|
||||
QList<Instructor> listInstructors;
|
||||
QList<Trainee> listTrainees;
|
||||
QList<Group> listGroups;
|
||||
|
||||
listInstructors.clear();
|
||||
listTrainees.clear();
|
||||
listGroups.clear();
|
||||
|
||||
groupsTraineesDOM.setContent(array);
|
||||
|
||||
/*
|
||||
groupsTraineesDOM.setContent(xmlInFile.readAll());
|
||||
xmlInFile.close();*/
|
||||
|
||||
//QDomNode groupsTraineesNode = groupsTraineesDOM.namedItem("groupsTrainees");
|
||||
|
||||
QDomNode allListsNode = groupsTraineesDOM.namedItem("AllLists");
|
||||
|
||||
QDomNode groupsTraineesNode = allListsNode.firstChildElement("GroupsTrainees");
|
||||
QDomNode allInstructorsNode = allListsNode.firstChildElement("Instructors");
|
||||
|
||||
for(int i = 0; i < groupsTraineesNode.childNodes().count(); i++)
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_INSTRUCTORS:
|
||||
{
|
||||
QDomNode groupNode = groupsTraineesNode.childNodes().at(i);
|
||||
if(groupNode.nodeName().toLower() == "group")
|
||||
{//Группа
|
||||
QList<Instructor> listInstructors;
|
||||
QDomNode listNode = commonDOM.namedItem("ListInstructors");
|
||||
|
||||
Group group;
|
||||
group.setName(groupNode.toElement().attribute("group_id"));
|
||||
group.setName(groupNode.toElement().attribute("name"));
|
||||
listGroups.append(group);
|
||||
for(int i = 0; i < listNode.childNodes().count(); i++)
|
||||
{
|
||||
QDomNode instructorNode = listNode.childNodes().at(i);
|
||||
if(instructorNode.nodeName() == "Instructor")
|
||||
{//Инструктор
|
||||
Instructor instructor;
|
||||
instructor.setID(instructorNode.toElement().attribute("instructor_id").toInt());
|
||||
instructor.setName(instructorNode.toElement().attribute("name"));
|
||||
instructor.setLogin(instructorNode.toElement().attribute("login"));
|
||||
instructor.setPassword(instructorNode.toElement().attribute("password"));
|
||||
instructor.setIsAdmin(instructorNode.toElement().attribute("is_admin").toInt());
|
||||
instructor.setArchived(instructorNode.toElement().attribute("archived").toInt());
|
||||
instructor.setLoggedIn(instructorNode.toElement().attribute("logged_in").toInt());
|
||||
|
||||
for(int j = 0; j < groupNode.childNodes().count(); j++)
|
||||
{
|
||||
QDomNode traineeNode = groupNode.childNodes().at(j);
|
||||
if(traineeNode.nodeName().toLower() == "trainee")
|
||||
{//Обучаемый
|
||||
|
||||
Trainee trainee;
|
||||
|
||||
trainee.setID(traineeNode.toElement().attribute("trainee_id").toInt());
|
||||
trainee.setName(traineeNode.toElement().attribute("name"));
|
||||
trainee.setLogin(traineeNode.toElement().attribute("login"));
|
||||
trainee.setPassword(traineeNode.toElement().attribute("password"));
|
||||
trainee.setArchived(traineeNode.toElement().attribute("archived") == QStringLiteral("true") ? true : false);
|
||||
trainee.setArchived(traineeNode.toElement().attribute("logged_in") == QStringLiteral("true") ? true : false);
|
||||
trainee.setGroup(group);
|
||||
|
||||
listTrainees.append(trainee);
|
||||
}
|
||||
listInstructors.append(instructor);
|
||||
}
|
||||
}
|
||||
}//for(int i = 0; i < groupsTraineesNode.childNodes().count(); i++)
|
||||
|
||||
for(int i = 0; i < allInstructorsNode.childNodes().count(); i++)
|
||||
emit sigAnswerQueryToDB_ListInstructors(listInstructors);
|
||||
}
|
||||
break;
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_GROUPS:
|
||||
{
|
||||
QDomNode instructorNode = allInstructorsNode.childNodes().at(i);
|
||||
if(instructorNode.nodeName().toLower() == "instructor")
|
||||
{//Инструктор
|
||||
QList<Group> listGroups;
|
||||
QDomNode listNode = commonDOM.namedItem("ListGroups");
|
||||
|
||||
Instructor instructor;
|
||||
instructor.setID(instructorNode.toElement().attribute("instructor_id").toInt());
|
||||
instructor.setName(instructorNode.toElement().attribute("name"));
|
||||
instructor.setLogin(instructorNode.toElement().attribute("login"));
|
||||
instructor.setPassword(instructorNode.toElement().attribute("password"));
|
||||
instructor.setIsAdmin(instructorNode.toElement().attribute("is_admin") == QStringLiteral("true") ? true : false);
|
||||
instructor.setArchived(instructorNode.toElement().attribute("archived") == QStringLiteral("true") ? true : false);
|
||||
instructor.setLoggedIn(instructorNode.toElement().attribute("logged_in") == QStringLiteral("true") ? true : false);
|
||||
for(int i = 0; i < listNode.childNodes().count(); i++)
|
||||
{
|
||||
QDomNode groupNode = listNode.childNodes().at(i);
|
||||
if(groupNode.nodeName() == "Group")
|
||||
{//Группа
|
||||
Group group;
|
||||
group.setID(groupNode.toElement().attribute("group_id").toInt());
|
||||
group.setName(groupNode.toElement().attribute("name"));
|
||||
|
||||
listInstructors.append(instructor);
|
||||
listGroups.append(group);
|
||||
}
|
||||
}
|
||||
}//for(int i = 0; i < allInstructorsNode.childNodes().count(); i++)
|
||||
emit sigAnswerQueryToDB_ListGroups(listGroups);
|
||||
}
|
||||
break;
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_TRAINEES:
|
||||
{
|
||||
QList<Trainee> listTrainees;
|
||||
QDomNode listNode = commonDOM.namedItem("ListTrainees");
|
||||
|
||||
*this->listInstructors = listInstructors;
|
||||
*this->listTrainees = listTrainees;
|
||||
*this->listGroups = listGroups;
|
||||
for(int i = 0; i < listNode.childNodes().count(); i++)
|
||||
{
|
||||
QDomNode traineeNode = listNode.childNodes().at(i);
|
||||
if(traineeNode.nodeName() == "Trainee")
|
||||
{//Обучаемый
|
||||
Trainee trainee;
|
||||
trainee.setID(traineeNode.toElement().attribute("trainee_id").toInt());
|
||||
trainee.setName(traineeNode.toElement().attribute("name"));
|
||||
trainee.setLogin(traineeNode.toElement().attribute("login"));
|
||||
trainee.setPassword(traineeNode.toElement().attribute("password"));
|
||||
trainee.setArchived(traineeNode.toElement().attribute("archived").toInt());
|
||||
trainee.setLoggedIn(traineeNode.toElement().attribute("logged_in").toInt());
|
||||
Group group(traineeNode.toElement().attribute("group_trainee").toInt(), "");
|
||||
trainee.setGroup(group);
|
||||
//trainee.setComputer()
|
||||
//trainee.setTasks()
|
||||
|
||||
emit sigAnswerQueryToDB(this->listInstructors, this->listTrainees, this->listGroups);
|
||||
}
|
||||
listTrainees.append(trainee);
|
||||
}
|
||||
}
|
||||
emit sigAnswerQueryToDB_ListTrainees(listTrainees);
|
||||
}
|
||||
break;
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_COMPUTERS:
|
||||
{
|
||||
QList<Computer> listComputers;
|
||||
QDomNode listNode = commonDOM.namedItem("ListComputers");
|
||||
|
||||
for(int i = 0; i < listNode.childNodes().count(); i++)
|
||||
{
|
||||
QDomNode computerNode = listNode.childNodes().at(i);
|
||||
if(computerNode.nodeName() == "Computer")
|
||||
{//Компьютер
|
||||
Computer computer;
|
||||
computer.setID(computerNode.toElement().attribute("computer_id").toInt());
|
||||
computer.setName(computerNode.toElement().attribute("name"));
|
||||
computer.setIpAddress(computerNode.toElement().attribute("ip_address"));
|
||||
//computer.setClassroom
|
||||
|
||||
listComputers.append(computer);
|
||||
}
|
||||
}
|
||||
emit sigAnswerQueryToDB_ListComputers(listComputers);
|
||||
}
|
||||
break;
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_CLASSROOMS:
|
||||
{
|
||||
QList<Classroom> listClassrooms;
|
||||
QDomNode listNode = commonDOM.namedItem("ListClassrooms");
|
||||
|
||||
for(int i = 0; i < listNode.childNodes().count(); i++)
|
||||
{
|
||||
QDomNode classroomNode = listNode.childNodes().at(i);
|
||||
if(classroomNode.nodeName() == "Classroom")
|
||||
{//Класс
|
||||
Classroom classroom;
|
||||
classroom.setID(classroomNode.toElement().attribute("classroom_id").toInt());
|
||||
classroom.setName(classroomNode.toElement().attribute("name"));
|
||||
|
||||
listClassrooms.append(classroom);
|
||||
}
|
||||
}
|
||||
emit sigAnswerQueryToDB_ListClassrooms(listClassrooms);
|
||||
}
|
||||
break;
|
||||
case TYPE_XMLANSWER_QUERY_DB__LIST_TASKS:
|
||||
{
|
||||
QList<Task> listTasks;
|
||||
QDomNode listNode = commonDOM.namedItem("ListTasks");
|
||||
|
||||
for(int i = 0; i < listNode.childNodes().count(); i++)
|
||||
{
|
||||
QDomNode taskNode = listNode.childNodes().at(i);
|
||||
if(taskNode.nodeName() == "Task")
|
||||
{//Задача
|
||||
Task task;
|
||||
task.setID(taskNode.toElement().attribute("task_id").toInt());
|
||||
task.setName(taskNode.toElement().attribute("name"));
|
||||
|
||||
listTasks.append(task);
|
||||
}
|
||||
}
|
||||
emit sigAnswerQueryToDB_ListTasks(listTasks);
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
void RecognizeSystem::checkAccessType(QString type)
|
||||
|
||||
@@ -38,6 +38,13 @@ signals:
|
||||
void sigSocketWaitForReadyRead(int waitTime);
|
||||
void sigStartCompare();
|
||||
|
||||
void sigAnswerQueryToDB_ListInstructors(QList<Instructor> listInstructors);
|
||||
void sigAnswerQueryToDB_ListGroups(QList<Group> listGroups);
|
||||
void sigAnswerQueryToDB_ListTrainees(QList<Trainee> listTrainees);
|
||||
void sigAnswerQueryToDB_ListComputers(QList<Computer> listComputers);
|
||||
void sigAnswerQueryToDB_ListClassrooms(QList<Classroom> listClassrooms);
|
||||
void sigAnswerQueryToDB_ListTasks(QList<Task> listTasks);
|
||||
|
||||
private:
|
||||
QList<QString> *folderList;
|
||||
//MainWindow *mainWindow;
|
||||
@@ -51,12 +58,8 @@ private:
|
||||
qint64 fileSize;
|
||||
int countSend;
|
||||
|
||||
QList<Instructor>* listInstructors;
|
||||
QList<Trainee>* listTrainees;
|
||||
QList<Group>* listGroups;
|
||||
|
||||
void xmlParser(QByteArray array);
|
||||
void xmlParserQueryToDB(QByteArray array);
|
||||
void xmlParserQueryToDB(PacketType packetType, QByteArray array);
|
||||
|
||||
void checkAccessType(QString type);
|
||||
};
|
||||
|
||||
@@ -32,8 +32,13 @@ enum PacketType{
|
||||
TYPE_QT = 9,
|
||||
TYPE_DISABLE = 11,
|
||||
|
||||
TYPE_GET_LIST_INSTRUCTORS = 100,
|
||||
TYPE_XMLANSWER_ON_QUERY_TO_DB = 101 //xml-ответ на запрос к БД
|
||||
//xml-ответы на запросы к БД
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_INSTRUCTORS = 100,
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_GROUPS = 101,
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_TRAINEES = 102,
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_COMPUTERS = 103,
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_CLASSROOMS = 104,
|
||||
TYPE_XMLANSWER_QUERY_DB__LIST_TASKS = 105
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(PacketType)
|
||||
|
||||
@@ -44,7 +44,8 @@ public:
|
||||
|
||||
enum TypeQueryToDB{
|
||||
TYPE_QUERY_GET_LIST_INSTRUCTORS,
|
||||
TYPE_QUERY_GET_ALL_LISTS
|
||||
TYPE_QUERY_GET_ALL_LISTS,
|
||||
TYPE_QUERY_NEW_INSTRUCTOR
|
||||
};
|
||||
|
||||
class ClientQueryToDB{
|
||||
|
||||
@@ -77,6 +77,92 @@ QList<Group> ConnectorToServer::getListGroups()
|
||||
return listGroups;
|
||||
}
|
||||
|
||||
QList<Computer> ConnectorToServer::getListComputers()
|
||||
{
|
||||
return listComputers;
|
||||
}
|
||||
|
||||
QList<Classroom> ConnectorToServer::getListClassrooms()
|
||||
{
|
||||
return listClassrooms;
|
||||
}
|
||||
|
||||
QList<Task> ConnectorToServer::getListTasks()
|
||||
{
|
||||
return listTasks;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::isArchivedInstructor(int id)
|
||||
{
|
||||
for(Instructor instructor : listInstructors)
|
||||
{
|
||||
if(instructor.getID() == id)
|
||||
{
|
||||
if(instructor.getArchived()) return true; else return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::isAdminInstructor(int id)
|
||||
{
|
||||
for(Instructor instructor : listInstructors)
|
||||
{
|
||||
if(instructor.getID() == id)
|
||||
{
|
||||
if(instructor.getIsAdmin()) return true; else return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::isLoggedInInstructor(int id)
|
||||
{
|
||||
for(Instructor instructor : listInstructors)
|
||||
{
|
||||
if(instructor.getID() == id)
|
||||
{
|
||||
if(instructor.getLoggedIn()) return true; else return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<Trainee> ConnectorToServer::getListTraineesInGroup(int id)
|
||||
{
|
||||
QList<Trainee> list;
|
||||
for(Trainee trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getGroup().getID() == id)
|
||||
list.append(trainee);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::isArchivedTrainee(int id)
|
||||
{
|
||||
for(Trainee trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getID() == id)
|
||||
{
|
||||
if(trainee.getArchived()) return true; else return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::isLoggedInTrainee(int id)
|
||||
{
|
||||
for(Trainee trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getID() == id)
|
||||
{
|
||||
if(trainee.getLoggedIn()) return true; else return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB(QList<Instructor>* listInstructors,
|
||||
QList<Trainee>* listTrainees,
|
||||
QList<Group>* listGroups)
|
||||
@@ -87,6 +173,44 @@ void ConnectorToServer::slot_AnswerQueryToDB(QList<Instructor>* listInstructors,
|
||||
emit signal_UpdateDB(true, true);
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB_ListInstructors(QList<Instructor> listInstructors)
|
||||
{
|
||||
this->listInstructors = listInstructors;
|
||||
emit signal_UpdateDB(true, false);
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB_ListGroups(QList<Group> listGroups)
|
||||
{
|
||||
this->listGroups = listGroups;
|
||||
emit signal_UpdateDB(false, true);
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB_ListTrainees(QList<Trainee> listTrainees)
|
||||
{
|
||||
this->listTrainees = listTrainees;
|
||||
emit signal_UpdateDB(false, true);
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB_ListComputers(QList<Computer> listComputers)
|
||||
{
|
||||
this->listComputers = listComputers;
|
||||
//emit signal_UpdateDB(false, true);
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB_ListClassrooms(QList<Classroom> listClassrooms)
|
||||
{
|
||||
this->listClassrooms = listClassrooms;
|
||||
//emit signal_UpdateDB(false, true);
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB_ListTasks(QList<Task> listTasks)
|
||||
{
|
||||
this->listTasks = listTasks;
|
||||
//emit signal_UpdateDB(false, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConnectorToServer::initialize()
|
||||
{
|
||||
createObjects();
|
||||
@@ -110,6 +234,13 @@ void ConnectorToServer::bindConnection()
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAuth,this,&ConnectorToServer::sigLoginResult);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigDeAuth,this,&ConnectorToServer::sigDeLoginResult);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB,this,&ConnectorToServer::slot_AnswerQueryToDB);
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListInstructors,this,&ConnectorToServer::slot_AnswerQueryToDB_ListInstructors);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListGroups,this,&ConnectorToServer::slot_AnswerQueryToDB_ListGroups);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListTrainees,this,&ConnectorToServer::slot_AnswerQueryToDB_ListTrainees);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListComputers,this,&ConnectorToServer::slot_AnswerQueryToDB_ListComputers);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListClassrooms,this,&ConnectorToServer::slot_AnswerQueryToDB_ListClassrooms);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListTasks,this,&ConnectorToServer::slot_AnswerQueryToDB_ListTasks);
|
||||
}
|
||||
|
||||
void ConnectorToServer::createObjects()
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "instructor.h"
|
||||
#include "trainee.h"
|
||||
#include "group.h"
|
||||
#include "computer.h"
|
||||
#include "classroom.h"
|
||||
#include "task.h"
|
||||
|
||||
class ConnectorToServer : public QObject
|
||||
{
|
||||
@@ -21,15 +24,35 @@ public:
|
||||
|
||||
bool sendQueryToDB(TypeQueryToDB typeQuery);
|
||||
|
||||
public:
|
||||
//Запросы к БД (локальной)
|
||||
QList<Instructor> getListInstructors();
|
||||
QList<Trainee> getListTrainees();
|
||||
QList<Group> getListGroups();
|
||||
QList<Computer> getListComputers();
|
||||
QList<Classroom> getListClassrooms();
|
||||
QList<Task> getListTasks();
|
||||
|
||||
bool isArchivedInstructor(int id);
|
||||
bool isAdminInstructor(int id);
|
||||
bool isLoggedInInstructor(int id);
|
||||
|
||||
QList<Trainee> getListTraineesInGroup(int id);
|
||||
bool isArchivedTrainee(int id);
|
||||
bool isLoggedInTrainee(int id);
|
||||
|
||||
public slots:
|
||||
void slot_AnswerQueryToDB(QList<Instructor>* listInstructors,
|
||||
QList<Trainee>* listTrainees,
|
||||
QList<Group>* listGroups);
|
||||
|
||||
void slot_AnswerQueryToDB_ListInstructors(QList<Instructor> listInstructors);
|
||||
void slot_AnswerQueryToDB_ListGroups(QList<Group> listGroups);
|
||||
void slot_AnswerQueryToDB_ListTrainees(QList<Trainee> listTrainees);
|
||||
void slot_AnswerQueryToDB_ListComputers(QList<Computer> listComputers);
|
||||
void slot_AnswerQueryToDB_ListClassrooms(QList<Classroom> listClassrooms);
|
||||
void slot_AnswerQueryToDB_ListTasks(QList<Task> listTasks);
|
||||
|
||||
signals:
|
||||
void sigSetConnect(ServerSettings* serverSettings,QThread *thread);
|
||||
void sigInitializeClient(RecognizeSystem *recognizeSystem,
|
||||
@@ -59,9 +82,13 @@ private:
|
||||
SendSystem *sendSystem;
|
||||
RecognizeSystem *recognizeSystem;
|
||||
|
||||
QList<Instructor> listInstructors;
|
||||
QList<Trainee> listTrainees;
|
||||
//Списочная модель БД СУО
|
||||
QList<Instructor> listInstructors;
|
||||
QList<Group> listGroups;
|
||||
QList<Trainee> listTrainees;
|
||||
QList<Computer> listComputers;
|
||||
QList<Classroom> listClassrooms;
|
||||
QList<Task> listTasks;
|
||||
};
|
||||
|
||||
#endif // CONNECTORTOSERVER_H
|
||||
|
||||
@@ -30,6 +30,10 @@ EditorInstructors::~EditorInstructors()
|
||||
|
||||
void EditorInstructors::on_btnNewInstructor_clicked()
|
||||
{
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_INSTRUCTOR);
|
||||
|
||||
return;
|
||||
|
||||
if(int id_instructor = dbLMS->newInstructor())
|
||||
{
|
||||
loadInstructorsFromDB();
|
||||
@@ -236,7 +240,7 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
|
||||
|
||||
int id = current->text(ColumnsTreeInsructors::clmn_ID).toInt();
|
||||
|
||||
if(dbLMS->isArchivedInstructor(id))
|
||||
if(connectorToServer->isArchivedInstructor(id))
|
||||
{//Архивный
|
||||
ui->btnToOrFromArchive->setText(tr("From archive"));
|
||||
ui->btnToOrFromArchive->setIcon(QIcon(QStringLiteral(":/icons/instructorFromArchive.png")));
|
||||
@@ -249,7 +253,7 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
|
||||
|
||||
ui->btnNewInstructor->setEnabled(true);
|
||||
|
||||
if(dbLMS->isAdminInstructor(id) || dbLMS->isLoggedInInstructor(id))
|
||||
if(connectorToServer->isAdminInstructor(id) || connectorToServer->isLoggedInInstructor(id))
|
||||
{//Это Админ или залогированный! Удалять/Архивировать/Редактировать нельзя!
|
||||
ui->btnDeleteInstructor->setEnabled(false);
|
||||
ui->btnToOrFromArchive->setEnabled(false);
|
||||
@@ -259,7 +263,7 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
|
||||
{
|
||||
ui->btnToOrFromArchive->setEnabled(true);
|
||||
|
||||
if(dbLMS->isArchivedInstructor(id))
|
||||
if(connectorToServer->isArchivedInstructor(id))
|
||||
ui->btnDeleteInstructor->setEnabled(true);
|
||||
else
|
||||
ui->btnDeleteInstructor->setEnabled(false);
|
||||
|
||||
@@ -40,6 +40,8 @@ void ViewerInstructors::on_btnEditorInstructors_clicked()
|
||||
Q_EMIT signal_BlockAutorization(true);
|
||||
|
||||
EditorInstructors editorInstructors(connectorToServer, adminMode);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateDB, &editorInstructors, &EditorInstructors::slot_NeedUpdateUI);
|
||||
|
||||
QDialog* dialog = new QDialog(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(dialog);
|
||||
layout->addWidget(&editorInstructors);
|
||||
|
||||
@@ -20,6 +20,12 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
|
||||
qRegisterMetaType<PacketType>("PacketType");
|
||||
qRegisterMetaType<QList<Instructor>>("QList<Instructor>");
|
||||
qRegisterMetaType<QList<Trainee>>("QList<Trainee>");
|
||||
qRegisterMetaType<QList<Group>>("QList<Group>");
|
||||
qRegisterMetaType<QList<Computer>>("QList<Computer>");
|
||||
qRegisterMetaType<QList<Classroom>>("QList<Classroom>");
|
||||
qRegisterMetaType<QList<Task>>("QList<Task>");
|
||||
|
||||
connectorToServer = new ConnectorToServer(this);
|
||||
connect(connectorToServer,&ConnectorToServer::sigLoginResult,this,&InstructorsAndTraineesWidget::checkLoginResult);
|
||||
@@ -28,8 +34,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
dbLMS = new InterfaceDataBaseLMS(this);
|
||||
connect(this, &InstructorsAndTraineesWidget::signal_LanguageChanged, dbLMS, &InterfaceDataBaseLMS::slot_LanguageChanged);
|
||||
|
||||
viewerTrainees = new ViewerTrainees(connectorToServer);
|
||||
viewerInstructors = new ViewerInstructors(connectorToServer);
|
||||
viewerTrainees = new ViewerTrainees(connectorToServer, this);
|
||||
viewerInstructors = new ViewerInstructors(connectorToServer, this);
|
||||
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);
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
#include "interfacedatabaselms.h"
|
||||
#include "connectortoserver.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QList<Instructor>)
|
||||
Q_DECLARE_METATYPE(QList<Trainee>)
|
||||
Q_DECLARE_METATYPE(QList<Group>)
|
||||
Q_DECLARE_METATYPE(QList<Computer>)
|
||||
Q_DECLARE_METATYPE(QList<Classroom>)
|
||||
Q_DECLARE_METATYPE(QList<Task>)
|
||||
|
||||
namespace Ui {
|
||||
class InstructorsAndTraineesWidget;
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
{
|
||||
ui->btnNewGroup->setEnabled(true);
|
||||
|
||||
if(dbLMS->getListTraineesInGroup(id_group).count() > 0)
|
||||
if(connectorToServer->getListTraineesInGroup(id_group).count() > 0)
|
||||
{//Группа не пуста
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
}
|
||||
@@ -424,7 +424,7 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
ui->btnNewTrainee->setEnabled(false);
|
||||
|
||||
if(dbLMS->isArchivedTrainee(id_trainee))
|
||||
if(connectorToServer->isArchivedTrainee(id_trainee))
|
||||
{//Архивный
|
||||
//ui->btnDeleteTrainee->setEnabled(true);
|
||||
|
||||
@@ -439,7 +439,7 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
ui->btnToOrFromArchiveTrainee->setIcon(QIcon(QStringLiteral(":/icons/traineeArchive.png")));
|
||||
}
|
||||
|
||||
if(dbLMS->isLoggedInTrainee(id_trainee))
|
||||
if(connectorToServer->isLoggedInTrainee(id_trainee))
|
||||
{//Это залогированный! Удалять/Архивировать/Редактировать нельзя!
|
||||
ui->btnDeleteTrainee->setEnabled(false);
|
||||
ui->btnToOrFromArchiveTrainee->setEnabled(false);
|
||||
@@ -449,7 +449,7 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
{
|
||||
ui->btnToOrFromArchiveTrainee->setEnabled(true);
|
||||
|
||||
if(dbLMS->isArchivedTrainee(id_trainee))
|
||||
if(connectorToServer->isArchivedTrainee(id_trainee))
|
||||
ui->btnDeleteTrainee->setEnabled(true);
|
||||
else
|
||||
ui->btnDeleteTrainee->setEnabled(false);
|
||||
|
||||
@@ -187,8 +187,8 @@ void TraineesView::loadTraineesFromDB()
|
||||
ItemTrainee->setHidden(true);
|
||||
}
|
||||
|
||||
if(! archiveVisible && cntChildsNotArchived == 0)
|
||||
delete ItemGroup;
|
||||
//if(! archiveVisible && cntChildsNotArchived == 0)
|
||||
//delete ItemGroup;
|
||||
}
|
||||
|
||||
treeWidget->expandAll();
|
||||
|
||||
@@ -68,6 +68,8 @@ void ViewerTrainees::on_btnEditorTrainees_clicked()
|
||||
Q_EMIT signal_BlockAutorization(true);
|
||||
|
||||
EditorTrainees editorTraineesGroups(connectorToServer, adminMode);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateDB, &editorTraineesGroups, &EditorTrainees::slot_NeedUpdateUI);
|
||||
|
||||
QDialog* dialog = new QDialog(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(dialog);
|
||||
layout->addWidget(&editorTraineesGroups);
|
||||
|
||||
Reference in New Issue
Block a user