/// <summary> /// 展开供应商树节点 /// </summary> /// <param name="id"></param> /// <returns></returns> public string PrivSupplierExpand(Guid id) { bool flag = false; List<LiveTreeNode> list = new List<LiveTreeNode>(); if (id.Equals(Guid.Empty)) { var oSuppierList =(from o in dbEntity.PurchaseSuppliers.Include("FullName").Include("ChildItems") where (o.Parent == null && o.Deleted == false) select o).ToList(); int noSupplierList = oSuppierList.Count; var oRefIDList = (from o in dbEntity.MemberPrivItems from p in dbEntity.MemberOrganizations where (o.RefID == p.Gid && o.Deleted == false && p.Otype == (byte)ModelEnum.OrganizationType.SUPPLIER && p.Deleted == false) select new { gid = o.RefID }).ToList(); int noRefIDList = oRefIDList.Count; foreach (var item in oSuppierList) { LiveTreeNode node = new LiveTreeNode(); for (int i = 0; i < noRefIDList; i++) { if (item.Gid == oRefIDList[i].gid) { flag = true; break; } } node.name = item.FullName.GetResource(CurrentSession.Culture); node.id = item.Gid.ToString(); if (flag == false) node.nodeChecked = false; else node.nodeChecked = true; if (item.ChildItems.Count > 0) node.isParent = true; else node.isParent = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); flag = false; } } else { var SupplierList = (from o in dbEntity.MemberOrganizations.Include("FullName").Include("ChildItems") where (o.Parent.Gid == id && o.Deleted == false) select o).ToList(); var SupItemList = (from o in dbEntity.MemberPrivItems from p in dbEntity.MemberOrganizations where (o.RefID == p.Gid && o.Deleted == false && p.Deleted == false && p.Otype == 3) select new { gid = o.RefID }).ToList(); int nSupItemList = SupItemList.Count; foreach (var item in SupplierList) { for (int i = 0; i < nSupItemList; i++) { if (item.Gid == SupItemList[i].gid) { flag = true; break; } } LiveTreeNode node = new LiveTreeNode(); node.name = item.FullName.GetResource(CurrentSession.Culture); node.id = item.Gid.ToString(); if (flag == true) node.nodeChecked = true; else node.nodeChecked = false; if (item.ChildItems.Count > 0) node.isParent = true; else node.isParent = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); flag = false; } } return list.ToJsonString(); }
/// <summary> /// 异步展开树节点,返回展开节点的json字符串 /// </summary> /// <param name="id">展开树节点的guid</param> /// <returns></returns> public string TreeExpand(Guid id) { string strTreeJson = ""; //当展开root节点的时候 if (id.ToString().Equals("00000000-0000-0000-0000-000000000000")) { var privateCategoryList = dbEntity.GeneralPrivateCategorys.Where(o => o.Parent == null && o.Deleted == false).ToList(); int iProgCount = privateCategoryList.Count(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in privateCategoryList) { if (item.Deleted == false) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.Name.GetResource(CurrentSession.Culture); treeNode.icon = ""; treeNode.iconClose = ""; treeNode.iconOpen = ""; treeNode.nodeChecked = false; treeNode.isParent = false; treeNode.progUrl = ""; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } } strTreeJson = CreateTreeJson(list, ""); } else //非root节点展开的时候,回传的gid不为空 { GeneralPrivateCategory privateCategoryChildList = dbEntity.GeneralPrivateCategorys.Include("ChildItems").Where(p => p.Gid == id).Single(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in privateCategoryChildList.ChildItems) { if (item.Deleted == false) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.Name.GetResource(CurrentSession.Culture); treeNode.icon = "../demo/zTreeStyle/img/edit.png"; treeNode.iconClose = "../demo/zTreeStyle/img/edit.png"; treeNode.iconOpen = "../demo/zTreeStyle/img/edit.png"; treeNode.nodeChecked = false; treeNode.isParent = false; treeNode.progUrl = ""; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } } strTreeJson = CreateTreeJson(list, ""); } return "[" + strTreeJson + "]"; }
public string RegionTreeExpand(Guid id) { string strTree=""; if (id.Equals("00000000-0000-0000-0000-000000000000")) { var RegionTreeList = from o in dbEntity.GeneralRegions where (o.Parent == null && o.Deleted == false) select o; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in RegionTreeList) { LiveTreeNode node = new LiveTreeNode(); node.name = item.FullName; node.id = item.Gid.ToString(); node.nodes = new List<LiveTreeNode>(); list.Add(node); } strTree = CreateTreeJson(list,""); } else { var RegionTreeList = from o in dbEntity.GeneralRegions.Include("Parent") where (o.Parent.Gid == id && o.Deleted == false) select o; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in RegionTreeList) { LiveTreeNode node = new LiveTreeNode(); node.name = item.FullName; node.id = item.Gid.ToString(); node.nodes = new List<LiveTreeNode>(); list.Add(node); } strTree = CreateTreeJson(list, ""); } return "[" + strTree + "]"; }
/// <summary> /// 加载商品树形结构 /// </summary> /// <returns></returns> public string PrivProductLoad() { Guid userID = new Guid("12db0a77-92c4-e011-afef-002269c9aa85"); Guid PrivID = (from o in dbEntity.MemberPrivileges where (o.UserID == userID && o.Ptype == 2 && o.Deleted == false) select o.Gid).Single(); var OrgPrivList = (from o in dbEntity.MemberPrivItems where (o.PrivID == PrivID && o.Deleted == false) select o).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in OrgPrivList) { MemberOrganization org = new MemberOrganization(); org.Gid = (Guid)item.RefID; var Org = (from o in dbEntity.MemberOrganizations.Include("ShortName") where (o.Gid == org.Gid && o.Deleted == false) select o).Single(); LiveTreeNode node = new LiveTreeNode(); node.name = Org.ShortName.Matter; node.id = Org.Gid.ToString(); node.nodeChecked = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); } string strTreeJson = CreateTree(list); return strTreeJson; }
/// <summary> /// 分类树展开 /// </summary> /// <param name="id"></param> /// <returns></returns> public string CategoryTreeExpand(Guid id) { List<LiveTreeNode> list = new List<LiveTreeNode>(); //根节点展开 if (id.Equals(Guid.Empty)) { var oPrivateCategory = (from o in dbEntity.GeneralPrivateCategorys.Include("Name").Include("ChildItems") where (o.OrgID == gOrgId && o.Ctype == 7 && o.Parent == null && o.Deleted == false) select o).ToList(); foreach (var item in oPrivateCategory) { LiveTreeNode node = new LiveTreeNode(); node.id = item.Gid.ToString(); node.name = item.Name.GetResource(CurrentSession.Culture); if (item.ChildItems.Count > 0) node.isParent = true; else node.isParent = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); } } else { var oPrivateCategory = (from o in dbEntity.GeneralPrivateCategorys.Include("Name").Include("ChildItems") where (o.OrgID == gOrgId && o.Ctype == 7 && o.aParent == id && o.Deleted == false) select o).ToList(); foreach (var item in oPrivateCategory) { LiveTreeNode node = new LiveTreeNode(); node.id = item.Gid.ToString(); node.name = item.Name.GetResource(CurrentSession.Culture); if (item.ChildItems.Count > 0) node.isParent = true; else node.isParent = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); } } return list.ToJsonString(); }
/// <summary> /// 加载已授权树 /// </summary> /// <returns></returns> public string SubProgramLoad() { string strTreeJson = ""; Guid userID = new Guid("12db0a77-92c4-e011-afef-002269c9aa85"); //MemberPrivilege表中选出类型为程序授权的记录 var PrivID= (from o in dbEntity.MemberPrivileges where(o.UserID==userID&&o.Deleted==false&&o.Ptype==0) select o).FirstOrDefault(); //若为空标志为对该用户进行授权,不生成树 if (PrivID == null) return strTreeJson; else { //MemberPrivItems表中选择所有授权的Program var oProgramList = (from o in dbEntity.MemberPrivItems where (o.PrivID == PrivID.Gid && o.Deleted == false) select o.RefID).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); for (int i = 0; i < oProgramList.Count; i++) { Guid oGid = new Guid(oProgramList[i].ToString()); var oProgram =( from o in dbEntity.GeneralPrograms where (o.Gid == oGid && o.Deleted == false) select o).Single(); //只加载父亲为空的节点 if (oProgram.Parent == null) { LiveTreeNode oTreeNode = new LiveTreeNode(); oTreeNode.id = oProgram.Gid.ToString(); oTreeNode.name = oProgram.Name.Matter; oTreeNode.nodeChecked= false; oTreeNode.progUrl = oProgram.ProgUrl; oTreeNode.nodes = new List<LiveTreeNode>(); list.Add(oTreeNode); } } strTreeJson = CreateTree(list); return strTreeJson; } }
/// <summary> /// 加载已授权供应商 /// </summary> /// <returns></returns> public string SubSupplierLoad() { string strTreeJson = ""; Guid userID = new Guid("12db0a77-92c4-e011-afef-002269c9aa85"); Guid PrivID = (from o in dbEntity.MemberPrivileges where (o.UserID == userID && o.Deleted == false && o.Ptype == 6) select o.Gid).FirstOrDefault(); if (PrivID == null) return null; else { var oSupItem = (from o in dbEntity.MemberPrivItems where (o.Deleted == false && o.PrivID == PrivID) select o.RefID).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); for (int i = 0; i < oSupItem.Count; i++) { Guid oGid = new Guid(oSupItem[i].ToString()); var oSupplier = (from o in dbEntity.MemberOrganizations where (o.Gid == oGid && o.Deleted == false) select o).FirstOrDefault(); //只加载父亲为空的节点 if (oSupplier.Parent == null) { LiveTreeNode oTreeNode = new LiveTreeNode(); oTreeNode.id = oSupplier.Gid.ToString(); oTreeNode.name = oSupplier.ShortName.Matter; oTreeNode.nodeChecked = false; oTreeNode.nodes = new List<LiveTreeNode>(); list.Add(oTreeNode); } } strTreeJson = CreateTree(list); return strTreeJson; } }
public string TreeGeneration() { //string strTreeJson = ""; //strTreeJson += "{\"name\":\"root\", \"id\":\"root\", \"checked\": false, \"isParent\":true, \"parentId\":null, \"open\":true , \"nodes\":["; var progList = dbEntity.GeneralRegions.Where(o => o.Parent == null && o.Deleted == false).ToList(); int iProgCount = progList.Count(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in progList) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.FullName; treeNode.icon = ""; treeNode.iconClose = ""; treeNode.iconOpen = ""; treeNode.nodeChecked = false; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } string strTreeJson = CreateTree(list); return strTreeJson; }
public string ShippingRegionTreeExpand(Guid id) { Guid ProductOnsaleShippingGid = Guid.Parse("4113a18d-47d2-e011-b92d-4437e63336bd"); string strTreeJson = ""; //展开root if (id.Equals(Guid.Empty)) { //加载父亲为空的地区 var oRegion = (from o in dbEntity.GeneralRegions where (o.Parent == null && o.Deleted == false) select o).ToList(); int nRegion = oRegion.Count; //该承运商已经支持的地区 var oShipRegion = (from o in dbEntity.ProductOnShipAreas where (o.OnShip == ProductOnsaleShippingGid && o.Deleted == false) select o).ToList(); int nShipRegion = oShipRegion.Count; bool flag = false; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in oRegion) { for (int i = 0; i < nShipRegion; i++) { if (item.Gid == oShipRegion[i].RegionID) { flag = true; break; } } LiveTreeNode TreeNode = new LiveTreeNode(); TreeNode.id = item.Gid.ToString(); TreeNode.name = item.ShortName; if (flag == true) { TreeNode.nodeChecked = true; } else { TreeNode.nodeChecked = false; } if (item.ChildItems.Count > 0) { TreeNode.isParent = true; } else { TreeNode.isParent = false; } TreeNode.nodes = new List<LiveTreeNode>(); list.Add(TreeNode); } strTreeJson = CreateTreeJson(list, ""); } else { //展开非root节点 var oRegion = (from o in dbEntity.GeneralRegions where (o.Parent.Gid == id && o.Deleted == false) select o).ToList(); //该承运商已经支持的地区 var oShipRegion = (from o in dbEntity.ProductOnShipAreas where (o.OnShip == ProductOnsaleShippingGid && o.Deleted == false) select o).ToList(); int nShipRegion = oShipRegion.Count; bool flag = false; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in oRegion) { for (int i = 0; i < nShipRegion; i++) { if (item.Gid == oShipRegion[i].RegionID) { flag = true; break; } } LiveTreeNode TreeNode = new LiveTreeNode(); TreeNode.id = item.Gid.ToString(); TreeNode.name = item.ShortName; if (flag == true) { TreeNode.nodeChecked = true; } else { TreeNode.nodeChecked = false; } if (item.ChildItems.Count > 0) { TreeNode.isParent = true; } else { TreeNode.isParent = false; } TreeNode.nodes = new List<LiveTreeNode>(); list.Add(TreeNode); flag = false; } strTreeJson = CreateTreeJson(list, ""); } return "[" + strTreeJson + "]"; }
private List<LiveTreeNode> PrivateCategoryListTreeNode(Guid? id) { Guid orgID = GetOrganization(); List<GeneralPrivateCategory> oCategoryByType = (from g in dbEntity.GeneralPrivateCategorys where g.Deleted == false && g.Ctype == nPrivateCategoryType && id == null ? g.aParent == null : g.aParent == id orderby g.Sorting descending select g).ToList(); List<GeneralPrivateCategory> oCategory = (from o in oCategoryByType where oPrivateCategoryOrg == null ? o.OrgID == orgID : o.OrgID == oPrivateCategoryOrg select o).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in oCategory) { LiveTreeNode treeNode = new LiveTreeNode() { id = item.Gid.ToString(), name = item.Name.GetResource(CurrentSession.Culture), icon = "", iconClose = "", iconOpen = "", nodeChecked = false, isParent = true, nodes = new List<LiveTreeNode>() }; list.Add(treeNode); } return list; }
private List<LiveTreeNode> StandardCategoryListTreeNode(Guid? id ) { List<GeneralStandardCategory> Category = (from g in dbEntity.GeneralStandardCategorys where g.Deleted == false && g.Ctype == nStandardCategoryType orderby g.Sorting descending select g).ToList(); List<GeneralStandardCategory> oCategory = (from c in Category where id == null ? c.aParent == null : c.aParent == id select c).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in oCategory) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = (item.Name == null) ? "" : item.Name.GetResource(CurrentSession.Culture); treeNode.icon = ""; treeNode.iconClose = ""; treeNode.iconOpen = ""; treeNode.nodeChecked = false; treeNode.isParent = true; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } return list; }
/// <summary> /// 加载商品授权树 /// </summary> /// <returns></returns> public string PrivProductLoad() { Guid gOrg = (from o in dbEntity.MemberUsers where (o.Gid == gUserID && o.Deleted == false) select o.OrgID).Single(); List<GeneralPrivateCategory> Category; List<Guid?> oRefList; List<LiveTreeNode> list = new List<LiveTreeNode>(); //商品私有分类 Category = (from o in dbEntity.GeneralPrivateCategorys.Include("Name").Include("ChildItems") where (o.OrgID == gOrgID && o.Parent == null &&o.Ctype==0&& o.Deleted == false) select o).ToList(); //已经被授权的商品分类 oRefList = (from o in dbEntity.MemberPrivileges from p in dbEntity.MemberPrivItems where (o.Ptype == 5 && o.Deleted == false && o.Gid == p.PrivID && p.Deleted == false)select p.RefID).ToList(); foreach (var item in Category) { LiveTreeNode node = new LiveTreeNode(); node.name = item.Name.GetResource(CurrentSession.Culture); node.id = item.Gid.ToString(); node.nodeChecked = oRefList.Any(id => id == item.Gid); node.isParent = (item.ChildItems.Any(c => !c.Deleted)); list.Add(node); } return list.ToJsonString(); }
/// <summary> /// 展开商品授权树节点 /// </summary> /// <param name="id"></param> /// <returns></returns> public string PrivProductExpand(Guid? id=null) { var ProductList = (from o in dbEntity.GeneralPrivateCategorys.Include("Parent").Include("ChildItems").Include("Name") where (o.Parent.Gid == id && o.Deleted == false) select o).ToList(); var oRefList = (from o in dbEntity.MemberPrivileges from p in dbEntity.MemberPrivItems where (o.Ptype == 5 && o.Deleted == false && o.Gid == p.PrivID && p.Deleted == false) select new{id=p.RefID}).ToList(); int noRefList = oRefList.Count; bool flag = false; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var Proitem in ProductList) { for (int i = 0; i < noRefList; i++) { if (Proitem.Gid == oRefList[i].id) { flag = true; break; } } LiveTreeNode node = new LiveTreeNode(); node.name = Proitem.Name.GetResource(CurrentSession.Culture); node.id = Proitem.Gid.ToString(); if (flag == false) node.nodeChecked = false; else node.nodeChecked = true; if (Proitem.ChildItems.Count > 0) node.isParent = true; else node.isParent = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); flag = false; } return list.ToJsonString(); }
/// <summary> /// 加载供应商树形结构 /// </summary> /// <returns></returns> public string PrivSupplierLoad() { var oSupplierList = (from o in dbEntity.PurchaseSuppliers.Include("FullName").Include("ChildItems") where (o.aParent == gOrgID && o.Deleted == false) select o).ToList(); int noSupplierList = oSupplierList.Count; var oRefIDList = (from o in dbEntity.MemberPrivItems from p in dbEntity.PurchaseSuppliers where (o.RefID == p.Gid && o.Deleted == false && p.Otype == (byte)ModelEnum.OrganizationType.SUPPLIER && p.Deleted == false) select new { gid = o.RefID }).ToList(); int noRefIDList = oRefIDList.Count; List<LiveTreeNode> list = new List<LiveTreeNode>(); bool flag = false; foreach (var item in oSupplierList) { LiveTreeNode node = new LiveTreeNode(); //判断节点是否是选中 for (int i = 0; i < noRefIDList; i++) { if (item.Gid == oRefIDList[i].gid) { flag = true; break; } } node.name = item.FullName.GetResource(CurrentSession.Culture); node.id = item.Gid.ToString(); if (flag == false) node.nodeChecked = false; else node.nodeChecked = true; if (item.ChildItems.Count > 0) node.isParent = true; else node.isParent = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); flag = false; } string strTree = CreateTree(list); return strTree; }
/// <summary> /// 加载供应商树形结构 /// </summary> /// <returns></returns> public string PrivSupplierLoad() { var SupplierList = from o in dbEntity.MemberOrganizations.Include("ShortName") where (o.Otype == 3 && o.Parent == null && o.Deleted == false) select o; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in SupplierList) { LiveTreeNode node = new LiveTreeNode(); node.name = item.ShortName.Matter; node.id = item.Gid.ToString(); node.nodeChecked = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); } string strTree = CreateTree(list); return strTree; }
//================================承运商的地区树状结构=============================================== public string ShippingRegionTreeLoad() { Guid ProductOnsaleShippingGid = Guid.Parse("4113a18d-47d2-e011-b92d-4437e63336bd"); //首次加载的树节点 var oRegion = (from o in dbEntity.GeneralRegions where (o.Parent == null && o.Deleted == false) select o).ToList(); int nRegion = oRegion.Count; //该承运商已经支持的地区 var oShipRegion = (from o in dbEntity.ProductOnShipAreas where (o.OnShip == ProductOnsaleShippingGid && o.Deleted == false) select o).ToList(); int nShipRegion = oShipRegion.Count; bool flag = false; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in oRegion) { for (int i = 0; i < nShipRegion; i++) { if (item.Gid == oShipRegion[i].RegionID) { flag = true; break; } } LiveTreeNode TreeNode = new LiveTreeNode(); TreeNode.id = item.Gid.ToString(); TreeNode.name = item.FullName; if (flag == true) TreeNode.nodeChecked = true; else TreeNode.nodeChecked = false; if (item.ChildItems.Count > 0) TreeNode.isParent = true; else TreeNode.isParent = false; TreeNode.nodes = new List<LiveTreeNode>(); list.Add(TreeNode); flag = false; } string strTreeJson = CreateTree(list); return strTreeJson; }
/// <summary> /// 展开已授权树节点 /// </summary> /// <param name="id"></param> /// <returns></returns> public string SubProgramExpand(Guid id) { string strTreeJson = ""; Guid userID = new Guid("12db0a77-92c4-e011-afef-002269c9aa85"); //MemberPrivilege表中选出类型为程序授权的记录 var PrivID = (from o in dbEntity.MemberPrivileges where (o.UserID == userID && o.Deleted == false && o.Ptype == 0) select o).FirstOrDefault(); List<LiveTreeNode> list = new List<LiveTreeNode>(); if (id.ToString().Equals("00000000-0000-0000-0000-000000000000")) { //MemberPrivItems表中选择所有授权的Program var oProgramList = (from o in dbEntity.MemberPrivItems where (o.PrivID == PrivID.Gid && o.Deleted == false) select o.RefID).ToList(); for (int i = 0; i < oProgramList.Count; i++) { Guid oGid = new Guid(oProgramList[i].ToString()); var oProgram = (from o in dbEntity.GeneralPrograms where (o.Gid == oGid && o.Deleted == false) select o).Single(); //只加载父亲为空的节点 if (oProgram.Parent == null) { LiveTreeNode oTreeNode = new LiveTreeNode(); oTreeNode.id = oProgram.Gid.ToString(); oTreeNode.name = oProgram.Name.Matter; oTreeNode.nodeChecked = false; oTreeNode.progUrl = oProgram.ProgUrl; oTreeNode.nodes = new List<LiveTreeNode>(); list.Add(oTreeNode); } } strTreeJson = CreateTreeJson(list, ""); return "["+ strTreeJson+"]"; } else { bool flag=false; Guid Pid = PrivID.Gid; var oProgram = (from o in dbEntity.GeneralPrograms.Include("Parent") where (o.Parent.Gid == id && o.Deleted == false) select o).ToList(); var oRef = (from o in dbEntity.MemberPrivItems where (o.PrivID == Pid && o.Deleted ==false) select o).ToList(); for (int i = 0; i < oProgram.Count; i++) { for (int j = 0; i < oRef.Count; j++) { if (oProgram[i].Gid == oRef[j].RefID) flag = true; break; } if (flag == false) { LiveTreeNode oTreeNode = new LiveTreeNode(); oTreeNode.id = oProgram[i].Gid.ToString(); oTreeNode.name = oProgram[i].Name.Matter; oTreeNode.nodeChecked = false; oTreeNode.progUrl = oProgram[i].ProgUrl; oTreeNode.nodes = new List<LiveTreeNode>(); list.Add(oTreeNode); } flag = false; } strTreeJson = CreateTreeJson(list, ""); return "[" + strTreeJson + "]"; } }
public string TestMutipleTreeGeneration() { var progList = dbEntity.GeneralRegions.Where(o => o.Parent == null && o.Deleted == false).ToList(); int iProgCount = progList.Count(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in progList) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.FullName; treeNode.icon = ""; treeNode.iconClose = ""; treeNode.iconOpen = ""; treeNode.nodeChecked = false; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } //strTreeJson = strTreeJson.Substring(0, strTreeJson.Length - 1); //strTreeJson += "]}"; //return "[" + strTreeJson + "]"; string strTreeJson = CreateTree(list); return strTreeJson; }
/// <summary> /// 展开已授权供应商 /// </summary> /// <param name="id"></param> /// <returns></returns> public string SubSupplierExpand(Guid id) { string strTreeJson = ""; Guid userID = new Guid("12db0a77-92c4-e011-afef-002269c9aa85"); Guid PrivID = (from o in dbEntity.MemberPrivileges where (o.UserID == userID && o.Deleted == false && o.Ptype == 0) select o.Gid).FirstOrDefault(); if (id.Equals("00000000-0000-0000-0000-000000000000")) { //所有已授权的供应商 var oSupItem = (from o in dbEntity.MemberPrivItems where (o.Deleted == false && o.PrivID == PrivID) select o.RefID).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); for (int i = 0; i < oSupItem.Count; i++) { Guid oGid = new Guid(oSupItem[i].ToString()); var oSupplier = (from o in dbEntity.MemberOrganizations where (o.Gid == oGid && o.Deleted == false) select o).Single(); //只加载父亲为空的节点 if (oSupplier.Parent == null) { LiveTreeNode oTreeNode = new LiveTreeNode(); oTreeNode.id = oSupplier.Gid.ToString(); oTreeNode.name = oSupplier.ShortName.Matter; oTreeNode.nodeChecked = false; oTreeNode.nodes = new List<LiveTreeNode>(); list.Add(oTreeNode); } } strTreeJson = CreateTreeJson(list, ""); } else { List<LiveTreeNode> list = new List<LiveTreeNode>(); bool flag = false; var oSup = (from o in dbEntity.MemberOrganizations.Include("Parent").Include("ShortName") where (o.Parent.Gid == id && o.Deleted == false) select o).ToList(); var oRef = (from o in dbEntity.MemberPrivItems where (o.PrivID == PrivID && o.Deleted == false) select o).ToList(); int noSup = oSup.Count; int noRef = oRef.Count; for (int i = 0; i < noSup; i++) { for (int j = 0; i < noRef; j++) { if (oSup[i].Gid == oRef[j].RefID) flag = true; break; } if (flag == false) { LiveTreeNode oTreeNode = new LiveTreeNode(); oTreeNode.id = oSup[i].Gid.ToString(); oTreeNode.name = oSup[i].ShortName.Matter; oTreeNode.nodeChecked = false; oTreeNode.nodes = new List<LiveTreeNode>(); list.Add(oTreeNode); } flag = false; } strTreeJson = CreateTreeJson(list, ""); } return "[" + strTreeJson + "]"; }
public string TreeExpand(Guid id) { string strTreeJson = ""; //当展开root节点的时候 if (id.ToString().Equals("00000000-0000-0000-0000-000000000000")) { var progList = dbEntity.GeneralRegions.Where(o => o.Parent == null && o.Deleted == false).ToList(); int iProgCount = progList.Count(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in progList) { if (item.Deleted == false) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.FullName; treeNode.icon = ""; treeNode.iconClose = ""; treeNode.iconOpen = ""; treeNode.nodeChecked = false; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } } strTreeJson = CreateTreeJson(list, ""); } else //非root节点展开的时候,回传的gid不为空 { GeneralRegion progChildList = dbEntity.GeneralRegions.Include("ChildItems").Where(p => p.Gid == id).Single(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in progChildList.ChildItems) { if (item.Deleted == false) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.FullName; treeNode.icon = ""; treeNode.iconClose = ""; treeNode.iconOpen = ""; treeNode.nodeChecked = false; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } } strTreeJson = CreateTreeJson(list, ""); } return "[" + strTreeJson + "]"; }
/// <summary> /// 展开树形节点 /// </summary> /// <param name="id"></param> /// <returns></returns> public string PrivProductExpand(Guid id) { string strTreeJson = ""; int nCount=0; Guid userID = new Guid("12db0a77-92c4-e011-afef-002269c9aa85"); //MemberPrivilege表中选择组织授权的Gid Guid PrivID = (from o in dbEntity.MemberPrivileges where (o.UserID == userID && o.Ptype == 2 && o.Deleted == false) select o.Gid).Single(); //MemberPrivItem表中选择出该用户有权查看的所有组织 var OrgPrivList = (from o in dbEntity.MemberPrivItems where (o.PrivID == PrivID && o.Deleted == false) select o).ToList(); //确定参数id是组织id还是商品id foreach(var item in OrgPrivList) { MemberOrganization org = new MemberOrganization(); org.Gid = (Guid)item.RefID; if (id == org.Gid) break; else nCount++; } //树节点为商品时展开 if (nCount==OrgPrivList.Count) { var ProductList = (from o in dbEntity.GeneralPrivateCategorys.Include("Parent") where ( o.Parent.Gid == id && o.Deleted == false) select o).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var Proitem in ProductList) { LiveTreeNode node = new LiveTreeNode(); node.name = Proitem.Name.Matter; node.id = Proitem.Gid.ToString(); node.nodeChecked = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); } strTreeJson = CreateTreeJson(list, ""); } //树节点为组织时展开 else { var ProductList = (from o in dbEntity.GeneralPrivateCategorys where(o.OrgID==id && o.Parent ==null&&o.Deleted==false) select o).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var Proitem in ProductList) { LiveTreeNode node = new LiveTreeNode(); node.name = Proitem.Name.Matter; node.id = Proitem.Gid.ToString(); node.nodeChecked = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); } strTreeJson = CreateTreeJson(list, ""); } return "["+strTreeJson+"]"; }
private List<LiveTreeNode> ListTreeNode(Guid id) { Guid? gNodeID = null; // 当展开root节点的时候 if (id != Guid.Empty) gNodeID = id; List<GeneralProgram> oUserPrograms = (from g in dbEntity.GeneralPrograms where g.Deleted == false && (gNodeID == null ? g.aParent == null : g.aParent == gNodeID) orderby g.Sorting descending select g).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in oUserPrograms) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.Name.GetResource(CurrentSession.Culture); treeNode.icon = ""; treeNode.iconClose = ""; treeNode.iconOpen = ""; treeNode.nodeChecked = false; if (item.Terminal == true) treeNode.isParent = false; else treeNode.isParent = true; treeNode.progUrl = item.ProgUrl; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } return list; }
/// <summary> /// 展开程序树节点 /// </summary> /// <param name="id">展开节点的id</param> /// <returns></returns> public string PrivProgramExpand(Guid id) { string strTreeJson = ""; //当展开root节点的时候 if (id.ToString().Equals("00000000-0000-0000-0000-000000000000")) { var ProgList = from o in dbEntity.GeneralPrograms.Include("Name") where (o.Parent == null && o.Deleted == false) select o; var CheckList = (from o in dbEntity.GeneralPrograms from p in dbEntity.MemberPrivItems where (o.Parent == null && o.Deleted == false && p.Deleted == false && o.Gid == p.RefID) select new { Gid = p.RefID }).ToList(); int nCount = ProgList.ToList().Count; int nCheck = CheckList.Count; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in ProgList) { // bool flag = false; LiveTreeNode treeNode = new LiveTreeNode(); // for (int i = 0; i < CheckList.Count; i++) // { // if (item.Gid == CheckList[i].Gid) // { // treeNode.nodeChecked = true; // flag = true; // break; // } // } // if (flag == false) treeNode.nodeChecked = false; treeNode.id = item.Gid.ToString(); //treeNode.name = item.name.GetResource(CurrentSession.Culture); treeNode.name = item.Name.Matter; treeNode.nodes = new List<LiveTreeNode>(); treeNode.progUrl = item.ProgUrl; list.Add(treeNode); } strTreeJson = CreateTreeJson(list, ""); } else //非root节点展开的时候,回传的gid不为空 { GeneralProgram Pro = (from o in dbEntity.GeneralPrograms where (o.Gid == id && o.Deleted == false) select o).FirstOrDefault(); //展开程序节点 if (Pro != null) { //展开叶子程序的功能节点 if (Pro.Terminal == true) { //该程序的功能节点 var ProgNode = from o in dbEntity.GeneralProgNodes.Include("Name").Include("Optional") where (o.ProgID == id && o.Deleted == false) select o; int nProNode = ProgNode.ToList().Count; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var Nodeitem in ProgNode) { //bool flag = false; LiveTreeNode treeNode = new LiveTreeNode(); //for (int i = 0; i < nPrivProgNode;i++ ) //{ // if (Nodeitem.Gid == PrivProgNode[i].Gid) // treeNode.nodeChecked = true; // flag = true; // break; //} //if (flag == false) treeNode.nodeChecked = false; treeNode.id = Nodeitem.Gid.ToString(); treeNode.name = string.Concat(Nodeitem.Name.Matter, " " + Nodeitem.InputMode.ToString()); if (Nodeitem.InputMode == 0) treeNode.progUrl = ""; else treeNode.progUrl = ""; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } strTreeJson = CreateTreeJson(list, ""); } else { var ProgChildList = from o in dbEntity.GeneralPrograms.Include("Name").Include("Parent") where (o.Parent.Gid == id && o.Deleted == false) select o; var CheckList = (from o in dbEntity.GeneralPrograms.Include("Parent") from p in dbEntity.MemberPrivItems where (o.Parent.Gid == id && o.Deleted == false && p.Deleted == false && o.Gid == p.RefID) select new { Gid = p.RefID }).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in ProgChildList) { bool flag = false; LiveTreeNode treeNode = new LiveTreeNode(); for (int i = 0; i < CheckList.Count; i++) { if (item.Gid == CheckList[i].Gid) { treeNode.nodeChecked = true; flag = true; break; } } if (flag == false) treeNode.nodeChecked = false; treeNode.id = item.Gid.ToString(); //treeNode.name = item.name.GetResource(CurrentSession.Culture); treeNode.name = item.Name.Matter; treeNode.nodes = new List<LiveTreeNode>(); treeNode.progUrl = item.ProgUrl; list.Add(treeNode); } strTreeJson = CreateTreeJson(list, ""); } } else { return null; } } return "[" + strTreeJson + "]"; }
private List<LiveTreeNode> ListTreeNode(Guid id) { Guid? gNodeID = null; // 当展开root节点的时候 if (id != Guid.Empty) gNodeID = id; List<GeneralProgram> oUserPrograms; if (CurrentSession.IsAdmin) { oUserPrograms = (from g in dbEntity.GeneralPrograms where g.Deleted == false && (gNodeID == null ? g.aParent == null : g.aParent == gNodeID) orderby g.Sorting descending select g).ToList(); } else { List<Guid> fnFindProgs = dbEntity.Database.SqlQuery<Guid>("SELECT Gid FROM dbo.fn_FindFullPrograms({0})", CurrentSession.UserID).ToList(); oUserPrograms = (from g in dbEntity.GeneralPrograms join p in fnFindProgs on g.Gid equals p where (gNodeID == null ? g.aParent == null : g.aParent == gNodeID) orderby g.Sorting descending select g).ToList(); } List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in oUserPrograms) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.Name.GetResource(CurrentSession.Culture); treeNode.icon = ""; treeNode.iconClose = ""; treeNode.iconOpen = ""; treeNode.nodeChecked = false; if (item.Terminal == true) treeNode.isParent = false; else treeNode.isParent = true; treeNode.progUrl = item.ProgUrl; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } return list; }
/// <summary> /// 分类树结构 /// </summary> /// <returns></returns> public string CategoryTreeLoad() { //私有分类表中读出文章分类 var oPrivateCategory =(from o in dbEntity.GeneralPrivateCategorys.Include("Name").Include("ChildItems") where(o.OrgID==gOrgId && o.Ctype==7&&o.Parent==null &&o.Deleted ==false)select o).ToList(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in oPrivateCategory) { LiveTreeNode node = new LiveTreeNode(); node.id = item.Gid.ToString(); node.name = item.Name.GetResource(CurrentSession.Culture); if (item.ChildItems.Count > 0) node.isParent = true; else node.isParent = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); } string strTreeJson = CreateTree(list); return strTreeJson; }
/// <summary> /// 加载程序树形结构 /// </summary> /// <returns></returns> public string PrivProgramLoad() { var ProgList = from o in dbEntity.GeneralPrograms.Include("Name") where (o.Parent == null && o.Deleted == false) select o; var CheckList = (from o in dbEntity.GeneralPrograms from p in dbEntity.MemberPrivItems where (o.Parent == null && o.Deleted == false&& p.Deleted == false&&o.Gid==p.RefID) select new { Gid=p.RefID }).ToList(); int nCount = ProgList.ToList().Count; int nCheck = CheckList.Count; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in ProgList) { //bool flag = false; LiveTreeNode treeNode = new LiveTreeNode(); //for (int i = 0; i < CheckList.Count; i++) //{ // if (item.Gid == CheckList[i].Gid) // { // treeNode.nodeChecked = true; // flag = true; // break; // } //} //if(flag == false) treeNode.nodeChecked = false; treeNode.id = item.Gid.ToString(); //treeNode.name = item.name.GetResource(CurrentSession.Culture); treeNode.name = item.Name.Matter; treeNode.nodes = new List<LiveTreeNode>(); treeNode.progUrl = item.ProgUrl; list.Add(treeNode); } string strTreeJson = CreateTree(list); return strTreeJson; }
/// <summary> /// 返回生成树的json数据 /// </summary> /// <returns></returns> public string TreeLoad() { var privateCategoryList = dbEntity.GeneralPrivateCategorys.Where(o => o.Parent == null && o.Deleted == false && o.Ctype == nPrivateCategoryType).ToList(); int nPrivateCategoryCount = privateCategoryList.Count(); List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in privateCategoryList) { LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.Name.GetResource(CurrentSession.Culture); treeNode.icon = ""; treeNode.iconClose = ""; treeNode.iconOpen = ""; treeNode.nodeChecked = false; treeNode.nodeChecked = true; treeNode.progUrl = ""; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); } string strTreeJson = CreateTree(list); return strTreeJson; }
/// <summary> /// 展开供应商树节点 /// </summary> /// <param name="id"></param> /// <returns></returns> public string PrivSupplierExpand(Guid id) { string strTreeJson = ""; if (id.Equals("00000000-0000-0000-0000-000000000000")) { var SuppierList = from o in dbEntity.MemberOrganizations.Include("ShortName") where (o.Parent == null && o.Deleted == false) select o; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in SuppierList) { LiveTreeNode node = new LiveTreeNode(); node.name = item.ShortName.Matter; node.id = item.Gid.ToString(); node.nodeChecked = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); } strTreeJson = CreateTreeJson(list, ""); } else { var SupplierList = from o in dbEntity.MemberOrganizations.Include("ShortName") where (o.Parent.Gid == id && o.Deleted == false) select o; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in SupplierList) { LiveTreeNode node = new LiveTreeNode(); node.name = item.ShortName.Matter; node.id = item.Gid.ToString(); node.nodeChecked = false; node.nodes = new List<LiveTreeNode>(); list.Add(node); } strTreeJson = CreateTreeJson(list, ""); } return "[" + strTreeJson + "]"; }
/// <summary> /// 加载地区树形结构 /// </summary> /// <returns></returns> public string RegionTreeLoad() { var RegionTreeList = from o in dbEntity.GeneralRegions where (o.Parent == null && o.Deleted == false) select o; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in RegionTreeList) { LiveTreeNode node = new LiveTreeNode(); node.name = item.FullName; node.id = item.Gid.ToString(); node.nodes = new List<LiveTreeNode>(); list.Add(node); } string strTree = CreateTree(list); return strTree ; }
/// <summary> /// 加载程序树形结构 /// </summary> /// <returns></returns> public string PrivProgramLoad() { //首次加载的,父节点为空的程序 var oProgramList = (from o in dbEntity.GeneralPrograms.Include("ChildItems") where (o.Parent == null && o.Deleted == false) select o).ToList(); Guid gPriID = (from o in dbEntity.MemberPrivileges where (o.Ptype == 0 && o.Deleted == false && o.UserID == gUserID && o.Pstatus == (byte)ModelEnum.GenericStatus.VALID) select o.Gid).FirstOrDefault(); //已授权的程序 var oRefList = (from p in dbEntity.MemberPrivItems where (p.PrivID == gPriID && p.Deleted == false) select p).ToList(); int noRefList = oRefList.Count; bool flag = false; List<LiveTreeNode> list = new List<LiveTreeNode>(); foreach (var item in oProgramList) { for (int i = 0; i < noRefList; i++) { if (item.Gid == oRefList[i].RefID) { flag = true; break; } } LiveTreeNode treeNode = new LiveTreeNode(); treeNode.id = item.Gid.ToString(); treeNode.name = item.Name.GetResource(CurrentSession.Culture); if (flag == false) treeNode.nodeChecked = false; else treeNode.nodeChecked = true; if (item.Terminal==false) treeNode.isParent = true; else treeNode.isParent = false; treeNode.nodes = new List<LiveTreeNode>(); list.Add(treeNode); flag = false; } string strTreeJson = CreateTree(list); return strTreeJson; }