private void BuildAddInList()
        {
            WebSecurityAddInCollection _securityAddIns;
            Control adminControl;
            Table   addInContainer = new Table();

            addInContainer.Width = Unit.Percentage(100);
            Table addInTable = new Table();

            // moved to css files:
            //			addInTable.CellSpacing = 2;
            //			addInTable.CellPadding = 4;
            addInTable.CssClass = "questionBuilder";
            Style controlStyle = new Style();

            controlStyle.CssClass = "addinsLayout";
            _securityAddIns       = WebSecurityAddInFactory.CreateWebSecurityAddInCollection(new SecurityAddIns().GetWebSecurityAddIns(SurveyId), ViewState, null);

            if (_securityAddIns.Count == 0)
            {
                SecurityOptionsPlaceHolder.Visible = false;
                // No Addins
                addInTable.Rows.Add(BuildAddInOptionsRow(null, _securityAddIns.Count));
            }
            else
            {
                SecurityOptionsPlaceHolder.Visible = true;
                for (int i = 0; i < _securityAddIns.Count; i++)
                {
                    addInTable.Rows.Add(BuildAddInOptionsRow(_securityAddIns[i], _securityAddIns.Count));
                    adminControl = _securityAddIns[i].GetAdministrationInterface(controlStyle);
                    if (adminControl != null)
                    {
                        addInTable.Rows.Add(BuildRow(adminControl));
                    }
                    else
                    {
                        addInTable.Rows.Add(BuildRow(new LiteralControl(((PageBase)Page).GetPageResource("AddInAdminNotAvailableMessage"))));
                    }
                    addInContainer.Rows.Add(BuildRow(addInTable));

                    AddInListPlaceHolder.Controls.Add(addInContainer);

                    // Creates a new page
                    addInContainer       = new Table();
                    addInContainer.Width = Unit.Percentage(100);
                    addInTable           = new Table();
                    // moved to css file
                    //					addInTable.CellSpacing = 2;
                    //					addInTable.CellPadding = 4;
                    addInTable.CssClass = "questionBuilder";
                }
            }

            addInContainer.Rows.Add(BuildRow(addInTable));
            AddInListPlaceHolder.Controls.Add(addInContainer);
        }
Example #2
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") : "";
            }
        }
Example #3
0
        private void AddAddinButton_Click(object sender, System.EventArgs e)
        {
            new SecurityAddIn().AddSecurityAddInToSurvey(SurveyId,
                                                         int.Parse(SecurityAddInDropDownList.SelectedValue), _addInOrder);

            WebSecurityAddInData.WebSecurityAddInsRow addInRow =
                (WebSecurityAddInData.WebSecurityAddInsRow) new SecurityAddIns().GetAddInById(SurveyId, int.Parse(SecurityAddInDropDownList.SelectedValue)).WebSecurityAddIns.Rows[0];
            try
            {
                IWebSecurityAddIn addedAddin = WebSecurityAddInFactory.Create(addInRow, ViewState, null);
                addedAddin.InitOnSurveyAddition();
            }
            catch (Exception)
            {
                new SecurityAddIn().DeleteWebSecurityAddIn(SurveyId, int.Parse(SecurityAddInDropDownList.SelectedValue));
                throw;
            }
            UINavigator.NavigateToSurveySecurity(SurveyId, MenuIndex);
        }
        /// <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 #5
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());
        }