/// <summary> /// 取得URL配制列表 /// </summary> public List <Dapper.Model.url_rewrite> GetList(string channel) { List <Dapper.Model.url_rewrite> ls = new List <Dapper.Model.url_rewrite>(); string filePath = Utils.GetXmlMapPath(DTKeys.FILE_URL_XML_CONFING); XmlDocument doc = new XmlDocument(); doc.Load(filePath); XmlNode xn = doc.SelectSingleNode("urls"); foreach (XmlElement xe in xn.ChildNodes) { if (xe.NodeType != XmlNodeType.Comment && xe.Name.ToLower() == "rewrite") { if (xe.Attributes["name"] != null) { if (!string.IsNullOrEmpty(channel)) { if (xe.Attributes["channel"] != null && channel.ToLower() == xe.Attributes["channel"].Value.ToLower()) { Dapper.Model.url_rewrite model = new Dapper.Model.url_rewrite(); if (xe.Attributes["name"] != null) { model.name = xe.Attributes["name"].Value; } if (xe.Attributes["type"] != null) { model.type = xe.Attributes["type"].Value; } if (xe.Attributes["page"] != null) { model.page = xe.Attributes["page"].Value; } if (xe.Attributes["inherit"] != null) { model.inherit = xe.Attributes["inherit"].Value; } if (xe.Attributes["templet"] != null) { model.templet = xe.Attributes["templet"].Value; } if (xe.Attributes["channel"] != null) { model.channel = xe.Attributes["channel"].Value; } if (xe.Attributes["pagesize"] != null) { model.pagesize = xe.Attributes["pagesize"].Value; } //再次遍历子节点 StringBuilder urlRewriteString = new StringBuilder(); List <Dapper.Model.url_rewrite_item> lsItems = new List <Dapper.Model.url_rewrite_item>(); foreach (XmlElement xe1 in xe.ChildNodes) { if (xe1.NodeType != XmlNodeType.Comment && xe1.Name.ToLower() == "item") { Dapper.Model.url_rewrite_item item = new Dapper.Model.url_rewrite_item(); if (xe1.Attributes["path"] != null) { item.path = xe1.Attributes["path"].Value; } if (xe1.Attributes["pattern"] != null) { item.pattern = xe1.Attributes["pattern"].Value; } if (xe1.Attributes["querystring"] != null) { item.querystring = xe1.Attributes["querystring"].Value; } urlRewriteString.Append(item.path + "," + item.pattern + "," + item.querystring + "&"); //组合成字符串 lsItems.Add(item); } } model.url_rewrite_str = Utils.DelLastChar(urlRewriteString.ToString(), "&"); model.url_rewrite_items = lsItems; ls.Add(model); } } else { Dapper.Model.url_rewrite model = new Dapper.Model.url_rewrite(); if (xe.Attributes["name"] != null) { model.name = xe.Attributes["name"].Value; } if (xe.Attributes["type"] != null) { model.type = xe.Attributes["type"].Value; } if (xe.Attributes["page"] != null) { model.page = xe.Attributes["page"].Value; } if (xe.Attributes["inherit"] != null) { model.inherit = xe.Attributes["inherit"].Value; } if (xe.Attributes["templet"] != null) { model.templet = xe.Attributes["templet"].Value; } if (xe.Attributes["channel"] != null) { model.channel = xe.Attributes["channel"].Value; } if (xe.Attributes["pagesize"] != null) { model.pagesize = xe.Attributes["pagesize"].Value; } //再次遍历子节点 StringBuilder urlRewriteString = new StringBuilder(); List <Dapper.Model.url_rewrite_item> lsItems = new List <Dapper.Model.url_rewrite_item>(); foreach (XmlElement xe1 in xe.ChildNodes) { if (xe1.NodeType != XmlNodeType.Comment && xe1.Name.ToLower() == "item") { Dapper.Model.url_rewrite_item item = new Dapper.Model.url_rewrite_item(); if (xe1.Attributes["path"] != null) { item.path = xe1.Attributes["path"].Value; } if (xe1.Attributes["pattern"] != null) { item.pattern = xe1.Attributes["pattern"].Value; } if (xe1.Attributes["querystring"] != null) { item.querystring = xe1.Attributes["querystring"].Value; } urlRewriteString.Append(item.path + "," + item.pattern + "," + item.querystring + "&"); //组合成字符串 lsItems.Add(item); } } model.url_rewrite_str = Utils.DelLastChar(urlRewriteString.ToString(), "&"); model.url_rewrite_items = lsItems; ls.Add(model); } } } } return(ls); }
/// <summary> /// 取得节点配制信息 /// </summary> public Dapper.Model.url_rewrite GetInfo(string attrValue) { Dapper.Model.url_rewrite model = new Dapper.Model.url_rewrite(); string filePath = Utils.GetXmlMapPath(DTKeys.FILE_URL_XML_CONFING); XmlDocument doc = new XmlDocument(); doc.Load(filePath); XmlNode xn = doc.SelectSingleNode("urls"); XmlNodeList xnList = xn.ChildNodes; if (xnList.Count > 0) { foreach (XmlElement xe in xnList) { if (xe.Attributes["name"].Value.ToLower() == attrValue.ToLower()) { if (xe.Attributes["name"] != null) { model.name = xe.Attributes["name"].Value; } if (xe.Attributes["type"] != null) { model.type = xe.Attributes["type"].Value; } if (xe.Attributes["page"] != null) { model.page = xe.Attributes["page"].Value; } if (xe.Attributes["inherit"] != null) { model.inherit = xe.Attributes["inherit"].Value; } if (xe.Attributes["templet"] != null) { model.templet = xe.Attributes["templet"].Value; } if (xe.Attributes["channel"] != null) { model.channel = xe.Attributes["channel"].Value; } if (xe.Attributes["pagesize"] != null) { model.pagesize = xe.Attributes["pagesize"].Value; } //再次遍历子节点 List <Dapper.Model.url_rewrite_item> lsItems = new List <Dapper.Model.url_rewrite_item>(); foreach (XmlElement xe1 in xe.ChildNodes) { if (xe1.NodeType != XmlNodeType.Comment && xe1.Name.ToLower() == "item") { Dapper.Model.url_rewrite_item item = new Dapper.Model.url_rewrite_item(); if (xe1.Attributes["path"] != null) { item.path = xe1.Attributes["path"].Value; } if (xe1.Attributes["pattern"] != null) { item.pattern = xe1.Attributes["pattern"].Value; } if (xe1.Attributes["querystring"] != null) { item.querystring = xe1.Attributes["querystring"].Value; } lsItems.Add(item); } } model.url_rewrite_items = lsItems; return(model); } } } return(null); }