From 2029e64ec0491f7e511dc15bffaf821bfbabe2de Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 20 七月 2020 14:10:22 +0800
Subject: [PATCH] 上传一个很特别的新版本

---
 ZigbeeApp/Shared/Phone/Device/Logic/Send.cs |   62 +++++++++++++++++-------------
 1 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs
index 26c0e85..7502d06 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs
@@ -1238,35 +1238,43 @@
         /// <returns></returns>
         public static async System.Threading.Tasks.Task<string> HttpWebRequest(string getUrl, string str, string method, int second = 3, bool _bool = false)
         {
-            HttpWebRequest request = WebRequest.Create(getUrl) as HttpWebRequest; //鍒涘缓璇锋眰
-            request.Method = method; //璇锋眰鏂瑰紡涓篜OST/GET
-            request.ContentType = "application/json"; 
-            request.Timeout = second * 1000;//瓒呮椂鏃堕棿
-            if (_bool) {
-                //鐢ㄤ簬楂樿儨鍙瀵硅鎺ュ彛
-                request.Headers.Add("Authorization", Config.Instance.Token);
+            try
+            {
+                HttpWebRequest request = WebRequest.Create(getUrl) as HttpWebRequest; //鍒涘缓璇锋眰
+                request.Method = method; //璇锋眰鏂瑰紡涓篜OST/GET
+                request.ContentType = "application/json";
+                request.Timeout = second * 1000;//瓒呮椂鏃堕棿
+                if (_bool)
+                {
+                    //鐢ㄤ簬楂樿儨鍙瀵硅鎺ュ彛
+                    request.Headers.Add("Authorization", Config.Instance.Token);
+                }
+                if (method == "POST")
+                {
+                    byte[] jsonbyte = System.Text.Encoding.UTF8.GetBytes(str);
+                    request.ContentLength = jsonbyte.Length;
+                    Stream postStream = request.GetRequestStream();
+                    postStream.Write(jsonbyte, 0, jsonbyte.Length);
+                    postStream.Close();
+                }
+                //鍙戦�佽姹傚苟鑾峰彇鐩稿簲鍥炲簲鏁版嵁       
+                HttpWebResponse res;
+                try
+                {
+                    res = (HttpWebResponse)request.GetResponse();
+                }
+                catch (WebException ex)
+                {
+                    res = (HttpWebResponse)ex.Response;
+                }
+                StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8);
+                string content = sr.ReadToEnd(); //鑾峰緱鍝嶅簲瀛楃涓�
+                return content;
             }
-            if (method == "POST")
-            {
-                byte[] jsonbyte = System.Text.Encoding.UTF8.GetBytes(str);
-                request.ContentLength = jsonbyte.Length;
-                Stream postStream = request.GetRequestStream();
-                postStream.Write(jsonbyte, 0, jsonbyte.Length);
-                postStream.Close();
+            catch
+            {
+                return null;
             }
-            //鍙戦�佽姹傚苟鑾峰彇鐩稿簲鍥炲簲鏁版嵁       
-            HttpWebResponse res;
-            try
-            {
-                res = (HttpWebResponse)request.GetResponse();
-            }
-            catch (WebException ex)
-            {
-                res = (HttpWebResponse)ex.Response;
-            }
-            StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8);
-            string content = sr.ReadToEnd(); //鑾峰緱鍝嶅簲瀛楃涓�
-            return content;
         }
         /// <summary>
         /// 璇锋眰鏈嶅姟鍣ㄧ殑鏂规硶

--
Gitblit v1.8.0