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/Common/CommonPage.cs | 187 ++++++++++++++++++---------------------------- 1 files changed, 74 insertions(+), 113 deletions(-) diff --git a/ZigbeeApp/Shared/Common/CommonPage.cs b/ZigbeeApp/Shared/Common/CommonPage.cs old mode 100755 new mode 100644 index edbd684..6211aa3 --- a/ZigbeeApp/Shared/Common/CommonPage.cs +++ b/ZigbeeApp/Shared/Common/CommonPage.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Net; using System.Text; -using Shared.Phone.UserCenter.Abount; + namespace Shared.Common { public class CommonPage : UIDrawerLayout @@ -28,41 +28,29 @@ public static Loading Loading = new Loading(); public void Show() { - //if (Application.IsPad) - //{ - // Application.DesignWidth = 2048; - // Application.DesignHeight = 1536; - // Pad.MainPage.Instance .Show(); - // } - //else - //{ Application.DesignWidth = 1080; Application.DesignHeight = 1920; Application.MainPage.AddChidren(this); AddChidren(Phone.UserView.HomePage.Instance); Application.MainPage.AddChidren(Loading); - //} - Phone.UserView.HomePage.Instance.InitPage(); + + Phone.UserView.HomePage.Instance.InitPage(); + + //璁剧疆椤堕儴鐘舵�佹爮鏂囧瓧涓洪粦鑹� + Application.SetStatusBarTextBlack(true); } - public static string SoftTitle = "ZigBee"; - /// <summary> - /// 鐭俊妯℃澘缂栧彿 - /// </summary> - public static int SoftSmsType = 0; - 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 = "https://global.hdlcontrol.com/ProposedProductionApi"; /// <summary> /// 鐗堟湰鍙� /// </summary> - public static string CodeIDString = "1.0.20042201"; + //public static string CodeIDString = "1.1.0121070801"; + public static string CodeIDString = "1.2.1"; /// <summary> /// 娉ㄥ唽鏉ユ簮(0:HDL On 1:Zigbee) /// </summary> public static int RegisterSoruceFromZIGBEE = 0; - public static string Source = "ZIGBEE"; /// <summary> /// Company 鐢ㄦ埛鍏徃鐢ㄤ簬鍏徃App瀹氬埗鐗� 榛樿0 /// </summary> @@ -80,10 +68,6 @@ /// </summary> public static int XLeft = 58; /// <summary> - /// button楂樺害--110 - /// </summary> - public static int ButtonHeight = 110; - /// <summary> /// 浣跨敤鐨勮瑷� /// </summary> public static string ZigBeeLanguage @@ -94,62 +78,13 @@ } } /// <summary> - /// 澶ф帶浠跺渾瑙� --- 10銆備笉鏄笉鍗婂渾閭g銆� - /// </summary> - public static uint BigFormRadius = 10; - /// <summary> /// 榛樿鎵嬫満鍖哄彿涓�86涓浗澶ч檰 /// </summary> public static string PhoneZoneStr = "86"; /// <summary> - /// 鎵嬫満鍖哄悕绉� - /// </summary> - public static string ZoneNameStr = "涓浗澶ч檰"; - /// <summary> - /// 璺濈椤剁楂樺害--80 鐘舵�佹爮楂樺害 - /// </summary> - public static int NavigationTitle_Y = 80; - /// <summary> - /// 琛岄珮--180 - /// </summary> - public static int RowHeight = 180; - /// <summary> /// APP瀹藉害 -- 1080 /// </summary> public static int AppRealWidth = 1080; - /// <summary> - /// APP楂樺害 -- 1920 - /// </summary> - public static int AppRealHeight = 1920; - /// <summary> - /// 杩斿洖閿窛绂诲乏杈圭殑璺濈 30 - /// </summary> - public static int Navigation_X = 30; - /// <summary> - /// 瀵艰埅鏍忛珮搴�-220 - /// </summary> - public static int Navigation_Height = 220; - /// <summary> - /// 搴曡竟鏍忛珮搴� - /// </summary> - public const int TabbarHeight = 141; - /// <summary> - /// 绾挎潯鐨勯珮搴�--瀹為檯鍍忕礌3 - /// </summary> - public static int LineHeight = 3; - /// <summary> - /// 鏁翠釜鍦烘櫙寤舵椂鏃堕棿--60绉� - /// </summary> - public static int SceneDelayTime = 60; - - /// <summary> - /// 闂撮殧澶氶暱鏃堕棿璇诲彇璁惧鐘舵�� 鍗曚綅 绉� --榛樿30 - /// </summary> - public static int ReadDeviceStatuSpan = 30; - /// <summary> - /// 璇诲彇澶氬皯椤�--999 - /// </summary> - public static int PageSize = 999; /// <summary> /// 鐢ㄤ簬涓浗澶ч檰楠岃瘉鎵嬫満鍙锋鍒欒〃杈惧紡 @@ -163,21 +98,6 @@ /// 鐢ㄤ簬楠岃瘉閭姝e垯琛ㄨ揪寮� /// </summary> public static string EmailRegexStr = "^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$"; - - - //public static Encoding EncodingUTF8 = Encoding.UTF8; - //public static Encoding EncodingGB2312 = Encoding.GetEncoding("gb2312"); - public static bool IsRemote = false; - public static bool FindGateway = false; - /// <summary> - /// 褰撳墠缃戠粶杩炴帴鐨勬ā寮� 0:娌℃湁缃戠粶 1锛氳繙绋嬭繛鎺ワ紝涔熷彨3G,4G 2锛歐IFI - /// </summary> - public static int nowNetworkMode = 0; - /// <summary> - /// 鍗犱綅瀛椾綋澶у皬 - /// 11 - /// </summary> - public static int PlaceHolderTextSize = 11; /// <summary> /// 瀹夊崜鐨勭郴缁熻繑鍥炴寜閿兘鍚︽寜涓�(姣斿鍦ㄥ浠借繕鍘熸椂,涓嶈兘鎸変笅杩斿洖閿�) /// </summary> @@ -189,10 +109,11 @@ /// </summary> /// <param name="requestUrl">璇锋眰Url</param> /// <param name="byteData">璇锋眰鐨勭殑鏁版嵁</param> + /// <param name="timeout">瓒呮椂,榛樿5绉�</param> /// <returns>寰楀埌鍝嶅簲鐨勬暟鎹�</returns> - public async System.Threading.Tasks.Task<Shared.Common.ResponseEntity.ResponsePack> RequestHttpsZigbeeAsync(string requestUrl, byte[] byteData) + public ResponseEntity.ResponsePack RequestHttpsZigbeeAsync(string requestUrl, byte[] byteData, int timeout = 5) { - string result = await this.RequestHttpsZigbeeResultAsync(requestUrl, byteData); + string result = this.RequestHttpsZigbeeResultAsync(requestUrl, byteData, timeout); if (result != null) { try @@ -214,10 +135,11 @@ /// </summary> /// <param name="requestUrl">璇锋眰Url</param> /// <param name="byteData">璇锋眰鐨勭殑鏁版嵁</param> + /// <param name="timeout">瓒呮椂,榛樿5绉�</param> /// <returns>寰楀埌鍝嶅簲鐨勬暟鎹�</returns> - public async System.Threading.Tasks.Task<string> RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData) + public string RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData, int timeout = 5) { - var result = await RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData); + var result = RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData, "POST", timeout); if (result != null) { return Encoding.UTF8.GetString(result); @@ -232,12 +154,13 @@ /// <param name="requestUrl">璇锋眰Url</param> /// <param name="byteData">璇锋眰鐨勭殑鏁版嵁</param> /// <param name="requestMethod">POST 鎴栬�� GET 绛夌瓑</param> + /// <param name="timeout">瓒呮椂,榛樿5绉�</param> /// <returns>寰楀埌鍝嶅簲鐨勬暟鎹�</returns> - public async System.Threading.Tasks.Task<byte[]> RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST") + public byte[] RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST", int timeout = 5) { //璇锋眰Url鐨勫畬鎴愯矾寰� var fullUrl = $"{RequestHttpsHost}/{requestUrl}"; - return await this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.Token, requestMethod); + return this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.Token, requestMethod, timeout); } /// <summary> @@ -247,13 +170,14 @@ /// <param name="requestUrl">璇锋眰Url</param> /// <param name="byteData">璇锋眰鐨勭殑鏁版嵁</param> /// <param name="requestMethod">POST 鎴栬�� GET 绛夌瓑</param> + /// <param name="timeout">瓒呮椂,榛樿5绉�</param> /// <returns>寰楀埌鍝嶅簲鐨勬暟鎹�</returns> - public async System.Threading.Tasks.Task<byte[]> RequestZigbeeHttpsByAdmin(string requestUrl, byte[] byteData, string requestMethod = "POST") + public byte[] RequestZigbeeHttpsByAdmin(string requestUrl, byte[] byteData, string requestMethod = "POST", int timeout = 5) { //璇锋眰Url鐨勫畬鎴愯矾寰� var fullUrl = $"{Config.Instance.AdminRequestBaseUrl}/{requestUrl}"; - return await this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.AdminRequestToken, requestMethod); - } + return this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.AdminRequestToken, requestMethod, timeout); + } /// <summary> /// 璇锋眰鏈嶅姟鍣ㄦ柟娉� @@ -263,8 +187,9 @@ /// <param name="byteData">璇锋眰鐨勭殑鏁版嵁</param> /// <param name="token">token</param> /// <param name="requestMethod">POST 鎴栬�� GET 绛夌瓑</param> + /// <param name="timeout">瓒呮椂,榛樿5绉�</param> /// <returns>寰楀埌鍝嶅簲鐨勬暟鎹�</returns> - public async System.Threading.Tasks.Task<byte[]> DoRequestZigbeeHttpsInterface(string requestFullUrl, byte[] byteData, string token, string requestMethod = "POST") + public byte[] DoRequestZigbeeHttpsInterface(string requestFullUrl, byte[] byteData, string token, string requestMethod = "POST", int timeout = 5) { try { @@ -274,7 +199,10 @@ //2锛� 鍒濆鍖朒ttpWebRequest瀵硅薄 webRequest.Method = requestMethod; - webRequest.Timeout = 10 * 1000; + webRequest.Timeout = timeout * 1000; + //鍙栨秷浣跨敤浠g悊璁块棶 + webRequest.Proxy = null; + webRequest.UseDefaultCredentials = false; if (token != null) { //瀵瑰簲寰俊缃戝潃 @@ -316,11 +244,18 @@ return ms.ToArray(); } } - catch (Exception e) + catch (WebException e) { -#if DEBUG - System.Console.WriteLine(e.Message); -#endif + if (e.Status == WebExceptionStatus.ConnectFailure//鐢辨湁缃戠粶鍒囨崲鍒版棤缃戠粶鏃惰Е鍙� + || e.Status == WebExceptionStatus.Timeout//瓒呮椂 + || e.Status == WebExceptionStatus.NameResolutionFailure)//鏈韩灏辨槸鏃犵綉缁滄椂鍚姩鏃惰Е鍙� + { + Phone.UserCenter.HdlWifiLogic.Current.CanAccessHttp = false; + } + return null; + } + catch (Exception e) + { return null; } } @@ -374,6 +309,17 @@ } } } + } + + //娓呴櫎瑙掓爣鏁板�� + public void clearBadgeNum() + { + try + { + //this.RequestHttpsZigbeeResultAsync("ZigbeeUsers/CornerClear", null, 10); + this.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/CornerClear", null, "GET", 10); + } + catch { } } /// <summary> @@ -384,15 +330,19 @@ try { Application.RunOnMainThread(() => - { - //璁惧畾涓�涓椂闂� + { +#if iOS + //鍏ㄨ閫氶��鍑虹櫥褰� + Shared.IOS.HDLFVSDK.Video.Logout(); +#endif + //璁惧畾涓�涓椂闂� Config.Instance.LoginDateTime = new DateTime(1970, 1, 1); Config.Instance.Save(); CommonPage.Instance.RemoveAll(); CommonPage.Instance.Show(); - var login = new Phone.Login.AccountLogin(); + var login = new Phone.Login.AccountLoginForm(); CommonPage.Instance.AddChidren(login); - login.Show(); + login.ShowForm(); }); } catch { } @@ -422,8 +372,12 @@ /// 鐧诲綍鎴愬姛鍚庝笂鎶ヨ澶噄d绛夌浉鍏充俊鎭粰鍚庣 /// </summary> /// <returns>杩斿洖鐘舵�佺爜</returns> - public async System.Threading.Tasks.Task<string> PushRegID() + public string PushRegID() { +//#if DEBUG +// //璋冭瘯涓嶉渶瑕佸彂閫佽繖涓笢瑗� +// return null; +//#endif try { string deviceAlias; @@ -433,8 +387,9 @@ deviceType = "iphone"; #elif Android deviceAlias = Android.OS.Build.Manufacturer; - deviceType = "android"; -#endif + deviceType = "android"; +#endif + var RegIDObj = new SendDataToServer.SignZigbeeNeedPushRegIDObj() { RegID = Shared.Common.Config.Instance.RegistrationID, @@ -442,11 +397,17 @@ DeviceType = deviceType }; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(RegIDObj); - var reverObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/SignZigbeeNeedPushRegID", System.Text.Encoding.UTF8.GetBytes(requestJson)); + Console.WriteLine(requestJson); + var reverObj = CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/SignZigbeeNeedPushRegID", System.Text.Encoding.UTF8.GetBytes(requestJson), 4); if (reverObj == null) - { + { + //璋冭瘯:璁板綍鏋佸厜ID + Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.JiguangFile, "send:" + RegIDObj.RegID + " fail,receive obj is null", false, true); return null; - } + } + //璋冭瘯:璁板綍鏋佸厜ID + Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.JiguangFile, "send:" + RegIDObj.RegID + " result:" + reverObj.StateCode, false, true); + return reverObj.StateCode; } catch -- Gitblit v1.8.0