예제 #1
0
        public LoginPageViewModel(INavigationService navigationService, IPageDialogService dialogService,
                                  LoginManager loginManager, SystemStatusManager systemStatusManager,
                                  AppStatus appStatus, RecordCacheHelper recordCacheHelper)
        {
            this.navigationService   = navigationService;
            this.dialogService       = dialogService;
            this.loginManager        = loginManager;
            this.systemStatusManager = systemStatusManager;
            this.appStatus           = appStatus;
            this.recordCacheHelper   = recordCacheHelper;
            LoginCommand             = new DelegateCommand(async() =>
            {
                using (IProgressDialog fooIProgressDialog = UserDialogs.Instance.Loading($"請稍後,更新資料中...", null, null, true, MaskType.Black))
                {
                    LoginRequestDTO loginRequestDTO = new LoginRequestDTO()
                    {
                        Account  = Account,
                        Password = Password,
                    };
                    var fooResult = await LoginUpdateTokenHelper.UserLoginAsync(dialogService, loginManager, systemStatusManager,
                                                                                loginRequestDTO, appStatus);
                    if (fooResult == false)
                    {
                        return;
                    }
                    await recordCacheHelper.RefreshAsync(fooIProgressDialog);
                }

                //await dialogService.DisplayAlertAsync("Info", "登入成功", "OK");
                await navigationService.NavigateAsync("/MDPage/NaviPage/HomePage");
            });
        }
        public LoginPageViewModel(INavigationService navigationService, IPageDialogService dialogService,
                                  LoginService loginService, MyUserService myUserService, SystemStatusService systemStatusService,
                                  AppStatus appStatus, RecordCacheHelper recordCacheHelper)
        {
            this.navigationService   = navigationService;
            this.dialogService       = dialogService;
            this.loginService        = loginService;
            this.myUserService       = myUserService;
            this.systemStatusService = systemStatusService;
            this.appStatus           = appStatus;
            this.recordCacheHelper   = recordCacheHelper;

            #region 登入按鈕命令
            LoginCommand = new DelegateCommand(async() =>
            {
                using (IProgressDialog fooIProgressDialog = UserDialogs.Instance.Loading($"請稍後,使用者登入驗證中...", null, null, true, MaskType.Black))
                {
                    LoginRequestDto loginRequestDTO = new LoginRequestDto()
                    {
                        Account  = Account,
                        Password = Password,
                    };
                    var fooResult = await LoginUpdateTokenHelper.UserLoginAsync(dialogService, loginService, systemStatusService,
                                                                                loginRequestDTO, appStatus);
                    if (fooResult == false)
                    {
                        await dialogService.DisplayAlertAsync("登入驗證失敗", "請重新輸入正確的帳號與密碼", "確定");
                        return;
                    }
                    await recordCacheHelper.RefreshAsync(fooIProgressDialog);
                    #region 取得 使用者清單
                    fooIProgressDialog.Title = "請稍後,取得 使用者清單";
                    await myUserService.ReadFromFileAsync();
                    APIResult apiResult = await myUserService.GetAsync();
                    if (apiResult.Status == true)
                    {
                        await myUserService.WriteToFileAsync();
                    }
                    #endregion
                }

                await navigationService.NavigateAsync("/MDPage/NaviPage/HomePage");
            });
            #endregion

            #region 切換使用者
            SwitchUserCommand = new DelegateCommand <string>(x =>
            {
                Account = x;
            });
            #endregion
        }
 public SplashPageViewModel(INavigationService navigationService, IPageDialogService dialogService,
                            SystemStatusService systemStatusService, SystemEnvironmentsService systemEnvironmentsService,
                            MyUserService myUserService,
                            RecordCacheHelper recordCacheHelper, AppStatus appStatus)
 {
     this.navigationService         = navigationService;
     this.dialogService             = dialogService;
     this.systemStatusService       = systemStatusService;
     this.systemEnvironmentsService = systemEnvironmentsService;
     this.myUserService             = myUserService;
     this.recordCacheHelper         = recordCacheHelper;
     this.appStatus = appStatus;
 }
        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
        }
 public SplashPageViewModel(INavigationService navigationService, IPageDialogService dialogService,
                            SystemStatusService systemStatusService, SystemEnvironmentsService systemEnvironmentsService,
                            ProjectService projectService, MyUserService myUserService,
                            RecordCacheHelper recordCacheHelper, AppStatus appStatus,
                            ExceptionRecordsService exceptionRecordsService, AppExceptionsService appExceptionsService,
                            LeaveCategoryService leaveCategoryService, OnCallPhoneService onCallPhoneService)
 {
     this.navigationService         = navigationService;
     this.dialogService             = dialogService;
     this.systemStatusService       = systemStatusService;
     this.systemEnvironmentsService = systemEnvironmentsService;
     this.projectService            = projectService;
     this.myUserService             = myUserService;
     this.recordCacheHelper         = recordCacheHelper;
     this.appStatus = appStatus;
     this.exceptionRecordsService = exceptionRecordsService;
     this.appExceptionsService    = appExceptionsService;
     this.leaveCategoryService    = leaveCategoryService;
     this.onCallPhoneService      = onCallPhoneService;
 }