mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
feat: change message and contac list attribute
This commit is contained in:
@@ -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