WJC
2019-10-18 2bc230cf2e7a7329c2329b07307a47b059835bbc
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs
@@ -1,4 +1,5 @@
using System;
using Shared.Common;
using System;
using System.Collections.Generic;
namespace Shared.Phone.UserCenter
@@ -169,7 +170,7 @@
        /// <summary>
        /// 房间名称
        /// </summary>
        public List<string> listRoomName = new List<string>();
        public string RoomName = string.Empty;
        /// <summary>
        /// 设备的打开状态
        /// </summary>
@@ -985,4 +986,75 @@
    }
    #endregion
    #region ■ 账号设置类__________________________
    /// <summary>
    /// 账号设置信息
    /// </summary>
    public class AccountOption
    {
        /// <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>
        public void Save()
        {
            //加密密码
            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;
        }
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <returns></returns>
        public AccountOption 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 AccountOption();
            }
            var varByte = Shared.IO.FileUtils.ReadFile(fileName);
            string strValue = System.Text.Encoding.UTF8.GetString(varByte);
            var info = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountOption>(strValue);
            //解密密码
            string hdlKey = "hD1(La3o";
            info.PswAuthentication = UserCenterLogic.DecryptPassword(hdlKey, info.PswAuthentication);
            info.GestureAuthentication = UserCenterLogic.DecryptPassword(hdlKey, info.GestureAuthentication);
            return info;
        }
    }
    #endregion
}