/// <summary> /// ��ʼ�� /// </summary> protected override void Init() { XmlDocument docXml = new XmlDocument(); docXml.Load(System.Web.HttpContext.Current.Server.MapPath("/Config/urls.config")); XmlNodeList list = docXml.GetElementsByTagName("rewrite"); for (int i = 0; i < list.Count; i++) { URLPatternInfo info = new URLPatternInfo(); info.Name = list[i].Attributes["name"].Value.ToString(); info.Page = list[i].Attributes["page"].Value.ToString().Replace("^", "&"); info.Pattern = list[i].Attributes["pattern"].Value.ToString(); info.QueryString = list[i].Attributes["querystring"].Value.ToString().Replace("^", "&"); info.Path = list[i].Attributes["path"].Value.ToString(); XmlAttribute att = list[i].Attributes["group"]; info.Group = ""; if (att != null) info.Group = att.Value.ToString(); UrlItems.Add(info); string gp = info.Group.Trim().ToLower(); switch (gp) { case "shop": ShopUrlItems.Add(info); break; case "news": NewsUrlItems.Add(info); break; case "trade": TradeUrlItems.Add(info); break; case "area": AreaUrlItems.Add(info); break; case "cate": ProCateUrlItems.Add(info); break; case "topshop": TopShopUrlItems.Add(info); break; case "sp": SpUrlItems.Add(info); break; default: GeneralUrlItems.Add(info); break; } } }
/// <summary> /// ������� /// </summary> /// <param name="info">������Ϣ</param> /// <returns></returns> public UrlsInsertState Insert(URLPatternInfo info) { if (null == GetItem(info.Name)) { //urlItems.Add(info); UrlItems.Insert(0, info); if (Update()) return UrlsInsertState.Inserted; else return UrlsInsertState.Error; } else { return UrlsInsertState.Iterance; } }