mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Refact connectortoserver
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
#include "connectortoserver.h"
|
||||
|
||||
QByteArray ConnectorToServer::getListTaskFimArray()
|
||||
{
|
||||
QMutexLocker locker(&mtxAccess);
|
||||
return listTaskFimArray;
|
||||
}
|
||||
|
||||
QByteArray ConnectorToServer::getListTaskAmmArray()
|
||||
{
|
||||
return listTaskAmmArray;
|
||||
}
|
||||
|
||||
QList<Instructor> ConnectorToServer::getListInstructors()
|
||||
{
|
||||
return listInstructors;
|
||||
}
|
||||
|
||||
QList<Trainee> ConnectorToServer::getListTrainees()
|
||||
{
|
||||
return listTrainees;
|
||||
}
|
||||
|
||||
QList<Group> ConnectorToServer::getListGroups()
|
||||
{
|
||||
return listGroups;
|
||||
}
|
||||
|
||||
QList<Computer> ConnectorToServer::getListComputers()
|
||||
{
|
||||
return listComputers;
|
||||
}
|
||||
|
||||
QList<Classroom> ConnectorToServer::getListClassrooms()
|
||||
{
|
||||
return listClassrooms;
|
||||
}
|
||||
|
||||
QList<TaskAmmFim> ConnectorToServer::getListTasksAMMforTrainee(int trainee_id)
|
||||
{
|
||||
if(mapTasksAMM.contains(trainee_id))
|
||||
return mapTasksAMM.value(trainee_id);
|
||||
else
|
||||
return QList<TaskAmmFim>();
|
||||
}
|
||||
|
||||
QList<TaskAmmFim> ConnectorToServer::getListTasksFIMforTrainee(int trainee_id)
|
||||
{
|
||||
if(mapTasksFIM.contains(trainee_id))
|
||||
return mapTasksFIM.value(trainee_id);
|
||||
else
|
||||
return QList<TaskAmmFim>();
|
||||
}
|
||||
|
||||
int ConnectorToServer::getCountTasksAMMforTrainee(int trainee_id)
|
||||
{
|
||||
if(mapTasksAMM.contains(trainee_id))
|
||||
return mapTasksAMM.value(trainee_id).count();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ConnectorToServer::getCountTasksFIMforTrainee(int trainee_id)
|
||||
{
|
||||
if(mapTasksFIM.contains(trainee_id))
|
||||
return mapTasksFIM.value(trainee_id).count();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
int ConnectorToServer::getIdTraineeByLogin(QString login)
|
||||
{
|
||||
for(Trainee trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getLogin() == login)
|
||||
return trainee.getID();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ConnectorToServer::getIdInstructorByLogin(QString login)
|
||||
{
|
||||
for(Instructor instructor : listInstructors)
|
||||
{
|
||||
if(instructor.getLogin() == login)
|
||||
return instructor.getID();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ConnectorToServer::clearListModelDB()
|
||||
{
|
||||
listInstructors.clear();
|
||||
listGroups.clear();
|
||||
listTrainees.clear();
|
||||
listComputers.clear();
|
||||
listClassrooms.clear();
|
||||
mapTasksAMM.clear();
|
||||
mapTasksFIM.clear();
|
||||
|
||||
listTaskFimArray.clear();
|
||||
listTaskAmmArray.clear();
|
||||
}
|
||||
Reference in New Issue
Block a user