public string Save()
        {
            string str1 = this.Request["html"];
            string str2 = this.Request["name"];
            string str3 = this.Request["att"];
            string str4 = this.Request["id"];
            string str5 = this.Request["type"];
            string str6 = this.Request["subtable"];
            string str7 = this.Request["formEvents"];

            if (str2.IsNullOrEmpty())
            {
                return("表单名称不能为空!");
            }
            Guid test;

            if (!str4.IsGuid(out test))
            {
                return("表单ID无效!");
            }
            RoadFlow.Platform.WorkFlowForm   workFlowForm = new RoadFlow.Platform.WorkFlowForm();
            RoadFlow.Data.Model.WorkFlowForm model        = workFlowForm.Get(test);
            bool   flag   = false;
            string oldXML = string.Empty;

            if (model == null)
            {
                model                = new RoadFlow.Data.Model.WorkFlowForm();
                model.ID             = test;
                model.CreateUserID   = RoadFlow.Platform.Users.CurrentUserID;
                model.CreateUserName = RoadFlow.Platform.Users.CurrentUserName;
                model.CreateTime     = DateTimeNew.Now;
                model.Status         = 0;
                flag = true;
            }
            else
            {
                oldXML = model.Serialize();
            }
            model.Attribute      = str3;
            model.Html           = str1;
            model.LastModifyTime = DateTimeNew.Now;
            model.Name           = str2;
            model.Type           = str5.ToGuid();
            model.SubTableJson   = str6;
            model.EventsJson     = str7;
            if (flag)
            {
                workFlowForm.Add(model);
                RoadFlow.Platform.Log.Add("添加了流程表单", model.Serialize(), RoadFlow.Platform.Log.Types.流程相关, "", "", (RoadFlow.Data.Model.Users)null);
            }
            else
            {
                workFlowForm.Update(model);
                RoadFlow.Platform.Log.Add("修改了流程表单", "", RoadFlow.Platform.Log.Types.流程相关, oldXML, model.Serialize(), (RoadFlow.Data.Model.Users)null);
            }
            return("保存成功!");
        }
Exemple #2
0
        public string Publish()
        {
            string html = Request["html"];
            string name = Request["name"];
            string att  = Request["att"];
            string id   = Request["id"];

            Guid gid;

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

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

            string fileName = id + ".cshtml";

            System.Text.StringBuilder serverScript = new System.Text.StringBuilder("@{\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("\tRoadFlow.Platform.Dictionary BDictionary = new RoadFlow.Platform.Dictionary();\r\n");
            serverScript.Append("\tRoadFlow.Platform.WorkFlow BWorkFlow = new RoadFlow.Platform.WorkFlow();\r\n");
            serverScript.Append("\tRoadFlow.Platform.WorkFlowTask BWorkFlowTask = new RoadFlow.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/FlowRun/Forms/flowform.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n");
            serverScript.Append("<script src=\"~/Scripts/FlowRun/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 = @Html.Raw(BWorkFlow.GetFormDataJsonString(initData));\r\n");
            serverScript.Append("\tvar fieldStatus = @Html.Raw(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 = Server.MapPath("~/Views/WorkFlowFormDesigner/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());
            html = HttpUtility.HtmlDecode(html);
            html = html.Replace("+", "%2B");
            sw.Write(HttpUtility.UrlDecode(html));
            sw.Close();
            stream.Close();


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

            RoadFlow.Platform.AppLibraryBLL App = new RoadFlow.Platform.AppLibraryBLL();
            var  app   = App.GetByCode(id);
            bool isAdd = false;

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

            RoadFlow.Platform.Log.Add("发布了流程表单", app.Serialize() + "内容:" + html, RoadFlow.Platform.Log.Types.流程相关);
            wff.Status = 1;
            WFF.Update(wff);
            return("发布成功!");
        }
Exemple #3
0
        public string Save()
        {
            string html       = Request["html"];
            string name       = Request["name"];
            string att        = Request["att"];
            string id         = Request["id"];
            string type       = Request["type"];
            string subtable   = Request["subtable"];
            string formEvents = Request["formEvents"];

            if (name.IsNullOrEmpty())
            {
                return("表单名称不能为空!");
            }

            Guid formID;

            if (!id.IsGuid(out formID))
            {
                return("表单ID无效!");
            }

            RoadFlow.Platform.WorkFlowForm   WFF = new RoadFlow.Platform.WorkFlowForm();
            RoadFlow.Data.Model.WorkFlowForm wff = WFF.Get(formID);
            bool   isAdd  = false;
            string oldXML = string.Empty;

            if (wff == null)
            {
                wff                = new RoadFlow.Data.Model.WorkFlowForm();
                wff.ID             = formID;
                wff.Type           = type.Convert <Guid>();
                wff.CreateUserID   = RoadFlow.Platform.UsersBLL.CurrentUserID;
                wff.CreateUserName = RoadFlow.Platform.UsersBLL.CurrentUserName;
                wff.CreateTime     = DateTime.Now;
                wff.Status         = 0;
                isAdd              = true;
            }
            else
            {
                oldXML = wff.Serialize();
            }

            wff.Attribute      = att;
            wff.Html           = html;
            wff.LastModifyTime = DateTime.Now;
            wff.Name           = name;
            wff.SubTableJson   = subtable;
            wff.EventsJson     = formEvents;

            if (isAdd)
            {
                WFF.Add(wff);
                RoadFlow.Platform.Log.Add("添加了流程表单", wff.Serialize(), RoadFlow.Platform.Log.Types.流程相关);
            }
            else
            {
                WFF.Update(wff);
                RoadFlow.Platform.Log.Add("修改了流程表单", "", RoadFlow.Platform.Log.Types.流程相关, oldXML, wff.Serialize());
            }
            return("保存成功!");
        }
Exemple #4
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"];
            string type       = context.Request["type"];
            string subtable   = context.Request["subtable"];
            string formEvents = context.Request["formEvents"];

            if (name.IsNullOrEmpty())
            {
                context.Response.Write("表单名称不能为空!");
                return;
            }

            Guid formID;

            if (!id.IsGuid(out formID))
            {
                context.Response.Write("表单ID无效!");
                return;
            }

            RoadFlow.Platform.WorkFlowForm   WFF = new RoadFlow.Platform.WorkFlowForm();
            RoadFlow.Data.Model.WorkFlowForm wff = WFF.Get(formID);
            bool   isAdd  = false;
            string oldXML = string.Empty;

            if (wff == null)
            {
                wff                = new RoadFlow.Data.Model.WorkFlowForm();
                wff.ID             = formID;
                wff.CreateUserID   = RoadFlow.Platform.Users.CurrentUserID;
                wff.CreateUserName = RoadFlow.Platform.Users.CurrentUserName;
                wff.CreateTime     = RoadFlow.Utility.DateTimeNew.Now;
                wff.Status         = 0;
                isAdd              = true;
            }
            else
            {
                oldXML = wff.Serialize();
            }

            wff.Type           = type.ToGuid();
            wff.Attribute      = att;
            wff.Html           = html;
            wff.LastModifyTime = RoadFlow.Utility.DateTimeNew.Now;
            wff.Name           = name;
            wff.SubTableJson   = subtable;
            wff.EventsJson     = formEvents;

            if (isAdd)
            {
                WFF.Add(wff);
                RoadFlow.Platform.Log.Add("添加了流程表单", wff.Serialize(), RoadFlow.Platform.Log.Types.流程相关);
            }
            else
            {
                WFF.Update(wff);
                RoadFlow.Platform.Log.Add("修改了流程表单", "", RoadFlow.Platform.Log.Types.流程相关, oldXML, wff.Serialize());
            }
            context.Response.Write("保存成功!");
        }
        public string Publish()
        {
            string s    = this.Request["html"];
            string str1 = this.Request["name"];
            string str2 = this.Request["att"];
            string str3 = this.Request["id"];
            string str4 = this.Request["formats"];
            Guid   test;

            if (!str3.IsGuid(out test) || str1.IsNullOrEmpty() || str2.IsNullOrEmpty())
            {
                return("参数错误!");
            }
            RoadFlow.Platform.WorkFlowForm   workFlowForm = new RoadFlow.Platform.WorkFlowForm();
            RoadFlow.Data.Model.WorkFlowForm model1       = workFlowForm.Get(test);
            if (model1 == null)
            {
                return("请先保存表单再发布!");
            }
            string        str5          = str3 + ".cshtml";
            StringBuilder stringBuilder = new StringBuilder("@{\r\n");
            JsonData      jsonData      = JsonMapper.ToObject(str2);

            stringBuilder.Append("\tstring FlowID = Request.QueryString[\"flowid\"];\r\n");
            stringBuilder.Append("\tstring StepID = Request.QueryString[\"stepid\"];\r\n");
            stringBuilder.Append("\tstring GroupID = Request.QueryString[\"groupid\"];\r\n");
            stringBuilder.Append("\tstring TaskID = Request.QueryString[\"taskid\"];\r\n");
            stringBuilder.Append("\tstring InstanceID = Request.QueryString[\"instanceid\"];\r\n");
            stringBuilder.Append("\tstring DisplayModel = Request.QueryString[\"display\"] ?? \"0\";\r\n");
            stringBuilder.AppendFormat("\tstring DBConnID = \"{0}\";\r\n", (object)jsonData["dbconn"].ToString());
            stringBuilder.AppendFormat("\tstring DBTable = \"{0}\";\r\n", (object)jsonData["dbtable"].ToString());
            stringBuilder.AppendFormat("\tstring DBTablePK = \"{0}\";\r\n", (object)jsonData["dbtablepk"].ToString());
            stringBuilder.AppendFormat("\tstring DBTableTitle = \"{0}\";\r\n", (object)jsonData["dbtabletitle"].ToString());
            stringBuilder.Append("\tif(InstanceID.IsNullOrEmpty()){InstanceID = Request.QueryString[\"instanceid1\"];}\r\n");
            stringBuilder.Append("\tRoadFlow.Platform.Dictionary BDictionary = new RoadFlow.Platform.Dictionary();\r\n");
            stringBuilder.Append("\tRoadFlow.Platform.WorkFlow BWorkFlow = new RoadFlow.Platform.WorkFlow();\r\n");
            stringBuilder.Append("\tRoadFlow.Platform.WorkFlowTask BWorkFlowTask = new RoadFlow.Platform.WorkFlowTask();\r\n");
            stringBuilder.Append("\tstring fieldStatus = BWorkFlow.GetFieldStatus(FlowID, StepID);\r\n");
            stringBuilder.Append("\tLitJson.JsonData initData = BWorkFlow.GetFormData(DBConnID, DBTable, DBTablePK, InstanceID, fieldStatus, \"" + str4 + "\");\r\n");
            stringBuilder.Append("\tstring TaskTitle = BWorkFlow.GetFromFieldData(initData, DBTable, DBTableTitle);\r\n");
            stringBuilder.Append("}\r\n");
            stringBuilder.Append("<link href=\"~/Scripts/FlowRun/Forms/flowform.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n");
            stringBuilder.Append("<script src=\"~/Scripts/FlowRun/Forms/common.js\" type=\"text/javascript\" ></script>\r\n");
            if (jsonData.ContainsKey("hasEditor") && "1" == jsonData["hasEditor"].ToString())
            {
                stringBuilder.Append("<script src=\"~/Scripts/Ueditor/ueditor.config.js\" type=\"text/javascript\" ></script>\r\n");
                stringBuilder.Append("<script src=\"~/Scripts/Ueditor/ueditor.all.min.js\" type=\"text/javascript\" ></script>\r\n");
                stringBuilder.Append("<script src=\"~/Scripts/Ueditor/lang/zh-cn/zh-cn.js\" type=\"text/javascript\" ></script>\r\n");
                stringBuilder.Append("<input type=\"hidden\" id=\"Form_HasUEditor\" name=\"Form_HasUEditor\" value=\"1\" />\r\n");
            }
            string str6 = jsonData.ContainsKey("validatealerttype") ? jsonData["validatealerttype"].ToString() : "2";

            stringBuilder.Append("<input type=\"hidden\" id=\"Form_ValidateAlertType\" name=\"Form_ValidateAlertType\" value=\"" + str6 + "\" />\r\n");
            if (jsonData.ContainsKey("autotitle") && jsonData["autotitle"].ToString().ToLower() == "true")
            {
                stringBuilder.AppendFormat("<input type=\"hidden\" id=\"{0}\" name=\"{0}\" value=\"{1}\" />\r\n", (object)(jsonData["dbtable"].ToString() + "." + jsonData["dbtabletitle"].ToString()), (object)"@(TaskTitle.IsNullOrEmpty() ? BWorkFlow.GetAutoTaskTitle(FlowID, StepID, Request.QueryString[\"groupid\"]) : TaskTitle)");
            }
            stringBuilder.AppendFormat("<input type=\"hidden\" id=\"Form_TitleField\" name=\"Form_TitleField\" value=\"{0}\" />\r\n", (object)(jsonData["dbtable"].ToString() + "." + jsonData["dbtabletitle"].ToString()));
            stringBuilder.AppendFormat("<input type=\"hidden\" id=\"Form_DBConnID\" name=\"Form_DBConnID\" value=\"{0}\" />\r\n", (object)jsonData["dbconn"].ToString());
            stringBuilder.AppendFormat("<input type=\"hidden\" id=\"Form_DBTable\" name=\"Form_DBTable\" value=\"{0}\" />\r\n", (object)jsonData["dbtable"].ToString());
            stringBuilder.AppendFormat("<input type=\"hidden\" id=\"Form_DBTablePk\" name=\"Form_DBTablePk\" value=\"{0}\" />\r\n", (object)jsonData["dbtablepk"].ToString());
            stringBuilder.AppendFormat("<input type=\"hidden\" id=\"Form_DBTableTitle\" name=\"Form_DBTableTitle\" value=\"{0}\" />\r\n", (object)jsonData["dbtabletitle"].ToString());
            stringBuilder.AppendFormat("<input type=\"hidden\" id=\"Form_AutoSaveData\" name=\"Form_AutoSaveData\" value=\"{0}\" />\r\n", (object)"1");
            stringBuilder.AppendFormat("<textarea id=\"Form_DBTableTitleExpression\" name=\"Form_DBTableTitleExpression\" style=\"display:none;width:0;height:0;\">{0}</textarea>\r\n", jsonData.ContainsKey("dbtabletitle1") ? (object)jsonData["dbtabletitle1"].ToString() : (object)"");
            stringBuilder.Append("<script type=\"text/javascript\">\r\n");
            stringBuilder.Append("\tvar initData = @Html.Raw(BWorkFlow.GetFormDataJsonString(initData));\r\n");
            stringBuilder.Append("\tvar fieldStatus = \"1\"==\"@Request.QueryString[\"isreadonly\"]\" ? {} : @Html.Raw(fieldStatus);\r\n");
            stringBuilder.Append("\tvar displayModel = '@DisplayModel';\r\n");
            stringBuilder.Append("\t$(window).load(function (){\r\n");
            stringBuilder.AppendFormat("\t\tformrun.initData(initData, \"{0}\", fieldStatus, displayModel);\r\n", (object)jsonData["dbtable"].ToString());
            stringBuilder.Append("\t});\r\n");
            stringBuilder.Append("</script>\r\n");
            FileStream fileStream = File.Open(this.Server.MapPath("~/Views/WorkFlowFormDesigner/Forms/" + str5), FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);

            fileStream.SetLength(0L);
            StreamWriter streamWriter = new StreamWriter((Stream)fileStream, Encoding.UTF8);

            streamWriter.Write(stringBuilder.ToString());
            streamWriter.Write(this.Server.HtmlDecode(s));
            streamWriter.Close();
            fileStream.Close();
            string str7 = JsonMapper.ToObject(model1.Attribute)["apptype"].ToString();

            RoadFlow.Platform.AppLibrary   appLibrary = new RoadFlow.Platform.AppLibrary();
            RoadFlow.Data.Model.AppLibrary model2     = appLibrary.GetByCode(str3, true);
            bool flag = false;

            if (model2 == null)
            {
                model2      = new RoadFlow.Data.Model.AppLibrary();
                model2.ID   = Guid.NewGuid();
                model2.Code = str3;
                flag        = true;
            }
            model2.Address  = "/Views/WorkFlowFormDesigner/Forms/" + str5;
            model2.Note     = "流程表单";
            model2.OpenMode = 0;
            model2.Params   = "";
            model2.Title    = str1.Trim();
            model2.Type     = str7.IsGuid() ? str7.ToGuid() : new RoadFlow.Platform.Dictionary().GetIDByCode("FormTypes");
            if (flag)
            {
                appLibrary.Add(model2);
            }
            else
            {
                appLibrary.Update(model2);
            }
            RoadFlow.Platform.Log.Add("发布了流程表单", model2.Serialize() + "内容:" + s, RoadFlow.Platform.Log.Types.流程相关, "", "", (RoadFlow.Data.Model.Users)null);
            model1.Status = 1;
            workFlowForm.Update(model1);
            return("发布成功!");
        }