示例#1
0
 public DoctorDisconnectedTimer(HubUser groupMember, int delay)
 {
     _groupMember = groupMember;
     Timer        = new System.Timers.Timer(delay);
     Timer.Start();
     Timer.Elapsed += _timer_Elapsed;
 }
示例#2
0
        public async void InitGroupScreen(HubUser hubUser)
        {
            await _hubContext.Clients.Group(hubUser.GroupName).SendAsync("ReceiveDoctorFullName", hubUser.UserId, string.Empty);

            await _hubContext.Clients.Group(hubUser.GroupName).SendAsync("ReceiveQueueNo", hubUser.UserId, SettingsHandler.ApplicationSettings.MessageWhenNoDoctorActiveInQueue);

            await _hubContext.Clients.Group(hubUser.GroupName).SendAsync("ReceiveAdditionalInfo", hubUser.UserId, string.Empty);
        }
示例#3
0
        public async void InitGroupScreen(HubUser hubUser)
        {
            await Clients.Group(hubUser.GroupName).SendAsync("ReceiveDoctorFullName", hubUser.UserId, string.Empty);

            await Clients.Group(hubUser.GroupName).SendAsync("ReceiveQueueNo", hubUser.UserId, SettingsHandler.ApplicationSettings.MessageWhenNoDoctorActiveInQueue);

            await Clients.Group(hubUser.GroupName).SendAsync("ReceiveAdditionalInfo", hubUser.UserId, string.Empty);

            Log.Information(String.Concat(logPrefix, "Room: [ ", hubUser.GroupName, " ] view initialized with empty data"));
        }
示例#4
0
        public async Task RegisterPatientView(int roomNo)
        {
            var newUser = new HubUser
            {
                ConnectionId = Context.ConnectionId,
                GroupName    = roomNo.ToString()
            };

            await Groups.AddToGroupAsync(newUser.ConnectionId, newUser.GroupName);

            if (!_connectedUsers.Contains(newUser))
            {
                _connectedUsers.Add(newUser);
            }
        }
示例#5
0
        public async Task RegisterPatientView(string roomNo)
        {
            var newUser = new HubUser
            {
                ConnectionId = Context.ConnectionId,
                GroupName    = roomNo
            };

            await Groups.AddToGroupAsync(newUser.ConnectionId, newUser.GroupName);

            await _hubUser.AddUserAsync(newUser);

            Log.Information(String.Concat(logPrefix, "Client [ ", newUser.ConnectionId, " ] registered as Patient for room: [ ",
                                          roomNo, " ]"));
        }
示例#6
0
        private void ChooseTypeToRemove(HubUser user)
        {
            var userAsConnected = _hubUser.ConnectedUsers.Where(u => u.Id == user.Id).SingleOrDefault();

            if (userAsConnected != null)
            {
                Remove(userAsConnected);
                return;
            }
            var userAsWaiting = _hubUser.WaitingUsers.Where(u => u.Id == user.Id).SingleOrDefault();

            if (userAsWaiting != null)
            {
                Remove(userAsWaiting);
                return;
            }
        }
示例#7
0
        public async Task RegisterDoctor(string userId, int roomNo)
        {
            var newUser = new HubUser {
                Id           = userId,
                ConnectionId = Context.ConnectionId,
                GroupName    = roomNo.ToString()
            };

            var userInControl = _connectedUsers.Where(m => m.Id != null && m.GroupName == newUser.GroupName).FirstOrDefault();

            if (userInControl == null)
            {
                await Groups.AddToGroupAsync(newUser.ConnectionId, newUser.GroupName);

                var user = _repo.User.FindByCondition(u => u.Id == userId).FirstOrDefault();

                string doctorFullName = QueueHelper.GetDoctorFullName(user);

                await Clients.Group(roomNo.ToString()).SendAsync("ReceiveDoctorFullName", userId, doctorFullName);

                var queue = _queueService.FindByUserId(userId);

                _queueService.SetQueueActive(queue);

                await Clients.Group(roomNo.ToString()).SendAsync("ReceiveQueueNo", userId, queue.QueueNoMessage);

                await Clients.Group(roomNo.ToString()).SendAsync("ReceiveAdditionalInfo", userId, queue.AdditionalMessage);

                if (!_connectedUsers.Contains(newUser))
                {
                    _connectedUsers.Add(newUser);
                }
            }
            else
            {
                if (!_waitingUsers.Contains(newUser))
                {
                    _waitingUsers.Add(newUser);
                }

                await Clients.Caller.SendAsync("NotifyQueueOccupied", StaticDetails.QueueOccupiedMessage);
            }
        }
示例#8
0
        public async Task RegisterDoctor(string roomNo)
        {
            var claimsIdentity = (ClaimsIdentity)Context.User.Identity;
            var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);
            var userId         = claim.Value;

            var newUser = new HubUser {
                UserId       = claim.Value,
                ConnectionId = Context.ConnectionId,
                GroupName    = roomNo
            };

            var userInControl = _hubUser.GetGroupMaster(newUser.GroupName);

            if (userInControl == null || userInControl.FirstOrDefault().UserId == newUser.UserId)
            {
                await Groups.AddToGroupAsync(newUser.ConnectionId, newUser.GroupName);

                var user = _repo.User.FindByCondition(u => u.Id == userId).FirstOrDefault();

                string doctorFullName = QueueHelper.GetDoctorFullName(user);
                await Clients.Group(roomNo).SendAsync("ReceiveDoctorFullName", userId, doctorFullName);

                var queue = _queueService.FindByUserId(userId);
                _queueService.SetQueueActive(queue);

                await Clients.Group(roomNo).SendAsync("ReceiveQueueNo", userId, queue.QueueNoMessage);

                await Clients.Group(roomNo).SendAsync("ReceiveAdditionalInfo", userId, queue.AdditionalMessage);
            }
            else
            {
                await Clients.Caller.SendAsync("NotifyQueueOccupied", StaticDetails.QueueOccupiedMessage);
            }
            await _hubUser.AddUserAsync(newUser);

            Log.Information(String.Concat(logPrefix, "Client [ ",
                                          newUser.ConnectionId, " ] registered as Doctor for room: [ ", roomNo, " ]"));
        }
示例#9
0
        public async Task AddUserAsync(HubUser user)
        {
            var userToSave = _mapper.Map <ConnectedHubUser>(user);

            if (_hubUser.ConnectedUsers.Where(u => u.GroupName == user.GroupName && !String.IsNullOrEmpty(u.UserId)).FirstOrDefault() == null)
            {
                await _hubUser.ConnectedUsers.AddAsync(userToSave);
            }
            else if (_hubUser.ConnectedUsers.Where(u => u.UserId == user.UserId && u.GroupName == user.GroupName).FirstOrDefault() != null)
            {
                await _hubUser.ConnectedUsers.AddAsync(userToSave);
            }
            else if (String.IsNullOrEmpty(user.UserId) && !String.IsNullOrEmpty(user.GroupName))
            {
                await _hubUser.ConnectedUsers.AddAsync(userToSave);
            }
            else
            {
                var waitingUserToSave = _mapper.Map <WaitingHubUser>(user);
                await _hubUser.WaitingUsers.AddAsync(waitingUserToSave);
            }
            await _hubUser.SaveChangesAsync();
        }
示例#10
0
 public async Task RemoveUserAsync(HubUser user)
 {
     ChooseTypeToRemove(user);
     await _hubUser.SaveChangesAsync();
 }
示例#11
0
 public void RemoveUser(HubUser user)
 {
     ChooseTypeToRemove(user);
     _hubUser.SaveChanges();
 }