/// <summary>
        /// Binds the pipeline actions section for a specific Sms Pipeline.
        /// </summary>
        /// <param name="smsPipeline">The SMS pipeline.</param>
        private void BindActions(SmsPipeline smsPipeline)
        {
            if (smsPipeline == null)
            {
                divSmsActionsPanel.Visible = false;
                return;
            }

            var actions = smsPipeline.SmsActions
                          .OrderBy(a => a.Order)
                          .ThenBy(a => a.Id)
                          .ToList()
                          .Select(a => new
            {
                a.Id,
                a.Name,
                a.SmsActionComponentEntityTypeId,
                a.IsActive,
                a.ContinueAfterProcessing,
                Component = SmsActionContainer.GetComponent(EntityTypeCache.Get(a.SmsActionComponentEntityTypeId).Name)
            })
                          .ToList();

            if (actions.Any())
            {
                olActions.RemoveCssClass("drag-container-empty");
            }
            else
            {
                olActions.AddCssClass("drag-container-empty");
            }

            rptrActions.DataSource = actions;
            rptrActions.DataBind();
        }
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var smsPipelineId      = GetSmsPipelineId();
            var rockContext        = new RockContext();
            var smsPipelineService = new SmsPipelineService(rockContext);

            SmsPipeline smsPipeline = null;

            if (smsPipelineId == null || smsPipelineId == 0)
            {
                smsPipeline = new SmsPipeline();
                smsPipelineService.Add(smsPipeline);
            }
            else
            {
                smsPipeline = GetSmsPipeline(smsPipelineId.Value, smsPipelineService);
            }

            if (smsPipeline == null)
            {
                return;
            }

            smsPipeline.Name        = tbPipelineName.Text;
            smsPipeline.IsActive    = cbPipelineIsActive.Checked;
            smsPipeline.Description = tbPipelineDescription.Text;

            rockContext.SaveChanges();

            var qryParams = new Dictionary <string, string>();

            qryParams[PageParameterKey.EntityId] = smsPipeline.Id.ToString();

            NavigateToPage(RockPage.Guid, qryParams);
        }
        /// <summary>
        /// Binds the pipeline detail read only section.
        /// </summary>
        /// <param name="smsPipeline">The SMS pipeline.</param>
        private void BindReadOnlyDetails(SmsPipeline smsPipeline)
        {
            divSmsActionsPanel.Visible = true;
            divEditDetails.Visible     = false;

            pdAuditDetails.Visible = true;
            pdAuditDetails.SetEntity(smsPipeline, ResolveRockUrl("~"));

            hlInactive.Visible = !smsPipeline.IsActive;

            lSmsPipelineDescription.Text = smsPipeline.Description;
            lSmsName.Text = smsPipeline.Name;

            var smsMedium    = new Sms();
            var smsTransport = smsMedium.Transport as ISmsPipelineWebhook;

            lWebhookUrl.Visible = false;
            if (smsTransport != null)
            {
                var    globalAttributes = GlobalAttributesCache.Get();
                string publicAppRoot    = globalAttributes.GetValue("PublicApplicationRoot");
                lWebhookUrl.Text    = string.Format("{0}{1}?{2}={3}", publicAppRoot, smsTransport.SmsPipelineWebhookPath, PageParameterKey.EntityId, GetSmsPipelineId());
                lWebhookUrl.Visible = true;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindComponents();

                int?        smsPipelineId = GetSmsPipelineId();
                SmsPipeline smsPipeline   = null;

                if (smsPipelineId == null || smsPipelineId == 0)
                {
                    BindEditDetails(null);
                }
                else
                {
                    var smsPipelineService = new SmsPipelineService(new RockContext());
                    smsPipeline = GetSmsPipeline(smsPipelineId.Value, smsPipelineService, "SmsActions");
                    BindReadOnlyDetails(smsPipeline);
                }

                BindActions(smsPipeline);

                //
                // This must come after BindComponents so that the SmsActionContainer will
                // have been initialized already and any new attributes created.
                //
                var smsActionEntityTypeId = EntityTypeCache.Get(typeof(SmsAction)).Id;
                var attributes            = AttributeCache.All()
                                            .Where(a => a.EntityTypeId == smsActionEntityTypeId)
                                            .Where(a => a.Key == "Order" || a.Key == "Active");
                avcAttributes.ExcludedAttributes    = attributes.ToArray();
                avcAttributes.ExcludedCategoryNames = new string[] { SmsActionComponent.BaseAttributeCategories.Filters };
                avcFilters.IncludedCategoryNames    = new string[] { SmsActionComponent.BaseAttributeCategories.Filters };
            }
            else
            {
                if (Request["__EVENTTARGET"].ToStringSafe() == lbDragCommand.ClientID)
                {
                    ProcessDragEvents();
                }

                if (hfIsTestingDrawerOpen.Value.AsBoolean())
                {
                    divTestingDrawer.Style.Add("display", null);
                }
                else
                {
                    divTestingDrawer.Style.Add("display", "none");
                }
            }

            base.OnLoad(e);
        }
        /// <summary>
        /// Binds the pipeline actions section.
        /// </summary>
        private void BindActions()
        {
            var smsPipelineId = GetSmsPipelineId();

            if (smsPipelineId == null || smsPipelineId == 0)
            {
                return;
            }

            var         smsPipelineService = new SmsPipelineService(new RockContext());
            SmsPipeline smsPipeline        = GetSmsPipeline(smsPipelineId.Value, smsPipelineService, "SmsActions");

            BindActions(smsPipeline);
        }
Esempio n. 6
0
        /// <summary>
        /// Binds the pipeline detail read only section.
        /// </summary>
        /// <param name="smsPipeline">The SMS pipeline.</param>
        private void BindReadOnlyDetails(SmsPipeline smsPipeline)
        {
            divSmsActionsPanel.Visible = true;
            divEditDetails.Visible     = false;

            pdAuditDetails.Visible = true;
            pdAuditDetails.SetEntity(smsPipeline, ResolveRockUrl("~"));

            hlInactive.Visible = !smsPipeline.IsActive;

            lSmsPipelineDescription.Text = smsPipeline.Description;
            lSmsName.Text = smsPipeline.Name;

            var    globalAttributes = GlobalAttributesCache.Get();
            string publicAppRoot    = globalAttributes.GetValue("PublicApplicationRoot").EnsureTrailingForwardslash();

            lWebhookUrl.Text = string.Format("{0}{1}?{2}={3}", publicAppRoot, "Webhooks/TwilioSms.ashx", PageParameterKey.EntityId, GetSmsPipelineId());
        }
        /// <summary>
        /// Binds the pipeline detail edit section.
        /// </summary>
        /// <param name="smsPipeline">The SMS pipeline.</param>
        private void BindEditDetails(SmsPipeline smsPipeline)
        {
            divReadOnlyDetails.Visible = false;
            divSmsActionsPanel.Visible = false;

            if (smsPipeline == null)
            {
                cbPipelineIsActive.Checked = true;
                pdAuditDetails.Visible     = false;
                return;
            }

            pdAuditDetails.Visible = true;
            pdAuditDetails.SetEntity(smsPipeline, ResolveRockUrl("~"));
            divEditDetails.Visible = true;
            hlInactive.Visible     = true;

            tbPipelineName.Text        = smsPipeline.Name;
            cbPipelineIsActive.Checked = smsPipeline.IsActive;
            tbPipelineDescription.Text = smsPipeline.Description;
        }