From 0d9f64668fd7350d6a21fd157e32009a96d98134 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期三, 16 十二月 2020 13:09:08 +0800 Subject: [PATCH] 新云端代码Ver1.2 --- ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs | 257 ++++++++++++++++++++++----------------------------- 1 files changed, 110 insertions(+), 147 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs b/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs index d068161..310e1f3 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs @@ -5,105 +5,76 @@ { [System.Serializable] public class Config - { - private const string fileName = "Config.json"; - - private static Config config = null; - 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; /// <summary> - /// + /// 褰撳墠鐧诲綍鐨勫笎鍙� + /// </summary> + 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 bool IsLogin + public string RegistrationID = string.Empty; + /// <summary> + /// 鍒ゆ柇褰撳墠鏃堕棿鐐规槸鍚﹁兘澶熻嚜鍔ㄧ櫥褰� + /// </summary> + public bool CanAutoLogin { 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 int AccountType = 0; + public bool AcceiptPolicy = false; /// <summary> - /// 褰撳墠鐧诲綍鐨勫笎鍙� - /// </summary> - public string Account = string.Empty; - /// <summary> - /// 褰撳墠甯愬彿瀵嗙爜 + /// 褰撳墠甯愬彿鐨凾oken(杩欎釜涓滆タ涓嶇敤瀛樹簡) /// </summary> [Newtonsoft.Json.JsonIgnore] - public string Password = string.Empty; - /// <summary> - /// 鍔犲瘑瀵嗙爜 - /// </summary> - public string PasswordEncrypt = string.Empty; + public string Token = string.Empty; /// <summary> - /// 鐭俊鐧诲綍杩斿洖鐨刴d5鍚庣殑瀵嗙爜 + /// 绠$悊鍛樿幏鍙栧埌鐨勪富浜虹殑Token(杩欎釜涓滆タ涓嶇敤瀛樹簡) /// </summary> [Newtonsoft.Json.JsonIgnore] - 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; + public string MasterToken = string.Empty; /// <summary> /// 杩滅▼杩炴帴鐨凪qtt鐨勫鎴风ID /// </summary> @@ -114,76 +85,19 @@ /// </summary> [Newtonsoft.Json.JsonIgnore] public bool TheSameLoginAccount = false; - - /// <summary> - /// 褰撳墠甯愬彿鐨凾oken + /// <summary> + /// 瀹夊崜鐨勭郴缁熻繑鍥炴寜閿兘鍚︽寜涓�(姣斿鍦ㄥ浠借繕鍘熸椂,涓嶈兘鎸変笅杩斿洖閿�) /// </summary> [Newtonsoft.Json.JsonIgnore] - 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"); - } - - } - + public bool BackKeyCanClick = true; /// <summary> - /// 浣撻獙璐﹀彿鐨凾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> - /// 浣忓畢鏂囦欢鍒楄〃 + /// 璁块棶浜戠鐨勮瑷�(鏈変簺鎺ュ彛闇�瑕�,鐩墠鏄� CHINESE 鎴栬�� ENGLISH) /// </summary> - public List<string> HomeFilePathList = new List<string>(); - + [Newtonsoft.Json.JsonIgnore] + public string HttpLanguage = "CHINESE"; + /// <summary> + /// 褰撳墠浣忓畢 + /// </summary> [Newtonsoft.Json.JsonIgnore] private House m_Home = null; /// <summary> @@ -199,7 +113,7 @@ { return m_Home; } - m_Home = Phone.UserCenter.HdlResidenceLogic.Current.GetHouseByHouseId(HomeId); + m_Home = Phone.HdlResidenceLogic.Current.GetHouseByHouseId(HomeId); if (m_Home == null) { m_Home = new House(); @@ -211,7 +125,6 @@ m_Home = value; } } - /// <summary> /// 鍏ㄨ矾寰� /// <para> 浣跨敤鏂规硶锛� FullPath + FileName </para> @@ -224,19 +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); - this.Md5pwdEncrypt = Phone.UserCenter.UserCenterLogic.EncryptPassword("hD1(La3o", this.MD5PWD); + 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); - } + + this.RefreshToken = oldToken1; + } + + #endregion } } -- Gitblit v1.8.0