public ActionResult AddApp(FormCollection collection) { AppLibraryBLL bappLibrary = new AppLibraryBLL(); RoleAppBLL broleApp = new RoleAppBLL(); RoleApp roleApp = null; string id = Request.QueryString["id"]; if (collection != null) { roleApp = broleApp.FindByID(id.ToGuid()); if (!Request.Form["Save"].IsNullOrEmpty()) { string name = Request.Form["Name"]; string type = Request.Form["Type"]; string appid = Request.Form["AppID"]; string params1 = Request.Form["Params"]; string ico = Request.Form["Ico"]; RoleApp roleApp1 = new RoleApp(); roleApp1.ID = Guid.NewGuid().ToString(); roleApp1.PID = id.ToGuid(); roleApp1.RoleID = roleApp.RoleID; roleApp1.Title = name.Trim(); roleApp1.PID = roleApp.ID; roleApp1.Sort = broleApp.GetMaxSort(roleApp.ID); roleApp1.Type = 0; if (appid.IsGuid()) { roleApp1.AppID = appid.ToGuid(); } else { roleApp1.AppID = null; } roleApp1.Params = params1.IsNullOrEmpty() ? null : params1.Trim(); if (!ico.IsNullOrEmpty()) { roleApp1.Ico = ico; } broleApp.Insert(roleApp1); //broleApp.ClearAllDataTableCache(); //RoadFlow.Platform.Log.Add("添加了应用模板", roleApp1.Serialize(), RoadFlow.Platform.Log.Types.角色应用); string refreshID = id; ViewBag.Script = "alert('添加成功');parent.frames[0].reLoad('" + refreshID + "');"; } } ViewBag.AppTypesOptions = bappLibrary.GetTypeOptions(); return(View()); }
public string Publish() { string html = Request["html"]; string name = Request["name"]; string att = Request["att"]; string id = Request["id"]; string gid; if (!id.IsGuid(out gid) || name.IsNullOrEmpty() || att.IsNullOrEmpty() || html.IsNullOrEmpty()) { return("参数错误!"); } WorkFlowFormBLL WFF = new WorkFlowFormBLL(); WorkFlowForm wff = WFF.FindByID(gid); if (wff == null) { return("未找到表单!"); } string fileName = id + ".cshtml"; System.Text.StringBuilder serverScript = new System.Text.StringBuilder("@using Next.WorkFlow.Utility\r\n"); serverScript.Append("@{\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("\tNext.WorkFlow.BLL.DictBLL BDictionary = new Next.WorkFlow.BLL.DictBLL();\r\n"); serverScript.Append("\tNext.WorkFlow.BLL.WorkFlowInfoBLL BWorkFlow = new Next.WorkFlow.BLL.WorkFlowInfoBLL();\r\n"); serverScript.Append("\tNext.WorkFlow.BLL.WorkFlowTaskBLL BWorkFlowTask = new Next.WorkFlow.BLL.WorkFlowTaskBLL();\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=\"~/Assets/WorkFlow/Scripts/FlowRun/Forms/flowform.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n"); serverScript.Append("<script src=\"~/Assets/WorkFlow/Scripts/FlowRun/Forms/common.js\" type=\"text/javascript\" ></script>\r\n"); if (attrJSON.ContainsKey("hasEditor") && "1" == attrJSON["hasEditor"].ToString()) { serverScript.Append("<script src=\"~/Assets/WorkFlow/Scripts/Ueditor/ueditor.config.js\" type=\"text/javascript\" ></script>\r\n"); serverScript.Append("<script src=\"~/Assets/WorkFlow/Scripts/Ueditor/ueditor.all.min.js\" type=\"text/javascript\" ></script>\r\n"); serverScript.Append("<script src=\"~/Assets/WorkFlow/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 = \"1\"==\"@Request.QueryString[\"isreadonly\"]\" ? {} : @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("~/Areas/Workflow/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()); string temp = Server.HtmlDecode(html); string content = HtmlCodeFormat.Format(temp); sw.Write(content); sw.Close(); stream.Close(); string attr = wff.Attribute; string appType = LitJson.JsonMapper.ToObject(attr)["apptype"].ToString(); AppLibraryBLL App = new AppLibraryBLL(); var app = App.GetByCode(id); bool isAdd = false; if (app == null) { app = new AppLibrary(); app.ID = Guid.NewGuid().ToString(); app.Code = id; isAdd = true; } app.Address = "/Areas/WorkFlow/Views/WorkFlowFormDesigner/Forms/" + fileName; app.Note = "流程表单"; app.OpenMode = 0; app.Params = ""; app.Title = name.Trim(); app.Type = appType.IsGuid() ? appType : new DictBLL().GetIDByCode("FormTypes"); if (isAdd) { App.Insert(app); } else { App.Update(app); } //RoadFlow.Platform.Log.Add("发布了流程表单", app.Serialize() + "内容:" + html, RoadFlow.Platform.Log.Types.流程相关); wff.Status = 1; WFF.Update(wff); return("发布成功!"); }
public ActionResult Body(FormCollection collection) { AppLibraryBLL bappLibrary = new AppLibraryBLL(); RoleAppBLL broleApp = new RoleAppBLL(); RoleApp roleApp = null; string id = Request.QueryString["id"]; string name = string.Empty; string type = string.Empty; string appid = string.Empty; string params1 = string.Empty; string ico = string.Empty; string appID; if (id.IsGuid(out appID)) { roleApp = broleApp.FindByID(appID); } if (!Request.Form["Save"].IsNullOrEmpty()) { name = Request.Form["Name"]; type = Request.Form["Type"]; appid = Request.Form["AppID"]; params1 = Request.Form["Params"]; ico = Request.Form["Ico"]; string oldXML = roleApp.Serialize(); roleApp.Title = name.Trim(); if (appid.IsGuid()) { roleApp.AppID = appid.ToGuid(); } else { roleApp.AppID = null; } roleApp.Params = params1.IsNullOrEmpty() ? null : params1.Trim(); if (!ico.IsNullOrEmpty()) { roleApp.Ico = ico; } else { roleApp.Ico = null; } broleApp.Update(roleApp); //broleApp.ClearAllDataTableCache(); //RoadFlow.Platform.Log.Add("修改了应用模板", "", RoadFlow.Platform.Log.Types.角色应用, oldXML, roleApp.Serialize()); string refreshID = roleApp.PID == string.Empty ? roleApp.ID.ToString() : roleApp.PID.ToString(); ViewBag.Script = "parent.frames[0].reLoad('" + refreshID + "');alert('保存成功!');"; } if (!Request.Form["Delete"].IsNullOrEmpty()) { int i = broleApp.DeleteAndAllChilds(roleApp.ID); //broleApp.ClearAllDataTableCache(); //RoadFlow.Platform.Log.Add("删除了模板及其所有下级共" + i.ToString() + "项", roleApp.Serialize(), RoadFlow.Platform.Log.Types.角色应用); string refreshID = roleApp.PID == string.Empty ? roleApp.ID.ToString() : roleApp.PID.ToString(); ViewBag.Script = "parent.frames[0].reLoad('" + refreshID + "');window.location='Body?id=" + refreshID + "&appid=" + Request.QueryString["appid"] + "&tabid=" + Request.QueryString["tabid"] + "';"; } if (roleApp != null) // && roleApp.AppID.HasValue) { var app = new AppLibraryBLL().FindByID(roleApp.AppID); //.Value); if (app != null) { type = app.Type.ToString(); } } ViewBag.AppTypesOptions = bappLibrary.GetTypeOptions(type); ViewBag.AppID = roleApp.AppID.ToString(); return(View(roleApp)); }