Пример #1
0
        private async Task LoadTasks(int RoleID, bool pullTasks)
        {
            try
            {
                ProgressBarVisibility = Visibility.Visible;
                ButtonEnable          = false;
                ClearTaskSheet();
                if (pullTasks)
                {
                    RestStatus pullTaskResult = await RestHub.PullTask(RoleID, pullTasks);

                    PullTask   pullTask   = pullTaskResult.UserObject != null ? (PullTask)pullTaskResult.UserObject : null;
                    PullTaskVM pullTaskVm = new PullTaskVM();
                    if (pullTask != null)
                    {
                        pullTaskVm.TanNumber = pullTask.TanNumber;
                        if (pullTask.UserRanks != null)
                        {
                            pullTaskVm.UserRank = pullTask.UserRanks.Find(ur => ur.Key == U.UserName)?.Rank;
                        }
                        if (pullTask.TanRanks != null && pullTask.TanNumber != null)
                        {
                            pullTaskVm.AllottedTanRank = pullTask.TanRanks.Find(ur => ur.Key == pullTask.TanNumber)?.Rank;
                        }
                        List <RankVM> rankVM = new List <RankVM>();
                        int           count  = 1;
                        foreach (var r in pullTask.TanRanks)
                        {
                            rankVM.Add(new RankVM {
                                DisplayOrder = count++, Key = r.Key, Rank = r.Rank, Score = r.Score.ToString()
                            });
                        }
                        pullTaskVm.TanRanks = new ObservableCollection <RankVM>(rankVM);
                        rankVM = new List <RankVM>();
                        count  = 1;
                        foreach (var r in pullTask.UserRanks)
                        {
                            rankVM.Add(new RankVM {
                                DisplayOrder = count++, Key = r.Key, Rank = r.Rank, Score = r.Score.ToString()
                            });
                        }
                        pullTaskVm.UserRanks = new ObservableCollection <Core.RankVM>(rankVM);
                        PullTaskDetails.ShowWindow(pullTaskVm);
                    }
                }
                RestStatus status = await RestHub.MyTans(RoleID, pullTasks);

                if (status.HttpCode == System.Net.HttpStatusCode.OK)
                {
                    List <TaskDTO> tans = status.UserObject as List <TaskDTO>;
                    if (tans != null && tans.Count > 0)
                    {
                        foreach (TaskDTO tan in tans)
                        {
                            Tasks.Add(new TaskDeatilsVM
                            {
                                TanId             = tan.Id,
                                TanName           = tan.TanName,
                                Status            = tan.Status,
                                Analyst           = tan.Analyst,
                                BatchNo           = tan.BatchNo,
                                NUMsCount         = tan.NUMsCount,
                                QC                = tan.QC,
                                Reviewer          = tan.Reviewer,
                                RXNsCount         = tan.RXNsCount,
                                Version           = tan.Version,
                                TanCompletionDate = tan.TanCompletionDate,
                                ProcessingNote    = tan.ProcessingNote,
                                NearToTargetDate  = tan.NearToTargetDate
                            });
                        }
                        Tasks.UpdateDisplayOrder();
                        UserTasks = new ListCollectionView(Tasks);
                    }
                    else
                    {
                        AppInfoBox.ShowInfoMessage("No Tasks Found. Try GetTasks After Some Time.");
                    }
                }
                else
                {
                    AppErrorBox.ShowErrorMessage("Some error occured in Getting Tans.", status.StatusMessage);
                }
                ButtonEnable = true;
            }
            catch (Exception ex)
            {
                Log.This(ex);
            }
            finally
            {
                ProgressBarVisibility = Visibility.Hidden;
            }
        }