/// <summary> /// 根据child_node递归获取gojs数据 /// </summary> /// <param name="query"></param> /// <returns></returns> public List <ServOrganizationChartModel> GetOrganizationCharByChildNode(ServOrganizationChartQuery query) { try { return(mapContext.QueryForList <ServOrganizationChartModel>("GetOrganizationCharByChildNode", query).ToList()); } catch (Exception ex) { throw ex; } }
/// <summary> /// 根据parent_node获取gojs展示所需数据和关联关系 /// </summary> /// <param name="pid"></param> /// <returns></returns> public GoJSModel GetOrganizationGoJsData(int pid) { try { ServOrganizationChartQuery query = new ServOrganizationChartQuery(); //query.parent_node = pid.ToString(); List <ServOrganizationChartModel> orgList = new List <ServOrganizationChartModel>(); if (pid == -1) { orgList = servOrganizationChartDAL.GetOrganizationChar(query); } else { query.child_node = pid.ToString(); orgList = servOrganizationChartDAL.GetOrganizationCharByChildNode(query); } List <GoJSNodeDataCustom> nodeList = new List <GoJSNodeDataCustom>(); List <GoJSLinkDataCustom> linkList = new List <GoJSLinkDataCustom>(); for (int i = 0; i < orgList.Count; i++) { GoJSNodeDataCustom node = new GoJSNodeDataCustom(); node.key = orgList[i].child_node; node.name = orgList[i].content; GoJSLinkDataCustom link = new GoJSLinkDataCustom(); link.from = orgList[i].parent_node; link.to = orgList[i].child_node; nodeList.Add(node); linkList.Add(link); } //if (pid == -1) //{ // GoJSNodeDataCustom node1 = new GoJSNodeDataCustom(); // node1.key = "-1"; // node1.name = "组织架构"; // nodeList.Add(node1); //} GoJSModel goJSModel = new GoJSModel(); goJSModel.nodeList = nodeList; goJSModel.linkList = linkList; return(goJSModel); } catch (Exception ex) { throw ex; } }