From f500e14c0a994487070380c50c85e0929cbc8e63 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期二, 05 一月 2021 10:48:04 +0800
Subject: [PATCH] 2021-01-05 1.更新

---
 Crabtree/SmartHome/UI/SimpleControl/MainPage.cs |   99 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 89 insertions(+), 10 deletions(-)

diff --git a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs
index 854b76f..47cc5a4 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs
@@ -38,7 +38,7 @@
         //public static Button LogoButton = new Button ();
   
 
-        public static string RequestVersion = "2.507241";
+        public static string RequestVersion = "2.512151";
         public static UserInfo LoginUser;
         /// <summary>
         /// 鏄惁鏄鐞嗗憳鏉冮檺(鍙樻洿浜�,鎴愬憳鐨勬椂鍊�,杩欎釜涔熶负ture銆備负浠�涔堜細澹版槑杩欐牱鍙橀噺,鍥犱负鏈変簺鎺ュ彛蹇呴』浣跨敤鍘熸潵鐨凾oken)
@@ -80,6 +80,17 @@
 
         //public static string RequestHttpsHost = "https://developer.hdlcontrol.com";
 
+        #region GetDesignHeight
+        /// <summary>
+        /// 鑾峰彇view鐨勮绠楅珮搴︼紝ON杞欢涓轰簡閫傞厤鍏ㄩ潰鐗规畩浣跨敤鐨勬瘮渚嬫柟娉曪紝鐢变簬涓�浜涜儗鏅浘鐗囨槸鐩存帴鍏ㄩ儴濉厖鐨勶紝鏀瑰姩鎴愪笁灞傜殑锛坴iew-button-button)鐨勫伐浣滈噺寰堝ぇ锛屼笉绂侀渶瑕佸鍔犱竴涓獀iew锛岃繕闇�瑕佷慨鏀瑰浘鐗�
+        /// </summary>
+        /// <returns>The view height.</returns>
+        public static int GetDesignHeight (int height)
+        {
+            int ss = Convert.ToInt32 (height / PixelScale);
+            return Application.GetRealHeight (ss);
+        }
+        #endregion
 
         public static double PixelScale {
             get {
@@ -146,6 +157,9 @@
                     Loading.TextColor = 0xFFA9A9A9;
                     Loading.LodingBackgroundColor = SkinStyle.Current.MainColor;
                 }
+
+                CommonUtlis.Current.CheckIfJailBreak ();
+
             } catch (Exception ex) {
                 //new Alert ("Eorr", ex.Message, "Close").Show();
             }
@@ -295,26 +309,20 @@
             ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, error) => {
                 return true;
             };
-
-
             #region HttpWebRequest
-
             try {
 
                 if (urlHead == "") {
                     urlHead = RequestHttpsHost;
                 }
                 string requestFullUrl = urlHead + methodType;
-
                 //鍒濆鍖栨柊鐨剋ebRequst
                 //1锛� 鍒涘缓httpWebRequest瀵硅薄
                 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create (new Uri (requestFullUrl));
 
                 //2锛� 鍒濆鍖朒ttpWebRequest瀵硅薄
                 webRequest.Method = requestMethod;
-
                 //webRequest.Timeout = mTimeout * 1000;
-
                 webRequest.Headers.Add (HttpRequestHeader.Authorization, LoginUser.LoginTokenString);
                 webRequest.Headers.Add ("RequestVersion", mUploadHomeAppGatewaySubFilesBigObj.RequestVersion);
                 webRequest.Headers.Add ("LoginAccessToken", LoginUser.LoginTokenString);
@@ -323,9 +331,7 @@
                 webRequest.Headers.Add ("FileName", mUploadHomeAppGatewaySubFilesBigObj.FileName);
                 webRequest.Headers.Add ("IsOtherAccountCtrl", mUploadHomeAppGatewaySubFilesBigObj.IsOtherAccountCtrl.ToString ());
 
-
                 //var byteData = new byte [] { }锛�//Encoding.UTF8.GetBytes (dataStringJson);
-
                 //if (LoginUser != null) {/* 濡傛灉涓嶉渶瑕侀獙璇乀oken鍙互涓嶇敤浼犲叆 */
                 //    //瀵瑰簲寰俊缃戝潃
 
@@ -483,6 +489,78 @@
 
         }
 
+        public const int TIME_OUT_20 = 30;
+        /// <summary>
+        /// 涓嬭浇鏂囦欢鏂规硶
+        /// </summary>
+        /// <param name="methodType"></param>
+        /// <param name="dataStringJson"></param>
+        /// <param name="urlHead"></param>
+        /// <param name="mTimeout"></param>
+        /// <param name="requestMethod"></param>
+        /// <returns></returns>
+        public static byte [] RequestHttpsReturnByteNew (string methodType, string dataStringJson, string urlHead = "", int mTimeout = 20, string requestMethod = "POST")
+        {
+            try {
+                #region
+                if (urlHead == "") {
+                    urlHead = RequestHttpsHost;
+                }
+                string requestFullUrl = urlHead + methodType;
+
+                //鍒濆鍖栨柊鐨剋ebRequst
+                //1锛� 鍒涘缓httpWebRequest瀵硅薄
+                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create (new Uri (requestFullUrl));
+
+                //2锛� 鍒濆鍖朒ttpWebRequest瀵硅薄
+                webRequest.Method = requestMethod;
+                //webRequest.Timeout = timeout * 1000;
+                //鍙栨秷浣跨敤浠g悊璁块棶
+                webRequest.Proxy = null;
+                webRequest.UseDefaultCredentials = false;
+              
+                if (requestMethod == "GET") {
+                    webRequest.ContentType = "application/json";
+                } else {
+                    var byteData = Encoding.UTF8.GetBytes (dataStringJson);
+                    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) {
+                        return null;
+                    }
+                    var ms = new MemoryStream ();
+                    var bytes = new byte [1024];
+                    var len = int.MaxValue;
+                    while (stream.CanRead && 0 < len) {
+                        len = stream.Read (bytes, 0, bytes.Length);
+                        ms.Write (bytes, 0, len);
+                    }
+                    return ms.ToArray ();
+                }
+                #endregion
+            } catch (WebException e) {
+                //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;
+            }
+        }
+
         #region LoadingTipMsg 杩滅▼杩炴帴Tip
 
         static Button btnLoadingTipMsg;
@@ -596,6 +674,7 @@
             });
         }
 
-     
+       
+
     }
 }

--
Gitblit v1.8.0