| | |
| | | [System.Serializable] |
| | | public class Config |
| | | { |
| | | static readonly string fileName = "Config.json"; |
| | | static Config config; |
| | | private const string fileName = "Config.json"; |
| | | |
| | | private static Config config = null; |
| | | public static Config Instance |
| | | { |
| | | get |
| | |
| | | /// <summary> |
| | | /// 账户登录成功时的时间 |
| | | /// </summary> |
| | | public DateTime LoginDateTime = DateTime.MinValue; |
| | | public DateTime LoginDateTime = DateTime.MinValue;
|
| | | /// <summary> |
| | | /// Gets a value indicating whether this <see cref="T:Shared.Common.Config"/> is login. |
| | | /// |
| | | /// </summary> |
| | | /// <value><c>true</c> if is login; otherwise, <c>false</c>.</value> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public bool IsLogin |
| | | { |
| | | get |
| | |
| | | return (DateTime.Now - LoginDateTime).Days < 7; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 账户登录成功的账户类型 |
| | | /// </summary> |
| | | public int AccountType = 0; |
| | | /// <summary> |
| | | /// 账户登录成功的主ID |
| | | /// </summary> |
| | | public int MasterID = 0; |
| | | |
| | | |
| | | public static void ReFresh() |
| | | { |
| | |
| | | //解密
|
| | | config.Password = Phone.UserCenter.UserCenterLogic.DecryptPassword("hD1(La3o", config.PasswordEncrypt);
|
| | | } |
| | | if (config.Md5pwdEncrypt != string.Empty) |
| | | { |
| | | //解密 |
| | | config.MD5PWD = Phone.UserCenter.UserCenterLogic.DecryptPassword("hD1(La3o", config.Md5pwdEncrypt); |
| | | } |
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 账户登录成功的账户类型(此变量默认为0,并且不赋值) |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int AccountType = 0;
|
| | | /// <summary> |
| | | /// 当前登录的帐号 |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 短信登录返回的md5后的密码 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string MD5PWD = string.Empty; |
| | | /// <summary> |
| | | /// 短信登录返回的md5后的加密密码 |
| | | /// </summary> |
| | | public string Md5pwdEncrypt = string.Empty; |
| | | /// <summary> |
| | | /// 登陆账号的Guid |
| | | /// </summary> |
| | |
| | | /// <summary>
|
| | | /// 成员请求控制主帐号此住宅时请求基地址
|
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string AdminRequestBaseUrl = string.Empty;
|
| | | /// <summary>
|
| | | /// 成员请求控制主帐号此住宅时请求基地址的LoginAccessToken的值
|
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string AdminRequestToken = string.Empty; |
| | | /// <summary>
|
| | | /// 远程连接的Mqtt的客户端ID
|
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string ConnEmqClientId = string.Empty; |
| | | |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string ConnEmqClientId = string.Empty;
|
| | | /// <summary>
|
| | | /// 当前登录的账号是不是之前的账号
|
| | | /// </summary>
|
| | | [Newtonsoft.Json.JsonIgnore]
|
| | | public bool TheSameLoginAccount = false;
|
| | |
|
| | | /// <summary> |
| | | /// 当前帐号的Token |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string Token |
| | | { |
| | | get |
| | | { |
| | | if (Shared.Phone.UserCenter.HdlExperienceAccountLogic.Current.IsExperience == true)
|
| | | {
|
| | | //体验账号的Token
|
| | | return this.TokenExperience;
|
| | | } |
| | | string md5Password; |
| | | if (string.IsNullOrEmpty(Password)) |
| | | { |
| | |
| | | return Convert.ToBase64String(tokenBytes).Replace("=", "%3D"); |
| | | } |
| | | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 体验账号的Token
|
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | private string m_TokenExperience = null;
|
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string TokenExperience
|
| | | {
|
| | | get
|
| | | {
|
| | | if (m_TokenExperience != null) { return m_TokenExperience; }
|
| | |
|
| | | var result = System.Text.Encoding.UTF8.GetBytes("123456");
|
| | | var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
| | | var output = md5.ComputeHash(result);
|
| | | var md5Password = BitConverter.ToString(output).Replace("-", "");
|
| | | var account_md5Pssword = "ceyir277@163.com:" + md5Password; |
| | | var tokenBytes = System.Text.Encoding.UTF8.GetBytes(account_md5Pssword); |
| | | m_TokenExperience = Convert.ToBase64String(tokenBytes).Replace("=", "%3D");
|
| | | return m_TokenExperience;
|
| | | }
|
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 登录时Token |
| | | /// 登录时Token(目前这东西没用) |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string LoginToken = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 登录过的帐号信息 |
| | | /// </summary> |
| | | public List<string> AccountList = new List<string> { }; |
| | | |
| | | public List<string> HomeFilePathList = new List<string> { }; |
| | | |
| | | public string HomeId = string.Empty;
|
| | |
|
| | | /// <summary>
|
| | | /// 住宅文件列表
|
| | | /// </summary>
|
| | | public List<string> HomeFilePathList = new List<string>();
|
| | |
|
| | | [Newtonsoft.Json.JsonIgnore] |
| | | private House m_Home = null; |
| | |
| | | {
|
| | | return m_Home;
|
| | | } |
| | | m_Home = House.GetHouseByHouseId(HomeId); |
| | | m_Home = Phone.UserCenter.HdlResidenceLogic.Current.GetHouseByHouseId(HomeId); |
| | | if (m_Home == null) |
| | | { |
| | | m_Home = new House(); |
| | |
| | | { |
| | | //加密,不能保存明码 |
| | | this.PasswordEncrypt = Phone.UserCenter.UserCenterLogic.EncryptPassword("hD1(La3o", this.Password); |
| | | this.Md5pwdEncrypt = Phone.UserCenter.UserCenterLogic.EncryptPassword("hD1(La3o", this.MD5PWD); |
| | | |
| | | var bytes = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); |
| | | Shared.IO.FileUtils.WriteFileByBytes(fileName, bytes); |
| | | ReFresh(); |
| | | } |
| | | } |
| | | } |