mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
feat: change message and contac list attribute
This commit is contained in:
@@ -20,8 +20,6 @@ kanban-plugin: board
|
||||
|
||||
## feature client Unity
|
||||
|
||||
- [ ] Добавить обновление инструктора, если он перелогинился
|
||||
- [ ] FIM проверять на null задачу
|
||||
- [ ] Если staticData не найдена, грузится как оффлайн, проверять просто иконки билда
|
||||
- [ ] Делить по группам номер группы
|
||||
- [ ] добавить тестово логины в строку контактов
|
||||
@@ -40,7 +38,6 @@ kanban-plugin: board
|
||||
|
||||
- [ ] добавить генерацию пустых файлов, если shared не найден
|
||||
- [ ] ПЕРЕВЕСТИ все действия под операции и формировать процент ПРИ загрузке из них
|
||||
- [ ] Добавить - фильтрацию trainees или instructor
|
||||
- [ ] убрать clientMap из serverLMS Widget в мультитред сервер
|
||||
|
||||
|
||||
@@ -50,6 +47,8 @@ kanban-plugin: board
|
||||
|
||||
## Complete
|
||||
|
||||
- [ ] FIM проверять на null задачу
|
||||
- [ ] Добавить - фильтрацию trainees или instructor
|
||||
- [ ] выбор версии на один клик
|
||||
- [ ] сделать header полупрозрачным прозрачным
|
||||
- [ ] на старте все мониторы должны быть активны
|
||||
@@ -334,6 +333,7 @@ kanban-plugin: board
|
||||
|
||||
## Cancel
|
||||
|
||||
- [ ] Добавить обновление инструктора, если он перелогинился
|
||||
- [ ] добавить в settings адрес и булку мат модели
|
||||
- [ ] Иерархия проекта - папка application, папка updater и линк на основной экзешник
|
||||
- [ ] добавить подключение без DB
|
||||
|
||||
@@ -27,6 +27,7 @@ add_library(DataBaseLMS SHARED
|
||||
typeQueryToDB.h
|
||||
timingoftrainee.cpp
|
||||
timingoftrainee.h
|
||||
contactModel.h
|
||||
)
|
||||
|
||||
target_link_libraries(DataBaseLMS PRIVATE Qt5::Widgets)
|
||||
|
||||
52
DataBaseLMS/contactModel.h
Normal file
52
DataBaseLMS/contactModel.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef CONTACTMODEL_H
|
||||
#define CONTACTMODEL_H
|
||||
|
||||
#include "instructor.h"
|
||||
#include "trainee.h"
|
||||
#include "user.h"
|
||||
|
||||
class ContactModel
|
||||
{
|
||||
public:
|
||||
ContactModel(Instructor instructor)
|
||||
{
|
||||
login = instructor.getLogin();
|
||||
name = instructor.getName();
|
||||
type = 0;
|
||||
loggedIn = instructor.getLoggedIn();
|
||||
id = instructor.getID();
|
||||
};
|
||||
|
||||
ContactModel(Trainee trainee)
|
||||
{
|
||||
login = trainee.getLogin();
|
||||
name = trainee.getName();
|
||||
type = 1;
|
||||
loggedIn = trainee.getLoggedIn();
|
||||
id = trainee.getID();
|
||||
}
|
||||
|
||||
void setType(int type){this->type = type;}
|
||||
int getType(){return type;}
|
||||
|
||||
void setName(QString name){this->name = name;}
|
||||
QString getName(){return name;}
|
||||
|
||||
void setLoggedIn(bool loggedIn){this->loggedIn = loggedIn;}
|
||||
bool getLoggedIn(){return loggedIn;}
|
||||
|
||||
void setLogin(QString login){this->login = login;}
|
||||
QString getLogin(){return login;}
|
||||
|
||||
void setID(int id){this->id = id;}
|
||||
int getID(){return id;}
|
||||
|
||||
private:
|
||||
QString login;
|
||||
QString name;
|
||||
bool loggedIn;
|
||||
int type;
|
||||
int id;
|
||||
};
|
||||
|
||||
#endif // CONTACTMODEL_H
|
||||
@@ -76,7 +76,7 @@ QByteArray DataParser::createAuthMessage(ClientAutorization *auth)
|
||||
return array;
|
||||
}
|
||||
|
||||
QByteArray DataParser::createMessage(ClientMessage *clientMessage)
|
||||
QByteArray DataParser::createMessage(ClientMessage clientMessage)
|
||||
{
|
||||
QByteArray array;
|
||||
QXmlStreamWriter xmlWriter(&array);
|
||||
@@ -85,9 +85,10 @@ QByteArray DataParser::createMessage(ClientMessage *clientMessage)
|
||||
xmlWriter.writeStartDocument();
|
||||
xmlWriter.writeStartElement("ClientMessage");
|
||||
|
||||
xmlWriter.writeAttribute("From",clientMessage->fromId);
|
||||
xmlWriter.writeAttribute("To", clientMessage->toId);
|
||||
xmlWriter.writeAttribute("Text", clientMessage->Text);
|
||||
xmlWriter.writeAttribute("From",clientMessage.fromId);
|
||||
xmlWriter.writeAttribute("To", clientMessage.toId);
|
||||
xmlWriter.writeAttribute("Text", clientMessage.Text);
|
||||
xmlWriter.writeAttribute("UserType",clientMessage.UserType);
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement();
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
void createFileDataList(QList<FileData> fileDataList,QString filename);
|
||||
|
||||
QByteArray createAuthMessage(ClientAutorization *auth);
|
||||
QByteArray createMessage(ClientMessage *toClientMessage);
|
||||
QByteArray createMessage(ClientMessage toClientMessage);
|
||||
QByteArray createQueryToDBMessage(ClientQueryToDB *queryToDB, int id = 0, void* data = nullptr);
|
||||
QByteArray createQueryTasksXMLMessage(QString type);
|
||||
QByteArray createDeAuthMessage(ClientDeAutorization *deAuth);
|
||||
|
||||
@@ -526,9 +526,14 @@ void RecognizeSystem::xmlParser(QByteArray array)
|
||||
if (name == "Text"){
|
||||
clientMessage->Text = value;
|
||||
}
|
||||
|
||||
if (name == "UserType")
|
||||
{
|
||||
clientMessage->UserType = value;
|
||||
}
|
||||
}
|
||||
|
||||
emit signal_ReceiveMessage(clientMessage->fromId, clientMessage->toId,clientMessage->Text);
|
||||
emit signal_ReceiveMessage(*clientMessage);
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "ServerDeAuthorization"){
|
||||
|
||||
@@ -41,7 +41,7 @@ signals:
|
||||
void sigSocketWaitForReadyRead(int waitTime);
|
||||
void sigStartCompare();
|
||||
|
||||
void signal_ReceiveMessage(QString fromId,QString toId, QString text);
|
||||
void signal_ReceiveMessage(ClientMessage clientMessage);
|
||||
|
||||
void sigAnswerQueryToDB_ListInstructors(QList<Instructor> listInstructors);
|
||||
void sigAnswerQueryToDB_ListGroups(QList<Group> listGroups);
|
||||
|
||||
@@ -77,6 +77,15 @@ public:
|
||||
QString fromId;
|
||||
QString toId;
|
||||
QString Text;
|
||||
QString UserType;
|
||||
ClientMessage(){}
|
||||
ClientMessage(QString fromId, QString toId, QString text, QString UserType)
|
||||
{
|
||||
this->fromId = fromId;
|
||||
this->toId = toId;
|
||||
this->Text = text;
|
||||
this->UserType = UserType;
|
||||
}
|
||||
};
|
||||
|
||||
class ServerTask
|
||||
|
||||
@@ -81,18 +81,12 @@ bool ConnectorToServer::sendQueryToDB(TypeQueryToDB typeQuery, int id, void* dat
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::sendMessage(QString fromId, QString toId, QString text)
|
||||
bool ConnectorToServer::sendMessage(ClientMessage clientMessage)
|
||||
{
|
||||
if (!client->getIsConnected())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ClientMessage *clientMessage = new ClientMessage;
|
||||
clientMessage->fromId = fromId;
|
||||
clientMessage->toId = toId;
|
||||
clientMessage->Text = text;
|
||||
|
||||
QByteArray array = dataParser->createMessage(clientMessage);
|
||||
emit signal_sendXMLmsgGUItoServer(array);
|
||||
|
||||
@@ -372,9 +366,9 @@ void ConnectorToServer::slot_AnswerQueryTasksXML_AMM(QByteArray array)
|
||||
emit signal_UpdateTasksAMM();
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_sendMessage(QString fromId, QString toId, QString text)
|
||||
void ConnectorToServer::slot_sendMessage(ClientMessage clientMessage)
|
||||
{
|
||||
sendMessage(fromId, toId, text);
|
||||
sendMessage(clientMessage);
|
||||
}
|
||||
|
||||
void ConnectorToServer::showServerList(QList<StreamingVersionData *> *serverList)
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
bool deAuthorizationInstructorLocal(QString login);
|
||||
|
||||
bool sendQueryToDB(TypeQueryToDB typeQuery, int id = 0, void* data = nullptr);
|
||||
bool sendMessage(QString fromId, QString toId, QString text);
|
||||
bool sendMessage(ClientMessage clientMessage);
|
||||
|
||||
bool sendQueryTasksXML(QString type);
|
||||
|
||||
@@ -81,7 +81,7 @@ public slots:
|
||||
void slot_AnswerQueryTasksXML_FIM(QByteArray array);
|
||||
void slot_AnswerQueryTasksXML_AMM(QByteArray array);
|
||||
|
||||
void slot_sendMessage(QString fromId, QString toId, QString text);
|
||||
void slot_sendMessage(ClientMessage clientMessage);
|
||||
void showServerList(QList<StreamingVersionData*> *serverList);
|
||||
|
||||
void slot_HashReady();
|
||||
@@ -110,7 +110,7 @@ signals:
|
||||
|
||||
void signal_InitMessanger(QList<Trainee> listTrainees);
|
||||
|
||||
void signal_receiveMessage(QString fromId, QString toId, QString text);
|
||||
void signal_receiveMessage(ClientMessage clientMessage);
|
||||
void sigSendAnswerToServer(QByteArray array);
|
||||
|
||||
private:
|
||||
|
||||
@@ -40,6 +40,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
qRegisterMetaType<QList<Module*>>("QList<Module*>");
|
||||
qRegisterMetaType<QList<QTreeWidgetItem*>>("QList<QTreeWidgetItem*>");
|
||||
qRegisterMetaType<QList<TaskAmmFim>>("QList<TaskAmmFim>");
|
||||
qRegisterMetaType<ClientMessage>("ClientMessage");
|
||||
|
||||
qDebug() << "InstructorsAndTraineesWidget init thread ID " << QThread::currentThreadId();
|
||||
|
||||
@@ -218,6 +219,7 @@ void InstructorsAndTraineesWidget::checkLoginResult(ServerAuthorization *serverA
|
||||
|
||||
connectorToServer->sendQueryTasksXML("fim");
|
||||
connectorToServer->sendQueryTasksXML("amm");
|
||||
messangerWidget->initialize(serverAuth->Id);
|
||||
//QMessageBox::information(this, tr("Instructor authorization"), tr("Successfully!"));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -153,8 +153,9 @@ void MessangerWidget::clear()
|
||||
void MessangerWidget::on_btnSend_clicked()
|
||||
{
|
||||
QString text = ui->editMsg->toPlainText();
|
||||
ClientMessage message = ClientMessage(currClientId,selectedUserId,text,"0");
|
||||
|
||||
emit signal_sendMessage(currClientId, selectedUserId, text);
|
||||
emit signal_sendMessage(message);
|
||||
|
||||
ui->editMsg->clear();
|
||||
|
||||
@@ -226,13 +227,13 @@ void MessangerWidget::slot_InitMessanger(QList<Trainee> listTrainees)
|
||||
}
|
||||
}
|
||||
|
||||
void MessangerWidget::slot_showMessage(QString fromId, QString toId, QString text)
|
||||
void MessangerWidget::slot_showMessage(ClientMessage clientMessage)
|
||||
{
|
||||
for(Trainee trainee: listTrainees)
|
||||
{
|
||||
if(QString::number(trainee.getID()) == fromId)
|
||||
if(QString::number(trainee.getID()) == clientMessage.fromId)
|
||||
{
|
||||
addMsgFromClient(trainee, text);
|
||||
addMsgFromClient(trainee, clientMessage.Text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ private slots:
|
||||
|
||||
signals:
|
||||
//сигнал о готовности нового сообщения на отправку клиенту
|
||||
void signal_sendMessage(QString fromId, QString toId, QString text);
|
||||
void signal_sendMessage(ClientMessage clientMessage);
|
||||
//сигнал об изменении вкладки диалога с клиентом (TabDialogMessenger)
|
||||
void signal_tabMessengerChanged(QString login);
|
||||
|
||||
@@ -58,7 +58,7 @@ public slots:
|
||||
//слот обработки сигнала о выборе обучаемого
|
||||
void slot_traineeSelected(QString login);
|
||||
//слот о приходе нового сообщения от клиента
|
||||
void slot_showMessage(QString fromId, QString toId, QString text);
|
||||
void slot_showMessage(ClientMessage clientMessage);
|
||||
|
||||
private:
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
@@ -41,6 +41,7 @@ add_library(ServerLMS SHARED
|
||||
Systems/tools.h
|
||||
Systems/chatsystem.cpp
|
||||
Systems/chatsystem.h
|
||||
Data/usertype.h
|
||||
providerdblms.cpp
|
||||
providerdblms.h
|
||||
resources.qrc
|
||||
|
||||
@@ -48,6 +48,12 @@ enum TypeClientAutorization{
|
||||
TYPE_GUI = 10
|
||||
};
|
||||
|
||||
enum UserType
|
||||
{
|
||||
INSTRUCTOR,
|
||||
TRAINEE
|
||||
};
|
||||
|
||||
class ClientAutorization
|
||||
{
|
||||
public:
|
||||
@@ -101,13 +107,15 @@ public:
|
||||
QString From;
|
||||
QString To;
|
||||
QString Text;
|
||||
QString Type; //ТИП ЮЗЕРА К КОТОРОМУ ПРИХОДИТ СООБЩЕНИЕ
|
||||
|
||||
ClientMessage(){}
|
||||
ClientMessage(QString from,QString to,QString text)
|
||||
ClientMessage(QString from,QString to,QString text,QString userType)
|
||||
{
|
||||
From = from;
|
||||
To = to;
|
||||
Text = text;
|
||||
Type = userType;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
9
ServerLMS/Data/userType.h
Normal file
9
ServerLMS/Data/userType.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef USERTYPE_H
|
||||
#define USERTYPE_H
|
||||
|
||||
enum UserType{
|
||||
INSTRUCTOR,
|
||||
TRAINEES
|
||||
};
|
||||
|
||||
#endif // USERTYPE_H
|
||||
@@ -43,7 +43,7 @@ QByteArray ClientAnswerParser::deAuthorization(bool result, QString login)
|
||||
return dataParser->xmlAnswer(listTag);
|
||||
}
|
||||
|
||||
QByteArray ClientAnswerParser::message(QString loginFrom,QString loginTo,QString text)
|
||||
QByteArray ClientAnswerParser::message(QString loginFrom,QString loginTo,QString text,QString type)
|
||||
{
|
||||
QList<SXmlAnswerTag> listTag;
|
||||
QList<SAttribute> listAttr;
|
||||
@@ -54,6 +54,8 @@ QByteArray ClientAnswerParser::message(QString loginFrom,QString loginTo,QString
|
||||
listAttr.append(attribute1);
|
||||
attribute1 = {"Text",text};
|
||||
listAttr.append(attribute1);
|
||||
attribute1 = {"UserType",type};
|
||||
listAttr.append(attribute1);
|
||||
|
||||
SXmlAnswerTag tag = {"ClientMessage", listAttr};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
|
||||
QByteArray authorization(bool result, QString instructorName, QString clientName, QString accessType, QString login, int id);
|
||||
QByteArray deAuthorization(bool result, QString login);
|
||||
QByteArray message(QString loginFrom,QString loginTo,QString text);
|
||||
QByteArray message(QString loginFrom,QString loginTo,QString text, QString userType);
|
||||
QByteArray task(QString text);
|
||||
QByteArray notify(QString code);
|
||||
QByteArray tasks(QStringList listTasks);
|
||||
|
||||
@@ -102,20 +102,22 @@ QByteArray DBAnswerParser::listClassrooms(bool result, QList<Classroom> *listCla
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
QByteArray DBAnswerParser::listContacts(bool result, QList<User> *listContacts)
|
||||
QByteArray DBAnswerParser::listContacts(bool result, QList<ContactModel> *listContacts)
|
||||
{
|
||||
QDomDocument doc;
|
||||
QDomProcessingInstruction xmlDecl = doc.createProcessingInstruction("xml", "version='1.0' encoding='utf-8'");
|
||||
doc.insertBefore(xmlDecl,doc.firstChild());
|
||||
QDomElement root = doc.createElement("ContactArray");
|
||||
|
||||
for(User entity : *listContacts)
|
||||
for(ContactModel entity : *listContacts)
|
||||
{
|
||||
QDomElement contact = doc.createElement("ContactData");
|
||||
contact.toElement().setAttribute("name",entity.getName());
|
||||
contact.toElement().setAttribute("id",entity.getID());
|
||||
QString isLogged = entity.getLoggedIn() ? "1" : "0";
|
||||
contact.toElement().setAttribute("isOnline",isLogged);
|
||||
contact.toElement().setAttribute("UserType",entity.getType());
|
||||
contact.toElement().setAttribute("Login",entity.getLogin());
|
||||
|
||||
root.appendChild(contact);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QDomDocument>
|
||||
#include <contactModel.h>
|
||||
|
||||
class DBAnswerParser : public QObject
|
||||
{
|
||||
@@ -18,7 +19,7 @@ public:
|
||||
QByteArray listTrainees(bool result, QList<Trainee> *listTrainees);
|
||||
QByteArray listComputers(bool result, QList<Computer> *listComputers);
|
||||
QByteArray listClassrooms(bool result, QList<Classroom> *listClassrooms);
|
||||
QByteArray listContacts(bool result, QList<User> *listContacts);
|
||||
QByteArray listContacts(bool result, QList<ContactModel> *listContacts);
|
||||
|
||||
QByteArray listTasksAMMofTrainee(bool result, QList<TaskAmmFim> *listTasks, int trainee_id, bool full_list);
|
||||
QByteArray listTasksFIMofTrainee(bool result, QList<TaskAmmFim> *listTasks, int trainee_id, bool full_list);
|
||||
|
||||
@@ -498,6 +498,8 @@ void ProcessParser::clientMessage(QXmlStreamReader &xmlReader,ClientHandler *cli
|
||||
clientMessage.From = value;
|
||||
if (name == "To")
|
||||
clientMessage.To = value;
|
||||
if (name == "UserType")
|
||||
clientMessage.Type = value;
|
||||
}
|
||||
|
||||
processingSystem->processingSendMessage(clientMessage);
|
||||
|
||||
@@ -13,9 +13,9 @@ void ChatSystem::initialize(CommonClientHandler *commonClientHandler, DataParser
|
||||
clientNotSendedMessage = new QMap<QString,QStack<ClientMessage>*>;
|
||||
|
||||
auto stack = new QStack<ClientMessage>;
|
||||
auto clientMessage1 = ClientMessage("1","102","Сообщение 1");
|
||||
auto clientMessage1 = ClientMessage("1","102","Сообщение 1","1");
|
||||
stack->append(clientMessage1);
|
||||
auto clientMessage2 = ClientMessage("1","102","Сообщение 2");
|
||||
auto clientMessage2 = ClientMessage("1","102","Сообщение 2","1");
|
||||
stack->append(clientMessage2);
|
||||
|
||||
clientNotSendedMessage->insert("102", stack);
|
||||
@@ -23,7 +23,7 @@ void ChatSystem::initialize(CommonClientHandler *commonClientHandler, DataParser
|
||||
|
||||
bool ChatSystem::sendTo(ClientMessage message)
|
||||
{
|
||||
QByteArray byteArrayMsg = dataParser->ClientAnswer()->message(message.From,message.To,message.Text);
|
||||
QByteArray byteArrayMsg = dataParser->ClientAnswer()->message(message.From,message.To,message.Text,message.Type);
|
||||
|
||||
foreach(int idSocket, clientsMap->keys())
|
||||
{
|
||||
|
||||
@@ -464,18 +464,20 @@ void ProcessingSystem::processingClientQueryToDB(ClientHandler *client, ClientQu
|
||||
|
||||
case TypeQueryToDB::TYPE_QUERY_GET_CONTACT_LIST:
|
||||
{
|
||||
QList<User> entitylist;
|
||||
QList<ContactModel> entitylist;
|
||||
QList<Instructor> listInstructor = providerDBLMS->GetListAllInstructors();
|
||||
QList<Trainee> listTrainees = providerDBLMS->GetListAllTrainees();
|
||||
|
||||
for (Instructor instructor : listInstructor)
|
||||
{
|
||||
entitylist.append(static_cast<User>(instructor));
|
||||
ContactModel model = ContactModel(instructor);
|
||||
entitylist.append(model);
|
||||
}
|
||||
|
||||
for (Trainee trainee : listTrainees)
|
||||
{
|
||||
entitylist.append(static_cast<User>(trainee));
|
||||
ContactModel model = ContactModel(trainee);
|
||||
entitylist.append(model);
|
||||
}
|
||||
|
||||
QByteArray arrayAnswer;
|
||||
|
||||
@@ -50,7 +50,7 @@ public slots:
|
||||
signals:
|
||||
void sigLoadHash();
|
||||
void sigSendToLogger(QString message);
|
||||
QByteArray sigSendXMLmessage(QString loginFrom, QString loginTo, QString text);
|
||||
QByteArray sigSendXMLmessage(QString loginFrom, QString loginTo, QString text, QString userType);
|
||||
QByteArray sigSendNotify(QString message);
|
||||
QByteArray sigSendVersion();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
|
||||
qRegisterMetaType<PacketType>("PacketType");
|
||||
qRegisterMetaType<UserType>("UserType");
|
||||
errorCode = 0;
|
||||
|
||||
ui->btnStopServer->setEnabled(false);
|
||||
|
||||
Reference in New Issue
Block a user