Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ErrorMessageLabel.Text      = "";
                ErrorMessageLabel.ForeColor = System.Drawing.Color.Black;
                SurveyLogicControl surveyLogicControl = new SurveyLogicControl();
                Question           question           = new Question();
                int currentQuestionSequence           = 0;

                if (string.IsNullOrEmpty(SessionControlUtil.getUserIPAddress()))
                {
                    string userIPAddress = AppUtil.getUserIPAddress();

                    if (!string.IsNullOrEmpty(userIPAddress))
                    {
                        Respondent respondent = new Respondent();
                        respondent.IpAddress = userIPAddress;
                        int userID = surveyLogicControl.insertRespondent(respondent);
                        SessionControlUtil.setUserID(userID);
                        SessionControlUtil.setUserIPAddress(userIPAddress);
                    }

                    // First time.
                    // Get the first question and set the session attributes control
                    question = surveyLogicControl.getNextQuestionBySequence(currentQuestionSequence);
                    SessionControlUtil.setCurrentQuestion(question);
                    SessionControlUtil.setCurrentQuestionSequence(question.QuestionSequence);
                    SessionControlUtil.incrementCurrentQuestionLevel();
                    HttpContext.Current.Session[AppConstants.sessionQuestionsAnswerList] = new List <SurveyQuestionAnswer>();
                }
                else
                {
                    question = SessionControlUtil.getCurrentQuestion();
                }

                this.displayQuestion(question);
            }
            catch (Exception ex)
            {
                /* IMPORTANT !!
                 * // No matter what was the error, user can not start, continue or
                 * // finalize the pageSurvey. So:
                 * // - A log (simulation) with the exception was done on the place that have occurred
                 * // - The exception comes till the final layer, shows a generic error to the user
                 * // - Insert more information on the log (simulation)
                 * */
                ErrorMessageLabel.Text      = AppConstants.errorSystemError;
                ErrorMessageLabel.ForeColor = System.Drawing.Color.Red;

                //Error log simulated
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
            }
        }
Ejemplo n.º 2
0
        ///////
        /// <summary>
        /// Insert an question ID List on Additional Questions Current Level List.
        /// </summary>
        /// <param name="questionIDList">List<int> questionIDList</param>
        /// <exception cref="AppPageException">AppPageException</exception>
        /// <exception cref="Exception">Exception</exception>
        public static void insertAdditionalQuestionsCurrentLevelList(List <int> questionIDList)
        {
            try
            {
                SessionControlUtil.incrementCurrentQuestionLevel();
                string currentQuestionsLevelKey = getCurrentQuestionsLevelKey();

                if (HttpContext.Current.Session[currentQuestionsLevelKey] == null)
                {
                    HttpContext.Current.Session[currentQuestionsLevelKey] = new ArrayList();
                }

                HttpContext.Current.Session[currentQuestionsLevelKey] = questionIDList;
            }
            catch (Exception ex)
            {
                //Error log simulated
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                throw;
            }
        }