| | |
| | | return result; |
| | | } |
| | | |
| | | public bool DownloadDataComplete = false; |
| | | public bool DownloadDataComplete = true; |
| | | /// <summary> |
| | | /// 下载数据 |
| | | /// </summary> |
| | |
| | | { |
| | | if (MainPage.InternetStatus == 0) |
| | | return; |
| | | //线程开始时间 |
| | | var beginTime = DateTime.Now.AddSeconds(6); |
| | | |
| | | DownloadDataComplete = false; |
| | | |
| | |
| | | |
| | | string code = StateCode.SUCCESS; |
| | | |
| | | new System.Threading.Thread(() => { |
| | | var downloadDataThread = new System.Threading.Thread(() => |
| | | { |
| | | //===================刷新Token======================= |
| | | code = Ins.HttpRequest.RefreshToken(); |
| | | if(code != StateCode.SUCCESS) |
| | | if (code != StateCode.SUCCESS) |
| | | { |
| | | MainPage.Log($"刷新token失败"); |
| | | return; |
| | |
| | | var pack = Ins.HttpRequest.GetSceneList(); |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | MainPage.Log($"读取场景数据成功");//:\r\n{pack.Data.ToString()}"); |
| | | MainPage.Log($"读取场景数据成功"); |
| | | var sceneList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString()); |
| | | if (sceneList != null) |
| | | { |
| | |
| | | |
| | | //===================读取逻辑列表========================== |
| | | UI.UI2.Intelligence.Automation.MainView.GetLogicList(); |
| | | }catch(Exception ex) |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"数据初始化失败:{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | beginTime = DateTime.MinValue; |
| | | DownloadDataComplete = true; |
| | | waitPage.Hide(); |
| | | waitPage.RemoveFromParent(); |
| | | }); |
| | | } |
| | | }); |
| | | downloadDataThread.IsBackground = true; |
| | | downloadDataThread.Start(); |
| | | |
| | | //网络卡顿,终止下载线程 |
| | | new System.Threading.Thread(() => |
| | | { |
| | | while (beginTime < DateTime.Now) |
| | | { |
| | | if (DownloadDataComplete) |
| | | { |
| | | break; |
| | | } |
| | | System.Threading.Thread.Sleep(100); |
| | | } |
| | | if (!DownloadDataComplete) |
| | | { |
| | | downloadDataThread.Abort(); |
| | | } |
| | | DownloadDataComplete = true; |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | waitPage.RemoveFromParent(); |
| | | }); |
| | | //初始化数据 |
| | | //SpatialInfo.CurrentSpatial.Clear(); |
| | | |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |