public string Install(string id) { string result = "failure"; AppLibrary appLibrary = BLLFactory <AppLibraryBLL> .Instance.FindByID(id); var exist = BLLFactory <MenuBLL> .Instance.FindByID(id); var menu = new Menu(); menu.ID = appLibrary.ID; menu.PID = "00000000-0000-0000-0000-000000000200"; menu.Name = appLibrary.Title; menu.WebIcon = "icon-blank"; menu.Url = "/" + appLibrary.Address + "?" + appLibrary.Params; menu.SystemTypeID = "00000000-0000-0000-0000-000000000100"; menu.Deleted = false; if (exist != null) { BLLFactory <MenuBLL> .Instance.Update(menu); } else { BLLFactory <MenuBLL> .Instance.Insert(menu); } result = "success"; //menu.ID= //var menu=BLLFactory<MenuBLL>.Instance return(result); }
/// <summary> /// 得到角色应用刷新JSON /// </summary> /// <returns></returns> public string GetRoleAppRefreshJsonString(string roleID, string userID, string refreshID, string rootDir = "") { RoleApp roleApp = new RoadFlow.Platform.RoleApp(); UsersApp UsersApp = new Platform.UsersApp(); AppLibrary Applibary = new AppLibrary(); DataTable roleAppDt = roleApp.GetAllDataTableFromCache(); DataTable appDt1 = CloneDataTable(roleAppDt); UsersApp.AppendUserApps(userID, appDt1); var dv = appDt1.DefaultView; dv.RowFilter = string.Format("PID='{0}'", refreshID); dv.Sort = "Sort"; var appDt = dv.ToTable(); if (appDt.Rows.Count == 0) { return("[]"); } int count = appDt.Rows.Count; System.Text.StringBuilder json = new System.Text.StringBuilder("[", count * 100); foreach (DataRow dr in appDt.Rows) { if (!dr["UseMember"].ToString().IsNullOrEmpty() && dr["AppID"].ToString().IsGuid() && !Applibary.GetUseMemberCache(dr["AppID"].ToString().ToGuid()).Contains(userID)) { continue; } json.Append("{"); json.AppendFormat("\"id\":\"{0}\",", dr["ID"].ToString()); json.AppendFormat("\"title\":\"{0}\",", dr["Title"].ToString().Trim()); json.AppendFormat("\"ico\":\"{0}\",", dr["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + dr["Ico"].ToString()); json.AppendFormat("\"link\":\"{0}\",", getAddress(dr)); json.AppendFormat("\"model\":\"{0}\",", dr["OpenMode"].ToString()); json.AppendFormat("\"width\":\"{0}\",", dr["Width"].ToString()); json.AppendFormat("\"height\":\"{0}\",", dr["Height"].ToString()); json.AppendFormat("\"hasChilds\":\"{0}\",", appDt1.Select(string.Format("PID='{0}'", dr["id"].ToString())).Length > 0 ? "1" : "0"); json.AppendFormat("\"childs\":["); json.Append("]"); json.Append("}"); if (dr["ID"].ToString() != appDt.Rows[appDt.Rows.Count - 1]["ID"].ToString()) { json.Append(","); } } json.Append("]"); return(json.ToString()); }
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 Edit(FormCollection collection) { string editID = Request.QueryString["id"]; string type = Request.QueryString["typeid"]; Next.WorkFlow.BLL.AppLibraryBLL bappLibrary = new Next.WorkFlow.BLL.AppLibraryBLL(); AppLibrary appLibrary = null; if (editID.IsGuid()) { appLibrary = bappLibrary.FindByID(editID.ToGuid()); } bool isAdd = !editID.IsGuid(); string oldXML = string.Empty; if (appLibrary == null) { appLibrary = new Next.WorkFlow.Entity.AppLibrary(); appLibrary.ID = Guid.NewGuid().ToString(); ViewBag.TypeOptions = new Next.WorkFlow.BLL.AppLibraryBLL().GetTypeOptions(type); ViewBag.OpenOptions = new Next.WorkFlow.BLL.DictBLL().GetOptionsByCode("appopenmodel", value: ""); } else { oldXML = appLibrary.Serialize(); ViewBag.TypeOptions = new Next.WorkFlow.BLL.AppLibraryBLL().GetTypeOptions(appLibrary.Type.ToString()); ViewBag.OpenOptions = new Next.WorkFlow.BLL.DictBLL().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.Insert(appLibrary); //RoadFlow.Platform.Log.Add("添加了应用程序库", appLibrary.Serialize(), RoadFlow.Platform.Log.Types.角色应用); ViewBag.Script = "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();"; } else { bappLibrary.Update(appLibrary); //RoadFlow.Platform.Log.Add("修改了应用程序库", "", RoadFlow.Platform.Log.Types.角色应用, oldXML, appLibrary.Serialize()); ViewBag.Script = "alert('修改成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();"; } //bappLibrary.UpdateUseMemberCache(appLibrary.ID); //bappLibrary.ClearCache(); //new RoadFlow.Platform.RoleApp().ClearAllDataTableCache(); } return(View(appLibrary)); }
/// <summary> /// 得到角色应用JSON /// </summary> /// <param name="roleID"></param> /// <returns></returns> public string GetRoleAppJsonString(string roleID, string userID, string rootDir = "") { RoleApp RoleApp = new RoleApp(); UsersApp UsersApp = new Platform.UsersApp(); AppLibrary Applibary = new AppLibrary(); System.Data.DataTable roleAppDt = RoleApp.GetAllDataTableFromCache(); System.Data.DataTable appDt = CloneDataTable(roleAppDt); UsersApp.AppendUserApps(userID, appDt); if (appDt.Rows.Count == 0) { return("[]"); } var root = appDt.Select(string.Format("PID='{0}' AND RoleID='{1}'", string.Empty.ToString(), roleID)); if (root.Length == 0) { return("[]"); } var apps = appDt.Select(string.Format("PID='{0}'", root[0]["ID"].ToString())); System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000); System.Data.DataRow rootDr = root[0]; json.Append("{"); json.AppendFormat("\"id\":\"{0}\",", rootDr["ID"].ToString()); json.AppendFormat("\"title\":\"{0}\",", rootDr["Title"].ToString().Trim()); json.AppendFormat("\"ico\":\"{0}\",", rootDr["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + rootDr["Ico"].ToString()); json.AppendFormat("\"link\":\"{0}\",", getAddress(rootDr).ToString()); json.AppendFormat("\"model\":\"{0}\",", rootDr["OpenMode"].ToString()); json.AppendFormat("\"width\":\"{0}\",", rootDr["Width"].ToString()); json.AppendFormat("\"height\":\"{0}\",", rootDr["Height"].ToString()); json.AppendFormat("\"hasChilds\":\"{0}\",", apps.Length > 0 ? "1" : "0"); json.AppendFormat("\"childs\":["); for (int i = 0; i < apps.Length; i++) { DataRow dr = apps[i]; if (!dr["UseMember"].ToString().IsNullOrEmpty() && dr["AppID"].ToString().IsGuid() && !Applibary.GetUseMemberCache(dr["AppID"].ToString().ToGuid()).Contains(userID)) { continue; } var childs = appDt.Select("PID='" + dr["ID"].ToString() + "'"); json.Append("{"); json.AppendFormat("\"id\":\"{0}\",", dr["ID"].ToString()); json.AppendFormat("\"title\":\"{0}\",", dr["Title"].ToString()); json.AppendFormat("\"ico\":\"{0}\",", dr["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + dr["Ico"].ToString()); json.AppendFormat("\"link\":\"{0}\",", getAddress(dr)); json.AppendFormat("\"model\":\"{0}\",", dr["OpenMode"].ToString()); json.AppendFormat("\"width\":\"{0}\",", dr["Width"].ToString()); json.AppendFormat("\"height\":\"{0}\",", dr["Height"].ToString()); json.AppendFormat("\"hasChilds\":\"{0}\",", childs.Length > 0 ? "1" : "0"); json.AppendFormat("\"childs\":["); /* DataRow[] apps1 = appDt.Select(string.Format("PID='{0}'", dr["ID"].ToString())); * for (int j = 0; j < apps1.Length; j++) * { * DataRow dr1 = apps1[j]; * var childs1 = appDt.Select("PID='" + dr1["ID"].ToString() + "'"); * json.Append("{"); * json.AppendFormat("\"id\":\"{0}\",", dr1["ID"]); * json.AppendFormat("\"title\":\"{0}\",", dr1["Title"]); * json.AppendFormat("\"ico\":\"{0}\",", dr1["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + dr1["Ico"]); * json.AppendFormat("\"link\":\"{0}\",", getAddress(dr1)); * json.AppendFormat("\"model\":\"{0}\",", dr1["OpenMode"]); * json.AppendFormat("\"width\":\"{0}\",", dr1["Width"]); * json.AppendFormat("\"height\":\"{0}\",", dr1["Height"]); * json.AppendFormat("\"hasChilds\":\"{0}\",", childs1.Length > 0 ? "1" : "0"); * json.AppendFormat("\"childs\":["); * json.Append("]"); * json.Append("}"); * if (j < apps1.Length - 1) * { * json.Append(","); * } * }*/ json.Append("]"); json.Append("}"); if (dr["ID"].ToString() != apps[apps.Length - 1]["ID"].ToString()) { json.Append(","); } } json.Append("]"); json.Append("}"); json.Append("]"); return(json.ToString()); }