public ActionResult GetMenuNodeList() { string fucId = Request.Params[0].Trim(); string userId = HttpContext.Session["User"].ToString(); MenuNodeList nodeList = new MenuNodeList(userId); MenuNode root = nodeList.GetCurrentRootNode(fucId); IList <MenuNodeDTO> result = new List <MenuNodeDTO>(); foreach (MenuNode child in root.Children) { MenuNodeDTO dto = new MenuNodeDTO(); dto.id = child.ID; dto.text = child.Name; dto.url = child.Url; dto.leaf = true; if (child.Children.Count > 0) { dto.leaf = false; dto.childNodes = new List <MenuNodeDTO>(); AddToRoot(child, dto.childNodes); } result.Add(dto); } return(this.Json(result)); }
public void AddToRoot(MenuNode parent, List<MenuNodeDTO> dtoList) { int i = 0; foreach (MenuNode child in parent.Children) { MenuNodeDTO dto = new MenuNodeDTO(); dto.id = child.ID; dto.text = child.Name; dto.url = child.Url; dto.leaf = true; if (child.Children.Count > 0) { dto.leaf = false; dto.childNodes = new List<MenuNodeDTO>(); AddToRoot(child, dto.childNodes); } dtoList.Add(dto); i++; } }
public void AddToRoot(MenuNode parent, List <MenuNodeDTO> dtoList) { int i = 0; foreach (MenuNode child in parent.Children) { MenuNodeDTO dto = new MenuNodeDTO(); dto.id = child.ID; dto.text = child.Name; dto.url = child.Url; dto.leaf = true; if (child.Children.Count > 0) { dto.leaf = false; dto.childNodes = new List <MenuNodeDTO>(); AddToRoot(child, dto.childNodes); } dtoList.Add(dto); i++; } }
public IList GetMenuNodeList() { IList rootList = new ArrayList(); ArrayList functionlist = ManagerFactory.UserManager.GetPermissionList(userId) as ArrayList; foreach (object[] fuc in functionlist) { string id = fuc[0].ToString(); int index = id.IndexOf("0"); int length = id.Length; if (nodeList.Count == 0) { if (index != 1) { continue; } if (IsCorrect(id, index)) { MenuNode node = new MenuNode(id, fuc[1].ToString(), fuc[2].ToString()); nodeList.Add(id, node); rootList.Add(node); } continue; } if (index == 1) { if (!nodeList.ContainsKey(id)) { if (IsCorrect(id, index)) { MenuNode node = new MenuNode(id, fuc[1].ToString(), fuc[2].ToString()); nodeList.Add(id, node); rootList.Add(node); } } } else { string parentId = ""; if (index != -1) { parentId = id.Substring(0, (index - 1)); } else { parentId = id.Substring(0, (length - 1)); } parentId = parentId.PadRight(length, '0'); if (nodeList.ContainsKey(parentId)) { if (IsCorrect(id, index)) { MenuNode node = new MenuNode(id, fuc[1].ToString(), fuc[2].ToString()); nodeList.Add(id, node); nodeList[parentId].Children.Add(node); nodeList[parentId].Leaf = false; } } } } return(rootList); }
public IList GetMenuNodeList() { IList rootList = new ArrayList(); ArrayList functionlist = ManagerFactory.UserManager.GetPermissionList(userId) as ArrayList; foreach (object[] fuc in functionlist) { string id = fuc[0].ToString(); int index = id.IndexOf("0"); int length = id.Length; if( nodeList.Count == 0 ) { if( index != 1 ) continue; if( IsCorrect( id, index )){ MenuNode node = new MenuNode(id, fuc[1].ToString(), fuc[2].ToString()); nodeList.Add( id, node ); rootList.Add( node ); } continue; } if( index == 1 ) { if( !nodeList.ContainsKey( id )) { if( IsCorrect( id, index )){ MenuNode node = new MenuNode(id, fuc[1].ToString(), fuc[2].ToString()); nodeList.Add( id, node ); rootList.Add( node ); } } } else { string parentId = ""; if( index != - 1) parentId = id.Substring( 0, ( index - 1 )); else parentId = id.Substring( 0, ( length - 1 )); parentId = parentId.PadRight( length , '0' ); if( nodeList.ContainsKey( parentId )) { if( IsCorrect( id, index )){ MenuNode node = new MenuNode(id, fuc[1].ToString(), fuc[2].ToString()); nodeList.Add( id, node ); nodeList[ parentId ].Children.Add( node ); nodeList[ parentId ].Leaf = false; } } } } return rootList; }