Exemplo n.º 1
0
        public async Task ApproveDenyRecord(LeaveAppForm leaveAppForm, bool isApprove)
        {
            #region 進行審核請假單
            APIResult fooResult;
            IsRefreshing = true;
            var fooProgressDialogConfig = new ProgressDialogConfig()
            {
                Title           = "請稍後,正在進行審核請假單清單中...",
                IsDeterministic = false,
            };
            using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
            {
                var fooLeaveAppFormRepository = new LeaveAppFormRepository();
                if (isApprove == true)
                {
                    leaveAppForm.ApproveResult = "已審核";
                    leaveAppForm.FormsStatus   = "已生效";
                }
                else
                {
                    leaveAppForm.ApproveResult = "被否決";
                    leaveAppForm.FormsStatus   = "未生效";
                }
                fooResult = await fooLeaveAppFormRepository.PutAsync(leaveAppForm);

                if (fooResult.Success == false)
                {
                    if (await MainHelper.CheckAccessToken(fooResult) == false)
                    {
                        return;
                    }

                    try
                    {
                        var fooAlertConfig = new AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"新增資料發生了錯誤 {Environment.NewLine}{fooResult.Message}",
                            OkText  = "確定"
                        };
                        CancellationTokenSource fooCancelSrc = new CancellationTokenSource(10000);
                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(fooAlertConfig, fooCancelSrc.Token);
                    }
                    catch (OperationCanceledException)
                    {
                    }
                }
            }
            if (fooResult.Success == true)
            {
                await RetriveRecords();
            }
            IsRefreshing = false;
            #endregion
        }
Exemplo n.º 2
0
        public async Task RetriveRecords()
        {
            #region 進行待審核請假單清單更新
            APIResult fooResult;
            IsRefreshing = true;
            var fooProgressDialogConfig = new ProgressDialogConfig()
            {
                Title           = "請稍後,正在進行待審核請假單清單更新中...",
                IsDeterministic = false,
            };
            using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
            {
                var fooLoginRepository = new LoginRepository();
                await fooLoginRepository.ReadAsync();

                var fooLeaveAppFormRepository = new LeaveAppFormRepository();
                fooResult = await fooLeaveAppFormRepository.PostByUserIDAsync(new LeaveAppFormByUserModel()
                {
                    Account = fooLoginRepository.Item.MyUser.EmployeeID,
                    Mode    = MainHelper.LeaveAppFormManagerMode
                });

                if (fooResult.Success == false)
                {
                    if (await MainHelper.CheckAccessToken(fooResult) == false)
                    {
                        IsRefreshing = false;
                        return;
                    }

                    try
                    {
                        var fooAlertConfig = new AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"更新資料發生了錯誤 {Environment.NewLine}{fooResult.Message}",
                            OkText  = "確定"
                        };
                        CancellationTokenSource fooCancelSrc = new CancellationTokenSource(10000);
                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(fooAlertConfig, fooCancelSrc.Token);
                    }
                    catch (OperationCanceledException)
                    {
                    }
                }
            }
            if (fooResult.Success == true)
            {
                await RefreshCache();
            }
            IsRefreshing = false;
            #endregion
        }
Exemplo n.º 3
0
        public async Task UpdateRecord(WorkingLog workingLog)
        {
            #region 進行工作日誌清單更新
            APIResult fooResult;
            IsRefreshing = true;
            var fooProgressDialogConfig = new ProgressDialogConfig()
            {
                Title           = "請稍後,正在進行工作日誌清單更新中...",
                IsDeterministic = false,
            };
            using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
            {
                var fooWorkingLog = new WorkingLogRepository();
                fooResult = await fooWorkingLog.PutAsync(workingLog);

                if (fooResult.Success == false)
                {
                    if (await MainHelper.CheckAccessToken(fooResult) == false)
                    {
                        return;
                    }

                    try
                    {
                        var fooAlertConfig = new AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"更新資料發生了錯誤 {Environment.NewLine}{fooResult.Message}",
                            OkText  = "確定"
                        };
                        CancellationTokenSource fooCancelSrc = new CancellationTokenSource(10000);
                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(fooAlertConfig, fooCancelSrc.Token);
                    }
                    catch (OperationCanceledException)
                    {
                    }
                }
            }
            if (fooResult.Success == true)
            {
                await RetriveRecords();
            }
            IsRefreshing = false;
            #endregion
        }
        public LeaveAppFormAgentViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            QueryAgentListCommand = new DelegateCommand(async() =>
            {
                var fooProgressDialogConfig = new ProgressDialogConfig()
                {
                    MaskType = MaskType.Black,
                    Title    = "請稍後,正在查詢可用代理人清單..."
                };
                using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
                {
                    APIResult fooResult;
                    var fooQueryAgentRepository = new QueryAgentRepository();
                    string fooDep = DepartmentSelectedItem ?? "";
                    fooResult     = await fooQueryAgentRepository.Post(new LAFAgentQuery()
                    {
                        DepartmentName = fooDep,
                        Name           = UserName
                    });
                    if (fooResult.Success == false)
                    {
                        if (await MainHelper.CheckAccessToken(fooResult) == false)
                        {
                            return;
                        }

                        try
                        {
                            var fooAlertConfig = new AlertConfig()
                            {
                                Title   = "警告",
                                Message = $"查詢可用代理人清單發生了錯誤 {Environment.NewLine}{fooResult.Message}",
                                OkText  = "確定"
                            };
                            CancellationTokenSource fooCancelSrc = new CancellationTokenSource(10000);
                            await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(fooAlertConfig, fooCancelSrc.Token);
                        }
                        catch (OperationCanceledException)
                        {
                        }
                    }
                    else
                    {
                        QueryAgentListSource.Clear();
                        QueryAgentSelectedItem = null;
                        foreach (var item in fooQueryAgentRepository.Items)
                        {
                            QueryAgentListSource.Add(item);
                        }
                    }
                }
            });

            SelectAgentCommand = new DelegateCommand(async() =>
            {
                if (QueryAgentSelectedItem == null)
                {
                    var config = new Acr.UserDialogs.AlertConfig()
                    {
                        Title   = "警告",
                        Message = $"您尚未選取請假代理人",
                        OkText  = "確定",
                    };

                    await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(config);
                }
                else
                {
                    LeaveAppFormItem.AgentId     = QueryAgentSelectedItem.MyUserId;
                    LeaveAppFormItem.AgentName   = QueryAgentSelectedItem.Name;
                    NavigationParameters fooPara = new NavigationParameters();
                    fooPara.Add(MainHelper.QueryUserAgent, LeaveAppFormItem.Clone());
                    await _navigationService.GoBackAsync(fooPara);
                }
            });
        }