public MDPageViewModel(INavigationService navigationService,
                               IPageDialogService dialogService, MyUserService myUserService,
                               LoginService loginService, SystemStatusService systemStatusService,
                               AppStatus appStatus, RecordCacheHelper recordCacheHelper,
                               LogoutCleanHelper logoutCleanHelper)
        {
            this.navigationService   = navigationService;
            this.dialogService       = dialogService;
            this.myUserService       = myUserService;
            this.loginService        = loginService;
            this.systemStatusService = systemStatusService;
            this.appStatus           = appStatus;
            this.recordCacheHelper   = recordCacheHelper;
            this.logoutCleanHelper   = logoutCleanHelper;

            #region 一般命令
            MenuCommand = new DelegateCommand <string>(async x =>
            {
                switch (x)
                {
                case "首頁":
                    await navigationService.NavigateAsync("/MDPage/NaviPage/HomePage");
                    break;
                }
            });
            #endregion

            #region 登出命令
            LogoutCommand = new DelegateCommand(async() =>
            {
                var isLogout = await dialogService.DisplayAlertAsync("警告",
                                                                     "你確定要登出嗎?", "確定", "取消");
                if (isLogout == true)
                {
                    using (IProgressDialog fooIProgressDialog = UserDialogs.Instance.Loading($"請稍後,更新資料中...", null, null, true, MaskType.Black))
                    {
                        await logoutCleanHelper.LogoutCleanAsync(fooIProgressDialog);
                        var fooResult = await LoginUpdateTokenHelper.UserLogoutAsync(dialogService, loginService, systemStatusService, appStatus);
                        if (fooResult == true)
                        {
                            await navigationService.NavigateAsync("/LoginPage");
                        }
                    }
                }
            });
            #endregion
        }
示例#2
0
 public MDPageViewModel(INavigationService navigationService, IPageDialogService dialogService,
                        LoginManager loginManager, SystemStatusManager systemStatusManager,
                        AppStatus appStatus, LogoutCleanHelper logoutCleanHelper)
 {
     this.navigationService   = navigationService;
     this.dialogService       = dialogService;
     this.loginManager        = loginManager;
     this.systemStatusManager = systemStatusManager;
     this.appStatus           = appStatus;
     this.logoutCleanHelper   = logoutCleanHelper;
     HomeCommand = new DelegateCommand(async() =>
     {
         await navigationService.NavigateAsync("/MDPage/NaviPage/HomePage");
     });
     SuggestionCommand = new DelegateCommand(async() =>
     {
         await navigationService.NavigateAsync("/MDPage/NaviPage/SuggestionPage");
     });
     ExceptionCommand = new DelegateCommand(() =>
     {
         throw new Exception("發生了一個自訂的例外異常");
     });
     UserGroupCommand = new DelegateCommand(async() =>
     {
         await navigationService.NavigateAsync("/MDPage/NaviPage/CommUsePage");
     });
     LeaveFormCommand = new DelegateCommand(async() =>
     {
         await navigationService.NavigateAsync("/MDPage/NaviPage/LeaveFormPage");
     });
     LogoutCommand = new DelegateCommand(async() =>
     {
         using (IProgressDialog fooIProgressDialog = UserDialogs.Instance.Loading($"請稍後,更新資料中...", null, null, true, MaskType.Black))
         {
             await logoutCleanHelper.LogoutCleanAsync(fooIProgressDialog);
             var fooResult = await LoginUpdateTokenHelper.UserLogoutAsync(dialogService, loginManager, systemStatusManager, appStatus);
             if (fooResult == true)
             {
                 await navigationService.NavigateAsync("/LoginPage");
             }
         }
     });
 }