| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using HDL_ON; |
| | | using HDL_ON.DAL; |
| | | using System.Net.Http; |
| | | using System.Threading.Tasks; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI.UI2.FuntionControlView.Video; |
| | |
| | | /// <summary> |
| | | /// token是否有效 |
| | | /// </summary> |
| | | public bool tokenInvalid = false; |
| | | public bool IsValidToken = false; |
| | | |
| | | public bool hadInternet = true; |
| | | /// <summary> |
| | |
| | | string code = StateCode.SUCCESS; |
| | | |
| | | Inverter.Ins.H5Page = null;//重置光伏页面 |
| | | var downloadDataThread = new System.Threading.Thread(() => |
| | | var downloadDataThread = new System.Threading.Thread(async() => |
| | | { |
| | | try |
| | | { |
| | | //增加3秒云服务器连接检测,连不上服务器的时候不刷新数据 |
| | | hadInternet = true; |
| | | //hadInternet = true; |
| | | var dataList = new List<GlobalRegionListRes>(); |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark }); |
| | | var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost, "", 3); |
| | |
| | | } |
| | | finally |
| | | { |
| | | MainPage.Log("服务器连接状态:" + hadInternet); |
| | | if (!hadInternet) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | |
| | | if (code != StateCode.SUCCESS) |
| | | { |
| | | DownloadDataComplete = true; |
| | | hadInternet = false; |
| | | IsValidToken= false; |
| | | try |
| | | { |
| | | var spatialInfoDataBytes = FileUtlis.Files.ReadFile("SpatialInfoData"); |
| | |
| | | MainPage.Log("Error", $"{this.GetType()}:加载缓存设备数据异常:{ex.StackTrace}"); |
| | | } |
| | | MainPage.Log($"刷新token失败"); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | hadInternet = true; |
| | | } |
| | | if (code != StateCode.SUCCESS) |
| | | { |
| | | |
| | | |
| | | if (waitPage != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | |
| | | }); |
| | | } |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | hadInternet = true; |
| | | } |
| | | MainPage.Log($"刷新token成功"); |
| | | //===================刷新住宅信息======================= |
| | |
| | | var pack = Ins.HttpRequest.GetSecurityList(); |
| | | } |
| | | |
| | | //public async Task<bool> CanConnectToHost() |
| | | //{ |
| | | // try |
| | | // { |
| | | // using (HttpClient client = new HttpClient()) |
| | | // { |
| | | // client.Timeout = TimeSpan.FromSeconds(3); // 超时时间 |
| | | // HttpResponseMessage response = await client.GetAsync(HttpUtil.GlobalRequestHttpsHost); |
| | | // return response.IsSuccessStatusCode; |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // MainPage.Log(ex.StackTrace); |
| | | // return false; |
| | | // } |
| | | //} |
| | | |
| | | |
| | | } |
| | | } |