public static string GetMeta(string _str) { string str = string.Empty; Meta mata = new Meta(); Meues m = new Meues(); try { XmlDocument doc = new XmlDocument(); doc.Load(HttpContext.Current.Server.MapPath("Config/MenuType.xml")); XmlNode root = doc.DocumentElement; //获取节点列表 XmlNodeList items = root.ChildNodes; //遍历item项 foreach (XmlNode item in items) { //var sss= item.Attributes["belong"].InnerText; str = item[_str].InnerText; } } catch (Exception es) { Tool.WritrErro(es); } return(str); }
public static DataTable GetMenu() { DataTable dt = new DataTable(); Meues m = new Meues(); dt.Columns.Add(m.Title); dt.Columns.Add(m.Id); dt.Columns.Add(m.Name); dt.Columns.Add(m.Url); try { XmlDocument doc = new XmlDocument(); doc.Load(HttpContext.Current.Server.MapPath("Config/MenuType.xml")); XmlNode root = doc.DocumentElement; //获取节点列表 XmlNodeList items = root.ChildNodes; //遍历item项 foreach (XmlNode item in items) { DataRow row = dt.NewRow(); row[m.Title] = item.Attributes["belong"].InnerText; row[m.Id] = item["ID"].InnerText; row[m.Name] = item["NAME"].InnerText; row[m.Url] = item["url"].InnerText; dt.Rows.Add(row); } } catch (Exception es) { Tool.WritrErro(es); } return(dt); }
/// <summary> /// 获取一级菜单名 /// </summary> /// <returns></returns> public static List <string> GetMenu_Title() { Meues m = new Meues(); List <string> list = new List <string>(); DataTable dt = DBHelper.GetMenu(); for (int i = 0; i < dt.Rows.Count; i++) { list.Add(dt.Rows[i][m.Title].ToString()); } return(list); }
public static Dictionary <string, string> GetName() { Meues m = new Meues(); Dictionary <string, string> dict = new Dictionary <string, string>(); for (int i = 0; i < GetMenu().Rows.Count; i++) { if (!dict.ContainsKey(GetMenu().Rows[i][m.Name].ToString())) { dict.Add(GetMenu().Rows[i][m.Name].ToString(), GetMenu().Rows[i][m.Url].ToString()); } } return(dict); }
public static Dictionary <string, string> GetTwoName() { Meues m = new Meues(); Dictionary <string, string> dict = new Dictionary <string, string>(); for (int i = 0; i < GetMenu_Title().Count; i++) { string name = GetMenu_Title()[i].ToString(); for (int j = 0; j < GetMenu().Rows.Count; j++) { if (name == GetMenu().Rows[i][m.Title].ToString()) { if (!dict.ContainsKey(name)) { dict.Add(name, GetMenu().Rows[i][m.Url].ToString()); } break; } } } return(dict); }