Exemplo n.º 1
0
        public void ShowLastStep()
        {
            Logger.Verbose("RaiseTicketActivity:ShowLastStep invoked");
            Logger.Verbose("RaiseTicketActivity:ShowLastStep Items in List before show and remove " + StepAnswersList.Count);

            //if there are still steps/questions
            if (StepAnswersList.Any())
            {
                //get the last step in the list
                var lastStep = StepAnswersList.Last();

                //display it
                ShowStep(lastStep.StepId);

                //then remove it from the list
                StepAnswersList.Remove(lastStep);
            }
            else
            {
                //if there are no steps remaining, call OnBackPressed
                base.OnBackPressed();
            }
        }
Exemplo n.º 2
0
        public override void UpdateScreen()
        {
            try
            {
                if (TicketQuestionListDefintion == null)
                {
                    using (var sr = new StreamReader(Assets.Open("ticketscreens.json")))
                    {
                        //load the screen definitions from the json file located in the Assets folder
                        TicketQuestionListDefintion = sr.ReadToEnd();
                    }
                }

                if (TicketQuestionListDefintion != null)
                {
                    //deserialize the json structure
                    TicketQuestionList = JsonConvert.DeserializeObject <List <TicketQuestion> >(TicketQuestionListDefintion);

                    Logger.Verbose("Deserialized Screen List Count : " + TicketQuestionList.Count());

                    //if we have list of questions
                    if (TicketQuestionList.Any())
                    {
                        TicketQuestion startTicketQuestion = null;

                        if (StepAnswersListDefintion != null)
                        {
                            StepAnswersList = JsonConvert.DeserializeObject <List <StepAnswer> >(StepAnswersListDefintion);
                        }

                        //determine the starting screen based on whether we have an existing list of step answers
                        if (StepAnswersList == null)
                        {
                            //startTicketQuestion = TicketQuestionList.ElementAt(0);
                            startTicketQuestion = TicketQuestionList.Find(q => q.ScreenId == _startScreenId);
                        }
                        else
                        {
                            //if there is persisted list, get the last one and use that as the starting point
                            if (StepAnswersList.Any())
                            {
                                var lastStepAnswer = StepAnswersList.ElementAt(StepAnswersList.Count() - 1);
                                Logger.Verbose("Last Step to be reloaded : " + lastStepAnswer.StepId);
                                startTicketQuestion = TicketQuestionList.Find(q => q.ScreenId == lastStepAnswer.StepId);
                            }
                            else
                            {
                                //startTicketQuestion = TicketQuestionList.ElementAt(0);
                                startTicketQuestion = TicketQuestionList.Find(q => q.ScreenId == _startScreenId);
                            }
                        }

                        if (startTicketQuestion != null)
                        {
                            if (StepAnswersList == null)
                            {
                                StepAnswersList = new List <StepAnswer>();
                            }

                            _ticketFragment = new FragmentTicket();
                            _ticketFragment.SetArgument(TicketFragment, startTicketQuestion);
                            ShowFragment(_ticketFragment);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Verbose(ex.Message);
                return;
            }
        }