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:
@@ -3,6 +3,10 @@
|
||||
#include "FileData.h"
|
||||
#include "tools.h"
|
||||
|
||||
#include "instructor.h"
|
||||
#include "trainee.h"
|
||||
#include "group.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
DataParser::DataParser(QObject *parent) :
|
||||
@@ -71,7 +75,7 @@ void DataParser::createAuthMessage(ClientAutorization *auth)
|
||||
file.close();
|
||||
}
|
||||
|
||||
void DataParser::createQueryToDBMessage(ClientQueryToDB *queryToDB, int id)
|
||||
void DataParser::createQueryToDBMessage(ClientQueryToDB *queryToDB, int id, void* data)
|
||||
{
|
||||
QFile file(tempName);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
@@ -86,6 +90,48 @@ void DataParser::createQueryToDBMessage(ClientQueryToDB *queryToDB, int id)
|
||||
if(id)
|
||||
xmlWriter.writeAttribute("id", QString::number(id));
|
||||
|
||||
if(data)
|
||||
{
|
||||
if(queryToDB->typeQuery == TypeQueryToDB::TYPE_QUERY_EDIT_INSTRUCTOR)
|
||||
{
|
||||
Instructor* instructor = (Instructor*)data;
|
||||
if(instructor)
|
||||
{
|
||||
xmlWriter.writeAttribute("instructor_id", QString::number(instructor->getID()));
|
||||
xmlWriter.writeAttribute("name", instructor->getName());
|
||||
xmlWriter.writeAttribute("login", instructor->getLogin());
|
||||
xmlWriter.writeAttribute("password", instructor->getPassword());
|
||||
xmlWriter.writeAttribute("is_admin", QString::number(instructor->getIsAdmin()));
|
||||
xmlWriter.writeAttribute("archived", QString::number(instructor->getArchived()));
|
||||
xmlWriter.writeAttribute("logged_in", QString::number(instructor->getLoggedIn()));
|
||||
}
|
||||
}
|
||||
else if(queryToDB->typeQuery == TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE)
|
||||
{
|
||||
Trainee* trainee = (Trainee*)data;
|
||||
if(trainee)
|
||||
{
|
||||
xmlWriter.writeAttribute("trainee_id", QString::number(trainee->getID()));
|
||||
xmlWriter.writeAttribute("name", trainee->getName());
|
||||
xmlWriter.writeAttribute("login", trainee->getLogin());
|
||||
xmlWriter.writeAttribute("password", trainee->getPassword());
|
||||
xmlWriter.writeAttribute("archived", QString::number(trainee->getArchived()));
|
||||
xmlWriter.writeAttribute("logged_in", QString::number(trainee->getLoggedIn()));
|
||||
xmlWriter.writeAttribute("group_trainee", QString::number(trainee->getGroup().getID()));
|
||||
xmlWriter.writeAttribute("computer_trainee", QString::number(trainee->getComputer().getID()));
|
||||
}
|
||||
}
|
||||
else if(queryToDB->typeQuery == TypeQueryToDB::TYPE_QUERY_EDIT_GROUP)
|
||||
{
|
||||
Group* group = (Group*)data;
|
||||
if(group)
|
||||
{
|
||||
xmlWriter.writeAttribute("group_id", QString::number(group->getID()));
|
||||
xmlWriter.writeAttribute("name", group->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndDocument();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define DATAPARSER_H
|
||||
|
||||
#include "FileData.h"
|
||||
#include "instructor.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <Datas.h>
|
||||
@@ -21,7 +22,7 @@ public:
|
||||
void saveClientSettrings(QString language,bool isAutoStart);
|
||||
void createFileDataList(QList<FileData> fileDataList,QString filename);
|
||||
void createAuthMessage(ClientAutorization *auth);
|
||||
void createQueryToDBMessage(ClientQueryToDB *queryToDB, int id = 0);
|
||||
void createQueryToDBMessage(ClientQueryToDB *queryToDB, int id = 0, void* data = nullptr);
|
||||
void createDeAuthMessage(ClientDeAutorization *deAuth);
|
||||
void createAuthData(ServerAuthorization *serverAuth);
|
||||
void createAuthDataOffline(QString username,QString pass);
|
||||
|
||||
@@ -46,7 +46,14 @@ enum TypeQueryToDB{
|
||||
TYPE_QUERY_GET_LIST_INSTRUCTORS,
|
||||
TYPE_QUERY_GET_ALL_LISTS,
|
||||
TYPE_QUERY_NEW_INSTRUCTOR,
|
||||
TYPE_QUERY_DEL_INSTRUCTOR
|
||||
TYPE_QUERY_DEL_INSTRUCTOR,
|
||||
TYPE_QUERY_EDIT_INSTRUCTOR,
|
||||
TYPE_QUERY_NEW_GROUP,
|
||||
TYPE_QUERY_DEL_GROUP,
|
||||
TYPE_QUERY_EDIT_GROUP,
|
||||
TYPE_QUERY_NEW_TRAINEE,
|
||||
TYPE_QUERY_DEL_TRAINEE,
|
||||
TYPE_QUERY_EDIT_TRAINEE
|
||||
};
|
||||
|
||||
class ClientQueryToDB{
|
||||
|
||||
@@ -46,7 +46,7 @@ bool ConnectorToServer::deAuthorizationInstructorLocal(QString login)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::sendQueryToDB(TypeQueryToDB typeQuery, int id)
|
||||
bool ConnectorToServer::sendQueryToDB(TypeQueryToDB typeQuery, int id, void* data)
|
||||
{
|
||||
if (!client->getIsConnected())
|
||||
{
|
||||
@@ -56,7 +56,7 @@ bool ConnectorToServer::sendQueryToDB(TypeQueryToDB typeQuery, int id)
|
||||
ClientQueryToDB *queryToDB = new ClientQueryToDB;
|
||||
queryToDB->typeQuery = typeQuery;
|
||||
|
||||
dataParser->createQueryToDBMessage(queryToDB, id);
|
||||
dataParser->createQueryToDBMessage(queryToDB, id, data);
|
||||
emit sigSendQueryToDB();
|
||||
|
||||
return true;
|
||||
@@ -128,6 +128,16 @@ bool ConnectorToServer::isLoggedInInstructor(int id)
|
||||
return false;
|
||||
}
|
||||
|
||||
Instructor ConnectorToServer::getInstructor(int id)
|
||||
{
|
||||
for(Instructor instructor : listInstructors)
|
||||
{
|
||||
if(instructor.getID() == id)
|
||||
return instructor;
|
||||
}
|
||||
return Instructor();
|
||||
}
|
||||
|
||||
QList<Trainee> ConnectorToServer::getListTraineesInGroup(int id)
|
||||
{
|
||||
QList<Trainee> list;
|
||||
@@ -163,6 +173,26 @@ bool ConnectorToServer::isLoggedInTrainee(int id)
|
||||
return false;
|
||||
}
|
||||
|
||||
Trainee ConnectorToServer::getTrainee(int id)
|
||||
{
|
||||
for(Trainee trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getID() == id)
|
||||
return trainee;
|
||||
}
|
||||
return Trainee();
|
||||
}
|
||||
|
||||
Group ConnectorToServer::getGroup(int id)
|
||||
{
|
||||
for(Group group : listGroups)
|
||||
{
|
||||
if(group.getID() == id)
|
||||
return group;
|
||||
}
|
||||
return Group();
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB(QList<Instructor>* listInstructors,
|
||||
QList<Trainee>* listTrainees,
|
||||
QList<Group>* listGroups)
|
||||
|
||||
@@ -22,7 +22,8 @@ public:
|
||||
bool authorizationInstructorLocal(QString login, QString password);
|
||||
bool deAuthorizationInstructorLocal(QString login);
|
||||
|
||||
bool sendQueryToDB(TypeQueryToDB typeQuery, int id = 0);
|
||||
//bool sendQueryToDB(TypeQueryToDB typeQuery, int id = 0, Instructor* instructor = nullptr);
|
||||
bool sendQueryToDB(TypeQueryToDB typeQuery, int id = 0, void* data = nullptr);
|
||||
|
||||
public:
|
||||
//Запросы к БД (локальной)
|
||||
@@ -36,10 +37,13 @@ public:
|
||||
bool isArchivedInstructor(int id);
|
||||
bool isAdminInstructor(int id);
|
||||
bool isLoggedInInstructor(int id);
|
||||
Instructor getInstructor(int id);
|
||||
|
||||
QList<Trainee> getListTraineesInGroup(int id);
|
||||
bool isArchivedTrainee(int id);
|
||||
bool isLoggedInTrainee(int id);
|
||||
Trainee getTrainee(int id);
|
||||
Group getGroup(int id);
|
||||
|
||||
public slots:
|
||||
void slot_AnswerQueryToDB(QList<Instructor>* listInstructors,
|
||||
|
||||
Reference in New Issue
Block a user