old mode 100644
new mode 100755
| | |
| | | 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]; |
| | |
| | | { |
| | | //服务返回来没有门锁成员信息,没有必要再去请求成员列表, |
| | | //原因:节约时间,体验效果好; |
| | | result = await UserCenter.UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra); |
| | | result = UserCenter.UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra); |
| | | }
|
| | | if (string.IsNullOrEmpty(result))
|
| | | {
|
| | |
| | | /// <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; //请求方式为POST/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; //请求方式为POST/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> |
| | |
| | | #endregion |
| | | |
| | | #region 存取本地文件的方法 ---暂时不用合并该方法--- |
| | | /// <summary> |
| | | /// <summary>
|
| | | /// 判断是否开启GPS服务 |
| | | /// </summary> |
| | | public static string If_Exist |
| | |
| | | } |
| | | |
| | | } |
| | | /// <summary>
|
| | | /// <summary> |
| | | /// 文件保存
|
| | | /// </summary>
|
| | | /// <param name="FileName">文件路径</param>
|
| | |
| | | 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);
|
| | | //字节流转换为字符串;
|