public async void OnNavigatedTo(NavigationParameters parameters)
        {
            var fooSystemStatusRepository = new SystemStatusRepository();
            await fooSystemStatusRepository.ReadAsync();

            UsingHttpGet = fooSystemStatusRepository.Item.LoginMethodAction;
        }
Пример #2
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
        }
Пример #3
0
        public async void OnNavigatedTo(INavigationParameters parameters)
        {
            var repoSystemStatus = new SystemStatusRepository();
            await repoSystemStatus.ReadAsync();

            UsingHttpGet = repoSystemStatus.Item.LoginMethodAction;
        }
Пример #4
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
        }
Пример #6
0
        public async void OnNavigatedTo(NavigationParameters parameters)
        {
            var fooAllSuccess = true;

            if (Plugin.Connectivity.CrossConnectivity.Current.IsConnected == false)
            {
                fooAllSuccess = false;
            }
            else
            {
                LoadingMessage = "正在更新 請假單分類清單 中";
                var fooLeaveCategoryRepository = new LeaveCategoryRepository();
                APIResult = await fooLeaveCategoryRepository.GetAsync();

                if (APIResult.Success == false)
                {
                    using (Acr.UserDialogs.UserDialogs.Instance.Toast(
                               $"無法進行 更新 請假單分類清單 中 ({APIResult.Message})", TimeSpan.FromMilliseconds(1500)))
                    {
                        await Task.Delay(2000);
                    }
                    fooAllSuccess = false;
                }
                else
                {
                    LoadingMessage = "正在更新 專案清單 中";
                    var fooProjectRepository = new ProjectRepository();
                    APIResult = await fooProjectRepository.GetAsync();

                    if (APIResult.Success == false)
                    {
                        using (Acr.UserDialogs.UserDialogs.Instance.Toast(
                                   $"無法進行 更新 專案清單 中({APIResult.Message})", TimeSpan.FromMilliseconds(1500)))
                        {
                            await Task.Delay(2000);
                        }
                        fooAllSuccess = false;
                    }
                    else
                    {
                        LoadingMessage = "正在更新 緊急連絡電話清單 中";
                        var fooOnCallPhoneRepository = new OnCallPhoneRepository();
                        APIResult = await fooOnCallPhoneRepository.GetAsync();

                        if (APIResult.Success == false)
                        {
                            using (Acr.UserDialogs.UserDialogs.Instance.Toast(
                                       $"無法進行 更新 緊急連絡電話清單 中({APIResult.Message})", TimeSpan.FromMilliseconds(1500)))
                            {
                                await Task.Delay(2000);
                            }
                            fooAllSuccess = false;
                        }
                    }
                }
            }

            if (fooAllSuccess == true)
            {
                LoadingMessage = "系統資料更新完成";
                var fooSystemStatusRepository = new SystemStatusRepository();
                await fooSystemStatusRepository.ReadAsync();

                if (string.IsNullOrEmpty(fooSystemStatusRepository.Item.AccessToken))
                {
                    await _navigationService.NavigateAsync("xf:///LoginPage");
                }
                else
                {
                    await _navigationService.NavigateAsync("xf:///MDPage/NaviPage/AboutPage");
                }
            }
            else
            {
                var config = new Acr.UserDialogs.ConfirmConfig()
                {
                    Title      = "警告",
                    Message    = "可能因為網路問題,無法進行系統資料更新,您確定要繼續執行嗎? (強制繼續執行 App,但有可能造成 App 不正常運作)",
                    OkText     = "確定",
                    CancelText = "停止"
                };
                await Task.Delay(1000);

                var fooConfirmResult =
                    await Acr.UserDialogs.UserDialogs.Instance.ConfirmAsync(config);

                if (fooConfirmResult == false)
                {
                    LoadingMessage = "請強制關閉 App,檢查網路是否可用,並且重新啟動 App";
                    return;
                }
                else
                {
                    LoadingMessage = "強制繼續執行 App";
                }
            }

            // 切換到首頁或者登入頁面
        }
Пример #7
0
        public async void OnNavigatedTo(INavigationParameters parameters)
        {
            var fooAllSuccess = true;

            if (Plugin.Connectivity.CrossConnectivity.Current.IsConnected == false)
            {
                fooAllSuccess = false;
            }
            else
            {
                //LoadingMessage = "正在更新 員工檔/部門檔清單 中";
                //var repoDepartment = new DepartmentRepository();
                //APIResult = await repoDepartment.GetAsync();
                //if (APIResult.Success == false)
                //{
                //    using (Acr.UserDialogs.UserDialogs.Instance.Toast($"無法進行更新[部門檔]清單 中 ({APIResult.Message})", TimeSpan.FromMilliseconds(1500)))
                //    {
                //        await Task.Delay(2000);
                //    }
                //    fooAllSuccess = false;
                //}
                //else
                //{
                //    var repoEmployee = new EmployeeRepository();
                //    APIResult = await repoEmployee.GetAsync();
                //    if (APIResult.Success == false)
                //    {
                //        using (Acr.UserDialogs.UserDialogs.Instance.Toast($"無法進行更新[員工檔]清單 中 ({APIResult.Message})", TimeSpan.FromMilliseconds(1500)))
                //        {
                //            await Task.Delay(2000);
                //        }
                //        fooAllSuccess = false;
                //    }
                //}
            }

            if (fooAllSuccess == true)
            {
                LoadingMessage = "系統資料更新完成";
                var fooSystemStatusRepository = new SystemStatusRepository();
                await fooSystemStatusRepository.ReadAsync();

                if (string.IsNullOrEmpty(fooSystemStatusRepository.Item.AccessToken))
                {
                    await _navigationService.NavigateAsync("xf:///LoginPage");
                }
                else
                {
                    await _navigationService.NavigateAsync("xf:///MDPage/NaviPage/AboutPage");
                }
            }
            else
            {
                var config = new Acr.UserDialogs.ConfirmConfig()
                {
                    Title      = "警告",
                    Message    = "可能因為網路問題,無法進行系統資料更新,您確定要繼續執行嗎? (強制繼續執行 App,但有可能造成 App 不正常運作)",
                    OkText     = "確定",
                    CancelText = "停止"
                };
                await Task.Delay(1000);

                var fooConfirmResult =
                    await Acr.UserDialogs.UserDialogs.Instance.ConfirmAsync(config);

                if (fooConfirmResult == false)
                {
                    LoadingMessage = "請強制關閉 App,檢查網路是否可用,並且重新啟動 App";
                    return;
                }
                else
                {
                    LoadingMessage = "強制繼續執行 App";
                }
            }
            // 切換到首頁或者登入頁面
        }