public void TansEntitiesToGenerTree(Entities ens, string rootNo, string checkIds) { EntityMultiTree root = ens.GetEntityByKey(rootNo) as EntityMultiTree; if (root == null) { throw new Exception("@没有找到rootNo=" + rootNo + "的entity."); } appendMenus.Append("[{"); appendMenus.Append("\"id\":\"" + rootNo + "\""); appendMenus.Append(",\"text\":\"" + root.Name + "\""); //attributes BP.WF.Template.FlowFormTree formTree = root as BP.WF.Template.FlowFormTree; if (formTree != null) { string url = formTree.Url == null ? "" : formTree.Url; url = url.Replace("/", "|"); appendMenus.Append(",\"attributes\":{\"NodeType\":\"" + formTree.NodeType + "\",\"Url\":\"" + url + "\"}"); } // 增加它的子级. appendMenus.Append(",\"children\":"); AddChildren(root, ens, checkIds); appendMenus.Append(appendMenuSb); appendMenus.Append("}]"); }
public void AddChildren(EntityTree parentEn, Entities ens, string checkIds) { appendMenus.Append(appendMenuSb); appendMenuSb.Clear(); appendMenuSb.Append("["); foreach (EntityTree item in ens) { if (item.ParentNo != parentEn.No) { continue; } if (checkIds.Contains("," + item.No + ",")) { appendMenuSb.Append("{\"id\":\"" + item.No + "\",\"text\":\"" + item.Name + "\",\"checked\":true"); } else { appendMenuSb.Append("{\"id\":\"" + item.No + "\",\"text\":\"" + item.Name + "\",\"checked\":false"); } //attributes BP.WF.Template.FlowFormTree formTree = item as BP.WF.Template.FlowFormTree; if (formTree != null) { string url = formTree.Url == null ? "" : formTree.Url; string ico = "icon-tree_folder"; string treeState = "closed"; url = url.Replace("/", "|"); appendMenuSb.Append(",\"attributes\":{\"NodeType\":\"" + formTree.NodeType + "\",\"IsEdit\":\"" + formTree.IsEdit + "\",\"Url\":\"" + url + "\"}"); //图标 if (formTree.NodeType == "form") { ico = "icon-sheet"; } appendMenuSb.Append(",\"state\":\"" + treeState + "\""); appendMenuSb.Append(",iconCls:\""); appendMenuSb.Append(ico); appendMenuSb.Append("\""); } // 增加它的子级. appendMenuSb.Append(",\"children\":"); AddChildren(item, ens, checkIds); appendMenuSb.Append("},"); } if (appendMenuSb.Length > 1) { appendMenuSb = appendMenuSb.Remove(appendMenuSb.Length - 1, 1); } appendMenuSb.Append("]"); appendMenus.Append(appendMenuSb); appendMenuSb.Clear(); }
/// <summary> /// 流程表单树 /// </summary> public FlowFormTrees(string flowNo) { int i = this.Retrieve(FlowFormTreeAttr.FK_Flow, flowNo); if (i == 0) { FlowFormTree tree = new FlowFormTree(); tree.No = "100"; tree.FK_Flow = flowNo; tree.Name = "根目录"; tree.IsDir = false; tree.ParentNo = "0"; tree.Insert(); //创建一个节点. tree.DoCreateSubNode(); } }
private string GetFlowFormTree() { string flowId = getUTF8ToString("flowId"); string nodeId = getUTF8ToString("nodeId"); //add root BP.WF.Template.FlowFormTree root = new BP.WF.Template.FlowFormTree(); root.No = "01"; root.ParentNo = "0"; root.Name = "目录"; root.NodeType = "root"; appFlowFormTree.Clear(); appFlowFormTree.AddEntity(root); #region 添加表单及文件夹 //节点表单 FrmNodes frmNodes = new FrmNodes(); QueryObject qo = new QueryObject(frmNodes); qo.AddWhere(FrmNodeAttr.FK_Node, nodeId); qo.addAnd(); qo.AddWhere(FrmNodeAttr.FK_Flow, flowId); qo.addOrderBy(FrmNodeAttr.Idx); qo.DoQuery(); //文件夹 SysFormTrees formTrees = new SysFormTrees(); formTrees.RetrieveAll(SysFormTreeAttr.Name); //所有表单集合 MapDatas mds = new MapDatas(); mds.Retrieve(MapDataAttr.AppType, (int)AppType.Application); foreach (FrmNode frmNode in frmNodes) { foreach (MapData md in mds) { if (frmNode.FK_Frm != md.No) { continue; } foreach (SysFormTree formTree in formTrees) { if (md.FK_FormTree != formTree.No) { continue; } if (!appFlowFormTree.Contains("No", formTree.No)) { BP.WF.Template.FlowFormTree nodeFolder = new BP.WF.Template.FlowFormTree(); nodeFolder.No = formTree.No; nodeFolder.ParentNo = root.No; nodeFolder.Name = formTree.Name; nodeFolder.NodeType = "folder"; appFlowFormTree.AddEntity(nodeFolder); } } //检查必填项 bool IsNotNull = false; FrmFields formFields = new FrmFields(); QueryObject obj = new QueryObject(formFields); obj.AddWhere(FrmFieldAttr.FK_Node, nodeId); obj.addAnd(); obj.AddWhere(FrmFieldAttr.FK_MapData, md.No); obj.addAnd(); obj.AddWhere(FrmFieldAttr.IsNotNull, "1"); obj.DoQuery(); if (formFields != null && formFields.Count > 0) { IsNotNull = true; } BP.WF.Template.FlowFormTree nodeForm = new BP.WF.Template.FlowFormTree(); nodeForm.No = md.No; nodeForm.ParentNo = md.FK_FormTree; nodeForm.Name = md.Name; nodeForm.NodeType = IsNotNull ? "form|1" : "form|0"; appFlowFormTree.AddEntity(nodeForm); } } #endregion //扩展工具,显示位置为表单树类型 NodeToolbars extToolBars = new NodeToolbars(); QueryObject info = new QueryObject(extToolBars); info.AddWhere(NodeToolbarAttr.FK_Node, nodeId); info.addAnd(); info.AddWhere(NodeToolbarAttr.ShowWhere, (int)ShowWhere.Tree); info.DoQuery(); foreach (NodeToolbar item in extToolBars) { string url = ""; if (string.IsNullOrEmpty(item.Url)) { continue; } url = item.Url; BP.WF.Template.FlowFormTree formTree = new BP.WF.Template.FlowFormTree(); formTree.No = item.OID.ToString(); formTree.ParentNo = "01"; formTree.Name = item.Title; formTree.NodeType = "tools|0"; if (!string.IsNullOrEmpty(item.Target) && item.Target.ToUpper() == "_BLANK") { formTree.NodeType = "tools|1"; } formTree.Url = url; appFlowFormTree.AddEntity(formTree); } TansEntitiesToGenerTree(appFlowFormTree, root.No, ""); return(appendMenus.ToString()); }
/// <summary> /// 获取表单库所有表单 /// </summary> /// <returns></returns> public string BindForm_GenerForms() { //形成树 FlowFormTrees appendFormTrees = new FlowFormTrees(); //节点绑定表单 FrmNodes frmNodes = new FrmNodes(this.FK_Flow, this.FK_Node); //所有表单类别 SysFormTrees formTrees = new SysFormTrees(); formTrees.RetrieveAll(SysFormTreeAttr.Idx); //根节点 BP.WF.Template.FlowFormTree root = new BP.WF.Template.FlowFormTree(); root.Name = "表单库"; int i = root.Retrieve(FlowFormTreeAttr.ParentNo, 0); if (i != 0) { root.Name = "表单库"; root.No = "1"; root.NodeType = "root"; root.Insert(); } root.NodeType = "root"; appendFormTrees.AddEntity(root); foreach (SysFormTree formTree in formTrees) { //已经添加排除 if (appendFormTrees.Contains("No", formTree.No) == true) { continue; } //根节点排除 if (formTree.ParentNo.Equals("0")) { root.No = formTree.No; continue; } //文件夹 BP.WF.Template.FlowFormTree nodeFolder = new BP.WF.Template.FlowFormTree(); nodeFolder.No = formTree.No; nodeFolder.ParentNo = formTree.ParentNo; nodeFolder.Name = formTree.Name; nodeFolder.NodeType = "folder"; if (formTree.ParentNo.Equals("0")) { nodeFolder.ParentNo = root.No; } appendFormTrees.AddEntity(nodeFolder); //表单 MapDatas mapS = new MapDatas(); mapS.RetrieveByAttr(MapDataAttr.FK_FormTree, formTree.No); if (mapS != null && mapS.Count > 0) { foreach (MapData map in mapS) { BP.WF.Template.FlowFormTree formFolder = new BP.WF.Template.FlowFormTree(); formFolder.No = map.No; formFolder.ParentNo = map.FK_FormTree; formFolder.Name = map.Name + "[" + map.No + "]"; formFolder.NodeType = "form"; appendFormTrees.AddEntity(formFolder); } } } string strCheckedNos = ""; //设置选中 foreach (FrmNode frmNode in frmNodes) { strCheckedNos += "," + frmNode.FK_Frm + ","; } //重置 appendMenus.Clear(); //生成数据 TansEntitiesToGenerTree(appendFormTrees, root.No, strCheckedNos); return(appendMenus.ToString()); }
private string GetFlowFormTree() { //add root BP.WF.Template.FlowFormTree root = new BP.WF.Template.FlowFormTree(); root.No = "00"; root.ParentNo = "0"; root.Name = "目录"; root.NodeType = "root"; appFlowFormTree.Clear(); appFlowFormTree.AddEntity(root); #region 添加表单及文件夹 //节点表单 string tfModel = SystemConfig.AppSettings["TreeFrmModel"]; BP.WF.Node nd = new BP.WF.Node(this.FK_Node); FrmNodes frmNodes = new FrmNodes(); QueryObject qo = new QueryObject(frmNodes); qo.AddWhere(FrmNodeAttr.FK_Node, this.FK_Node); qo.addAnd(); qo.AddWhere(FrmNodeAttr.FK_Flow, this.FK_Flow); //如果配置了启用关键字段,一下会判断绑定的独立表单中的关键字段是否有数据,没有就不会被显示 // add by 海南 zqp if (tfModel == "1") { //针对合流点与分合流节点有效 //获取独立表单的字段 MapDatas mdes = new MapDatas(); string mypks = ""; if (nd.IsStartNode == false) { qo.addOrderBy(FrmNodeAttr.Idx); qo.DoQuery(); foreach (FrmNode fn in frmNodes) { if (fn.HisFrmType == FrmType.Column4Frm || fn.HisFrmType == FrmType.FreeFrm) { mdes.Retrieve(MapDataAttr.No, fn.FK_Frm); //根据设置的关键字段是否有值,进行判断 foreach (MapData md in mdes) { Paras ps = new Paras(); ps.SQL = "SELECT " + fn.GuanJianZiDuan + " FROM " + md.PTable + " WHERE " + " OID=" + SystemConfig.AppCenterDBVarStr + "OID"; if (this.FID == 0) { ps.Add("OID", this.WorkID); } else { ps.Add("OID", this.FID); } try { DataTable dtmd = BP.DA.DBAccess.RunSQLReturnTable(ps); string dtVal = dtmd.Rows[0]["" + fn.GuanJianZiDuan + ""].ToString(); if (string.IsNullOrWhiteSpace(dtVal)) { mypks = mypks + "'" + md.No + "',"; } } catch (Exception ex) { mypks = mypks + "'" + md.No + "',"; } } } } mypks = mypks.TrimEnd(','); if (!string.IsNullOrWhiteSpace(mypks)) { //添加查询条件 qo = new QueryObject(frmNodes); qo.AddWhere(FrmNodeAttr.FK_Node, this.FK_Node); qo.addAnd(); qo.AddWhere(FrmNodeAttr.FK_Flow, this.FK_Flow); qo.addAnd(); qo.AddWhere(FrmNodeAttr.FK_Frm + " not in(" + mypks + ")"); qo.addOrderBy(FrmNodeAttr.Idx); qo.DoQuery(); } } else { qo.addOrderBy(FrmNodeAttr.Idx); qo.DoQuery(); } } else { qo.addOrderBy(FrmNodeAttr.Idx); qo.DoQuery(); } //文件夹 SysFormTrees formTrees = new SysFormTrees(); formTrees.RetrieveAll(SysFormTreeAttr.Name); //所有表单集合 MapDatas mds = new MapDatas(); mds.RetrieveInSQL("SELECT FK_Frm FROM WF_FrmNode WHERE FK_Node=" + this.FK_Node); foreach (FrmNode frmNode in frmNodes) { #region 增加判断是否启用规则. switch (frmNode.FrmEnableRole) { case FrmEnableRole.Allways: break; case FrmEnableRole.WhenHaveData: //判断是否有数据. MapData md = new MapData(frmNode.FK_Frm); if (DBAccess.RunSQLReturnValInt("SELECT COUNT(*) as Num FROM " + md.PTable + " WHERE OID=" + this.WorkID) == 0) { continue; } break; case FrmEnableRole.WhenHaveFrmPara: //判断是否有参数. string frms = this.Request.QueryString["Frms"]; if (frms != null && frms.Contains(frmNode.FK_Frm) == true) { /*包含这个表单.*/ } else { continue; } break; case FrmEnableRole.ByFrmFields: throw new Exception("@这种类型的判断,ByFrmFields 还没有完成。"); case FrmEnableRole.BySQL: // 按照SQL的方式. string mysql = frmNode.FrmEnableExp.Clone() as string; mysql = mysql.Replace("@OID", this.WorkID.ToString()); mysql = mysql.Replace("@WorkID", this.WorkID.ToString()); mysql = mysql.Replace("@NodeID", this.FK_Node.ToString()); mysql = mysql.Replace("@FK_Node", this.FK_Node.ToString()); mysql = mysql.Replace("@FK_Flow", this.FK_Flow); if (DBAccess.RunSQLReturnValFloat(mysql) <= 0) { continue; } break; case FrmEnableRole.Disable: // 如果禁用了,就continue出去.. continue; default: throw new Exception("@没有判断的规则." + frmNode.FrmEnableRole); } #endregion #region 检查是否有没有目录的表单? bool isHave = false; foreach (MapData md in mds) { if (md.FK_FormTree == "") { isHave = true; break; } } string treeNo = "0"; if (isHave && mds.Count == 1) { treeNo = "0"; } else if (isHave == true) { foreach (MapData md in mds) { if (md.FK_FormTree != "") { treeNo = md.FK_FormTree; break; } } } #endregion 检查是否有没有目录的表单? foreach (MapData md in mds) { if (frmNode.FK_Frm != md.No) { continue; } #warning 这里有错误, 如果是节点表单的话,就没有这个值,没有这个值就绑定不到表单树,代国强解决. if (md.FK_FormTree == "") { md.FK_FormTree = treeNo; } foreach (SysFormTree formTree in formTrees) { if (md.FK_FormTree != formTree.No) { continue; } if (appFlowFormTree.Contains("No", formTree.No) == false) { BP.WF.Template.FlowFormTree nodeFolder = new BP.WF.Template.FlowFormTree(); nodeFolder.No = formTree.No; nodeFolder.ParentNo = root.No; nodeFolder.Name = formTree.Name; nodeFolder.NodeType = "folder"; appFlowFormTree.AddEntity(nodeFolder); } } //检查必填项 bool IsNotNull = false; FrmFields formFields = new FrmFields(); QueryObject obj = new QueryObject(formFields); obj.AddWhere(FrmFieldAttr.FK_Node, this.FK_Node); obj.addAnd(); obj.AddWhere(FrmFieldAttr.FK_MapData, md.No); obj.addAnd(); obj.AddWhere(FrmFieldAttr.IsNotNull, "1"); obj.DoQuery(); if (formFields != null && formFields.Count > 0) { IsNotNull = true; } BP.WF.Template.FlowFormTree nodeForm = new BP.WF.Template.FlowFormTree(); nodeForm.No = md.No; nodeForm.ParentNo = md.FK_FormTree; nodeForm.Name = md.Name; nodeForm.NodeType = IsNotNull ? "form|1" : "form|0"; nodeForm.IsEdit = Convert.ToString(Convert.ToInt32(frmNode.IsEdit)); appFlowFormTree.AddEntity(nodeForm); } } #endregion //扩展工具,显示位置为表单树类型 NodeToolbars extToolBars = new NodeToolbars(); QueryObject info = new QueryObject(extToolBars); info.AddWhere(NodeToolbarAttr.FK_Node, this.FK_Node); info.addAnd(); info.AddWhere(NodeToolbarAttr.ShowWhere, (int)ShowWhere.Tree); info.DoQuery(); foreach (NodeToolbar item in extToolBars) { string url = ""; if (string.IsNullOrEmpty(item.Url)) { continue; } url = item.Url; BP.WF.Template.FlowFormTree formTree = new BP.WF.Template.FlowFormTree(); formTree.No = item.OID.ToString(); formTree.ParentNo = "01"; formTree.Name = item.Title; formTree.NodeType = "tools|0"; if (!string.IsNullOrEmpty(item.Target) && item.Target.ToUpper() == "_BLANK") { formTree.NodeType = "tools|1"; } formTree.Url = url; appFlowFormTree.AddEntity(formTree); } TansEntitiesToGenerTree(appFlowFormTree, root.No, ""); return(appendMenus.ToString()); }