| | |
| | | return result; |
| | | } |
| | | |
| | | public bool DownloadDataComplete = false; |
| | | public bool DownloadDataComplete = true; |
| | | /// <summary> |
| | | /// 下载数据 |
| | | /// </summary> |
| | |
| | | { |
| | | if (MainPage.InternetStatus == 0) |
| | | return; |
| | | //线程开始时间 |
| | | var endTime = DateTime.Now.AddSeconds(6); |
| | | |
| | | MainPage.Log($"开始同步云端数据"); |
| | | |
| | | DownloadDataComplete = false; |
| | | |
| | | var waitPage = new Loading(); |
| | | MainPage.BaseView.AddChidren(waitPage); |
| | | waitPage.Start(); |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | |
| | | string code = StateCode.SUCCESS; |
| | | |
| | | new System.Threading.Thread(() => { |
| | | var downloadDataThread = new System.Threading.Thread(() => |
| | | { |
| | | MainPage.Log($"进入读取云端数据线程"); |
| | | //===================刷新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(() => |
| | | { |
| | | MainPage.Log($"结束读取云端数据线程"); |
| | | endTime = DateTime.MinValue; |
| | | DownloadDataComplete = true; |
| | | waitPage.Hide(); |
| | | waitPage.RemoveFromParent(); |
| | | }); |
| | | } |
| | | }); |
| | | downloadDataThread.IsBackground = true; |
| | | downloadDataThread.Priority = System.Threading.ThreadPriority.Highest; |
| | | downloadDataThread.Start(); |
| | | |
| | | //网络卡顿,终止下载线程 |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | while (endTime > 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(); |
| | | |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | #region 读取本地数据 |
| | | //读取音乐信息 |
| | | UI.Music.A31MusicModel.ReadMusicStates(); |
| | | //搜索网关 |
| | | DriverLayer.Control.Ins.SearchLoaclGateway(); |
| | | #endregion |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |