Ejemplo n.º 1
0
        private async Task AddScannedStudent(ScannerInput scannerInput, UserSignalR currentUser)
        {
            var card = currentUser.Ssm.AddScannedStudenToFlight(scannerInput, Convert.ToInt32(currentUser.UserId), currentUser.SchoolId);

            if (card == null)
            {
                await this.Clients.Client(Context.ConnectionId).InvokeAsync("FlightNotification", currentUser.Ssm.Status);
            }
            else
            {
                if (currentUser.Ssm.CloseLaneStatus != "")
                {
                    await this.Clients.Client(Context.ConnectionId).InvokeAsync("FlightNotification", currentUser.Ssm.CloseLaneStatus);
                }
                await this.Clients.Client(Context.ConnectionId).InvokeAsync("CardData", card);

                var classStudent = new SchoolClassroomManager();
                var classCard    = classStudent.GetClassroomCard(card.CardId);
                classCard.FlightId     = card.FligthId;
                classCard.FlightNumber = card.FlightNumber;
                await this.Clients.Group("Teacher" + currentUser.SchoolId.ToString()).InvokeAsync("GetScannedCard", classCard);

                var closedflightId = currentUser.Ssm.CloseFlightId;
                if (closedflightId != 0)
                {
                    await this.Clients.Group("Teacher" + currentUser.SchoolId.ToString()).InvokeAsync("StatusFlight", new FlightModel {
                        FlightId = closedflightId, Status = "Closed"
                    });
                }
            }
            // await this.Clients.Group(currentUser.UserGroup).InvokeAsync("CurrentFlight", card.FlightNumber);
        }
Ejemplo n.º 2
0
        //for classroom and dismissalTeacher role
        public async Task SetClassroomTeacher(int userId, string scId)
        {
            //needs to add implimintation for superAdmin -> schoolId

            int schoolId = 0;

            using (var ds = new DataSeed())
            {
                schoolId = Convert.ToInt32(ds.GetUserSchoolId(userId));
            };

            var currentUser = Users.Where(p => p.ConnectionId == Context.ConnectionId).FirstOrDefault();

            if (currentUser == null)
            {
                currentUser = new UserSignalR {
                    ConnectionId = Context.ConnectionId, SchoolId = Convert.ToInt32(schoolId), UserId = userId, Role = HubRole.Teacher
                };
                Users.Add(currentUser);
            }
            else
            {
                currentUser.SchoolId = Convert.ToInt32(schoolId);
                currentUser.UserId   = userId;
                currentUser.Role     = HubRole.Teacher;
            }

            await Groups.AddAsync(Context.ConnectionId, currentUser.UserGroup);

            // await this.Clients.Client(currentUser.ConnectionId).InvokeAsync("SetClassroomTeacher", currentUser);
        }
Ejemplo n.º 3
0
        //for scanner role
        public async Task SetScanner(int userId)
        {
            ScannerManager manager;
            UserSignalR    currentUser = null;
            int?           schoolId    = null;

            using (var ds = new DataSeed()) {
                schoolId = ds.GetUserSchoolId(userId);
                if (schoolId == 0)
                {
                    return;
                }
                var sameUser = Users.FirstOrDefault(p => p.UserId == userId);
                if (sameUser != null)
                {
                    Users.Remove(sameUser);
                }
                var schoolScanner = Users.FirstOrDefault(p => p.SchoolId == schoolId && p.Role == HubRole.Scanner);
                currentUser = Users.FirstOrDefault(p => p.ConnectionId == Context.ConnectionId);
                if (schoolScanner == null)
                {
                    manager = new ScannerManager(Convert.ToInt32(schoolId), userId, ds);
                }
                else
                {
                    manager = schoolScanner.Ssm;
                }
            }
            //set User data
            currentUser.SchoolId = Convert.ToInt32(schoolId);
            currentUser.UserId   = userId;
            currentUser.Ssm      = manager;
            currentUser.Role     = HubRole.Scanner;

            await Groups.AddAsync(Context.ConnectionId, currentUser.UserGroup);
        }