Beispiel #1
0
        public ActionResult PyScriptForm(string name)
        {
            try
            {
                var script = FetchPyScriptForm(name);

                if (!script.HasValue())
                    return Message("no script named " + name);
                var pe = new PythonEvents(Util.Host);
                foreach (var key in Request.QueryString.AllKeys)
                    pe.DictionaryAdd(key, Request.QueryString[key]);
                pe.DictionaryAdd("pyscript", name);
                pe.HttpMethod = "get";
                pe.RunScript(script);
                return View(pe);
            }
            catch (Exception ex)
            {
                return RedirectShowError(ex.Message);
            }
        }
Beispiel #2
0
        public ActionResult PyScriptForm()
        {
            try
            {
                var pe = new PythonEvents(Util.Host);
                foreach (var key in Request.Form.AllKeys)
                    pe.DictionaryAdd(key, Request.Form[key]);
                pe.HttpMethod = "post";

                var script = FetchPyScriptForm(pe.Dictionary("pyscript"));
                return Content(pe.RunScript(script));
            }
            catch (Exception ex)
            {
                return RedirectShowError(ex.Message);
            }
        }
Beispiel #3
0
        public ActionResult PyScript(string name, string p1, string p2, string v1, string v2)
        {
            try
            {
                var script = DbUtil.Db.ContentOfTypePythonScript(name);
                if (!script.HasValue())
                    return Message("no script named " + name);

                if (script.Contains("model.Form"))
                    return Redirect("/PyScriptForm/" + name);
                script = script.Replace("@P1", p1 ?? "NULL")
                    .Replace("@P2", p2 ?? "NULL")
                    .Replace("V1", v1 ?? "None")
                    .Replace("V2", v2 ?? "None");

                var pe = new PythonEvents(Util.Host);

                foreach (var key in Request.QueryString.AllKeys)
                {
                    pe.DictionaryAdd(key, Request.QueryString[key]);
                }

                pe.RunScript(script);

                return View(pe);
            }
            catch (Exception ex)
            {
                return RedirectShowError(ex.Message);
            }
        }