using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 账号设置信息 /// public class AccountOptionClass { #region ■ 变量声明___________________________ /// /// 是否使用指纹验证 /// public bool FingerprintAuthentication = false; /// /// 密码验证 /// public string PswAuthentication = string.Empty; /// /// 手势验证 /// public string GestureAuthentication = string.Empty; /// /// 是否使用远程开锁 /// public bool DoorUnLockByRemote = false; /// /// 密码剩余可输入次数 /// [Newtonsoft.Json.JsonIgnore] public int PasswordInputCount = 3; /// /// 手势密码剩余可输入次数 /// [Newtonsoft.Json.JsonIgnore] public int PasswordGestureInputCount = 5; /// /// 检测APP是否能够退出 /// [Newtonsoft.Json.JsonIgnore] public bool AppCanSignout = false; /// /// 前一次的住宅ID,这个东西是给UserCenterLogic.InitUserCenterMenmoryAndThread()用的 /// [Newtonsoft.Json.JsonIgnore] public string OldHomeStringId = string.Empty; /// /// 前一次的登录账号,这个东西是给UserCenterLogic.InitUserCenterMenmoryAndThread()用的 /// [Newtonsoft.Json.JsonIgnore] public string OldAccountId = string.Empty; /// /// 用户图片目录路径 /// [Newtonsoft.Json.JsonIgnore] public string UserPictruePath = string.Empty; #endregion #region ■ 一般方法___________________________ /// /// 保存 /// public void Save() { try { //加密密码 string hdlKey = "hD1(La3o"; string oldPswAuthentication = PswAuthentication; PswAuthentication = UserCenterLogic.EncryptPassword(hdlKey, oldPswAuthentication); string oldGestureAuthentication = GestureAuthentication; GestureAuthentication = UserCenterLogic.EncryptPassword(hdlKey, oldGestureAuthentication); var data = Newtonsoft.Json.JsonConvert.SerializeObject(this); var byteData = System.Text.Encoding.UTF8.GetBytes(data); string fullName = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.AccountOptionFile); //写入内容 Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData); //还原明码 PswAuthentication = oldPswAuthentication; GestureAuthentication = oldGestureAuthentication; } catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); } } /// /// 加载数据 /// /// public AccountOptionClass Load() { string fileName = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.AccountOptionFile); if (System.IO.File.Exists(fileName) == false) { return new AccountOptionClass(); } try { var varByte = Shared.IO.FileUtils.ReadFile(fileName); string strValue = System.Text.Encoding.UTF8.GetString(varByte); var info = Newtonsoft.Json.JsonConvert.DeserializeObject(strValue); //解密密码 string hdlKey = "hD1(La3o"; info.PswAuthentication = UserCenterLogic.DecryptPassword(hdlKey, info.PswAuthentication); info.GestureAuthentication = UserCenterLogic.DecryptPassword(hdlKey, info.GestureAuthentication); return info; } catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); return new AccountOptionClass(); } } /// /// 重置密码剩余次数 /// public void ResetPasswordCount() { this.PasswordInputCount = 3; this.PasswordGestureInputCount = 5; } #endregion } }