예제 #1
0
        private static User getSuccessfulLogInUser()
        {
            Console.WriteLine("------Login--------");

            int counter = 0;

            while (true)
            {
                Console.WriteLine("Please enter username: "******"Please enter password: "******"Log in successfully.");
                    return(user);
                }
                else
                {
                    Console.WriteLine("Log in fail");
                    counter++;
                    if (counter == 3)
                    {
                        Console.WriteLine("You have 3 unseccessful traing please wait 3 minutes and try again");
                        Console.WriteLine(DateTime.Now.ToLongTimeString());
                        var stopwatch = Stopwatch.StartNew();
                        Thread.Sleep(180000);
                        stopwatch.Stop();
                        Console.WriteLine(stopwatch.ElapsedMilliseconds);
                        Console.WriteLine(DateTime.Now.ToLongTimeString());
                        counter = 0;
                    }
                }
            }
        }
예제 #2
0
        private static void administrator()
        {
            User u = getSuccessfulLogInUser();

            if (u != null)
            {
                Console.WriteLine("Username: "******"Password: "******"Faculty Number: " + u.fNumber);
                Console.WriteLine("Date: " + u.Created);
                Console.WriteLine("Active until: " + u.expiryDate);



                String type = LoginValidation.currentUserRole.ToString();
                switch (type)
                {
                case "ANONYMOUS":
                    Console.WriteLine("This person is an anonymous.");
                    break;

                case "ADMIN":
                    Console.WriteLine("This person is an admin.");
                    break;

                case " INSPECTOR":
                    Console.WriteLine("This person is an inspector.");
                    break;

                case " PROFESSOR":
                    Console.WriteLine("This person is a professor.");
                    break;

                case "STUDENT":
                    Console.WriteLine("This person is a student.");
                    break;
                }

                showMenu();
                Console.WriteLine("Enter person name for search: ");
                String searchedName = Console.ReadLine();
                User   searchedUser = UserData.getUserByName(searchedName);
                Console.WriteLine("Enter choice from menu options:");
                String choice = Console.ReadLine();

                switch (choice)
                {
                case "0":
                    return;

                case "1":
                    Console.WriteLine("You choose to set new role to user " + u.name);
                    Console.WriteLine("New role:");
                    String newRole = Console.ReadLine();
                    UserData.AssignUserRole(searchedName, newRole);
                    break;

                case "2":
                    Console.WriteLine("New expiry date: ");
                    DateTime date = new DateTime(Console.Read(), Console.Read(), Console.Read());
                    searchedUser.expiryDate = date;
                    break;

                case "3":
                    UserData.ListAllUsers();
                    break;

                case "4":
                    Logger.GetLogFileActivities();
                    break;

                case "5":
                    Logger.GetCurrentSessionActivities();
                    break;

                default:
                    Console.WriteLine("Your choice does not exist.");
                    break;
                }
            }
        }