/// <summary> /// 修改节点 /// </summary> public bool Edit(Model.configs.urls_config model) { string filePath = Utils.GetXmlMapPath(OSKeys.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() == model.Name.ToLower()) { if (!string.IsNullOrEmpty(model.Path)) { xe.SetAttribute("path", model.Path); } else if (xe.Attributes["path"] != null) { xe.Attributes["path"].RemoveAll(); } if (!string.IsNullOrEmpty(model.Pattern)) { xe.SetAttribute("pattern", model.Pattern); } else if (xe.Attributes["Pattern"] != null) { xe.Attributes["pattern"].RemoveAll(); } if (!string.IsNullOrEmpty(model.Page)) { xe.SetAttribute("page", model.Page); } else if (xe.Attributes["Page"] != null) { xe.Attributes["page"].RemoveAll(); } if (!string.IsNullOrEmpty(model.QueryString)) { xe.SetAttribute("querystrings", model.QueryString); } else if (xe.Attributes["querystrings"] != null) { xe.Attributes["querystrings"].RemoveAll(); } doc.Save(filePath); return(true); } } } return(false); }
/// <summary> /// 取得节点配制信息 /// </summary> public Model.configs.urls_config GetInfo(string attrValue) { Model.configs.urls_config model = new Model.configs.urls_config(); string filePath = Utils.GetXmlMapPath(OSKeys.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["path"] != null) { model.Path = xe.Attributes["path"].Value; } if (xe.Attributes["pattern"] != null) { model.Pattern = xe.Attributes["pattern"].Value; } if (xe.Attributes["page"] != null) { model.Page = xe.Attributes["page"].Value; } if (xe.Attributes["querystrings"] != null) { model.QueryString = xe.Attributes["querystrings"].Value; } return(model); } } } return(null); }
/// <summary> /// 取得URL配制列表 /// </summary> public List <Model.configs.urls_config> GetList() { List <Model.configs.urls_config> ls = new List <Model.configs.urls_config>(); string filePath = Utils.GetXmlMapPath(OSKeys.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) { Model.configs.urls_config model = new Model.configs.urls_config(); if (xe.Attributes["name"] != null) { model.Name = xe.Attributes["name"].Value; } if (xe.Attributes["path"] != null) { model.Path = xe.Attributes["path"].Value; } if (xe.Attributes["pattern"] != null) { model.Pattern = xe.Attributes["pattern"].Value; } if (xe.Attributes["page"] != null) { model.Page = xe.Attributes["page"].Value; } if (xe.Attributes["querystrings"] != null) { model.QueryString = xe.Attributes["querystrings"].Value; } ls.Add(model); } } } return(ls); }
/// <summary> /// 增加节点 /// </summary> public bool Add(Model.configs.urls_config model) { try { string filePath = Utils.GetXmlMapPath(OSKeys.FILE_URL_XML_CONFING); XmlDocument doc = new XmlDocument(); doc.Load(filePath); XmlNode xn = doc.SelectSingleNode("urls"); XmlElement xe = doc.CreateElement("rewrite"); if (!string.IsNullOrEmpty(model.Name)) { xe.SetAttribute("name", model.Name); } if (!string.IsNullOrEmpty(model.Path)) { xe.SetAttribute("path", model.Path); } if (!string.IsNullOrEmpty(model.Pattern)) { xe.SetAttribute("pattern", model.Pattern); } if (!string.IsNullOrEmpty(model.Page)) { xe.SetAttribute("page", model.Page); } if (!string.IsNullOrEmpty(model.QueryString)) { xe.SetAttribute("querystrings", model.QueryString); } XmlNode newXn = xn.AppendChild(xe); doc.Save(filePath); return(true); } catch { return(false); } }
/// <summary> /// 取得节点配制信息 /// </summary> public Model.configs.urls_config GetInfo(string attrValue) { Model.configs.urls_config model = new Model.configs.urls_config(); string filePath = Utils.GetXmlMapPath(OSKeys.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["path"] != null) model.Path = xe.Attributes["path"].Value; if (xe.Attributes["pattern"] != null) model.Pattern = xe.Attributes["pattern"].Value; if (xe.Attributes["page"] != null) model.Page = xe.Attributes["page"].Value; if (xe.Attributes["querystrings"] != null) model.QueryString = xe.Attributes["querystrings"].Value; return model; } } } return null; }
/// <summary> /// 取得URL配制列表 /// </summary> public List<Model.configs.urls_config> GetList() { List<Model.configs.urls_config> ls = new List<Model.configs.urls_config>(); string filePath = Utils.GetXmlMapPath(OSKeys.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) { Model.configs.urls_config model = new Model.configs.urls_config(); if (xe.Attributes["name"] != null) model.Name = xe.Attributes["name"].Value; if (xe.Attributes["path"] != null) model.Path = xe.Attributes["path"].Value; if (xe.Attributes["pattern"] != null) model.Pattern = xe.Attributes["pattern"].Value; if (xe.Attributes["page"] != null) model.Page = xe.Attributes["page"].Value; if (xe.Attributes["querystrings"] != null) model.QueryString = xe.Attributes["querystrings"].Value; ls.Add(model); } } } return ls; }
/// <summary> /// 修改节点 /// </summary> public bool Edit(Model.configs.urls_config model) { return(dal.Edit(model)); }
/// <summary> /// 增加节点 /// </summary> public bool Add(Model.configs.urls_config model) { return(dal.Add(model)); }