Exemplo n.º 1
0
 private void DoSelect(FormProxy sourceProxy)
 {
     if (rule.Select != null)
     {
         // Select makes no changes to the form
         rule.Select.Method(sourceProxy);
     }
 }
        public GatedFormViewModel(ICaptchaGatedFormSettings captchaGatedFormSettings, DataSourceItemProxy dataSourceItemProxy)
        {
            DataSourceItemProxy      = dataSourceItemProxy;
            CaptchaGatedFormSettings = captchaGatedFormSettings;
            FormProxy = new FormProxy(DataSourceItemProxy.FormMarkup, dataSourceItemProxy.TestSettings.TestingForceInvalidFormMarkup);

            AddCaptchaGateNodesToFormProxy();
        }
Exemplo n.º 3
0
 private void DoUpdate(FormProxy sourceProxy, FormProxy updateProxy)
 {
     if (rule.Update != null)
     {
         // Copy of the source form will be chnaged
         var targetForm = sourceProxy.Form.CopyForm(false);
         updateProxy.WithForm(targetForm);
         if (rule.Update.Method(sourceProxy, updateProxy))
         {
             engine.ActivePlugin.AddForm(targetForm);
             Updated++;
         }
     }
 }
Exemplo n.º 4
0
        private void DoInserts(FormProxy sourceProxy)
        {
            if (rule.Inserts != null)
            {
                foreach (var insert in rule.Inserts)
                {
                    Form targetForm;
                    if (insert.Copy && sourceProxy != null && sourceProxy.Form.FormKind == insert.InsertedFormKind)
                    {
                        // Copy form data if  source is the same as target (and source is not null)
                        targetForm = sourceProxy.Form.CopyForm(true);
                    }
                    else
                    {
                        // Create new otherwise
                        targetForm = engine.Context.CreateForm(insert.InsertedFormKind);
                    }

                    var targetProxy = engine.ProxyProvider.CreateFormProxy(targetForm, ProxyMode.Target);
                    if (insert.Method(sourceProxy, targetProxy))
                    {
                        if (insert.InsertedFormId != 0)
                        {
                            // Set explicit Form ID
                            targetForm.FormId = insert.InsertedFormId;
                        }

                        engine.ActivePlugin.AddForm(targetForm);
                        Created++;

                        // Tag the new form now that it has a Form ID
                        // if it has been tagged during its creation
                        foreach (var text in targetProxy.DelayedTags)
                        {
                            engine.Tags.Tag(text, targetForm.FormId);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
 private void DoUpdate(FormProxy sourceProxy, FormProxy updateProxy)
 {
     if (rule.Update != null)
     {
         // Copy of the source form will be chnaged
         var targetForm = sourceProxy.Form.CopyForm(false);
         updateProxy.WithForm(targetForm);
         if (rule.Update.Method(sourceProxy, updateProxy))
         {
             engine.ActivePlugin.AddForm(targetForm);
             Updated++;
         }
     }
 }
Exemplo n.º 6
0
 private void DoSelect(FormProxy sourceProxy)
 {
     if (rule.Select != null)
     {
         // Select makes no changes to the form
         rule.Select.Method(sourceProxy);
     }
 }
Exemplo n.º 7
0
        private void DoInserts(FormProxy sourceProxy)
        {
            if (rule.Inserts != null)
            {
                foreach (var insert in rule.Inserts)
                {
                    Form targetForm;
                    if (insert.Copy && sourceProxy != null && sourceProxy.Form.FormKind == insert.InsertedFormKind)
                    {
                        // Copy form data if  source is the same as target (and source is not null)
                        targetForm = sourceProxy.Form.CopyForm(true);
                    }
                    else
                    {
                        // Create new otherwise
                        targetForm = engine.Context.CreateForm(insert.InsertedFormKind);
                    }

                    var targetProxy = engine.ProxyProvider.CreateFormProxy(targetForm, ProxyMode.Target);
                    if (insert.Method(sourceProxy, targetProxy))
                    {
                        if (insert.InsertedFormId != 0)
                        {
                            // Set explicit Form ID
                            targetForm.FormId = insert.InsertedFormId;
                        }

                        engine.ActivePlugin.AddForm(targetForm);
                        Created++;

                        // Tag the new form now that it has a Form ID
                        // if it has been tagged during its creation
                        foreach (var text in targetProxy.DelayedTags)
                        {
                            engine.Tags.Tag(text, targetForm.FormId);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
 private void DoActions(FormProxy sourceProxy, FormProxy updateProxy)
 {
     DoSelect(sourceProxy);
     DoUpdate(sourceProxy, updateProxy);
     DoInserts(sourceProxy);
 }
Exemplo n.º 9
0
 private void DoActions(FormProxy sourceProxy, FormProxy updateProxy)
 {
     DoSelect(sourceProxy);
     DoUpdate(sourceProxy, updateProxy);
     DoInserts(sourceProxy);
 }
Exemplo n.º 10
0
        private async Task <ActionResult> GetActionForCaptchaPass(FormRelayer formCollectionHelper, GatedFormViewModel viewModel, FormProxy formProxy)
        {
            ActionResult toReturn = null;

            if (viewModel != null)
            {
                if (viewModel.FormProxy != null)
                {
                    formCollectionHelper.CleanForm();

                    if (formProxy.OriginalMethod.Equals(FormsConstants.FormsHtml.Attributes.Post, StringComparison.OrdinalIgnoreCase))
                    {
                        var response = await formCollectionHelper.SubmitFormPostAsync(formProxy.OriginalAction);

                        if (response.IsSuccessStatusCode)
                        {
                            GatedContentLogger.Log.Debug("Setting redirect to: " + viewModel.DataSourceItemProxy.OnFormSubmitSuccess);
                            toReturn = new RedirectResult(viewModel.DataSourceItemProxy.OnFormSubmitSuccess);
                        }
                        else
                        {
                            GatedContentLogger.Error(response.ToString(), this);
                            toReturn = new RedirectResult(viewModel.DataSourceItemProxy.OnFormSubmitFailUrlStr);
                        }
                    }
                    else
                    {
                        GatedContentLogger.Error("Unhandled submit method", this);
                    }
                }
                else
                {
                    Sitecore.Diagnostics.Log.Error("Null formProxy", this);
                }
            }
            return(toReturn);
        }
Exemplo n.º 11
0
 public string CreateProxy(FormProxy formProxy)
 {
     formProxy.SourceEmpNo = base.EmpNo;
     return(new BaseServices <FormProxy>().IsAddEntity(formProxy) ? "success" : "error");
 }