gxc
2019-10-29 081ea8d273048fd03756718ac6fb48a3c09218e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter
{
    /// <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>
        [Newtonsoft.Json.JsonIgnore]
        public int PasswordInputCount = 3;
        /// <summary>
        /// 检测APP是否能够退出
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public bool AppCanSignout = false;
        /// <summary>
        /// 前一次的住宅ID,这个东西是给UserCenterLogic.InitUserCenterMenmoryAndThread()用的
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string OldHomeStringId = string.Empty;
        /// <summary>
        /// 前一次的登录账号,这个东西是给UserCenterLogic.InitUserCenterMenmoryAndThread()用的
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string OldAccountId = string.Empty;
        /// <summary>
        /// 用户图片目录路径
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string UserPictruePath = string.Empty;
        /// <summary>
        /// 安防报警信息记录一天内最大的报警数
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int SafetyOnedayMaxAlarmMsgCount = 50;
        /// <summary>
        /// 安防报警信息记录最大天数
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int SafetyMaxAlarmMsgDay = 5;
        /// <summary>
        /// 门锁报警信息记录一天内最大的报警数
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int DoorLockOnedayMaxAlarmMsgCount = 200;
        /// <summary>
        /// 门锁报警信息记录最大天数
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int DoorLockMaxAlarmMsgDay = 5;
 
        #region ■ 一般方法___________________________
 
        /// <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;
        }
 
        /// <summary>
        /// 重置密码剩余次数
        /// </summary>
        public void ResetPasswordCount()
        {
            this.PasswordInputCount = 3;
        }
 
        #endregion
    }
}