コード例 #1
0
ファイル: UserList_Test.cs プロジェクト: 2DKot/ChatProject
        public void RemoveAllUsers()
        {
            UserList ulist = new UserList();

            ulist.Add(new User(new TcpClient(), "ЮзерОдин"));
            ulist.Add(new User(new TcpClient(), "ЮзерДва"));
            ulist.RemoveAll();
            User result = ulist.Find("ЮзерОдин");

            Assert.AreEqual(null, result);
            result = ulist.Find("ЮзерДва");
            Assert.AreEqual(null, result);
        }
コード例 #2
0
ファイル: UserList_Test.cs プロジェクト: 2DKot/ChatProject
        public void RemoveUser_UserExists()
        {
            UserList ulist = new UserList();
            User     user  = new User(new TcpClient(), "СуперЮзер");

            ulist.Add(user);
            User result = ulist.Find("СуперЮзер");

            Assert.AreEqual(user, result, "Юзер не добавился!");
            ulist.Remove(user);
            result = ulist.Find("СуперЮзер");
            Assert.AreSame(null, result, "Удаление юзера не сработало!");
        }
コード例 #3
0
        public bool EditWcsUser(WcsUser user, out string result)
        {
            if (!UserList.Exists(c => user.id == c.id))
            {
                result = "不存在该用户信息!";
                return(false);
            }

            if (UserList.Exists(c => user.id != c.id && user.username.Equals(c.username)))
            {
                result = "已经存在该用户名!";
                return(false);
            }

            result = "";
            WcsUser ouser = UserList.Find(c => c.id == user.id);

            ouser.name     = user.name;
            ouser.username = user.username;
            ouser.password = user.password;
            ouser.exitwcs  = user.exitwcs;
            ouser.memo     = user.memo;
            ouser.role_id  = user.role_id;
            return(PubMaster.Mod.RoleSql.EditeWcsUser(ouser));
        }
コード例 #4
0
ファイル: UserList_Test.cs プロジェクト: 2DKot/ChatProject
        public void FindUserByName_FindNotExistingUser()
        {
            UserList ulist  = new UserList();
            User     result = ulist.Find("Не существующий Юзер");

            Assert.AreSame(null, result);
        }
コード例 #5
0
        private WcsRole GetUserRole(string username, string password)
        {
            if (IsUserMatch(username, password))
            {
                int roleid = UserList.Find(c => c.username.Equals(username))?.role_id ?? 0;
                return(GetRole(roleid));
            }

            return(null);
        }
コード例 #6
0
ファイル: SofaSoup.cs プロジェクト: magentapowa/SofaSoup
// Sign Up
        #region Sign up
        public User SignUp(string breadcrumb = "")
        {
            // Username______________________________________
            string name     = "";
            string message1 = "Choose a username:"******"";

            while (true)
            {
                Console.Clear();
                Console.WriteLine(LoadHeader());
                Console.WriteLine(breadcrumb);
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("\t" + message2);
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("\t" + message1);
                Console.Write("\t>");
                Console.Write(name);
                var key = Console.ReadKey();

                if (key.Key == ConsoleKey.Escape)
                {
                    return(null);
                }
                if (key.Key == ConsoleKey.Backspace)
                {
                    if (name.Length > 0)
                    {
                        name = name.Remove(name.Length - 1);
                    }
                    continue;
                }
                else if (key.Key == ConsoleKey.Enter)
                {
                    if (!(UserList.Find(i => i.username == name) is null))
                    {
                        Console.Clear();
                        message2 = "That username is taken.";
                        message1 = "Try another one:";
                        name     = "";
                        // Prompt to sign up or try again for username?
                        // How will the user go back to main menu?
                    }
                    else
                    {
                        break;
                    }
                }
                if (Tools.IsSymbol(key.KeyChar) > -1 || char.IsNumber(key.KeyChar) || char.IsLetter(key.KeyChar))
                {
                    Console.Write(key);
                    name += key.KeyChar;
                }
            }
コード例 #7
0
ファイル: UserList_Test.cs プロジェクト: 2DKot/ChatProject
        public void AddUsers_FindUser()
        {
            User     expected = new User(null, "СуперЮзер");
            UserList ulist    = new UserList();

            ulist.Add(expected);
            ulist.Add(new User(new TcpClient(), "ДругойЮзер"));
            User result = ulist.Find("СуперЮзер");

            Assert.AreSame(expected, result, expected.name + " и " + result.name);
        }
コード例 #8
0
        private void FindPerson(int uid)
        {
            string ucl;

            if (!__uid__ucl__.TryGetValue(uid, out ucl))
            {
                User person;
                UserList.Find(uid: uid, val: out person);
                __uid__ucl__.Add(uid, person.name);
            }
        }
コード例 #9
0
ファイル: FriendsPage.xaml.cs プロジェクト: samuelarbibe/taki
        private void RemoveFriendButton_OnClick(object sender, RoutedEventArgs e)
        {
            Button b  = sender as Button;
            User   u2 = b.DataContext as User;

            MainWindow.Service.RemoveFriend(MainWindow.CurrentUser, u2);

            View.ItemsSource = null;

            _ul.Remove(_ul.Find(u => u.Id == u2.Id));

            View.ItemsSource = _ul;
        }
コード例 #10
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            User currentUser = _userList.Find(txtLogin.Text, txtPassword.Text);

            if (currentUser != null)
            {
                Service.CurrentUser = currentUser;
                var studentsForm = new Students();
                studentsForm.AddOwnedForm(this);
                Hide();
                studentsForm.Show();
            }
            else
            {
                MessageBox.Show("Такого пользователя не существует!", "Ошибка!");
            }
        }
コード例 #11
0
        private async void StartUp()
        {
            if (MainAuth.UserID == null)
            {
                LoginNavigate();
            }
            else
            {
                await MainAuth.GenerateAccessToken();

                await RefreshShifts();
                await RefreshUsers();

                User user = UserList.Find(x => x._ID == MainAuth.UserID);
                MainAuth.UserName = $"{user.FirstName} {user.LastName}";

                ShiftListNavigate();
            }
        }
コード例 #12
0
ファイル: Settings.cs プロジェクト: MrCheka/deanery
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Service.CurrentUser.Role != User.UserRole.Admin)
            {
                if (txtLogin.Text == "" || txtPassword.Text == "" || txtFio.Text == "")
                {
                    MessageBox.Show("Не все поля заполнены!", "Ошибка!");
                }
                else
                {
                    User oldUser = _userList.Find(Service.CurrentUser);
                    oldUser.Login    = txtLogin.Text;
                    oldUser.Password = txtPassword.Text;
                    oldUser.Fio      = txtFio.Text;
                    oldUser.Role     = (User.UserRole)cmbRole.SelectedIndex;

                    _userList.Update();
                }
            }
            else
            {
                var editedUser = new User();
                editedUser.Login    = txtLogin.Text;
                editedUser.Password = txtPassword.Text;
                editedUser.Fio      = txtFio.Text;
                editedUser.Role     = (User.UserRole)cmbRole.SelectedIndex;

                _userList.Replace(_selectedUserId, editedUser);
                _userList.Update();
            }
            if (_selectedUserId == Service.CurrentUser.UserId)
            {
                _userList.SetNewCurrentUser();
            }
            dgvUsers.DataSource = typeof(List <User>);
            dgvUsers.DataSource = _userList.Value;
        }
コード例 #13
0
ファイル: SofaSoup.cs プロジェクト: magentapowa/SofaSoup
// Log in.
        #region Log in
        public User LogIn()
        {
            // Username______________________________________
            string name    = "";
            string message = "";

            while (true)
            {
                Console.Clear();
                Console.WriteLine(LoadHeader());
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine(message);
                Console.ForegroundColor = ConsoleColor.Black;
                message = "";
                Console.Write("\tUsername:\n\t>");
                Console.Write(name);
                var key = Console.ReadKey();

                if (key.Key == ConsoleKey.Escape)
                {
                    return(null);
                }
                if (key.Key == ConsoleKey.Backspace)
                {
                    if (name.Length > 0)
                    {
                        name = name.Remove(name.Length - 1);
                    }
                    continue;
                }
                else if (key.Key == ConsoleKey.Enter)
                {
                    if (UserList.Find(i => i.username == name) is null)
                    {
                        Console.Clear();
                        message = "\tThat name is not my DB.";
                        name    = "";
                    }
                    else
                    {
                        break;
                    }
                }
                if (Tools.IsSymbol(key.KeyChar) > -1 || char.IsNumber(key.KeyChar) || char.IsLetter(key.KeyChar))
                {
                    Console.Write(key);
                    name += key.KeyChar;
                }
            }
            //-------------------------------------------------------------------


            // Password______________________________________
            string password = "";

            message = "";

            while (true)
            {
                Console.Clear();
                Console.WriteLine(LoadHeader());
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine(message);
                Console.ForegroundColor = ConsoleColor.Black;
                message = "";
                Console.Write("\tPassword:\n\t>");
                Console.Write("*".Times(password.Length));
                var key = Console.ReadKey(true);

                if (key.Key == ConsoleKey.Escape)
                {
                    return(null);
                }
                if (key.Key == ConsoleKey.Backspace)
                {
                    if (password.Length > 0)
                    {
                        password = password.Remove(password.Length - 1);
                    }
                    continue;
                }
                if (key.Key == ConsoleKey.Enter)
                {
                    if (password.Length != 0)
                    {
                        if (UserList.Find(i => i.username == name).password == password)
                        {
                            break;
                        }
                        message  = "\tWrong password!";
                        password = "";
                    }
                    continue;
                }


                if (Tools.IsSymbol(key.KeyChar) > -1 || char.IsNumber(key.KeyChar) || char.IsLetter(key.KeyChar))
                {
                    //Console.Write("*");
                    password += key.KeyChar;
                }
            }
            //-------------------------------------------------------------------

            // LoadSpecific UserDB
            User user = UserList.Find(i => i.username == name);

            this.Log($"User loged in(userID:{user.UserID})");
            return(user);
        }
コード例 #14
0
 public WcsUser GetUser(int id)
 {
     return(UserList.Find(c => c.id == id));
 }
コード例 #15
0
 public int AdjustKhepris(string username, int khepris)
 {
     UserList.Find(mentionedUser => mentionedUser.username.Equals(username)).khepris += khepris;
     AdjustSafeKhepris(UserList.Find(mentionedUser => mentionedUser.username.Equals(username)).safename, khepris);
     return(UserList.Find(mentionedUser => mentionedUser.username.Equals(username)).khepris);
 }
コード例 #16
0
 public WcsUser GetUser(string username, string password)
 {
     return(UserList.Find(c => username.Equals(c.username) && password.Equals(c.password)));
 }
コード例 #17
0
 /// <summary>
 /// 获取默认的用户账号
 /// </summary>
 /// <returns></returns>
 public WcsUser GetGuestUser()
 {
     return(UserList.Find(c => c.guest));
 }