| | |
| | | /// 下载数据完成标记 |
| | | /// </summary> |
| | | public bool DownloadDataComplete = false; |
| | | |
| | | public bool hadInternet = true; |
| | | /// <summary> |
| | | /// 下载数据 |
| | | /// </summary> |
| | | public void DownloadData() |
| | | { |
| | | if (MainPage.InternetStatus == 0 || MainPage.NoLoginMode) |
| | | if (MainPage.NoLoginMode) |
| | | { |
| | | DownloadDataComplete = true; |
| | | return; |
| | |
| | | var waitPage = new Loading(); |
| | | MainPage.BaseView.AddChidren(waitPage); |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | |
| | | |
| | | string code = StateCode.SUCCESS; |
| | | |
| | | Inverter.Ins.H5Page = null;//重置光伏页面 |
| | | |
| | | var downloadDataThread = new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | //增加3秒云服务器连接检测,连不上服务器的时候不刷新数据 |
| | | 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); |
| | | if (revertObj == null || revertObj.Code != StateCode.SUCCESS) |
| | | { |
| | | DownloadDataComplete = true; |
| | | hadInternet = false; |
| | | try |
| | | { |
| | | var spatialInfoDataBytes = FileUtlis.Files.ReadFile("SpatialInfoData"); |
| | | if (spatialInfoDataBytes != null) |
| | | { |
| | | var spatialInfoDataString = System.Text.Encoding.UTF8.GetString(spatialInfoDataBytes); |
| | | if (spatialInfoDataString != null && !string.IsNullOrEmpty(spatialInfoDataString)) |
| | | { |
| | | var spatialInfoDataList = JsonConvert.DeserializeObject<List<SpatialInfo>>(spatialInfoDataString); |
| | | SpatialInfo.CurrentSpatial.UpdateSpatialList(spatialInfoDataList); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"{this.GetType()}:加载缓存房间数据异常:{ex.Message}"); |
| | | } |
| | | |
| | | try |
| | | { |
| | | var fileList = Common.FileUtlis.Files.ReadFiles(); |
| | | foreach (var file in fileList) |
| | | { |
| | | FunctionList.List.IniFunctionList(file, true); |
| | | } |
| | | Room.CurrentSpatial.InitRoomListFunctions(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"{this.GetType()}:加载缓存设备数据异常:{ex.Message}"); |
| | | } |
| | | |
| | | |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | hadInternet = true; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"Error:下载数据1:{ex.Message}"); |
| | | DownloadDataComplete = true; |
| | | return; |
| | | } |
| | | finally |
| | | { |
| | | if (!hadInternet) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (waitPage != null) |
| | | { |
| | | waitPage.Hide(); |
| | | waitPage.RemoveFromParent(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | MainPage.Log($"进入读取云端数据线程"); |
| | | //===================刷新Token======================= |
| | | code = Ins.HttpRequest.RefreshToken(); |
| | |
| | | if (roomResult.Code == StateCode.SUCCESS) |
| | | { |
| | | MainPage.Log($"读取房间信息成功"); |
| | | var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<SpatialApiPack>(roomResult.Data.ToString()); |
| | | var revData = JsonConvert.DeserializeObject<SpatialApiPack>(roomResult.Data.ToString()); |
| | | if (revData == null) |
| | | { |
| | | revData = new SpatialApiPack(); |
| | | } |
| | | { |
| | | SpatialInfo.CurrentSpatial.UpdateSpatialList(revData.list); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(revData.list)); |
| | | FileUtlis.Files.WriteFileByBytes("SpatialInfoData", ssd); |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"{this.GetType()}:保存房间信息异常:{ex.Message}"); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | } |
| | | else |
| | |
| | | //======================安防==================== |
| | | GetSecurityList(); |
| | | |
| | | //===================读取逻辑列表========================== |
| | | //===================读取逻辑列表==================== |
| | | Logic.LogicList.Clear();//主页下拉强制刷新自动化列表 |
| | | MainView.GetLogicList();//读取自动化列表 |
| | | }) |