old mode 100644
new mode 100755
| | |
| | | /// <summary> |
| | | /// 版本号 |
| | | /// </summary> |
| | | public static string CodeIDString = "1.0.19071001"; |
| | | public static string CodeIDString = "1.0.19071501"; |
| | | /// <summary> |
| | | /// 注册来源(0:HDL On 1:Zigbee) |
| | | /// </summary> |
| | |
| | | public async System.Threading.Tasks.Task<string> RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData) |
| | | { |
| | | var result = await RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData); |
| | | if (result != null) |
| | | { |
| | | return Encoding.UTF8.GetString(result); |
| | | if (result != null)
|
| | | {
|
| | | return Encoding.UTF8.GetString(result);
|
| | | } |
| | | return null; |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="requestUrl">请求Url</param> |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <param name="requestMethod">POST 或者 GET 等等</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | public async System.Threading.Tasks.Task<byte[]> RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData) |
| | | public async System.Threading.Tasks.Task<byte[]> RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST") |
| | | { |
| | | //请求Url的完成路径 |
| | | var fullUrl = $"{RequestHttpsHost}/{requestUrl}"; |
| | | return await this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.Token, requestMethod); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// <pra>请求服务器方法,指定一个Url,和请求方法,数据,Cookie,得到响应的数据</pra> |
| | | /// <pra>注意!!此方法仅限【拥有管理员权限的成员】调用</pra> |
| | | /// </summary>
|
| | | /// <param name="requestUrl">请求Url</param> |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <param name="requestMethod">POST 或者 GET 等等</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | public async System.Threading.Tasks.Task<byte[]> RequestZigbeeHttpsByAdmin(string requestUrl, byte[] byteData, string requestMethod = "POST") |
| | | {
|
| | | //请求Url的完成路径 |
| | | var fullUrl = $"{Config.Instance.AdminRequestBaseUrl}/{requestUrl}";
|
| | | return await this.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.AdminRequestToken, requestMethod); |
| | | } |
| | |
|
| | | /// <summary> |
| | | /// 请求服务器方法 |
| | | /// 指定一个Url,和请求方法,数据,Cookie,得到响应的数据 |
| | | /// </summary> |
| | | /// <param name="requestFullUrl">请求Url的完成路径</param> |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <param name="token">token</param> |
| | | /// <param name="requestMethod">POST 或者 GET 等等</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | private async System.Threading.Tasks.Task<byte[]> DoRequestZigbeeHttpsInterface(string requestFullUrl, byte[] byteData, string token, string requestMethod = "POST") |
| | | {
|
| | | try |
| | | { |
| | | //初始化新的webRequst |
| | | //1. 创建httpWebRequest对象 |
| | | HttpWebRequest webRequest = null; |
| | | if (Config.Instance.isAdministrator == true)
|
| | | {
|
| | | webRequest = (HttpWebRequest)WebRequest.Create(new Uri($"{Config.Instance.AdminRequestBaseUrl}/{requestUrl}"));
|
| | | } |
| | | else
|
| | | {
|
| | | webRequest = (HttpWebRequest)WebRequest.Create(new Uri($"{RequestHttpsHost}/{requestUrl}"));
|
| | | } |
| | | HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(requestFullUrl));
|
| | | |
| | | //2. 初始化HttpWebRequest对象 |
| | | webRequest.Method = "POST"; |
| | | webRequest.ContentType = "application/json"; |
| | | webRequest.Timeout = 10*1000; |
| | | webRequest.ContentLength = byteData.Length; |
| | | webRequest.Timeout = 10*1000; |
| | | webRequest.Headers.Add(HttpRequestHeader.Authorization, Config.Instance.Token); |
| | | //3. 附加要POST给服务器的数据到HttpWebRequest对象(附加POST数据的过程比较特殊,它并没有提供一个属性给用户存取,需要写入HttpWebRequest对象提供的一个stream里面。) |
| | | var newStream = webRequest.GetRequestStream();//创建一个Stream,赋值是写入HttpWebRequest对象提供的一个stream里面 |
| | | newStream.Write(byteData, 0, byteData.Length); |
| | | newStream.Flush(); |
| | | newStream.Close(); |
| | | webRequest.Method = requestMethod; |
| | | webRequest.Timeout = 10 * 1000; |
| | | webRequest.Headers.Add(HttpRequestHeader.Authorization, token); |
| | | if (requestMethod == "GET") |
| | | { |
| | | //webRequest.ContentType = "text/html"; |
| | | webRequest.ContentType = "application/json"; |
| | | } |
| | | else |
| | | { |
| | | webRequest.ContentType = "application/json"; |
| | | webRequest.ContentLength = byteData.Length; |
| | | |
| | | //3. 附加要POST给服务器的数据到HttpWebRequest对象(附加POST数据的过程比较特殊,它并没有提供一个属性给用户存取,需要写入HttpWebRequest对象提供的一个stream里面。) |
| | | var newStream = webRequest.GetRequestStream();//创建一个Stream,赋值是写入HttpWebRequest对象提供的一个stream里面 |
| | | newStream.Write(byteData, 0, byteData.Length); |
| | | newStream.Flush(); |
| | | newStream.Close(); |
| | | } |
| | | |
| | | //4. 读取服务器的返回信息 |
| | | var response = (HttpWebResponse)webRequest.GetResponse(); |
| | | using (var stream = response.GetResponseStream()) |
| | | { |
| | | if(stream==null) |
| | | if (stream == null)
|
| | | { |
| | | return null; |
| | | } |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | #if iOS |
| | | /// <summary> |
| | | /// 获取iOS-APP版本信息 |