using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace Shared.Phone
|
{
|
/// <summary>
|
/// 账号设置信息
|
/// </summary>
|
public class AccountOptionClass
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 是否使用指纹验证
|
/// </summary>
|
public bool FingerprintAuthentication = false;
|
/// <summary>
|
/// 密码验证
|
/// </summary>
|
public string PswAuthentication = string.Empty;
|
/// <summary>
|
/// 手势验证
|
/// </summary>
|
public string GestureAuthentication = string.Empty;
|
/// <summary>
|
/// 是否使用远程开锁
|
/// </summary>
|
public bool DoorUnLockByRemote = false;
|
/// <summary>
|
/// 密码剩余可输入次数
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public int PasswordInputCount = 3;
|
/// <summary>
|
/// 手势密码剩余可输入次数
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public int PasswordGestureInputCount = 5;
|
/// <summary>
|
/// 检测APP是否能够退出
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public bool AppCanSignout = false;
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
public void Save()
|
{
|
try
|
{
|
//加密密码
|
string hdlKey = "hD1(La3o";
|
string oldPswAuthentication = PswAuthentication;
|
PswAuthentication = HdlCommonLogic.Current.EncryptPassword(hdlKey, oldPswAuthentication);
|
|
string oldGestureAuthentication = GestureAuthentication;
|
GestureAuthentication = HdlCommonLogic.Current.EncryptPassword(hdlKey, oldGestureAuthentication);
|
|
//写入内容
|
HdlFileLogic.Current.SaveFileContent(HdlFileNameResourse.AccountOptionFile, this);
|
//还原明码
|
PswAuthentication = oldPswAuthentication;
|
GestureAuthentication = oldGestureAuthentication;
|
}
|
catch (Exception ex)
|
{
|
HdlLogLogic.Current.WriteLog(ex);
|
}
|
}
|
|
/// <summary>
|
/// 加载数据
|
/// </summary>
|
/// <returns></returns>
|
public AccountOptionClass Load()
|
{
|
string fileName = HdlFileNameResourse.AccountOptionFile;
|
if (System.IO.File.Exists(fileName) == false)
|
{
|
return new AccountOptionClass();
|
}
|
try
|
{
|
var varByte = HdlFileLogic.Current.ReadFileByteContent(fileName);
|
string strValue = System.Text.Encoding.UTF8.GetString(varByte);
|
var info = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountOptionClass>(strValue);
|
//解密密码
|
string hdlKey = "hD1(La3o";
|
info.PswAuthentication = HdlCommonLogic.Current.DecryptPassword(hdlKey, info.PswAuthentication);
|
info.GestureAuthentication = HdlCommonLogic.Current.DecryptPassword(hdlKey, info.GestureAuthentication);
|
|
return info;
|
}
|
catch (Exception ex)
|
{
|
HdlLogLogic.Current.WriteLog(ex);
|
return new AccountOptionClass();
|
}
|
}
|
|
/// <summary>
|
/// 重置密码剩余次数
|
/// </summary>
|
public void ResetPasswordCount()
|
{
|
this.PasswordInputCount = 3;
|
this.PasswordGestureInputCount = 5;
|
}
|
|
#endregion
|
}
|
}
|