Esempio n. 1
0
        private void UpdateForm()
        {
            var formClassInfo = DataClassInfoProvider.GetDataClassInfo(FORM_CLASS_NAME);

            if (formClassInfo == null)
            {
                return;
            }

            var form = new FormInfo(formClassInfo.ClassFormDefinition);

            if (form.FieldExists(FORM_FIELD_NAME))
            {
                return;
            }

            // Update ClassFormDefinition
            var field = CreateFormField();

            form.AddFormItem(field);
            formClassInfo.ClassFormDefinition = form.GetXmlDefinition();
            formClassInfo.Update();

            // Update Form builder JSON
            IFormBuilderConfigurationSerializer formBuilderConfigurationSerializer = Service.Resolve <IFormBuilderConfigurationSerializer>();
            var contactUsForm            = BizFormInfoProvider.GetBizFormInfo(FORM_NAME, mSite.SiteID);
            var formBuilderConfiguration = formBuilderConfigurationSerializer.Deserialize(contactUsForm.FormBuilderLayout);

            formBuilderConfiguration.EditableAreas.LastOrDefault()
            .Sections.LastOrDefault()
            .Zones.LastOrDefault()
            .FormComponents
            .Add(new FormComponentConfiguration {
                Properties = new ConsentAgreementProperties()
                {
                    Guid = field.Guid
                }
            });
            contactUsForm.FormBuilderLayout = formBuilderConfigurationSerializer.Serialize(formBuilderConfiguration, true);
            contactUsForm.Update();
        }
Esempio n. 2
0
        public ActionResult GenerateDataProtectionDemo([FromServices] IFormBuilderConfigurationSerializer formBuilderConfigurationSerializer)
        {
            if (!IsAdmin())
            {
                return(UnauthorizedView());
            }

            var site = siteService.CurrentSite;

            new TrackingConsentGenerator(site).Generate();
            new FormConsentGenerator(site, formBuilderConfigurationSerializer).Generate(FORM_NAME, FORM_FIELD_NAME);
            new FormContactGroupGenerator().Generate();

            EnableDataProtectionSamples(site);

            var model = new GeneratorIndexViewModel
            {
                DisplaySuccessMessage = true
            };

            return(View("Index", model));
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="site">Site the form consent will be generated for</param>
 public FormConsentGenerator(ISiteInfo site, IFormBuilderConfigurationSerializer formBuilderConfigurationSerializer)
 {
     mSite = site;
     mFormBuilderConfigurationSerializer = formBuilderConfigurationSerializer;
 }