示例#1
0
        public async Task GetBoards()
        {
            Boards.Clear();

            var result = await _boardsService.GetTestedBoards(CertificateId);

            if (!result.Success)
            {
                Dialogs.Toast(result.Message);
                return;
            }

            var boards = result.ResultObject as List <BoardTest>;

            if (boards == null || !boards.Any())
            {
                return;
            }

            Boards.AddRange(new List <BoardTest>(boards.OrderBy(x => x.BoardIdentity)));
            await GetCircuitsForCurrentBoard();
        }
示例#2
0
        private async Task GetBoards(BoardsFilters filters, bool forceCloud = false)
        {
            try
            {
                using (var dlg = this.Dialogs.Loading("Progress (No Cancel)"))
                {
                    Boards.Clear();

                    var testedBoardsResult = await _boardsService.GetTestedBoards(CertificateId);

                    if (!testedBoardsResult.Success)
                    {
                        Dialogs.Toast(testedBoardsResult.Message);
                        return;
                    }

                    var relatedBoards = testedBoardsResult.ResultObject as List <BoardTest>;

                    if (relatedBoards != null)
                    {
                        TestedBoards = relatedBoards;

                        var allBoardsResult = await _boardsService.GetAllBoards(filters, BuildingId, forceCloud);

                        if (!allBoardsResult.Success)
                        {
                            Dialogs.Toast(allBoardsResult.Message);
                            return;
                        }

                        var boardsAndNumber = allBoardsResult.ResultObject as Tuple <IEnumerable <BoardRow>, int, int>;
                        if (boardsAndNumber == null)
                        {
                            return;
                        }

                        Dialogs.Toast("Results; " + boardsAndNumber.Item3 + " records returned out of " + boardsAndNumber.Item2 + " found.");

                        var boards = boardsAndNumber.Item1;

                        if (boards != null && boards.Any())
                        {
                            foreach (var board in boards)
                            {
                                var selectableBoard = new BoardSelect {
                                    Board = board, IsSelected = false
                                };
                                if (relatedBoards.Any(x => x.BoardId == board.BoardId))
                                {
                                    selectableBoard.IsSelected = true;
                                }
                                Boards.Add(selectableBoard);
                            }
                        }
                    }
                }
            }
            catch (ServiceAuthenticationException e)
            {
                var result = await TryToLogin();

                if (!result)
                {
                    await NavigationService.NavigateToAsync <LoginViewModel>();
                }
                else
                {
                    await GetBoards(filters, forceCloud);
                }
            }
            catch (Exception e)
            {
                await ShowErrorAlert(e.Message);
            }
        }
示例#3
0
        public async Task CheckDoesEveryBoardHasAssociatedCircuit()
        {
            try
            {
                var listOfBoards = "";
                DoesEveryBoardHasAssociatedCircuit = true;

                var testedBoardsResult = await _boardsService.GetTestedBoards(CertificateId);

                if (!testedBoardsResult.Success)
                {
                    Dialogs.Toast(testedBoardsResult.Message);
                    return;
                }

                var boards = testedBoardsResult.ResultObject as List <BoardTest>;
                if (boards != null && boards.Any())
                {
                    foreach (var board in boards)
                    {
                        var circuitResult = await _boardsService.GetTestedCircuits(CertificateId, board.BoardId);

                        if (!circuitResult.Success)
                        {
                            Dialogs.Toast(circuitResult.Message);
                            return;
                        }

                        var circuitTest = circuitResult.ResultObject as List <CircuitTest>;
                        if (circuitTest != null)
                        {
                            if (circuitTest.Any())
                            {
                                continue;
                            }

                            DoesEveryBoardHasAssociatedCircuit = false;
                            listOfBoards += board.BoardIdentity + ", ";
                        }
                    }
                    if (!string.IsNullOrEmpty(listOfBoards))
                    {
                        listOfBoards += ".";
                        listOfBoards  = listOfBoards.Replace(", .", ".");

                        ListOfBoardsWithoutAssociatedCircuit = listOfBoards;
                        ErrorMessage = "Following boards: " + ListOfBoardsWithoutAssociatedCircuit +
                                       " Has no circuit selected, please select a board and then associate a circuit!";

                        ShowError();
                    }

                    MessagingCenter.Send(this,
                                         DoesEveryBoardHasAssociatedCircuit
                            ? MessengerCenterMessages.ShowBackOnCertificateDetails
                            : MessengerCenterMessages.HideBackOnCertificateDetails);
                }
            }
            catch (Exception e)
            {
                await ShowErrorAlert(e.Message);
            }
        }
示例#4
0
        private async Task GetBoards()
        {
            try
            {
                using (var dlg = this.Dialogs.Loading("Progress (No Cancel)"))
                {
                    Boards.Clear();

                    var testedBoardsResult = await _boardsService.GetTestedBoards(CertificateId);

                    if (!testedBoardsResult.Success)
                    {
                        Dialogs.Toast(testedBoardsResult.Message);
                        return;
                    }

                    var relatedBoards = testedBoardsResult.ResultObject as List <BoardTest>;

                    if (relatedBoards != null)
                    {
                        TestedBoards = relatedBoards;

                        var downloadedBoardsResult = await _boardsService.GetAllDownloadedBoards(BuildingId);

                        if (!downloadedBoardsResult.Success)
                        {
                            Dialogs.Toast(downloadedBoardsResult.Message);
                            return;
                        }

                        var boards = downloadedBoardsResult.ResultObject as List <Board>;

                        if (boards != null && boards.Any())
                        {
                            foreach (var board in boards)
                            {
                                var selectableBoard = new BoardDetailsSelect {
                                    Board = board, IsSelected = false
                                };

                                if (relatedBoards.Any(x => x.BoardId == board.BoardId))
                                {
                                    selectableBoard.IsSelected = true;
                                }
                                Boards.Add(selectableBoard);
                            }

                            foreach (var board in relatedBoards)
                            {
                                if (Boards.Any(x => x.Board.BoardId == board.BoardId))
                                {
                                    continue;
                                }

                                var testedBoard     = AutoMapper.Mapper.Map <Board>(board);
                                var selectableBoard = new BoardDetailsSelect {
                                    Board = testedBoard, IsSelected = true
                                };
                                Boards.Add(selectableBoard);
                            }
                        }
                    }
                }
            }
            catch (ServiceAuthenticationException e)
            {
                var result = await TryToLogin();

                if (!result)
                {
                    await NavigationService.NavigateToAsync <LoginViewModel>();
                }
                else
                {
                    await GetBoards();
                }
            }
            catch (Exception e)
            {
                await ShowErrorAlert(e.Message);
            }
        }