/// <summary> /// 数据信息工整 /// </summary> public static void FixMenus() { BLL.menus bmenus = new BLL.menus(); var list = bmenus.GetList(); for (int i = 0; i < list.Count; i++) { var item = list[i]; var itempath = item.path; var itempathArr = itempath.Trim('-').Split('-'); var pathdeep = itempathArr.Length; var innerList = bmenus.GetList().FindAll(c => c.path.IndexOf(itempath) > -1); var realMenu = bmenus.GetList().Find(c => c.path == itempath);//绝对存在 if (realMenu != null) { if (innerList.Count > 1) { realMenu.stem = 1; realMenu.haschild = 1; } else { realMenu.stem = 0; realMenu.haschild = 0; } bmenus.Update(realMenu); } } }
protected void Page_Load(object sender, EventArgs e) { BLL.menus bmenus = new BLL.menus(); productParentmenu = bmenus.GetList().Find(c => c.linktag == "product"); productMenulist = bmenus.GetList().FindAll(c => c.parentid == productParentmenu.id);//只取一层级 colorParentmenu = bmenus.GetList().Find(c => c.linktag == "color"); colorMenulist = bmenus.GetList().FindAll(c => c.parentid == colorParentmenu.id);//只取一层级 }
/// <summary> /// 删除外键数据相关 /// </summary> /// <param name="ids"></param> public static void FixMenusExt(string ids) { BLL.menus bmenus = new BLL.menus(); BLL.posts bposts = new BLL.posts(); var arr = ids.Split(','); for (int i = 0; i < arr.Length; i++) { var id = arr[i]; var menu = bmenus.Get(Int32.Parse(id)); if (menu != null) { var list = bmenus.GetList().FindAll(c => c.path.IndexOf(menu.path) > -1); for (int j = 0; j < list.Count; j++) { var sub = list[j]; bmenus.Del(sub.id);//删除关联menus //删除关联子posts,并非typeid in ids var postList = bposts.GetList("typeid=" + sub.id); for (int m = 0; m < postList.Count; m++) { var item = postList[m]; bposts.Del(item.id); } } } } }
protected void Page_Load(object sender, EventArgs e) { BLL.menus bmenus = new BLL.menus(); parentmenu = bmenus.GetList().Find(c => c.linktag == linktag); menulist = bmenus.GetList().FindAll(c => c.parentid == parentmenu.id);//只取一层级 }