Пример #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            string Template = ModuleContext.Settings["template"] as string;

            if (!Page.IsPostBack)
            {
                InitForm(Template);
            }
            else
            {
                if (Request.QueryString["result"] == "submit")
                {
                    /*
                     * int id = int.Parse(Request.QueryString["result"]);
                     * OpenFormController ctrl =new OpenFormController();
                     * var content = ctrl.GetContent(id, ModuleId);
                     */
                    string json = hfOpenForm.Value;
                    phForm.Visible   = false;
                    phResult.Visible = true;
                    string  formData = "";
                    dynamic data     = OpenFormUtils.GenerateFormData(json, out formData);

                    string      jsonSettings = Settings["data"] as string;
                    SettingsDTO settings     = JsonConvert.DeserializeObject <SettingsDTO>(jsonSettings);
                    if (settings != null && settings.Settings != null)
                    {
                        HandlebarsEngine hbs = new HandlebarsEngine();
                        lMessage.Text  = hbs.Execute(settings.Settings.Message, data);
                        lTracking.Text = settings.Settings.Tracking;
                    }
                }
            }
        }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            string Template = ModuleContext.Settings["template"] as string;

            if (!Page.IsPostBack)
            {
                InitForm(Template);
            }
            else
            {
                if (Request.QueryString["result"] == "submit")
                {
                    /*
                     * int id = int.Parse(Request.QueryString["result"]);
                     * OpenFormController ctrl =new OpenFormController();
                     * var content = ctrl.GetContent(id, ModuleId);
                     */
                    string json = Request["__OPENFORM" + ModuleId];
                    phForm.Visible   = false;
                    phResult.Visible = true;
                    string  formData = "";
                    dynamic data     = OpenFormUtils.GenerateFormData(json, out formData);

                    string      jsonSettings = Settings["data"] as string;
                    SettingsDTO settings     = JsonConvert.DeserializeObject <SettingsDTO>(jsonSettings);
                    if (settings != null && settings.Settings != null)
                    {
                        if (!string.IsNullOrEmpty(settings.Settings.Message))
                        {
                            HandlebarsEngine hbs = new HandlebarsEngine();
                            lMessage.Text = hbs.Execute(settings.Settings.Message, data);
                        }
                        lTracking.Text = settings.Settings.Tracking;
                    }
                    var razorscript = new FileUri(Path.GetDirectoryName(Template), "aftersubmit.cshtml");
                    if (razorscript.FileExists)
                    {
                        data.FeedBackMessage = lMessage.Text;
                        data.IPAddress       = Request.UserHostAddress;
                        lMessage.Text        = ExecuteRazor(razorscript, data);
                    }
                }
            }
        }