예제 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string title     = Request.Form["title1"];
            string address   = Request.Form["address"];
            string openModel = Request.Form["openModel"];
            string width     = Request.Form["width"];
            string height    = Request.Form["height"];
            string params1   = Request.Form["Params"];
            string note      = Request.Form["note"];
            string useMember = Request.Form["UseMember"];
            string type      = Request.Form["type"];

            bool   isAdd  = false;
            string oldXML = string.Empty;

            if (appLibrary == null)
            {
                isAdd         = true;
                appLibrary    = new MyCreek.Data.Model.AppLibrary();
                appLibrary.ID = Guid.NewGuid();
            }
            else
            {
                oldXML = appLibrary.Serialize();
            }
            appLibrary.Address  = address.Trim();
            appLibrary.Height   = height.ToIntOrNull();
            appLibrary.Note     = note;
            appLibrary.OpenMode = openModel.ToInt();
            appLibrary.Params   = params1;
            appLibrary.Title    = title;
            appLibrary.Type     = type.ToGuid();
            appLibrary.Width    = width.ToIntOrNull();

            if (!useMember.IsNullOrEmpty())
            {
                appLibrary.UseMember = useMember;
            }
            else
            {
                appLibrary.UseMember = null;
            }
            if (isAdd)
            {
                bappLibrary.Add(appLibrary);
                MyCreek.Platform.Log.Add("添加了应用程序库", appLibrary.Serialize(), MyCreek.Platform.Log.Types.角色应用);
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true);
            }
            else
            {
                bappLibrary.Update(appLibrary);
                MyCreek.Platform.Log.Add("修改了应用程序库", "", MyCreek.Platform.Log.Types.角色应用, oldXML, appLibrary.Serialize());
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('修改成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true);
            }
            bappLibrary.UpdateUseMemberCache(appLibrary.ID);
            bappLibrary.ClearCache();
            new MyCreek.Platform.RoleApp().ClearAllDataTableCache();
        }
예제 #2
0
        public ActionResult Edit(FormCollection collection)
        {
            string editID = Request.QueryString["id"];
            string type   = Request.QueryString["typeid"];

            MyCreek.Platform.AppLibrary   bappLibrary = new MyCreek.Platform.AppLibrary();
            MyCreek.Data.Model.AppLibrary appLibrary  = null;
            if (editID.IsGuid())
            {
                appLibrary = bappLibrary.Get(editID.ToGuid());
            }
            bool   isAdd  = !editID.IsGuid();
            string oldXML = string.Empty;

            if (appLibrary == null)
            {
                appLibrary          = new MyCreek.Data.Model.AppLibrary();
                appLibrary.ID       = Guid.NewGuid();
                ViewBag.TypeOptions = new MyCreek.Platform.AppLibrary().GetTypeOptions(type);
                ViewBag.OpenOptions = new MyCreek.Platform.Dictionary().GetOptionsByCode("appopenmodel", value: "");
            }
            else
            {
                oldXML = appLibrary.Serialize();
                ViewBag.TypeOptions = new MyCreek.Platform.AppLibrary().GetTypeOptions(appLibrary.Type.ToString());
                ViewBag.OpenOptions = new MyCreek.Platform.Dictionary().GetOptionsByCode("appopenmodel", value: appLibrary.OpenMode.ToString());
            }

            if (collection != null)
            {
                string title     = collection["title"];
                string address   = collection["address"];
                string openModel = collection["openModel"];
                string width     = collection["width"];
                string height    = collection["height"];
                string params1   = collection["Params"];
                string note      = collection["note"];
                string useMember = collection["UseMember"];
                type = collection["type"];

                appLibrary.Address  = address.Trim();
                appLibrary.Height   = height.ToIntOrNull();
                appLibrary.Note     = note;
                appLibrary.OpenMode = openModel.ToInt();
                appLibrary.Params   = params1;
                appLibrary.Title    = title;
                appLibrary.Type     = type.ToGuid();
                appLibrary.Width    = width.ToIntOrNull();

                if (!useMember.IsNullOrEmpty())
                {
                    appLibrary.UseMember = useMember;
                }
                else
                {
                    appLibrary.UseMember = null;
                }

                if (isAdd)
                {
                    bappLibrary.Add(appLibrary);
                    MyCreek.Platform.Log.Add("添加了应用程序库", appLibrary.Serialize(), MyCreek.Platform.Log.Types.角色应用);
                    ViewBag.Script = "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                else
                {
                    bappLibrary.Update(appLibrary);
                    MyCreek.Platform.Log.Add("修改了应用程序库", "", MyCreek.Platform.Log.Types.角色应用, oldXML, appLibrary.Serialize());
                    ViewBag.Script = "alert('修改成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                bappLibrary.UpdateUseMemberCache(appLibrary.ID);
                bappLibrary.ClearCache();
                new MyCreek.Platform.RoleApp().ClearAllDataTableCache();
            }
            return(View(appLibrary));
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string html = context.Request["html"];
            string name = context.Request["name"];
            string att  = context.Request["att"];
            string id   = context.Request["id"];

            Guid gid;

            if (!id.IsGuid(out gid) || name.IsNullOrEmpty() || att.IsNullOrEmpty() || html.IsNullOrEmpty())
            {
                context.Response.Write("参数错误!");
                return;
            }
            MyCreek.Platform.WorkFlowForm WFF = new MyCreek.Platform.WorkFlowForm();

            MyCreek.Data.Model.WorkFlowForm wff = WFF.Get(gid);
            if (wff == null)
            {
                context.Response.Write("未找到表单!");
                return;
            }

            string fileName = id + ".aspx";

            System.Text.StringBuilder serverScript = new System.Text.StringBuilder("<%@ Page Language=\"C#\"%>\r\n<%\r\n");
            var attrJSON = LitJson.JsonMapper.ToObject(att);

            serverScript.Append("\tstring FlowID = Request.QueryString[\"flowid\"];\r\n");
            serverScript.Append("\tstring StepID = Request.QueryString[\"stepid\"];\r\n");
            serverScript.Append("\tstring GroupID = Request.QueryString[\"groupid\"];\r\n");
            serverScript.Append("\tstring TaskID = Request.QueryString[\"taskid\"];\r\n");
            serverScript.Append("\tstring InstanceID = Request.QueryString[\"instanceid\"];\r\n");
            serverScript.Append("\tstring DisplayModel = Request.QueryString[\"display\"] ?? \"0\";\r\n");
            serverScript.AppendFormat("\tstring DBConnID = \"{0}\";\r\n", attrJSON["dbconn"].ToString());
            serverScript.AppendFormat("\tstring DBTable = \"{0}\";\r\n", attrJSON["dbtable"].ToString());
            serverScript.AppendFormat("\tstring DBTablePK = \"{0}\";\r\n", attrJSON["dbtablepk"].ToString());
            serverScript.AppendFormat("\tstring DBTableTitle = \"{0}\";\r\n", attrJSON["dbtabletitle"].ToString());
            serverScript.Append("if(InstanceID.IsNullOrEmpty()){InstanceID = Request.QueryString[\"instanceid1\"];}");

            serverScript.Append("\tMyCreek.Platform.Dictionary BDictionary = new MyCreek.Platform.Dictionary();\r\n");
            serverScript.Append("\tMyCreek.Platform.WorkFlow BWorkFlow = new MyCreek.Platform.WorkFlow();\r\n");
            serverScript.Append("\tMyCreek.Platform.WorkFlowTask BWorkFlowTask = new MyCreek.Platform.WorkFlowTask();\r\n");
            serverScript.Append("\tstring fieldStatus = BWorkFlow.GetFieldStatus(FlowID, StepID);\r\n");
            serverScript.Append("\tLitJson.JsonData initData = BWorkFlow.GetFormData(DBConnID, DBTable, DBTablePK, InstanceID, fieldStatus);\r\n");
            serverScript.Append("\tstring TaskTitle = BWorkFlow.GetFromFieldData(initData, DBTable, DBTableTitle);\r\n");

            serverScript.Append("%>\r\n");
            serverScript.Append("<link href=\"Scripts/Forms/flowform.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n");
            serverScript.Append("<script src=\"Scripts/Forms/common.js\" type=\"text/javascript\" ></script>\r\n");

            if (attrJSON.ContainsKey("hasEditor") && "1" == attrJSON["hasEditor"].ToString())
            {
                serverScript.Append("<script src=\"../../Scripts/Ueditor/ueditor.config.js\" type=\"text/javascript\" ></script>\r\n");
                serverScript.Append("<script src=\"../../Scripts/Ueditor/ueditor.all.min.js\" type=\"text/javascript\" ></script>\r\n");
                serverScript.Append("<script src=\"../../Scripts/Ueditor/lang/zh-cn/zh-cn.js\" type=\"text/javascript\" ></script>\r\n");
                serverScript.Append("<input type=\"hidden\" id=\"Form_HasUEditor\" name=\"Form_HasUEditor\" value=\"1\" />\r\n");
            }
            string validatePropType = attrJSON.ContainsKey("validatealerttype") ? attrJSON["validatealerttype"].ToString() : "2";

            serverScript.Append("<input type=\"hidden\" id=\"Form_ValidateAlertType\" name=\"Form_ValidateAlertType\" value=\"" + validatePropType + "\" />\r\n");
            if (attrJSON.ContainsKey("autotitle") && attrJSON["autotitle"].ToString().ToLower() == "true")
            {
                serverScript.AppendFormat("<input type=\"hidden\" id=\"{0}\" name=\"{0}\" value=\"{1}\" />\r\n",
                                          string.Concat(attrJSON["dbtable"].ToString(), ".", attrJSON["dbtabletitle"].ToString()),
                                          "<%=TaskTitle.IsNullOrEmpty() ? BWorkFlow.GetAutoTaskTitle(FlowID, StepID, Request.QueryString[\"groupid\"]) : TaskTitle %>"
                                          );
            }
            serverScript.AppendFormat("<input type=\"hidden\" id=\"Form_TitleField\" name=\"Form_TitleField\" value=\"{0}\" />\r\n", string.Concat(attrJSON["dbtable"].ToString(), ".", attrJSON["dbtabletitle"].ToString()));
            //serverScript.AppendFormat("<input type=\"hidden\" id=\"Form_Name\" name=\"Form_Name\" value=\"{0}\" />\r\n", attrJSON["name"].ToString());
            serverScript.AppendFormat("<input type=\"hidden\" id=\"Form_DBConnID\" name=\"Form_DBConnID\" value=\"{0}\" />\r\n", attrJSON["dbconn"].ToString());
            serverScript.AppendFormat("<input type=\"hidden\" id=\"Form_DBTable\" name=\"Form_DBTable\" value=\"{0}\" />\r\n", attrJSON["dbtable"].ToString());
            serverScript.AppendFormat("<input type=\"hidden\" id=\"Form_DBTablePk\" name=\"Form_DBTablePk\" value=\"{0}\" />\r\n", attrJSON["dbtablepk"].ToString());
            serverScript.AppendFormat("<input type=\"hidden\" id=\"Form_DBTableTitle\" name=\"Form_DBTableTitle\" value=\"{0}\" />\r\n", attrJSON["dbtabletitle"].ToString());
            serverScript.AppendFormat("<input type=\"hidden\" id=\"Form_AutoSaveData\" name=\"Form_AutoSaveData\" value=\"{0}\" />\r\n", "1");
            serverScript.Append("<script type=\"text/javascript\">\r\n");
            serverScript.Append("\tvar initData = <%=BWorkFlow.GetFormDataJsonString(initData)%>;\r\n");
            serverScript.Append("\tvar fieldStatus = \"1\"==\"<%=Request.QueryString[\"isreadonly\"]%>\"? {} : <%=fieldStatus%>;\r\n");
            serverScript.Append("\tvar displayModel = '<%=DisplayModel%>';\r\n");
            serverScript.Append("\t$(window).load(function (){\r\n");
            serverScript.AppendFormat("\t\tformrun.initData(initData, \"{0}\", fieldStatus, displayModel);\r\n", attrJSON["dbtable"].ToString());
            serverScript.Append("\t});\r\n");
            serverScript.Append("</script>\r\n");


            string file = context.Server.MapPath("Forms/" + fileName);

            System.IO.Stream stream = System.IO.File.Open(file, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
            stream.SetLength(0);

            StreamWriter sw = new StreamWriter(stream, System.Text.Encoding.UTF8);

            sw.Write(serverScript.ToString());
            sw.Write(context.Server.HtmlDecode(html));

            sw.Close();
            stream.Close();


            string attr    = wff.Attribute;
            string appType = LitJson.JsonMapper.ToObject(attr)["apptype"].ToString();

            MyCreek.Platform.AppLibrary App = new MyCreek.Platform.AppLibrary();
            var  app   = App.GetByCode(id);
            bool isAdd = false;

            if (app == null)
            {
                app      = new MyCreek.Data.Model.AppLibrary();
                app.ID   = Guid.NewGuid();
                app.Code = id;
                isAdd    = true;
            }
            app.Address  = "/Platform/WorkFlowFormDesigner/Forms/" + fileName;
            app.Note     = "流程表单";
            app.OpenMode = 0;
            app.Params   = "";
            app.Title    = name.Trim();
            app.Type     = appType.IsGuid() ? appType.ToGuid() : new MyCreek.Platform.Dictionary().GetIDByCode("FormTypes");
            if (isAdd)
            {
                App.Add(app);
            }
            else
            {
                App.Update(app);
            }

            MyCreek.Platform.Log.Add("发布了流程表单", app.Serialize() + "内容:" + html, MyCreek.Platform.Log.Types.流程相关);
            wff.Status = 1;
            WFF.Update(wff);
            context.Response.Write("发布成功!");
        }