Example #1
0
        /// <summary>
        /// 要進行登出,所以,清空本機快取資料
        /// </summary>
        /// <returns></returns>
        public static async Task CleanRepositories()
        {
            #region 要進行登出,所以,清空本機快取資料
            var fooSystemStatusRepository = new SystemStatusRepository();
            await fooSystemStatusRepository.ReadAsync();

            fooSystemStatusRepository.Item.AccessToken = "";
            await fooSystemStatusRepository.SaveAsync();

            var fooLoginRepository = new LoginRepository();
            fooLoginRepository.Item = new Models.UserLoginResultModel();
            await fooLoginRepository.SaveAsync();

            var fooWorkingLogRepository = new WorkingLogRepository();
            fooWorkingLogRepository.Items = new List <Models.WorkingLog>();
            await fooWorkingLogRepository.SaveAsync();

            var fooLeaveAppFormRepository = new LeaveAppFormRepository();
            fooLeaveAppFormRepository.Items = new List <Models.LeaveAppForm>();
            await fooLeaveAppFormRepository.SaveAsync(MainHelper.LeaveAppFormUserMode);

            await fooLeaveAppFormRepository.SaveAsync(MainHelper.LeaveAppFormManagerMode);

            #endregion
        }
Example #2
0
        public LoginPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            LoginCommand = new DelegateCommand(async() =>
            {
                var repoLogin = new LoginRepository();

                var pdcMessage = new ProgressDialogConfig()
                {
                    MaskType = MaskType.Black,
                    Title    = "請稍後,正在身分驗證中..."
                };
                using (Acr.UserDialogs.UserDialogs.Instance.Progress(pdcMessage))
                {
                    APIResult apiResult;
                    if (UsingHttpGet == true)
                    {
                        apiResult = await repoLogin.GetAsync(Account, Password);
                    }
                    else
                    {
                        apiResult = await repoLogin.PostAsync(Account, Password);
                    }

                    apiResult = new APIResult()
                    {
                        Success = true
                    };                                            //跳過驗證debug

                    if (apiResult.Success == false)
                    {
                        var config = new Acr.UserDialogs.AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"進行使用者身分驗證失敗,原因:{Environment.NewLine}{apiResult.Message}",
                            OkText  = "確定",
                        };

                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(config);
                    }
                    else
                    {
                        var repoSystemStatus = new SystemStatusRepository();
                        await repoSystemStatus.ReadAsync();
                        repoSystemStatus.Item.LoginMethodAction = UsingHttpGet;
                        repoSystemStatus.Item.AccessToken       = repoLogin.Item.AccessToken;
                        await repoSystemStatus.SaveAsync();
                        await _navigationService.NavigateAsync("xf:///MDPage/NaviPage/AboutPage");
                    }
                }
            });
#if DEBUG
            Account  = "ycwu";
            Password = "******";
#endif
        }
        public LoginPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            LoginCommand = new DelegateCommand(async() =>
            {
                var fooLoginRepository = new LoginRepository();

                var fooProgressDialogConfig = new ProgressDialogConfig()
                {
                    MaskType = MaskType.Black,
                    Title    = "請稍後,正在身分驗證中..."
                };
                using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
                {
                    APIResult fooResult;
                    if (UsingHttpGet == true)
                    {
                        fooResult = await fooLoginRepository.GetAsync(Account, Password);
                    }
                    else
                    {
                        fooResult = await fooLoginRepository.PostAsync(Account, Password);
                    }
                    if (fooResult.Success == false)
                    {
                        var config = new Acr.UserDialogs.AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"進行使用者身分驗證失敗,原因:{Environment.NewLine}{fooResult.Message}",
                            OkText  = "確定",
                        };

                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(config);
                    }
                    else
                    {
                        var fooSystemStatusRepository = new SystemStatusRepository();
                        await fooSystemStatusRepository.ReadAsync();
                        fooSystemStatusRepository.Item.LoginMethodAction = UsingHttpGet;
                        fooSystemStatusRepository.Item.AccessToken       = fooLoginRepository.Item.AccessToken;
                        await fooSystemStatusRepository.SaveAsync();
                        await _navigationService.NavigateAsync("xf:///MDPage/NaviPage/AboutPage");
                    }
                }
            });

#if DEBUG
            Account  = "user1";
            Password = "******";
#endif
        }