Esempio n. 1
0
        /// <summary>
        /// 登录
        /// </summary>
        private void Login()
        {
            // 登录
            Device.BeginInvokeOnMainThread(async() =>
            {
                // 登录
                if (InitCount <= 1)
                {
                    IsLoading = true;


                    await Task.Run(async() =>
                    {
                        await ExtX.WaitForLoading();

                        Device.BeginInvokeOnMainThread(() =>
                        {
                            NavigationPath.Instance.RoomListPage       = new RoomListPage();
                            NavigationPath.Instance.ChangePasswordPage = new ChangePasswordPage();
                            NavigationPath.Instance.AboutPage          = new AboutPage();
                            NavigationPath.Instance.BalancePage        = new BalancePage();
                            NavigationPath.Instance.StatisticPage      = new StatisticPage();



                            NavigationPath.Instance.MainListPage   = new MainListPage();
                            NavigationPath.Instance.MainNavigation = new MainPage(NavigationPath.Instance.MainListPage);
                            NavigationPath.Instance.InitialMainNavigations(NavigationPath.Instance.MainNavigation);
                        });

                        await ExtX.Sleep(2000);
                    });

                    // 登录通知
                    Notification.Instance.ActionLogin(null, null, null);

                    NavigationPath.Instance.SwitchNavigate(1);
                    NavigationPath.Instance.CurrentNavigate.BindingContext = new MainViewModel(NavigationPath.Instance.CurrentNavigate);



                    NavigationPath.Instance.MainListPage.Init();
                    NavigationPath.Instance.GoNavigateNext(NavigationPath.Instance.MainListPage);

                    IsLoading = false;

                    Setting();
                }
                // 以后就是直接打开了
                else
                {
                    // 登录通知
                    Notification.Instance.ActionLogin(null, null, null);

                    NavigationPath.Instance.SwitchNavigate(1);
                    MainViewModel viewModel = NavigationPath.Instance.CurrentNavigate.BindingContext as MainViewModel;
                    viewModel.Resize();

                    Setting();
                }
            });
        }
Esempio n. 2
0
        protected override void OnResume()
        {
            RoomListViewModel viewModel = null;

            if (null != NavigationPath.Instance.RoomListPage)
            {
                viewModel = NavigationPath.Instance.RoomListPage.BindingContext as RoomListViewModel;

                if (null != viewModel)
                {
                    viewModel.IsLoading = true;
                }
            }



            ReloadTheme();

            if (TradingSystemX.Resources.Instance.IsSessionExists())
            {
                // 注册睡眠唤醒(免得session失效)
                Task.Run(async() =>
                {
                    try
                    {
                        OperatesService.Instance.AbortService();


                        // Handle when your app resumes


                        await OperatesService.Instance.ServiceSession(false, null, true);
                    }
                    catch (Exception ex)
                    {
                        //QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, Res.Instance.GetString("Error"), ex.Message + ex.StackTrace, MessageBoxMode.Dialog, MessageBoxImageMode.Error, MessageBoxButtonMode.OK, null, null);
                        ExceptionPro.ExpLog(ex);
                    }
                    finally
                    {
                        if (OperatesService.Instance.IsExpired || OperatesService.Instance.IsAdminUsing)
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                viewModel.IsLoading      = false;
                                MainViewModel viewModel2 = NavigationPath.Instance.CurrentNavigate.BindingContext as MainViewModel;
                                viewModel2.ReLyout();
                            });
                        }
                        else
                        {
                            if (null != viewModel)
                            {
                                await ExtX.Sleep(100);
                                NavigationPath.Instance.RoomListPage.RefreshRoomList();
                                Device.BeginInvokeOnMainThread(() =>
                                {
                                    viewModel.IsLoading = false;
                                });
                            }
                        }

                        Session.Instance.Start();
                    }
                });
            }
        }