Ejemplo n.º 1
0
        public void ShowStep(int?stepId)
        {
            if (stepId == null)
            {
                //display alert dialog
                return;
            }

            //if the answer's next screen Id is not null, find it's definition and load the fragment
            try
            {
                var ticketStepDefinition = TicketQuestionList.Find(q => q.ScreenId == stepId);

                if (ticketStepDefinition != null)
                {
                    //_ticketFragment = new FragmentTicket(ticketStepDefinition);
                    _ticketFragment = new FragmentTicket();
                    _ticketFragment.SetArgument(TicketFragment, ticketStepDefinition);
                    ShowFragment(_ticketFragment);
                }
                else
                {
                    //display alertdialog stating step definition could not be found
                }
            }
            catch (Exception ex)
            {
                Logger.Verbose(ex.Message);
                return;
            }
        }
Ejemplo n.º 2
0
 private void ShowFragment(FragmentTicket newfragment)
 {
     try
     {
         GetFragmentManager().BeginTransaction().Replace(Resource.Id.ticket_placeholder, newfragment, TicketFragmentTag).Show(newfragment).CommitAllowingStateLoss();
     }
     catch (Exception ex)
     {
         Logger.Verbose(ex.Message);
         return;
     }
 }
Ejemplo n.º 3
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;
            }
        }