Exemple #1
0
        public List <UserClient> GetConnectedUsers(string physicianName)
        {
            List <User> users     = new List <User>();
            Physician   physician = null;

            foreach (ServerClient client in ConnectedClients)
            {
                if (client.user is Physician)
                {
                    if (client.user.username.Equals(physicianName))
                    {
                        physician = (Physician)client.user;
                    }
                }
                else
                {
                    users.Add(client.user);
                }
            }

            /*
             * Console.WriteLine("\nThe users: ");
             * foreach(User user in users)
             *  Console.WriteLine(user);
             * Console.WriteLine("\nThe physician shit");
             * foreach (User user in physician.clients)
             *  Console.WriteLine(user);*/

            try
            {
                //Console.WriteLine("usersss: " + users.Count + "  specia: " + physician.clients.Count );
                //List<UserClient> connectedUsers = physician.clients;
                //Console.WriteLine("size: " + connectedUsers.Count);
                return(physician.clients);
            }
            catch (Exception e)
            {
                Console.WriteLine("FATAL ERROR");
                return(null);
            }
        }
Exemple #2
0
        public void AddNewUser(User newUser, string physicianName)
        {
            Console.WriteLine("naam2: " + physicianName);
            Physician physician = null;

            foreach (ServerClient client in ConnectedClients)
            {
                if (client.user is Physician)
                {
                    Console.WriteLine("found one");
                    if (client.user.username.Equals(physicianName))
                    {
                        Console.WriteLine("sameee");
                        physician = (Physician)client.user;
                    }
                }
            }
            physician.addClient((UserClient)newUser);
            users.Add(newUser);
            SaveAllData();
        }