From 652243206427f35a256400a149a1734085824cb9 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 02 九月 2020 17:35:03 +0800 Subject: [PATCH] 2020-09-02-4 --- ZigbeeApp/Shared/Phone/Device/Logic/Send.cs | 109 +++++++++++++++++++++++++++--------------------------- 1 files changed, 54 insertions(+), 55 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs old mode 100644 new mode 100755 index 14495cf..1f50bbe --- a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs @@ -656,7 +656,7 @@ return await System.Threading.Tasks.Task.Run(async () => { - var listLogic = new List<Common.Logic>(); + var listLogic = new List<Common.Logic>(); Action<string, string> action = (topic, data) => { var gatewayID = topic.Split('/')[0]; @@ -868,7 +868,7 @@ { //鏈嶅姟杩斿洖鏉ユ病鏈夐棬閿佹垚鍛樹俊鎭紝娌℃湁蹇呰鍐嶅幓璇锋眰鎴愬憳鍒楄〃锛� //鍘熷洜锛氳妭绾︽椂闂达紝浣撻獙鏁堟灉濂斤紱 - result = await UserCenter.UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra); + result = UserCenter.UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra); } if (string.IsNullOrEmpty(result)) { @@ -1234,43 +1234,42 @@ /// <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;//瓒呮椂鏃堕棿 - try - { - 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; + 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; } catch - { - return null; + { + return null; } } /// <summary> @@ -1320,14 +1319,14 @@ #endregion #region 瀛樺彇鏈湴鏂囦欢鐨勬柟娉� ---鏆傛椂涓嶇敤鍚堝苟璇ユ柟娉�--- - /// <summary> + /// <summary> /// 鍒ゆ柇鏄惁寮�鍚疓PS鏈嶅姟 /// </summary> - public static string It_Exist + public static string If_Exist { get { - string value = ReadLocalFile("GPS_File"); + string value = ReadLocalFile(Config.Instance.HomeId+"_GPS_File"); //璇诲彇鏈湴GPS鏈嶅姟鐘舵�� if (value == "0"||string.IsNullOrEmpty(value)) { @@ -1337,7 +1336,7 @@ } } - /// <summary> + /// <summary> /// 鏂囦欢淇濆瓨 /// </summary> /// <param name="FileName">鏂囦欢璺緞</param> @@ -1350,27 +1349,27 @@ var byteData = System.Text.Encoding.UTF8.GetBytes(data); //鍐欏叆鏁版嵁锛� Shared.IO.FileUtils.WriteFileByBytes(FileName, byteData); - } - /// <summary> - /// 鏂囦欢淇濆瓨 - /// </summary> - /// <param name="FileName">鏂囦欢璺緞</param> - /// <param name="data">瀛楃涓�</param> - public static void SaveLocalFile(string FileName, string data) - { - //鍏堝簭鍒楀寲鏁版嵁锛� - //鏁版嵁杞崲涓哄瓧鑺傛祦锛� - var byteData = System.Text.Encoding.UTF8.GetBytes(data); - //鍐欏叆鏁版嵁锛� - Shared.IO.FileUtils.WriteFileByBytes(FileName, byteData); } + /// <summary> + /// 鏂囦欢淇濆瓨 + /// </summary> + /// <param name="FileName">鏂囦欢璺緞</param> + /// <param name="data">瀛楃涓�</param> + public static void SaveLocalFile(string FileName, string data) + { + //鍏堝簭鍒楀寲鏁版嵁锛� + //鏁版嵁杞崲涓哄瓧鑺傛祦锛� + var byteData = System.Text.Encoding.UTF8.GetBytes(data); + //鍐欏叆鏁版嵁锛� + Shared.IO.FileUtils.WriteFileByBytes(FileName, byteData); + } /// <summary> /// 鏂囦欢璇诲彇 /// </summary> /// <param name="FileName">鏂囦欢璺緞</param> /// <returns></returns> public static string ReadLocalFile(string FileName) - { + { //璇诲嚭淇濆瓨璇ヨ矾寰勭殑鏂囦欢锛� var varByte = Shared.IO.FileUtils.ReadFile(FileName); //瀛楄妭娴佽浆鎹负瀛楃涓诧紱 -- Gitblit v1.8.0