From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3
---
ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs | 237 ++++++++++++++++++++++++++++++----------------------------
1 files changed, 123 insertions(+), 114 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs b/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs
index 7c83759..310e1f3 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs
@@ -5,140 +5,99 @@
{
[System.Serializable]
public class Config
- {
- static readonly string fileName = "Config.json";
- static Config config;
- public static Config Instance
- {
- get
- {
- if (config == null)
- {
- ReFresh();
- }
- return config;
- }
- }
+ {
+ #region 鈻� 闇�瑕佷繚瀛樼殑鍙橀噺_____________________
- /// <summary>
- /// 鏈嶅姟鍣ㄦ敞鍐孖D
+ /// <summary>
+ /// 褰撳墠璐﹀彿锛氬埛鏂癟oken鐢ㄧ殑token(涓嶇敤璁板綍浠�涔堟湁鏁堟湡,濡傛灉鍒锋柊澶辫触,灏辫涪浜哄嵆鍙�)
/// </summary>
- public string RegistrationID = string.Empty;
-
+ public string RefreshToken = string.Empty;
+ /// <summary>
+ /// 灏嗘瀬鍏塈D鍙戠粰浜戠涔嬪悗,浜戠杩斿洖鐨凾oken
+ /// </summary>
+ public string PushId = string.Empty;
/// <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>
- public bool IsLogin
+ public string Account = string.Empty;
+ /// <summary>
+ /// 娣诲姞鍒癟oken澶撮儴鐨勪笢瑗�(涓嶈鐞嗗畠,鍙粰搴曞眰浣跨敤)
+ /// </summary>
+ public string HeaderPrefix = string.Empty;
+ /// <summary>
+ /// 鐧婚檰璐﹀彿鐨凣uid,涔熸槸璐﹀彿鐨剈serId
+ /// </summary>
+ public string Guid = string.Empty;
+ /// <summary>
+ /// 褰撳墠鐨勪綇瀹匢D
+ /// </summary>
+ public string HomeId = string.Empty;
+ /// <summary>
+ /// 浣忓畢鏂囦欢鍒楄〃
+ /// </summary>
+ public List<string> HomeFilePathList = new List<string>();
+
+ #endregion
+
+ #region 鈻� 缂撳瓨鍙橀噺___________________________
+
+ /// <summary>
+ /// 鏈嶅姟鍣ㄦ敞鍐孖D(鍙互璇存槸鏋佸厜ID)
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public string RegistrationID = string.Empty;
+ /// <summary>
+ /// 鍒ゆ柇褰撳墠鏃堕棿鐐规槸鍚﹁兘澶熻嚜鍔ㄧ櫥褰�
+ /// </summary>
+ public bool CanAutoLogin
{
get
{
return (DateTime.Now - LoginDateTime).Days < 7;
}
- }
-
- /// <summary>
- /// 璐︽埛鐧诲綍鎴愬姛鐨勮处鎴风被鍨�
- /// </summary>
- public int AccountType = 0;
- /// <summary>
- /// 璐︽埛鐧诲綍鎴愬姛鐨勪富ID
- /// </summary>
- public int MasterID = 0;
-
-
- public static void ReFresh()
- {
- var file = Shared.IO.FileUtils.ReadFile(fileName);
- config = Newtonsoft.Json.JsonConvert.DeserializeObject<Config>(System.Text.Encoding.UTF8.GetString(file));
-
- if (config == null)
- {
- config = new Config { };
- }
- if (config.PasswordEncrypt != string.Empty)
- {
- //瑙e瘑
- config.Password = Phone.UserCenter.UserCenterLogic.DecryptPassword("hD1(La3o", config.PasswordEncrypt);
- }
}
-
/// <summary>
- /// 褰撳墠鐧诲綍鐨勫笎鍙�
- /// </summary>
- public string Account = string.Empty;
- /// <summary>
- /// 褰撳墠甯愬彿瀵嗙爜
+ /// 鏄惁鍚屾剰闅愮鏀跨瓥
/// </summary>
[Newtonsoft.Json.JsonIgnore]
- public string Password = string.Empty;
- /// <summary>
- /// 鍔犲瘑瀵嗙爜
- /// </summary>
- public string PasswordEncrypt = string.Empty;
+ public bool AcceiptPolicy = false;
/// <summary>
- /// 鐭俊鐧诲綍杩斿洖鐨刴d5鍚庣殑瀵嗙爜
+ /// 褰撳墠甯愬彿鐨凾oken(杩欎釜涓滆タ涓嶇敤瀛樹簡)
/// </summary>
- public string MD5PWD = string.Empty;
+ [Newtonsoft.Json.JsonIgnore]
+ public string Token = string.Empty;
/// <summary>
- /// 鐧婚檰璐﹀彿鐨凣uid
+ /// 绠$悊鍛樿幏鍙栧埌鐨勪富浜虹殑Token(杩欎釜涓滆タ涓嶇敤瀛樹簡)
/// </summary>
- public string Guid = string.Empty;
- /// <summary>
- /// 鎴愬憳璇锋眰鎺у埗涓诲笎鍙锋浣忓畢鏃惰姹傚熀鍦板潃
- /// </summary>
- public string AdminRequestBaseUrl = string.Empty;
- /// <summary>
- /// 鎴愬憳璇锋眰鎺у埗涓诲笎鍙锋浣忓畢鏃惰姹傚熀鍦板潃鐨凩oginAccessToken鐨勫��
- /// </summary>
- public string AdminRequestToken = string.Empty;
+ [Newtonsoft.Json.JsonIgnore]
+ public string MasterToken = string.Empty;
/// <summary>
/// 杩滅▼杩炴帴鐨凪qtt鐨勫鎴风ID
/// </summary>
[Newtonsoft.Json.JsonIgnore]
- public string ConnEmqClientId = string.Empty;
-
- [Newtonsoft.Json.JsonIgnore]
- /// <summary>
- /// 褰撳墠甯愬彿鐨凾oken
- /// </summary>
- public string Token
- {
- get
- {
- string md5Password;
- if (string.IsNullOrEmpty(Password))
- {
- //鐢ㄤ簬鐭俊鐧诲綍瀵嗙爜涓�
- md5Password = MD5PWD;
- }
- else
- {
- var result = System.Text.Encoding.UTF8.GetBytes(Password);
- var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
- var output = md5.ComputeHash(result);
- md5Password = BitConverter.ToString(output).Replace("-", "");
- }
- var account_md5Pssword = Account + ":" + md5Password;
- var tokenBytes = System.Text.Encoding.UTF8.GetBytes(account_md5Pssword);
- return Convert.ToBase64String(tokenBytes).Replace("=", "%3D");
- }
-
- }
-
+ public string ConnEmqClientId = string.Empty;
/// <summary>
- /// 鐧诲綍鏃禩oken
+ /// 褰撳墠鐧诲綍鐨勮处鍙锋槸涓嶆槸涔嬪墠鐨勮处鍙�
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public bool TheSameLoginAccount = false;
+ /// <summary>
+ /// 瀹夊崜鐨勭郴缁熻繑鍥炴寜閿兘鍚︽寜涓�(姣斿鍦ㄥ浠借繕鍘熸椂,涓嶈兘鎸変笅杩斿洖閿�)
/// </summary>
- public string LoginToken = string.Empty;
-
- public List<string> HomeFilePathList = new List<string> { };
-
- public string HomeId = string.Empty;
-
+ [Newtonsoft.Json.JsonIgnore]
+ public bool BackKeyCanClick = true;
+ /// <summary>
+ /// 璁块棶浜戠鐨勮瑷�(鏈変簺鎺ュ彛闇�瑕�,鐩墠鏄� CHINESE 鎴栬�� ENGLISH)
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public string HttpLanguage = "CHINESE";
+ /// <summary>
+ /// 褰撳墠浣忓畢
+ /// </summary>
[Newtonsoft.Json.JsonIgnore]
private House m_Home = null;
/// <summary>
@@ -154,7 +113,7 @@
{
return m_Home;
}
- m_Home = House.GetHouseByHouseId(HomeId);
+ m_Home = Phone.HdlResidenceLogic.Current.GetHouseByHouseId(HomeId);
if (m_Home == null)
{
m_Home = new House();
@@ -166,7 +125,6 @@
m_Home = value;
}
}
-
/// <summary>
/// 鍏ㄨ矾寰�
/// <para> 浣跨敤鏂规硶锛� FullPath + FileName </para>
@@ -179,18 +137,69 @@
{
return System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Instance.Guid, Instance.HomeId);
}
- }
+ }
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// Config鏂囦欢鍚�
+ /// </summary>
+ private const string fileName = "Config.json";
+ private static Config config = null;
+ /// <summary>
+ /// Config瀵硅薄
+ /// </summary>
+ public static Config Instance
+ {
+ get
+ {
+ if (config == null)
+ {
+ ReFresh();
+ }
+ return config;
+ }
+ }
+
+ /// <summary>
+ /// 鍒锋柊
+ /// </summary>
+ private static void ReFresh()
+ {
+ var file = Shared.IO.FileUtils.ReadFile(fileName);
+ if (file != null && file.Length > 0)
+ {
+ config = Newtonsoft.Json.JsonConvert.DeserializeObject<Config>(System.Text.Encoding.UTF8.GetString(file));
+ //瑙e瘑
+ config.RefreshToken = Phone.HdlCommonLogic.Current.DecryptPassword("hD1(La3o", config.RefreshToken);
+ }
+ else
+ {
+ config = new Config();
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 淇濆瓨_______________________________
+
/// <summary>
/// 淇濆瓨褰撳墠瀵硅薄
/// </summary>
public void Save()
{
//鍔犲瘑,涓嶈兘淇濆瓨鏄庣爜
- this.PasswordEncrypt = Phone.UserCenter.UserCenterLogic.EncryptPassword("hD1(La3o", this.Password);
+ var oldToken1 = this.RefreshToken;
+ this.RefreshToken = Phone.HdlCommonLogic.Current.EncryptPassword("hD1(La3o", oldToken1);
+
var bytes = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
Shared.IO.FileUtils.WriteFileByBytes(fileName, bytes);
- ReFresh();
- }
+
+ this.RefreshToken = oldToken1;
+ }
+
+ #endregion
}
}
--
Gitblit v1.8.0