From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码
---
ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs | 255 +++++++++++++++++++++++++++++---------------------
1 files changed, 146 insertions(+), 109 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs b/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs
index 62a3c5b..d068161 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs
@@ -5,76 +5,105 @@
{
[System.Serializable]
public class Config
- {
- #region 鈻� 闇�瑕佷繚瀛樼殑鍙橀噺_____________________
+ {
+ private const string fileName = "Config.json";
+
+ private static Config config = null;
+ public static Config Instance
+ {
+ get
+ {
+ if (config == null)
+ {
+ ReFresh();
+ }
+ return config;
+ }
+ }
- /// <summary>
- /// 褰撳墠璐﹀彿锛氬埛鏂癟oken鐢ㄧ殑token(涓嶇敤璁板綍浠�涔堟湁鏁堟湡,濡傛灉鍒锋柊澶辫触,灏辫涪浜哄嵆鍙�)
+ /// <summary>
+ /// 鏈嶅姟鍣ㄦ敞鍐孖D
/// </summary>
- public string RefreshToken = string.Empty;
- /// <summary>
- /// 灏嗘瀬鍏塈D鍙戠粰浜戠涔嬪悗,浜戠杩斿洖鐨凾oken
- /// </summary>
- public string PushId = string.Empty;
+ public string RegistrationID = string.Empty;
+
/// <summary>
/// 璐︽埛鐧诲綍鎴愬姛鏃剁殑鏃堕棿
/// </summary>
public DateTime LoginDateTime = DateTime.MinValue;
/// <summary>
- /// 褰撳墠鐧诲綍鐨勫笎鍙�
- /// </summary>
- public string Account = string.Empty;
- /// <summary>
- /// 娣诲姞鍒癟oken澶撮儴鐨勪笢瑗�(涓嶈鐞嗗畠,鍙粰搴曞眰浣跨敤)
- /// </summary>
- public string HeaderPrefix = string.Empty;
- /// <summary>
- /// 鐧婚檰璐﹀彿鐨凣uid
- /// </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
+ public bool IsLogin
{
get
{
return (DateTime.Now - LoginDateTime).Days < 7;
}
+ }
+
+ 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);
+ }
+ if (config.Md5pwdEncrypt != string.Empty)
+ {
+ //瑙e瘑
+ config.MD5PWD = Phone.UserCenter.UserCenterLogic.DecryptPassword("hD1(La3o", config.Md5pwdEncrypt);
+ }
}
+
/// <summary>
- /// 鏄惁鍚屾剰闅愮鏀跨瓥
+ /// 璐︽埛鐧诲綍鎴愬姛鐨勮处鎴风被鍨�(姝ゅ彉閲忛粯璁や负0,骞朵笖涓嶈祴鍊�)
/// </summary>
[Newtonsoft.Json.JsonIgnore]
- public bool AcceiptPolicy = false;
+ public int AccountType = 0;
/// <summary>
- /// 褰撳墠甯愬彿鐨凾oken(杩欎釜涓滆タ涓嶇敤瀛樹簡)
+ /// 褰撳墠鐧诲綍鐨勫笎鍙�
+ /// </summary>
+ public string Account = string.Empty;
+ /// <summary>
+ /// 褰撳墠甯愬彿瀵嗙爜
/// </summary>
[Newtonsoft.Json.JsonIgnore]
- public string Token = string.Empty;
+ public string Password = string.Empty;
+ /// <summary>
+ /// 鍔犲瘑瀵嗙爜
+ /// </summary>
+ public string PasswordEncrypt = string.Empty;
/// <summary>
- /// 绠$悊鍛樿幏鍙栧埌鐨勪富浜虹殑Token(杩欎釜涓滆タ涓嶇敤瀛樹簡)
+ /// 鐭俊鐧诲綍杩斿洖鐨刴d5鍚庣殑瀵嗙爜
/// </summary>
[Newtonsoft.Json.JsonIgnore]
- public string MasterToken = string.Empty;
+ public string MD5PWD = string.Empty;
+ /// <summary>
+ /// 鐭俊鐧诲綍杩斿洖鐨刴d5鍚庣殑鍔犲瘑瀵嗙爜
+ /// </summary>
+ public string Md5pwdEncrypt = string.Empty;
+ /// <summary>
+ /// 鐧婚檰璐﹀彿鐨凣uid
+ /// </summary>
+ public string Guid = string.Empty;
+ /// <summary>
+ /// 鎴愬憳璇锋眰鎺у埗涓诲笎鍙锋浣忓畢鏃惰姹傚熀鍦板潃
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public string AdminRequestBaseUrl = string.Empty;
+ /// <summary>
+ /// 鎴愬憳璇锋眰鎺у埗涓诲笎鍙锋浣忓畢鏃惰姹傚熀鍦板潃鐨凩oginAccessToken鐨勫��
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public string AdminRequestToken = string.Empty;
/// <summary>
/// 杩滅▼杩炴帴鐨凪qtt鐨勫鎴风ID
/// </summary>
@@ -85,19 +114,76 @@
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool TheSameLoginAccount = false;
- /// <summary>
- /// 瀹夊崜鐨勭郴缁熻繑鍥炴寜閿兘鍚︽寜涓�(姣斿鍦ㄥ浠借繕鍘熸椂,涓嶈兘鎸変笅杩斿洖閿�)
+
+ /// <summary>
+ /// 褰撳墠甯愬彿鐨凾oken
/// </summary>
[Newtonsoft.Json.JsonIgnore]
- public bool BackKeyCanClick = true;
+ public string Token
+ {
+ get
+ {
+ if (Shared.Phone.UserCenter.HdlExperienceAccountLogic.Current.IsExperience == true)
+ {
+ //浣撻獙璐﹀彿鐨凾oken
+ return this.TokenExperience;
+ }
+ 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");
+ }
+
+ }
+
/// <summary>
- /// 璁块棶浜戠鐨勮瑷�(鏈変簺鎺ュ彛闇�瑕�,鐩墠鏄� CHINESE 鎴栬�� ENGLISH)
- /// </summary>
- [Newtonsoft.Json.JsonIgnore]
- public string HttpLanguage = "CHINESE";
+ /// 浣撻獙璐﹀彿鐨凾oken
+ /// </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>
- /// 褰撳墠浣忓畢
+ /// 鐧诲綍鏃禩oken(鐩墠杩欎笢瑗挎病鐢�)
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public string LoginToken = string.Empty;
+
+ public string HomeId = string.Empty;
+
+ /// <summary>
+ /// 浣忓畢鏂囦欢鍒楄〃
/// </summary>
+ public List<string> HomeFilePathList = new List<string>();
+
[Newtonsoft.Json.JsonIgnore]
private House m_Home = null;
/// <summary>
@@ -113,7 +199,7 @@
{
return m_Home;
}
- m_Home = Phone.HdlResidenceLogic.Current.GetHouseByHouseId(HomeId);
+ m_Home = Phone.UserCenter.HdlResidenceLogic.Current.GetHouseByHouseId(HomeId);
if (m_Home == null)
{
m_Home = new House();
@@ -125,6 +211,7 @@
m_Home = value;
}
}
+
/// <summary>
/// 鍏ㄨ矾寰�
/// <para> 浣跨敤鏂规硶锛� FullPath + FileName </para>
@@ -137,69 +224,19 @@
{
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()
{
//鍔犲瘑,涓嶈兘淇濆瓨鏄庣爜
- var oldToken1 = this.RefreshToken;
- this.RefreshToken = Phone.HdlCommonLogic.Current.EncryptPassword("hD1(La3o", oldToken1);
+ 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);
-
- this.RefreshToken = oldToken1;
- }
-
- #endregion
+ }
}
}
--
Gitblit v1.8.0