Пример #1
0
        /// <summary>
        /// Handles the ItemDataBound event of the rQuestions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rQuestions_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var assessmentResponseRow       = e.Item.DataItem as AssessmentResponse;
            RockRadioButtonList rblQuestion = e.Item.FindControl("rblQuestion") as RockRadioButtonList;

            if (assessmentResponseRow.Code.EndsWith("N"))
            {
                rblQuestion.DataSource = _negativeOption;
            }
            else
            {
                rblQuestion.DataSource = _positiveOption;
            }

            rblQuestion.DataTextField  = "Value";
            rblQuestion.DataValueField = "Key";
            rblQuestion.DataBind();

            rblQuestion.Label = assessmentResponseRow.Question;

            if (assessmentResponseRow != null && assessmentResponseRow.Response.HasValue)
            {
                rblQuestion.SetValue(assessmentResponseRow.Response);
            }
            else
            {
                rblQuestion.SetValue(string.Empty);
            }
        }
Пример #2
0
        /// <summary>
        /// Handles the ItemDataBound event of the rQuestions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rQuestions_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var assessmentResponseRow       = e.Item.DataItem as AssessmentResponse;
            RockRadioButtonList rblQuestion = e.Item.FindControl("rblQuestion") as RockRadioButtonList;

            if (assessmentResponseRow != null && assessmentResponseRow.Response.HasValue)
            {
                rblQuestion.SetValue(assessmentResponseRow.Response);
            }
            else
            {
                rblQuestion.SetValue(string.Empty);
            }
        }
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl)
        {
            RockDropDownList ddlInteractionChannel = new RockDropDownList();

            ddlInteractionChannel.ID                    = parentControl.ID + "_ddlInteractionChannel";
            ddlInteractionChannel.Label                 = "Interaction Channel";
            ddlInteractionChannel.Required              = true;
            ddlInteractionChannel.AutoPostBack          = true;
            ddlInteractionChannel.SelectedIndexChanged += ddlInteractionChannel_SelectedIndexChanged;
            parentControl.Controls.Add(ddlInteractionChannel);

            var interactionChannelService = new InteractionChannelService(new RockContext());
            var noteTypes = interactionChannelService.Queryable().OrderBy(a => a.Name).Select(a => new
            {
                a.Id,
                a.Name
            }).ToList();

            ddlInteractionChannel.Items.Clear();
            ddlInteractionChannel.Items.Add(new ListItem());
            ddlInteractionChannel.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray());

            int?selectedInteractionChannelId = parentControl.Page.Request.Params[ddlInteractionChannel.UniqueID].AsIntegerOrNull();

            ddlInteractionChannel.SetValue(selectedInteractionChannelId);


            RockDropDownList ddlInteractionComponent = new RockDropDownList();

            ddlInteractionComponent.ID    = parentControl.ID + "_ddlInteractionComponent";
            ddlInteractionComponent.Label = "Interaction Component";
            ddlInteractionComponent.EnhanceForLongLists = true;
            parentControl.Controls.Add(ddlInteractionComponent);

            PopulateInteractionComponent(selectedInteractionChannelId, ddlInteractionComponent);
            RockTextBox tbOperation = new RockTextBox();

            tbOperation.Label = "Operation";
            tbOperation.ID    = parentControl.ID + "_tbOperation";
            parentControl.Controls.Add(tbOperation);


            RockRadioButtonList rblSelectionMode = new RockRadioButtonList();

            rblSelectionMode.ID    = parentControl.ID + "rblSelectionMode";
            rblSelectionMode.Label = "Selection Mode";
            rblSelectionMode.BindToEnum <FirstLastInteraction>();
            rblSelectionMode.SetValue(FirstLastInteraction.First.ConvertToInt());
            parentControl.Controls.Add(rblSelectionMode);

            return(new System.Web.UI.Control[] { ddlInteractionChannel, ddlInteractionComponent, tbOperation, rblSelectionMode });
        }
Пример #4
0
        /// <summary>
        /// Handles the ItemDataBound event of the rQuestions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rQuestions_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var assessmentResponseRow       = e.Item.DataItem as AssessmentResponse;
            RockRadioButtonList rblQuestion = e.Item.FindControl("rblQuestion") as RockRadioButtonList;

            if (assessmentResponseRow.OptionType == MotivatorService.OptionType.Frequency)
            {
                rblQuestion.DataSource = MotivatorService.Frequency_Option;
            }
            else
            {
                rblQuestion.DataSource = MotivatorService.Agreement_Option;
            }

            rblQuestion.DataTextField = "Name";

            if (assessmentResponseRow.Code.EndsWith("N"))
            {
                rblQuestion.DataValueField = "Negative";
            }
            else
            {
                rblQuestion.DataValueField = "Positive";
            }

            rblQuestion.DataBind();

            rblQuestion.Label = assessmentResponseRow.Question;

            if (assessmentResponseRow != null && assessmentResponseRow.Response.HasValue)
            {
                rblQuestion.SetValue(assessmentResponseRow.Response);
            }
            else
            {
                rblQuestion.SetValue(string.Empty);
            }
        }
Пример #5
0
        /// <summary>
        /// Sets the selection.
        /// </summary>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection(System.Web.UI.Control[] controls, string selection)
        {
            RockDropDownList    locationTypeList           = controls[0] as RockDropDownList;
            RockRadioButtonList addressPartRadioButtonList = controls[1] as RockRadioButtonList;

            string[] values = selection.Split('|');

            if (values.Length >= 1)
            {
                locationTypeList.SetValue(values[0]);
            }

            if (values.Length >= 2)
            {
                addressPartRadioButtonList.SetValue(values[1]);
            }
        }
Пример #6
0
        /// <summary>
        /// Sets control values from a communication record.
        /// </summary>
        /// <param name="communication">The communication.</param>
        public override void SetFromCommunication(CommunicationDetails communication)
        {
            EnsureChildControls();
            tbTitle.Text   = communication.PushTitle;
            tbMessage.Text = communication.PushMessage;

            iupPushImage.BinaryFileId = communication.PushImageBinaryFileId;
            if (communication.PushOpenAction != null)
            {
                rbOpenAction.SetValue(communication.PushOpenAction.ConvertToInt().ToString());
            }

            var pushData = new PushData();

            if (communication.PushData.IsNotNullOrWhiteSpace())
            {
                pushData = Newtonsoft.Json.JsonConvert.DeserializeObject <PushData>(communication.PushData);
            }

            ddlMobileApplications.SelectedValue = null;
            htmlAdditionalDetails.Text          = null;
            if (communication.PushOpenAction == PushOpenAction.ShowDetails)
            {
                ddlMobileApplications.SelectedValue = pushData.MobileApplicationId.ToStringSafe();
                htmlAdditionalDetails.Text          = communication.PushOpenMessage;
            }

            kvlQuerystring.Value = null;
            if (communication.PushOpenAction == PushOpenAction.LinkToMobilePage)
            {
                ppMobilePage.SetValue(pushData.MobilePageId);

                if (pushData.MobilePageQueryString != null)
                {
                    kvlQuerystring.Value = pushData.MobilePageQueryString.Select(a => string.Format("{0}^{1}", a.Key, a.Value)).ToList().AsDelimited("|");
                }
            }

            urlLink.Text = null;
            if (communication.PushOpenAction == PushOpenAction.LinkToUrl)
            {
                urlLink.Text = pushData.Url;
            }
        }
        /// <summary>
        /// Sets the selection.
        /// </summary>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection(System.Web.UI.Control[] controls, string selection)
        {
            string[] selectionValues = selection.Split('|');
            if (selectionValues.Length >= 1)
            {
                Guid interactionChannelGuid = selectionValues[0].AsGuid();
                var  rockContext            = new RockContext();
                var  interactionChannel     = new InteractionChannelService(rockContext).Get(interactionChannelGuid);
                var  ddlInteractionChannel  = (controls[0] as RockDropDownList);
                ddlInteractionChannel.SetValue(interactionChannel != null ? interactionChannel.Id : ( int? )null);

                ddlInteractionChannel_SelectedIndexChanged(ddlInteractionChannel, new EventArgs());

                if (selectionValues.Length >= 2)
                {
                    var interactionComponentGuid = selectionValues[1].AsGuidOrNull();
                    if (interactionComponentGuid.HasValue)
                    {
                        RockDropDownList ddlInteractionComponent = (controls[1] as RockDropDownList);
                        var interactionComponent = new InteractionComponentService(rockContext).Get(interactionComponentGuid.Value);
                        ddlInteractionComponent.SetValue(interactionComponent != null ? interactionComponent.Id : ( int? )null);
                    }
                }

                RockTextBox tbOperation = controls[2] as RockTextBox;
                if (selectionValues.Length >= 3)
                {
                    tbOperation.Text = selectionValues[2];
                }

                RockRadioButtonList rblSelectionMode = controls[3] as RockRadioButtonList;
                if (selectionValues.Length >= 4)
                {
                    rblSelectionMode.SetValue(selectionValues[3]);
                }
            }
        }