示例#1
0
        public static Menu[] GetAllMenus()
        {//先去掉state树状态,just for test
            List <Menu> retValue = new List <Menu>();

            using (MySqlConnection conn = DBUtility.OpenConnection())
            {
                Menu[] menus = MenuDal.GetMenusByParentID(0, conn);
                foreach (Menu menu in menus)
                {
                    //child
                    Menu[] children = MenuDal.GetMenusByParentID(menu.id, conn);
                    if (children != null && children.Length > 0)
                    {
                        menu.children = new Menu[children.Length];
                        for (int i = 0; i < children.Length; i++)
                        {
                            menu.children[i] = children[i];
                            //menu.children[i].state = "";
                        }
                    }
                    retValue.Add(menu);
                }
            }
            if (retValue.Count > 0)
            {
                //retValue[0].state = "";
            }
            return(retValue.ToArray());
        }