Example #1
0
        /// <summary>
        /// Get the current DB stats and fill
        /// the label with them
        /// </summary>
        private void BindData()
        {
            isScored = new Surveys().IsSurveyScored(SurveyId);
            var      survey = new Surveys().GetSurveyById(SurveyId, null);
            TimeSpan timeTaken;

            _voterAnswers = new Voters().GetVoterAnswers(_voterId);

            if (!_voterAnswers.Voters[0].IsVoteDateNull() && !_voterAnswers.Voters[0].IsStartDateNull())
            {
                timeTaken = _voterAnswers.Voters[0].VoteDate - _voterAnswers.Voters[0].StartDate;
            }
            else
            {
                timeTaken = new TimeSpan(0);
            }
            SurveyTitle.Text = survey.Surveys[0].Title;


            IPAddressLabel.Text = _voterAnswers.Voters[0].IPSource;
            VoteDateLabel.Text  = _voterAnswers.Voters[0].VoteDate.ToString();
            VoterEmail.Text     = _voterAnswers.Voters[0].IsEmailNull() ? GetPageResource("AnonymousVoteInfo") : _voterAnswers.Voters[0].Email;
            VoterUserName.Text  = _voterAnswers.Voters[0].IsContextUserNameNull() ? GetPageResource("ContextUserNameDisabled") : _voterAnswers.Voters[0].ContextUserName;
            //VoterLanguageValueLabel.Text = _voterAnswers.Voters[0].IsLanguageCodeNull() || _voterAnswers.Voters[0].LanguageCode.Length == 0 ?
            //	GetPageResource("LanguageUndefined") : _voterAnswers.Voters[0].LanguageCode;
            TimeToTakeSurveyLabel.Text = string.Format("{0} {1}, {2} secs.", timeTaken.Minutes.ToString(), GetPageResource("MinutesInfo"), timeTaken.Seconds.ToString());

            WebSecurityAddInCollection securityAddIns = WebSecurityAddInFactory.CreateWebSecurityAddInCollection(new SecurityAddIns().GetWebSecurityAddIns(SurveyId), ViewState, null);
            NameValueCollection        addInVoterData;

            for (int i = 0; i < securityAddIns.Count; i++)
            {
                addInVoterData = securityAddIns[i].GetAddInVoterData(_voterId);
                if (addInVoterData != null)
                {
                    // Creates a new addin voter details page
                    SecurityAddInVoterReportControl addInVoterControl =
                        (SecurityAddInVoterReportControl)LoadControl("UserControls/SecurityAddInVoterReportControl.ascx");

                    addInVoterControl.AddInDescription = securityAddIns[i].Description;
                    addInVoterControl.AddInVoterData   = addInVoterData;
                    AddInVoterDataPlaceHolder.Controls.Add(addInVoterControl);
                }
            }

            _questionData = new Questions().GetQuestionHierarchy(SurveyId);
            QuestionsDataGrid.DataSource   = GetParentQuestions();
            QuestionsDataGrid.DataKeyField = "QuestionId";
            QuestionsDataGrid.DataBind();
            if (isScored)
            {
                //VoterScoreTotalLabel.Text = GetPageResource("VoterScoreTotalLabel") + _totalScore.ToString();
                VoterScoreTotalLabel.Text   = _totalScore.ToString();
                VoterAverageScoreLabel.Text = (questionCount != 0) ? (Convert.ToDouble(_totalScore) / questionCount).ToString("N2") : "";
            }
        }
        /// <summary>
        /// Get the current DB stats and fill
        /// the label with them
        /// </summary>
        private void BindData()
        {
            TimeSpan timeTaken;

            _voterAnswers = new Voters().GetVoterAnswers(_voterId);

            if (!_voterAnswers.Voters[0].IsVoteDateNull() && !_voterAnswers.Voters[0].IsStartDateNull())
            {
                timeTaken = _voterAnswers.Voters[0].VoteDate - _voterAnswers.Voters[0].StartDate;
            }
            else
            {
                timeTaken = new TimeSpan(0);
            }

            VoterUIDLabel.Text         = _voterId.ToString();
            IPAddressLabel.Text        = _voterAnswers.Voters[0].IPSource;
            VoteDateLabel.Text         = _voterAnswers.Voters[0].VoteDate.ToString();
            VoterEmail.Text            = _voterAnswers.Voters[0].IsEmailNull() ? GetPageResource("AnonymousVoteInfo") : _voterAnswers.Voters[0].Email;
            VoterUserName.Text         = _voterAnswers.Voters[0].IsContextUserNameNull() ?  GetPageResource("ContextUserNameDisabled") : _voterAnswers.Voters[0].ContextUserName;
            TimeToTakeSurveyLabel.Text = string.Format("{0} {1}, {2} secs.",
                                                       timeTaken.Minutes.ToString(), GetPageResource("MinutesInfo"), timeTaken.Seconds.ToString());

            WebSecurityAddInCollection securityAddIns = WebSecurityAddInFactory.CreateWebSecurityAddInCollection(new SecurityAddIns().GetWebSecurityAddIns(SurveyId), ViewState, null);
            NameValueCollection        addInVoterData;

            for (int i = 0; i < securityAddIns.Count; i++)
            {
                addInVoterData = securityAddIns[i].GetAddInVoterData(_voterId);
                if (addInVoterData != null)
                {
                    // Creates a new addin voter details page
                    SecurityAddInVoterReportControl addInVoterControl =
                        (SecurityAddInVoterReportControl)LoadControl("UserControls/SecurityAddInVoterReportControl.ascx");

                    addInVoterControl.AddInDescription = securityAddIns[i].Description;
                    addInVoterControl.AddInVoterData   = addInVoterData;
                    AddInVoterDataPlaceHolder.Controls.Add(addInVoterControl);
                }
            }
        }
Example #3
0
        protected virtual string GenerateAddInsReport()
        {
            StringBuilder addInsReport = new StringBuilder();

            WebSecurityAddInCollection securityAddIns = WebSecurityAddInFactory.CreateWebSecurityAddInCollection(new SecurityAddIns().GetWebSecurityAddIns(_surveyId), null, null);
            NameValueCollection        addInVoterData;

            for (int i = 0; i < securityAddIns.Count; i++)
            {
                addInVoterData = securityAddIns[i].GetAddInVoterData(_voterAnswers.Voters[0].VoterId);
                if (addInVoterData != null)
                {
                    addInsReport.Append(Environment.NewLine + securityAddIns[i].Description + Environment.NewLine + "<br />" + "-----------------------------------------" + Environment.NewLine + "<br />");
                    for (int j = 0; j < addInVoterData.Count; j++)
                    {
                        addInsReport.Append(addInVoterData.GetKey(i) + " : " + addInVoterData[i] + Environment.NewLine + "<br />");
                    }
                }
            }

            return(addInsReport.ToString());
        }