Beispiel #1
0
        static void Main(string[] args)
        {
            //Set Console's Encoding to support cyrillic symbols.
            Console.OutputEncoding = Encoding.UTF8;

            /*Only called once to fill db
             * CopyTestUsers();*/

            Console.WriteLine("Въведете потребителско име: ");
            string Username = Console.ReadLine();

            Console.WriteLine("Въведете парола: ");
            string Password = Console.ReadLine();

            User currentUser = new User(Username, Password);

            LoginValidation loginValidation = new LoginValidation(Username, Password, PrintErrorMessage);

            if (loginValidation.ValidateUserInput(currentUser))
            {
                PrintUserInfo();

                if (LoginValidation.CurrentUserRole.Equals(UserRoles.ADMIN))
                {
                    PrintAdminMenu();
                    GetAdminChoice();
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            User user = null;

            string          username = AskForUsername();
            string          password = AskForPassword();
            LoginValidation logVal   = new LoginValidation(username, password, OnError);

            if (logVal.ValidateUserInput(ref user))
            {
                switch (LoginValidation.currentUserRole)
                {
                case UserRoles.ADMIN:
                    Console.WriteLine("You are the admin. You are the boss.");
                    AdminMenu();
                    break;

                case UserRoles.STUDENT:
                    Console.WriteLine("You are a student. What's up?");
                    break;

                case UserRoles.ANONYMOUS:
                    Console.WriteLine("You are annonymous. Yey");
                    break;

                default:
                    Console.WriteLine("You are by default without any role. How is that possible.");
                    break;
                }
                Console.WriteLine(user);
            }
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            UserData.ResetTestUserData();
            string username = null, password = null;

            Console.WriteLine("0-Exit");
            Console.WriteLine("1-Login");
            //Console.WriteLine("2-Register");

            Console.Write("Choose command: ");
            var command = int.Parse(Console.ReadLine());

            if (command == 0)
            {
                Console.WriteLine("Bye");
            }

            var done = false;

            while (command != 0 && !done)
            {
                switch (command)
                {
                case 0:
                    break;

                case 1:
                    Console.Write("Username:"******"Password:"******"Choose command: ");
                        command = int.Parse(Console.ReadLine());
                    }

                    break;

                //case 2:
                //  break;

                default:
                    Console.Write("Wrong command!!! Try again: ");
                    command = int.Parse(Console.ReadLine());
                    break;
                }
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Console.Write("Enter username: "******"Enter password: ");
            string          password        = Console.ReadLine();
            LoginValidation loginValidation = new LoginValidation(username, password, ActionOnError);
            User            user            = new User();

            if (loginValidation.ValidateUserInput(ref user))
            {
                int choice;
                do
                {
                    Menu();
                    choice = Convert.ToInt32(Console.ReadLine());
                    UserChoice(choice);
                } while (choice != 0);
                Console.WriteLine(user);
            }
            else
            {
                Console.WriteLine(loginValidation.errorMessage);
            }
            Console.ReadKey();
        }
        static void Main()
        {
            Console.Write("Enter Username: "******"Enter password: "******"Data for user: Username - {0}, Password - {1}, Fac. Number: {2}, date register: {3}, role: {4}",
                                  user.Username, user.Password, user.FacNumber, user.Created, LoginValidation.currentUserRole);

                if (LoginValidation.currentUserRole.ToString() == "ADMIN")
                {
                    AdminOptions();
                }
            }
            else
            {
                Console.WriteLine("User role: {0}", LoginValidation.currentUserRole);
            }
        }
Beispiel #6
0
        static void Main()
        {
            Console.Write("Enter Username: "******"Enter password: "******"Enter date: ");
            string   strdate = Console.ReadLine();
            DateTime date    = Convert.ToDateTime(strdate);

            LoginValidation validator = new LoginValidation(username, password, ActionOnError);

            User user = new User();

            user.username = username;
            user.password = password;

            if (validator.ValidateUserInput(ref user))
            {
                Console.WriteLine("Data for user: Username - {0}, Password - {1}, Fac. Number: {2}, role: {3}, time: {4}, expired: {5}",
                                  user.username, user.password, user.facNumber, LoginValidation.currentUserRoles, user.Created, user.Expired);
                if (user.roleId == 1)
                {
                    AdminOptions(user);
                }
            }
            else
            {
                Console.WriteLine("ERROR: {0}", validator.errorException);
                Console.WriteLine("User role: {0}", LoginValidation.currentUserRoles);
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            User          us = new User();
            RightsGranted rg = new RightsGranted();

            Console.WriteLine("Въведете потребителско име : ");
            us.Username = Console.ReadLine();
            Console.WriteLine("Въведете парола : ");
            us.Password = Console.ReadLine();

            LoginValidation logVal = new LoginValidation(us.Username, us.Password, printError);


            User us1 = null;

            if (logVal.ValudateUserInput(ref us1))
            {
                Console.WriteLine("\n\nПотеребителско име :" + us1.Username + "\nПарола :" + us1.Password
                                  + "\nФакултетен номер :" + us1.FakNum + "\nРоля :" + us1.Role);

                UserData.UserRoleOfCurrUser = us1.Role;

                Console.Write("\n\nРолята на потребителя, който използва приложението е : ");
                switch ((Int32)LoginValidation._currentUserRole)
                {
                case (2):
                    Console.WriteLine("Администратор");
                    callMenu(us1.Role);
                    break;

                case (3):
                    Console.WriteLine("Инспектор");
                    callMenu(us1.Role);
                    break;

                case (4):
                    Console.WriteLine("Професор");
                    callMenu(us1.Role);
                    break;

                case (5):
                    Console.WriteLine("Студент");
                    callMenu(us1.Role);
                    break;

                default:
                    Console.WriteLine("Нещо се обърка");
                    break;
                }

                Console.ReadLine();
            }
            else
            {
                printError("\n\nРолята на потребителя, който използва приложението е : " + LoginValidation._currentUserRole);
                Console.ReadLine();
            }
            Console.ReadLine();
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please, enter your user name: ");
            string userName = Console.ReadLine();

            Console.WriteLine("Please, enter your password: "******"Hello, {0}! ", LoginValidation.CurrentUserRole);
                    break;

                case 1:
                    Console.WriteLine("Hello, {0}! ", LoginValidation.CurrentUserRole);
                    adminFunc();
                    break;

                case 2:
                    Console.WriteLine("Hello, {0}! ", LoginValidation.CurrentUserRole);
                    adminFunc();
                    break;

                case 3:
                    Console.WriteLine("Hello, {0}! ", LoginValidation.CurrentUserRole);
                    break;
                }
            }
            else
            {
                switch (obj.Role)
                {
                case 0:
                    Console.WriteLine("Hello, {0}! ", LoginValidation.CurrentUserRole);
                    break;
                }
            }
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter username: "******"Enter passsword: ");
            string password = Console.ReadLine();
            User   usr      = null;

            if (UserData.TestUserfEmpty() == true)

            {
                UserData.CopyTestUser();
            }



            LoginValidation validator = new LoginValidation(userName, password, OnError);

            if (validator.ValidateUserInput(ref usr) == true)
            {
                Console.WriteLine("Username: "******"Faculty Number: " + usr.facNumber);
                Console.WriteLine("Role ID: " + usr.role);



                switch (LoginValidation.currentUserRole)
                {
                case UserRoles.ANONYMOUS:
                    Console.WriteLine("You are anomymous");
                    break;

                case UserRoles.ADMIN:
                    Console.WriteLine("You are admin");
                    MenuAdmin();
                    break;

                case UserRoles.INSPECTOR:
                    Console.WriteLine("You are inspector");
                    break;

                case UserRoles.PROFESSOR:
                    Console.WriteLine("You are professor");
                    break;

                case UserRoles.STUDENT:
                    Console.WriteLine("You are student");
                    break;
                }
            }
            //validator.badLogin(userName, password);
        }
Beispiel #10
0
        public static void Main(string[] args)
        {
            //List<User> users = UserData.TestUsers();

            Console.WriteLine("Enter username and password");
            string username = Console.ReadLine();
            string password = Console.ReadLine();

            LoginValidation check = new LoginValidation(username, password, pringError);

            User user = new User();

            if (check.ValidateUserInput(ref user))
            {
                Console.WriteLine(user.ToString());

                //Console.WriteLine("Role: " + LoginValidation.currentUserRole);

                switch (user.role)
                {
                case 0:
                    Console.WriteLine("User is Anonymous");
                    break;

                case 1:
                    Console.WriteLine("User is Admin");
                    break;

                case 2:
                    Console.WriteLine("User is Inspector");
                    break;

                case 3:
                    Console.WriteLine("User is professor");
                    break;

                case 4:
                    Console.WriteLine("User is Student");
                    break;

                default:
                    Console.WriteLine("Error");
                    break;
                }

                if (user.role == 1)
                {
                    adminFunction();
                }
            }
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Въведете потребителското име:");
            String usernameInput = Console.ReadLine();

            Console.WriteLine("Въведете парола:");
            String passwordInput = Console.ReadLine();

            LoginValidation validation = new LoginValidation(usernameInput, passwordInput, printError);

            User user = new User();

            if (validation.ValidateUserInput(ref user))
            {
                Console.WriteLine(user.ToString());
                Console.WriteLine("Роля на потребителя: " + LoginValidation.currentUserRole);
                LoginValidation.CheckLogDate(user);

                switch (user.role)
                {
                case 0:
                    Console.WriteLine("Потребителя е ANONYMOUS.\n");
                    break;

                case 1:
                    Console.WriteLine("Потребителя е ADMINISTRATOR.\n");
                    break;

                case 2:
                    Console.WriteLine("Потребителя е INSPECTOR.\n");
                    break;

                case 3:
                    Console.WriteLine("Потребителя е PROFESSOR.\n");
                    break;

                case 4:
                    Console.WriteLine("Потребителя е STUDENT.\n");
                    break;

                default:
                    Console.WriteLine("ERROR");
                    break;
                }
                if (user.role == 1)
                {
                    adminFunction();
                }
            }
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            int shouldRun = 1;

            while (shouldRun == 1)
            {
                if (!LoginValidation.UserLoginPossible())
                {
                    Console.WriteLine("Too many failed login attempts");
                    Thread.Sleep(120 * 1000);
                    continue;
                }

                Console.WriteLine("Username:"******"Password:"******"Anonymous");
                        break;

                    case UserRoles.ADMIN:
                        Console.WriteLine("Admin");
                        shouldRun = AdminMenu();
                        break;

                    case UserRoles.INSPECTOR:
                        Console.WriteLine("Inspector");
                        break;

                    case UserRoles.PROFESSOR:
                        Console.WriteLine("Profesor");
                        break;

                    case UserRoles.STUDENT:
                        Console.WriteLine("Student");
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            //UserData user = new UserData();
            RightsGranted.SetUserPermisions();
            User user = null;

            Console.WriteLine("Username: "******"Password: "******"Username: "******"Password: "******"Faculty Number: " + user.facultyNumber);

                switch (user.role)
                {
                case UserRole.ANONYMOUS: Console.WriteLine("Role: " + UserRole.ANONYMOUS);
                    break;

                case UserRole.ADMIN: Console.WriteLine("Role: " + UserRole.ADMIN);
                    AdminMenu();
                    break;

                case UserRole.INSPECTOR: Console.WriteLine("Role: " + UserRole.INSPECTOR);
                    break;

                case UserRole.PROFESSOR:
                    Console.WriteLine("Role: " + UserRole.PROFESSOR);
                    break;

                case UserRole.STUDENT:
                    Console.WriteLine("Role: " + UserRole.STUDENT);
                    break;
                }
            }
            else
            {
                Console.WriteLine(vali.Error);
                Console.ReadLine();
            }
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            Console.Write("Username: "******"Password: "******"\nИме: " + user.username);
                Console.WriteLine("Факултетен номер: " + user.fakNum);
                switch (LoginValidation.currentUserRole)
                {
                case UserRoles.ANONYMOUS:
                    Console.WriteLine("Роля: Анонимен");
                    break;

                case UserRoles.ADMIN:
                    Console.WriteLine("Роля: Администратор");
                    break;

                case UserRoles.INSPECTOR:
                    Console.WriteLine("Роля: Инспектор");
                    break;

                case UserRoles.PROFESSOR:
                    Console.WriteLine("Роля: Професор");
                    break;

                case UserRoles.STUDENT:
                    Console.WriteLine("Роля: Студент");
                    break;
                }
                Console.WriteLine("Дата на създаване: " + user.created);
                Console.WriteLine("Активност: " + user.isActive);
            }
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            string logInMessage = "Hello, you are logged as ";

            Console.WriteLine("Enter username:"******"Enter password:"******"Last time when you logged was before " + getDaysDifference(DateTime.Now, (DateTime)user.LastTimeLogged));
                UserData.SetUserLastTimeLogged(user.Username, DateTime.Now);
                switch (LoginValidation.currentUserRole)
                {
                case UserRoles.ADMIN:
                    Console.WriteLine(logInMessage + "Admin.");
                    AdminMenu(user);
                    break;

                case UserRoles.INSPECTOR:
                    Console.WriteLine(logInMessage + "Inspector.");
                    break;

                case UserRoles.PROFESSOR:
                    Console.WriteLine(logInMessage + "Professor.");
                    break;

                case UserRoles.STUDENT:
                    Console.WriteLine(logInMessage + "Student.");
                    break;

                case UserRoles.ANONYMOUS:
                    Console.WriteLine("You aren't logged in.");
                    break;

                default:
                    Console.WriteLine("Something went wrong");
                    break;
                }
            }
            Console.ReadLine();
        }
Beispiel #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Въведете потребителско име:");
            string username = Console.ReadLine();

            Console.WriteLine("Въведете парола:");
            string password = Console.ReadLine();

            LoginValidation loginValidation = new LoginValidation(username, password, PrintMessage);
            User            user            = null;

            if (loginValidation.ValidateUserInput(ref user))
            {
                Console.WriteLine("Потребител с\n Потребителско име: {0}\n Парола: {1}\n Роля: {2}\n", user.Username, user.Password, user.Role);
                Console.WriteLine(LoginValidation.CurrentUserRole);
            }
        }
Beispiel #17
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Моля, въведете потребителско име:");
            string enteredUsername = Console.ReadLine();

            Console.WriteLine("Моля, въведете парола:");
            string enteredPassword = Console.ReadLine();

            LoginValidation lv = new LoginValidation(enteredUsername, enteredPassword, errorFunc);

            User tempUser = new User();

            if (lv.ValidateUserInput(ref tempUser))
            {
                Console.WriteLine("\nПотребителско име: " + tempUser.username);
                Console.WriteLine("Парола: " + tempUser.password);
                Console.WriteLine("Факултетен номер: " + tempUser.fNumber);
                Console.WriteLine("Потребителски тип: " + tempUser.role + "\n");

                switch (LoginValidation.currentUserRole)
                {
                case UserRoles.ANONYMOUS:
                    Console.WriteLine("Потребителят е: Анонимен");
                    break;

                case UserRoles.ADMIN:
                    Console.WriteLine("Потребителят е: Администратор");
                    adminMenu();
                    break;

                case UserRoles.INSPECTOR:
                    Console.WriteLine("Потребителят е: Инспектор");
                    break;

                case UserRoles.PROFESSOR:
                    Console.WriteLine("Потребителят е: Професор");
                    break;

                case UserRoles.STUDENT:
                    Console.WriteLine("Потребителят е: Студент");
                    break;
                }
            }
        }
Beispiel #18
0
      static void Main(string[] args)
      {
          /*User x1 = new User() ;
           * x1.name = "Mila";
           *
           * x1.pass = "******";
           * x1.facNum = "121212";
           * x1.role = 3;
           */
          String name1;
          String pass1;

          Console.WriteLine("Please enter name of the user.");
          name1 = Console.ReadLine();
          Console.WriteLine("Please enter password for the user.");
          pass1 = Console.ReadLine();


          User            myUser = null;
          LoginValidation lv1    = new LoginValidation(name1, pass1, MyErrorMessage);

          if (lv1.ValidateUserInput(ref myUser) == true)
          {
              Console.WriteLine("Name is " + myUser.name + " Pass is: " + myUser.pass + " Fac num is: " + myUser.facNum + " Role is: " + myUser.role + " Log Val:" + LoginValidation.currentUserRole + "User Logged times: " + ShowActivity(myUser.name));
              switch (LoginValidation.currentUserRole)
              {
              case UserRoles.ANONYMOUS: Console.WriteLine("ANONYMOUS IS MY POWER"); break;

              case UserRoles.ADMIN: Console.WriteLine("THIS IS A FAKIN ADMIN"); break;

              case UserRoles.INSPECTOR: Console.WriteLine("I'm an insperktor"); break;

              case UserRoles.PROFESSOR: Console.WriteLine("I'm a professor"); break;

              case UserRoles.STUDENT: Console.WriteLine("Nobody cares about me, jsut a stupid student"); break;
              }

              if (LoginValidation.currentUserRole == UserRoles.ADMIN)
              {
                  IfAdmin();
              }
              Console.ReadLine();
          }
      }
        static void Main(string[] args)
        {
            UserData.ResetTestUserData();
            RightsGranted.InitRoleRights();

            Console.Write("Username: "******"Password: ");
            string password = Console.ReadLine();


            LoginValidation validator = new LoginValidation(username, password, Console.WriteLine);
            User            user      = null;

            if (validator.ValidateUserInput(ref user))
            {
                SelectMenuOption(user);
            }
        }
Beispiel #20
0
        static public void LogActivity(string activity)
        {
            string nameOfCurrUser = LoginValidation.getCurrUserName();
            string activityLine   = DateTime.Now + ";"
                                    + LoginValidation.getCurrUserName() + ";"
                                    + LoginValidation.currentUserRole + ";"
                                    + activity;

            currentSessionActivities.Add(activityLine);
            if (File.Exists(filePath))
            {
                File.AppendAllText(filePath, activityLine, Encoding.UTF8);
            }
            else
            {
                Console.WriteLine("Error while working with log file.");
            }

            currentSessionActivities.Add(activityLine);
        }
Beispiel #21
0
        static void Main(string[] args)
        {
            Console.Write("Username: "******"Password ");
            string password   = Console.ReadLine();
            var    validation = new LoginValidation(username, password, DisplayError);
            User   user       = null;

            if (validation.ValidateUserInput(ref user))
            {
                Console.WriteLine("Username:"******"Role: ");
                switch (LoginValidation.currentUserRole)
                {
                case UserRoles.ANONYMOUS:
                    Console.WriteLine("ANONYMOUS");
                    break;

                case UserRoles.ADMIN:
                    Console.WriteLine("ADMIN");
                    ShowAdministratorMenu();
                    break;

                case UserRoles.INSPECTOR:
                    Console.WriteLine("INSPECTOR");
                    break;

                case UserRoles.PROFESSOR:
                    Console.WriteLine("PROFESSOR");
                    break;

                case UserRoles.STUDENT:
                    Console.WriteLine("STUDEN");
                    break;
                }
            }

            Console.ReadLine();
        }
Beispiel #22
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Enter userName");
            string userName = Console.ReadLine();

            Console.WriteLine("Enter password");
            string password = Console.ReadLine();

            LoginValidation loginValidation = new LoginValidation(userName, password, ErrorLogger);

            if (loginValidation.ValidateUserInput(out User user))
            {
                AdminPanel();

                Console.WriteLine($"\nUser name: {user.UserName}\nUser password: {user.Password}\nFaculty number: {user.FacultyNumber}\nCreated on: {user.CreatedOn}\nActive until: {user.ActiveUntil}");

                switch ((int)LoginValidation.CurrentUserRole)
                {
                case 1:
                    Console.WriteLine("Current user role: Anonymous");
                    break;

                case 2:
                    Console.WriteLine("Current user role: Admin");
                    break;

                case 3:
                    Console.WriteLine("Current user role: Inspector");
                    break;

                case 4:
                    Console.WriteLine("Current user role: Professor");
                    break;

                case 5:
                    Console.WriteLine("Current user role: Student");
                    break;
                }
            }
        }
Beispiel #23
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;
                    }
                }
            }
        }
Beispiel #24
0
        static void Main(string[] args)
        {
            if (UserData.TestUsersIfEmpty())
            {
                UserData.CopyTestUsers();
            }

            LoginValidation login = BuildValidator();

            while (Logger.CanUserLogIn(LoginValidation.currentUserUsername))
            {
                User user = null;

                if (LoginValidation.ValidateUserInput(ref user))
                {
                    Console.WriteLine(user.ToString());
                    PrintCurrentUserRole();

                    if (user.Role == UserRoles.ADMIN)
                    {
                        OpenAdminMenu();
                    }
                    else
                    {
                        Console.WriteLine("Hello, " + user.Username);
                        Console.ReadKey();
                        return;
                    }
                }
                else
                {
                    Logger.IncrementLoginAttemts(LoginValidation.currentUserUsername);
                    login = BuildValidator();
                }
            }

            Console.WriteLine("Exiting... Press anykey to continue");
            Console.ReadKey();
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter username:"******"Enter password:"******"Logged in user {0} ", user.Username));
                switch (user.Role)
                {
                case UserRoles.ANONYMOUS:
                    Console.WriteLine("You are logged in as anonymous user");
                    break;

                case UserRoles.ADMIN:
                    Console.WriteLine("You are logged in as administrator user");
                    AdminMenu();
                    break;

                case UserRoles.INSPECTOR:
                    Console.WriteLine("You are logged in as inspector user");
                    break;

                case UserRoles.STUDENT:
                    Console.WriteLine("You are logged in as student user");
                    break;

                case UserRoles.PROFESSOR:
                    Console.WriteLine("You are logged in as professor user");
                    break;
                }
            }
        }
Beispiel #26
0
        static void Main(string[] args)
        {
            Console.WriteLine("Username:"******"Admin";//Console.ReadLine();

            Console.WriteLine("Password:"******"Admin123";//Console.ReadLine();
            LoginValidation validator = new LoginValidation(username, password, printError);
            User            user      = null;

            if (validator.ValidateUserInput(ref user))
            {
                Console.WriteLine("Username: {0}, Password: {1}, FN: {2}, RoleCode: {3}", user.UserName, user.Password, user.FacultyNumber, user.Role);
                switch (LoginValidation.CurrentUserRole)
                {
                case UserRoles.ANONYMOUS:
                    Console.WriteLine("Current user is logged as Anonymous");
                    break;

                case UserRoles.INSPECTOR:
                    Console.WriteLine("Current user is inspecting");
                    break;

                case UserRoles.PROFESSOR:
                    Console.WriteLine("Current user is a professor");
                    break;

                case UserRoles.STUDENT:
                    Console.WriteLine("Current user is a student");
                    break;

                case UserRoles.ADMIN:
                    Console.WriteLine("An admin has logged");
                    ControlAdminPanel();
                    break;
                }
            }
        }
Beispiel #27
0
        static void Main(string[] args)
        {
            String          username        = Console.ReadLine();
            String          password        = Console.ReadLine();
            LoginValidation loginValidation = new LoginValidation(username, password, new LoginValidation.ActionOnError(logErrorToConsole));
            User            user            = new User("", "", "", 5, DateTime.Now, DateTime.Now);

            if (loginValidation.ValidateUserInput(ref user))
            {
                Console.WriteLine(user.username);
                Console.WriteLine(user.password);
                Console.WriteLine(user.number);
                Console.WriteLine((UserRoles)user.role);
                Console.WriteLine(user.created);
                Console.WriteLine(user.activeTo);
            }

            if (user.role == (int)UserRoles.ADMIN)
            {
                Program.openAdminMenu();
            }
            Console.ReadLine();
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            Console.WriteLine("Username: "******"Password: "******"!!" + err + "!!");
                Logger.LogActivity("Error: " + err);
            });

            User user = new User();


            if (LogVal.ValidateUserInput(ref user))
            {
                switch (LoginValidation.CurrentUserRole)
                {
                case UserRoles.ADMIN:
                    Console.WriteLine("Zdr shefe");
                    AdminMenu();
                    break;

                case UserRoles.STUDENT:
                    Console.WriteLine("Zdr malak student");
                    StudentMenu(user);
                    break;

                case UserRoles.ANONYMOUS:
                    Console.WriteLine("koi si ti");
                    break;
                }
            }
        }
Beispiel #29
0
        public static void Main()
        {
            string uname, pass;

            Read(out uname, out pass);
            LoginValidation lv = new LoginValidation(uname, pass, Printer);
            User            u;

            if (lv.ValidateUserInput(out u))
            {
                Console.WriteLine(u.Username + " "
                                  + u.Password + " "
                                  + u.FakNum + " "
                                  + u.Role);
                switch (LoginValidation.CurrentRole)
                {
                case (int)UserRole.Admin:
                    Console.WriteLine("Admin");
                    break;

                case (int)UserRole.Anonymous:
                    Console.WriteLine("Anonymous");
                    break;

                case (int)UserRole.Inspector:
                    Console.WriteLine("Inspector");
                    break;

                case (int)UserRole.Professor:
                    Console.WriteLine("Professor");
                    break;

                case (int)UserRole.Student:
                    Console.WriteLine("Student");
                    break;

                default:
                    Console.WriteLine("Incorrect role");
                    break;
                }

                if (u.Role == (int)UserRole.Admin)
                {
                    for (bool b = true; b;)
                    {
                        Console.WriteLine("Изберте опция:\n" +
                                          "0: Изход\n" +
                                          "1: Промяна на роля на потребител\n" +
                                          "2: Промяна на активност на потребител\n" +
                                          "3: Списък на потребителите\n" +
                                          "4: Преглед на лог активност\n" +
                                          "5: Преглед на текуща активност");
                        string input = Console.ReadLine();
                        string user;
                        switch (int.Parse(input))
                        {
                        case 0:
                            b = false;
                            break;

                        case 1:
                            Console.WriteLine("Въведете потребителско име:");
                            user = Console.ReadLine();
                            Console.Write("0: Anonymous\n" +
                                          "1: Admin\n" +
                                          "2: Inspector\n" +
                                          "3: Professor\n" +
                                          "4: Student\n" +
                                          "Нова роля:");
                            input = Console.ReadLine();
                            UserRole role;
                            if (!UserRole.TryParse(input, out role))
                            {
                                switch (input)
                                {
                                case "Anonymous":
                                    role = UserRole.Anonymous;
                                    break;

                                case "Admin":
                                    role = UserRole.Admin;
                                    break;

                                case "Inspector":
                                    role = UserRole.Inspector;
                                    break;

                                case "Professor":
                                    role = UserRole.Professor;
                                    break;

                                case "Student":
                                    role = UserRole.Student;
                                    break;

                                default:
                                    Console.WriteLine("Невалидна роля.");
                                    break;
                                }
                            }

                            UserData.AssignUserRole(user, role);
                            break;

                        case 2:
                            Console.WriteLine("Въведете потребителско име:");
                            user = Console.ReadLine();
                            Console.WriteLine("Въведете новата дата във формата дд.мм.гггг:");
                            string date = Console.ReadLine();
                            int[]  d    = date.Split('.').ToList().ConvertAll(Convert.ToInt32).ToArray();
                            if (d.Length == 3)
                            {
                                UserData.SetUserActiveTo(user, new DateTime(d[2], d[1], d[0]));
                            }
                            else
                            {
                                Console.WriteLine("Невалидна дата.");
                            }

                            break;

                        case 3:
                            UserData.TestUsers.ForEach(Console.WriteLine);
                            break;

                        case 4:
                            StreamReader reader = new StreamReader(Logger.FileName);
                            for (; !reader.EndOfStream;)
                            {
                                Console.WriteLine(reader.ReadLine());
                            }

                            reader.Close();
                            break;

                        case 5:
                            Console.WriteLine(Logger.GetCurrentSessionActivities());
                            break;

                        default:
                            Console.WriteLine("Невалиден избор.");
                            break;
                        }
                    }
                }
            }


            // DateTimeExploration();
        }
Beispiel #30
0
        static void Main(string[] args)
        {
            //User user1 = new User("Emil", "12345", "121216092", 1);
            //user1.toPrint();
            //UserData.TestUser.toPrint();
            //DateTime dt = DateTime.MaxValue;
            //Console.WriteLine(dt.ToLongDateString());
            //DateTime dt2 = dt.AddHours(13);
            //int nextyear = dt2.Day;

            //Console.WriteLine(dt2.ToLongTimeString());
            //Console.WriteLine(nextyear);

            //string date = Console.ReadLine();
            //DateTime dt = DateTime.Parse(date);
            //Console.WriteLine(dt.ToLongDateString() + " " + dt.ToLongTimeString());

            //int ad = Convert.ToInt32( Console.ReadLine());
            //Console.WriteLine(ad);

            string name = null;
            string pass = null;

            Console.WriteLine("Enter Username:"******"Enter Password:"******"You are {0}! There is no user with this Username!", LoginValidation.CurrentUserRole);
                    break;
                }

                case 1:
                {
                    Console.WriteLine("You are {0}! you have permission to do anything!", LoginValidation.CurrentUserRole);
                    MenuAdmin();
                    break;
                }

                case 2:
                {
                    Console.WriteLine("You are {0}! you have permission to see private data!", LoginValidation.CurrentUserRole);
                    break;
                }

                case 3:
                {
                    Console.WriteLine("You are {0}! you have permission to add or delete materials!", LoginValidation.CurrentUserRole);
                    break;
                }

                case 4:
                {
                    Console.WriteLine("You are {0}! you have permission raed materials !", LoginValidation.CurrentUserRole);
                    break;
                }

                default:
                {
                    Console.WriteLine("Error with your position!");
                    break;
                }
                }
            }
        }