客户端中追加账户记录有效期,七天不登陆自动清空填写

This commit is contained in:
dathlin
2017-06-09 11:40:31 +08:00
parent 59b62e6577
commit f11d7b8499
2 changed files with 16 additions and 5 deletions

View File

@@ -89,6 +89,11 @@ namespace CommonLibrary
/// 上次系统登录的密码
/// </summary>
public string Password { get; set; } = "";
/// <summary>
/// 上次系统登录的时间
/// </summary>
public DateTime LoginTime { get; set; } = DateTime.Now;
/// <summary>
/// 当前计算机的机器码,用来判定参数是否是正确的
@@ -107,6 +112,7 @@ namespace CommonLibrary
json.Add(nameof(Password), new JValue(Password));
json.Add(nameof(IsNewVersionRunning), new JValue(IsNewVersionRunning));
json.Add(nameof(SystemInfo), new JValue(SystemInfo));
json.Add(nameof(LoginTime), new JValue(LoginTime));
return json.ToString();
}
public override void LoadByString(string content)
@@ -119,6 +125,7 @@ namespace CommonLibrary
LoginName = SoftBasic.GetValueFromJsonObject(json, nameof(LoginName), LoginName);
IsNewVersionRunning = SoftBasic.GetValueFromJsonObject(json, nameof(IsNewVersionRunning), IsNewVersionRunning);
Password = SoftBasic.GetValueFromJsonObject(json, nameof(Password), Password);
LoginTime = SoftBasic.GetValueFromJsonObject(json, nameof(LoginTime), LoginTime);
}
}

View File

@@ -49,11 +49,14 @@ namespace 软件系统客户端模版
{
IsWindowShow = true;
//加载数据
textBox_userName.Text = UserClient.JsonSettings.LoginName ?? "";
textBox_password.Text = UserClient.JsonSettings.Password ?? "";
checkBox_remeber.Checked = UserClient.JsonSettings.Password != "";
//如果七天未登录,账户密码清除
if ((DateTime.Now - UserClient.JsonSettings.LoginTime).TotalDays < 7)
{
//加载数据
textBox_userName.Text = UserClient.JsonSettings.LoginName ?? "";
textBox_password.Text = UserClient.JsonSettings.Password ?? "";
checkBox_remeber.Checked = UserClient.JsonSettings.Password != "";
}
//初始化输入焦点
if (UserClient.JsonSettings.Password != "") userButton_login.Focus();
else if (UserClient.JsonSettings.LoginName != "") textBox_password.Focus();
@@ -230,6 +233,7 @@ namespace 软件系统客户端模版
//登录成功,进行保存用户名称和密码
UserClient.JsonSettings.LoginName = textBox_userName.Text;
UserClient.JsonSettings.Password = checkBox_remeber.Checked ? textBox_password.Text : "";
UserClient.JsonSettings.LoginTime = DateTime.Now;
UserClient.JsonSettings.SaveToFile();