Ejemplo n.º 1
0
        public static void SaveFormState(Form frm, string title, ViewModelBase vm = null)
        {
            string    profileName = (frm.GetType().FullName + "_" + title + (vm == null ? "" : vm.GetType().FullName));
            FormState profile     = new FormState {
                WindowState = frm.WindowState, Location = frm.Location, Size = frm.Size
            };

            LocalUserProfile.Save(ClientInfo.UserLoginName, profileName, profile);
        }
Ejemplo n.º 2
0
 private void SaveUserHistory()
 {
     if (cRememberPwd.Checked)
     {
         LocalUserProfile.SaveContent(_vm.UserName, "password", _vm.Password);
     }
     else
     {
         LocalUserProfile.Delete(_vm.UserName, "password");
     }
 }
Ejemplo n.º 3
0
        public static void LoadFormState(Form frm, string title, ViewModelBase vm = null)
        {
            string    profileName = (frm.GetType().FullName + "_" + title + (vm == null ? "" : vm.GetType().FullName));
            FormState profile     = LocalUserProfile.GetProfile <FormState>(ClientInfo.UserLoginName, profileName);

            if (profile != null)
            {
                frm.WindowState = profile.WindowState;
                if (frm.WindowState != FormWindowState.Maximized)
                {
                    frm.StartPosition = FormStartPosition.Manual;
                    frm.Location      = profile.Location;
                    frm.Size          = profile.Size;
                }
            }
        }
Ejemplo n.º 4
0
        private void LoadUserHistory()
        {
            //只加载最近10个
            var dirs = new DirectoryInfo(LocalUserProfile.UserProfileDirecotry).GetDirectories().OrderByDescending(d => d.LastWriteTime).Take(10);

            foreach (var d in dirs)//每个目录一个用户(的所有设置)
            {
                //找密码
                string pwd = LocalUserProfile.GetProfileContent(d.Name, "password");
                _userHistory[d.Name] = pwd;
                cmbUserName.Items.Add(d.Name);
            }
            if (_userHistory.Any())
            {
                _vm.UserName = _userHistory.Keys.First();
            }
        }
Ejemplo n.º 5
0
        public VMLoginForm()
        {
            //加载登录记录
            //只加载最近10个
            var dirs = new DirectoryInfo(LocalUserProfile.UserProfileDirecotry).GetDirectories().OrderByDescending(d => d.LastWriteTime).Take(10);

            foreach (var d in dirs)//每个目录一个用户(的所有设置)
            {
                //找密码
                string pwd = LocalUserProfile.GetProfileContent(d.Name, "password");
                _userHistory[d.Name] = pwd;
            }
            UserHistory = _userHistory.Keys.ToArray();
            if (UserHistory.Length > 0)
            {
                UserName    = UserHistory[0];
                Password    = _userHistory[UserName];
                RememberPwd = Password != null;
            }
        }
Ejemplo n.º 6
0
        public override bool Submit()
        {
            if (!base.Submit())
            {
                return(false);
            }

            using (SettlementContainer container = new SettlementContainer())
            {
                string hashValue = Password.GetMD5();
                var    user      = container.UserInfoSet.FirstOrDefault(u => u.UserName == UserName && u.Password == hashValue);

                if (user == null)
                {
                    ValidateFailed?.Invoke(nameof(UserName), "用户名不存在或密码错误!");
                    return(false);
                }
                if (user.Disabled)
                {
                    ValidateFailed?.Invoke(nameof(UserName), "该用户已被禁用!");
                    return(false);
                }
                ClientInfo.UserID        = user.Id;
                ClientInfo.UserLoginName = user.UserName;
                ClientInfo.UserName      = user.DisplayName;
            }

            if (RememberPwd)
            {
                LocalUserProfile.SaveContent(UserName, "password", Password);
            }
            else
            {
                LocalUserProfile.Delete(UserName, "password");
            }
            return(true);
        }