From f1c3921b08bb22ac6f5db22d620e01d7e8e5c49f Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期一, 30 十二月 2019 13:32:33 +0800 Subject: [PATCH] 2019-12-30-1 --- ZigbeeApp/Shared/Common/CommonPage.cs | 135 +++++++++++++++++++++++++++++++-------------- 1 files changed, 93 insertions(+), 42 deletions(-) diff --git a/ZigbeeApp/Shared/Common/CommonPage.cs b/ZigbeeApp/Shared/Common/CommonPage.cs index 06afe41..e64b370 100644 --- a/ZigbeeApp/Shared/Common/CommonPage.cs +++ b/ZigbeeApp/Shared/Common/CommonPage.cs @@ -7,7 +7,7 @@ using Shared.Phone.UserCenter.Abount; namespace Shared.Common { - public class CommonPage : FrameLayout + public class CommonPage : UIDrawerLayout { static CommonPage commonPage; public static CommonPage Instance @@ -43,6 +43,11 @@ Application.MainPage.AddChidren(Loading); //} Phone.UserView.HomePage.Instance.InitPage(); + + var roomList = new Shared.Phone.Device.Room.RoomManagement(); + + Instance.AddLeftView(roomList); + roomList.Show(); } public static string SoftTitle = "ZigBee"; @@ -53,11 +58,11 @@ public static string LogoString = @"Logo/Logo.png"; public static string RegisterLogoString = @"Logo/Register_logo.png"; public static string RequestHttpsHost = "https://global.hdlcontrol.com/HangZhouHdlCloudApi"; - //public static string RequestHttpsHost = "http://172.16.2.225:13061"; + //public static string RequestHttpsHost = "http://172.16.2.192:13061"; /// <summary> /// 鐗堟湰鍙� /// </summary> - public static string CodeIDString = "1.0.19071001"; + public static string CodeIDString = "1.0.19112901"; /// <summary> /// 娉ㄥ唽鏉ユ簮(0:HDL On 1:Zigbee) /// </summary> @@ -74,11 +79,11 @@ /// <summary> /// 璇锋眰鐗堟湰鍙� /// </summary> - public static string RequestVersion = "1.0"; + public static string RequestVersion = "2.0"; /// <summary> - /// 宸﹁竟璺濈灞忓箷鐨勫搴�--50 + /// 宸﹁竟璺濈灞忓箷鐨勫搴�--58 /// </summary> - public static int XLeft = 50; + public static int XLeft = 58; /// <summary> /// button楂樺害--110 /// </summary> @@ -130,9 +135,9 @@ /// </summary> public static int Navigation_Height = 220; /// <summary> - /// 搴曡竟鏍忛珮搴� 160 + /// 搴曡竟鏍忛珮搴� /// </summary> - public static int TabbarHeight = 160; + public const int TabbarHeight = 141; /// <summary> /// 绾挎潯鐨勯珮搴�--瀹為檯鍍忕礌3 /// </summary> @@ -177,8 +182,15 @@ /// 褰撳墠缃戠粶杩炴帴鐨勬ā寮� 0:娌℃湁缃戠粶 1锛氳繙绋嬭繛鎺ワ紝涔熷彨3G,4G 2锛歐IFI /// </summary> public static int nowNetworkMode = 0; - - + /// <summary> + /// 鍗犱綅瀛椾綋澶у皬 + /// 11 + /// </summary> + public static int PlaceHolderTextSize = 11; + /// <summary> + /// 瀹夊崜鐨勭郴缁熻繑鍥炴寜閿兘鍚︽寜涓�(姣斿鍦ㄥ浠借繕鍘熸椂,涓嶈兘鎸変笅杩斿洖閿�) + /// </summary> + public static bool BackKeyCanClick = true; /// <summary> /// 璇锋眰鏈嶅姟鍣ㄦ柟娉� @@ -215,9 +227,9 @@ public async System.Threading.Tasks.Task<string> RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData) { var result = await RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData); - if (result != null) - { - return Encoding.UTF8.GetString(result); + if (result != null) + { + return Encoding.UTF8.GetString(result); } return null; } @@ -228,39 +240,77 @@ /// </summary> /// <param name="requestUrl">璇锋眰Url</param> /// <param name="byteData">璇锋眰鐨勭殑鏁版嵁</param> + /// <param name="requestMethod">POST 鎴栬�� GET 绛夌瓑</param> /// <returns>寰楀埌鍝嶅簲鐨勬暟鎹�</returns> - public async System.Threading.Tasks.Task<byte[]> RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData) + public async System.Threading.Tasks.Task<byte[]> RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST") { + //璇锋眰Url鐨勫畬鎴愯矾寰� + var fullUrl = $"{RequestHttpsHost}/{requestUrl}"; + return await this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.Token, requestMethod); + } + + /// <summary> + /// <pra>璇锋眰鏈嶅姟鍣ㄦ柟娉�,鎸囧畾涓�涓猆rl,鍜岃姹傛柟娉曪紝鏁版嵁锛孋ookie锛屽緱鍒板搷搴旂殑鏁版嵁</pra> + /// <pra>娉ㄦ剰!!姝ゆ柟娉曚粎闄愩�愭嫢鏈夌鐞嗗憳鏉冮檺鐨勬垚鍛樸�戣皟鐢�</pra> + /// </summary> + /// <param name="requestUrl">璇锋眰Url</param> + /// <param name="byteData">璇锋眰鐨勭殑鏁版嵁</param> + /// <param name="requestMethod">POST 鎴栬�� GET 绛夌瓑</param> + /// <returns>寰楀埌鍝嶅簲鐨勬暟鎹�</returns> + public async System.Threading.Tasks.Task<byte[]> RequestZigbeeHttpsByAdmin(string requestUrl, byte[] byteData, string requestMethod = "POST") + { + //璇锋眰Url鐨勫畬鎴愯矾寰� + var fullUrl = $"{Config.Instance.AdminRequestBaseUrl}/{requestUrl}"; + return await this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.AdminRequestToken, requestMethod); + } + + /// <summary> + /// 璇锋眰鏈嶅姟鍣ㄦ柟娉� + /// 鎸囧畾涓�涓猆rl,鍜岃姹傛柟娉曪紝鏁版嵁锛孋ookie锛屽緱鍒板搷搴旂殑鏁版嵁 + /// </summary> + /// <param name="requestFullUrl">璇锋眰Url鐨勫畬鎴愯矾寰�</param> + /// <param name="byteData">璇锋眰鐨勭殑鏁版嵁</param> + /// <param name="token">token</param> + /// <param name="requestMethod">POST 鎴栬�� GET 绛夌瓑</param> + /// <returns>寰楀埌鍝嶅簲鐨勬暟鎹�</returns> + public async System.Threading.Tasks.Task<byte[]> DoRequestZigbeeHttpsInterface(string requestFullUrl, byte[] byteData, string token, string requestMethod = "POST") + { try { //鍒濆鍖栨柊鐨剋ebRequst //1锛� 鍒涘缓httpWebRequest瀵硅薄 - HttpWebRequest webRequest = null; - if (Config.Instance.isAdministrator == true) - { - webRequest = (HttpWebRequest)WebRequest.Create(new Uri($"{Config.Instance.AdminRequestBaseUrl}/{requestUrl}")); - } - else - { - webRequest = (HttpWebRequest)WebRequest.Create(new Uri($"{RequestHttpsHost}/{requestUrl}")); - } + HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(requestFullUrl)); + //2锛� 鍒濆鍖朒ttpWebRequest瀵硅薄 - webRequest.Method = "POST"; - webRequest.ContentType = "application/json"; - webRequest.Timeout = 10*1000; - webRequest.ContentLength = byteData.Length; - webRequest.Timeout = 10*1000; - webRequest.Headers.Add(HttpRequestHeader.Authorization, Config.Instance.Token); - //3锛� 闄勫姞瑕丳OST缁欐湇鍔″櫒鐨勬暟鎹埌HttpWebRequest瀵硅薄(闄勫姞POST鏁版嵁鐨勮繃绋嬫瘮杈冪壒娈婏紝瀹冨苟娌℃湁鎻愪緵涓�涓睘鎬х粰鐢ㄦ埛瀛樺彇锛岄渶瑕佸啓鍏ttpWebRequest瀵硅薄鎻愪緵鐨勪竴涓猻tream閲岄潰銆�) - var newStream = webRequest.GetRequestStream();//鍒涘缓涓�涓猄tream,璧嬪�兼槸鍐欏叆HttpWebRequest瀵硅薄鎻愪緵鐨勪竴涓猻tream閲岄潰 - newStream.Write(byteData, 0, byteData.Length); - newStream.Flush(); - newStream.Close(); + webRequest.Method = requestMethod; + webRequest.Timeout = 10 * 1000; + if (token != null) + { + //瀵瑰簲寰俊缃戝潃 + webRequest.Headers.Add(HttpRequestHeader.Authorization, token); + } + if (requestMethod == "GET") + { + //webRequest.ContentType = "text/html"; + webRequest.ContentType = "application/json"; + } + else + { + webRequest.ContentType = "application/json"; + webRequest.ContentLength = byteData.Length; + + //3锛� 闄勫姞瑕丳OST缁欐湇鍔″櫒鐨勬暟鎹埌HttpWebRequest瀵硅薄(闄勫姞POST鏁版嵁鐨勮繃绋嬫瘮杈冪壒娈婏紝瀹冨苟娌℃湁鎻愪緵涓�涓睘鎬х粰鐢ㄦ埛瀛樺彇锛岄渶瑕佸啓鍏ttpWebRequest瀵硅薄鎻愪緵鐨勪竴涓猻tream閲岄潰銆�) + var newStream = webRequest.GetRequestStream();//鍒涘缓涓�涓猄tream,璧嬪�兼槸鍐欏叆HttpWebRequest瀵硅薄鎻愪緵鐨勪竴涓猻tream閲岄潰 + newStream.Write(byteData, 0, byteData.Length); + newStream.Flush(); + newStream.Close(); + } + //4锛� 璇诲彇鏈嶅姟鍣ㄧ殑杩斿洖淇℃伅 var response = (HttpWebResponse)webRequest.GetResponse(); using (var stream = response.GetResponseStream()) { - if(stream==null) + if (stream == null) { return null; } @@ -276,13 +326,13 @@ } } catch (Exception e) - { - System.Console.WriteLine(e.Message); + { +#if DEBUG + System.Console.WriteLine(e.Message); +#endif return null; } } - - #if iOS /// <summary> /// 鑾峰彇iOS-APP鐗堟湰淇℃伅 @@ -346,13 +396,14 @@ return null; } int MaxIndex = 0; - int NewID = 0; + int NewVersion = 0; for (int i = 0; i < responeData.pageData.Count; i++) { var apkInfo = responeData.pageData[i]; - if (int.Parse(apkInfo.Id) > NewID) + var version = int.Parse(apkInfo.FirmwareVersion.Replace(".", "")); + if (version > NewVersion) { - NewID = int.Parse(apkInfo.Id); + NewVersion = version; MaxIndex = i; } } -- Gitblit v1.8.0