/// <summary> /// 保存节点绑定人员信息 /// </summary> /// <returns></returns> public string Dot2DotTreeDeptEmpModel_SaveNodeEmps() { JsonResultInnerData jr = new JsonResultInnerData(); string nodeid = this.GetRequestVal("nodeid"); string data = this.GetRequestVal("data"); string partno = this.GetRequestVal("partno"); bool lastpart = false; int partidx = 0; int partcount = 0; int nid = 0; if (string.IsNullOrWhiteSpace(nodeid) || int.TryParse(nodeid, out nid) == false) { throw new Exception("参数nodeid不正确"); } if (string.IsNullOrWhiteSpace(data)) { data = ""; } BP.WF.Template.NodeEmps nemps = new BP.WF.Template.NodeEmps(); string[] empNos = data.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); //提交内容过长时,采用分段式提交 if (string.IsNullOrWhiteSpace(partno)) { nemps.Delete(BP.WF.Template.NodeEmpAttr.FK_Node, nid); } else { string[] parts = partno.Split("/".ToCharArray()); if (parts.Length != 2) { throw new Exception("参数partno不正确"); } partidx = int.Parse(parts[0]); partcount = int.Parse(parts[1]); empNos = data.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (partidx == 1) { nemps.Delete(BP.WF.Template.NodeEmpAttr.FK_Node, nid); } lastpart = partidx == partcount; } DataTable dtEmps = DBAccess.RunSQLReturnTable("SELECT No FROM Port_Emp"); BP.WF.Template.NodeEmp nemp = null; foreach (string empNo in empNos) { if (dtEmps.Select(string.Format("No='{0}'", empNo)).Length + dtEmps.Select(string.Format("NO='{0}'", empNo)).Length == 0) { continue; } nemp = new BP.WF.Template.NodeEmp(); nemp.FK_Node = nid; nemp.FK_Emp = empNo; nemp.Insert(); } if (string.IsNullOrWhiteSpace(partno)) { jr.Msg = "保存成功"; } else { jr.InnerData = new { lastpart, partidx, partcount }; if (lastpart) { jr.Msg = "保存成功"; } else { jr.Msg = string.Format("第{0}/{1}段保存成功", partidx, partcount); } } return(Newtonsoft.Json.JsonConvert.SerializeObject(jr)); }
/// <summary> /// 初始化节点属性列表. /// </summary> /// <returns></returns> public string NodeAttrs_Init() { var strFlowId = GetRequestVal("FK_Flow"); if (DataType.IsNullOrEmpty(strFlowId)) { return("err@参数错误!"); } Nodes nodes = new Nodes(); nodes.Retrieve("FK_Flow", strFlowId); //因直接使用nodes.ToJson()无法获取某些字段(e.g.HisFormTypeText,原因:Node没有自己的Attr类) //故此处手动创建前台所需的DataTable DataTable dt = new DataTable(); dt.Columns.Add("NodeID"); //节点ID dt.Columns.Add("Name"); //节点名称 dt.Columns.Add("HisFormType"); //表单方案 dt.Columns.Add("HisFormTypeText"); dt.Columns.Add("HisRunModel"); //节点类型 dt.Columns.Add("HisRunModelT"); dt.Columns.Add("HisDeliveryWay"); //接收方类型 dt.Columns.Add("HisDeliveryWayText"); dt.Columns.Add("HisDeliveryWayJsFnPara"); dt.Columns.Add("HisDeliveryWayCountLabel"); dt.Columns.Add("HisDeliveryWayCount"); //接收方Count dt.Columns.Add("HisCCRole"); //抄送人 dt.Columns.Add("HisCCRoleText"); dt.Columns.Add("HisFrmEventsCount"); //消息&事件Count dt.Columns.Add("HisFinishCondsCount"); //流程完成条件Count DataRow dr; foreach (Node node in nodes) { dr = dt.NewRow(); dr["NodeID"] = node.NodeID; dr["Name"] = node.Name; dr["HisFormType"] = node.HisFormType; dr["HisFormTypeText"] = node.HisFormTypeText; dr["HisRunModel"] = node.HisRunModel; dr["HisRunModelT"] = node.HisRunModelT; dr["HisDeliveryWay"] = node.HisDeliveryWay; dr["HisDeliveryWayText"] = node.HisDeliveryWayText; //接收方数量 var intHisDeliveryWayCount = 0; if (node.HisDeliveryWay == BP.WF.DeliveryWay.ByStation) { dr["HisDeliveryWayJsFnPara"] = "ByStation"; dr["HisDeliveryWayCountLabel"] = "岗位"; BP.WF.Template.NodeStations nss = new BP.WF.Template.NodeStations(); intHisDeliveryWayCount = nss.Retrieve(BP.WF.Template.NodeStationAttr.FK_Node, node.NodeID); } else if (node.HisDeliveryWay == BP.WF.DeliveryWay.ByDept) { dr["HisDeliveryWayJsFnPara"] = "ByDept"; dr["HisDeliveryWayCountLabel"] = "部门"; BP.WF.Template.NodeDepts nss = new BP.WF.Template.NodeDepts(); intHisDeliveryWayCount = nss.Retrieve(BP.WF.Template.NodeDeptAttr.FK_Node, node.NodeID); } else if (node.HisDeliveryWay == BP.WF.DeliveryWay.ByBindEmp) { dr["HisDeliveryWayJsFnPara"] = "ByDept"; dr["HisDeliveryWayCountLabel"] = "人员"; BP.WF.Template.NodeEmps nes = new BP.WF.Template.NodeEmps(); intHisDeliveryWayCount = nes.Retrieve(BP.WF.Template.NodeStationAttr.FK_Node, node.NodeID); } dr["HisDeliveryWayCount"] = intHisDeliveryWayCount; //抄送 dr["HisCCRole"] = node.HisCCRole; dr["HisCCRoleText"] = node.HisCCRoleText; //消息&事件Count BP.Sys.FrmEvents fes = new BP.Sys.FrmEvents(); dr["HisFrmEventsCount"] = fes.Retrieve(BP.Sys.FrmEventAttr.FK_MapData, "ND" + node.NodeID); //流程完成条件Count BP.WF.Template.Conds conds = new BP.WF.Template.Conds(BP.WF.Template.CondType.Flow, node.NodeID); dr["HisFinishCondsCount"] = conds.Count; dt.Rows.Add(dr); } return(BP.Tools.Json.ToJson(dt)); }
/// <summary> /// 获取指定部门下一级子部门及人员列表 /// </summary> /// <returns></returns> public string Dot2DotTreeDeptEmpModel_GetSubDepts() { string parentid = this.GetRequestVal("parentid"); string nid = this.GetRequestVal("nodeid"); if (string.IsNullOrWhiteSpace(parentid)) { throw new Exception("参数parentid不能为空"); } if (string.IsNullOrWhiteSpace(nid)) { throw new Exception("参数nodeid不能为空"); } EasyuiTreeNode node = null; List <EasyuiTreeNode> d = new List <EasyuiTreeNode>(); BP.WF.Template.NodeEmps semps = new BP.WF.Template.NodeEmps(); semps.Retrieve(BP.WF.Template.NodeEmpAttr.FK_Node, int.Parse(nid)); if (BP.WF.Glo.OSModel == OSModel.OneOne) { BP.Port.Dept parentDept = new BP.Port.Dept(parentid); BP.Port.Depts depts = new BP.Port.Depts(); depts.Retrieve(BP.Port.DeptAttr.ParentNo, parentid, BP.Port.DeptAttr.Name); BP.Port.Emps emps = new BP.Port.Emps(); emps.Retrieve(BP.Port.EmpAttr.FK_Dept, parentid, BP.Port.EmpAttr.Name); //增加部门 foreach (BP.Port.Dept dept in depts) { node = new EasyuiTreeNode(); node.id = "DEPT_" + dept.No; node.text = dept.Name; node.iconCls = "icon-department"; node.attributes = new EasyuiTreeNodeAttributes(); node.attributes.No = dept.No; node.attributes.Name = dept.Name; node.attributes.ParentNo = dept.ParentNo; node.attributes.TType = "DEPT"; node.attributes.Code = BP.Tools.chs2py.ConvertStr2Code(dept.Name); node.state = "closed"; node.children = new List <EasyuiTreeNode>(); node.children.Add(new EasyuiTreeNode()); node.children[0].text = "loading..."; d.Add(node); } //增加人员 foreach (BP.Port.Emp emp in emps) { node = new EasyuiTreeNode(); node.id = "EMP_" + parentid + "_" + emp.No; node.text = emp.Name; node.iconCls = "icon-user"; node.@checked = semps.GetEntityByKey(BP.WF.Template.NodeEmpAttr.FK_Emp, emp.No) != null; node.attributes = new EasyuiTreeNodeAttributes(); node.attributes.No = emp.No; node.attributes.Name = emp.Name; node.attributes.ParentNo = parentDept.No; node.attributes.ParentName = parentDept.Name; node.attributes.TType = "EMP"; node.attributes.Code = BP.Tools.chs2py.ConvertStr2Code(emp.Name); d.Add(node); } } else { BP.GPM.Dept parentDept = new BP.GPM.Dept(parentid); BP.GPM.Depts depts = new BP.GPM.Depts(); depts.Retrieve(BP.GPM.DeptAttr.ParentNo, parentid, BP.GPM.DeptAttr.Name); BP.GPM.DeptEmps des = new BP.GPM.DeptEmps(); des.Retrieve(BP.GPM.DeptEmpAttr.FK_Dept, parentid); BP.GPM.Emps emps = new BP.GPM.Emps(); emps.RetrieveAll(BP.GPM.EmpAttr.Name); BP.GPM.Emp emp = null; //增加部门 foreach (BP.GPM.Dept dept in depts) { node = new EasyuiTreeNode(); node.id = "DEPT_" + dept.No; node.text = dept.Name; node.iconCls = "icon-department"; node.attributes = new EasyuiTreeNodeAttributes(); node.attributes.No = dept.No; node.attributes.Name = dept.Name; node.attributes.ParentNo = parentDept.No; node.attributes.ParentName = parentDept.Name; node.attributes.TType = "DEPT"; node.attributes.Code = BP.Tools.chs2py.ConvertStr2Code(dept.Name); node.state = "closed"; node.children = new List <EasyuiTreeNode>(); node.children.Add(new EasyuiTreeNode()); node.children[0].text = "loading..."; d.Add(node); } //增加人员 foreach (BP.GPM.DeptEmp de in des) { emp = emps.GetEntityByKey(BP.GPM.EmpAttr.No, de.FK_Emp) as BP.GPM.Emp; if (emp == null) { continue; } node = new EasyuiTreeNode(); node.id = "EMP_" + parentid + "_" + emp.No; node.text = emp.Name; node.iconCls = "icon-user"; node.@checked = semps.GetEntityByKey(BP.WF.Template.NodeEmpAttr.FK_Emp, emp.No) != null; node.attributes = new EasyuiTreeNodeAttributes(); node.attributes.No = emp.No; node.attributes.Name = emp.Name; node.attributes.ParentNo = parentDept.No; node.attributes.ParentName = parentDept.Name; node.attributes.TType = "EMP"; node.attributes.Code = BP.Tools.chs2py.ConvertStr2Code(emp.Name); d.Add(node); } } return(Newtonsoft.Json.JsonConvert.SerializeObject(d)); }