public ListPublishHandler(string Url) { config = (ListConfigurationSection)ConfigurationManager.GetSection("publish/listPublish"); Logger = LogManager.GetLogger(config.Logger); dal = new ListDataAccess(config); PageParameter = GetParameter(Url); PageFileName = GetPageFileName(); }
private ListPageParameter GetParameter(string Url) { ListPageParameter parm = null; string pattern = @"list(_|-)+(?<cfid>\d+)((_|-)+(?<pageIndex>\d+))?((_|-)+b(?<brand>\d+))?((_|-)+r(?<price>\d+~\d+))?((_|-)+o(?<order>\d+))?((_|-)+v(?<properity>.+)e)?"; Match match = Regex.Match(Url, pattern); if (match.Success) { parm = new ListPageParameter(); parm.Properities = null; parm.OrderValue = 0; parm.CategoryID = int.Parse(match.Groups["cfid"].Value); parm.BrandID = 0; parm.PriceRange = null; if (match.Groups["pageIndex"].Success) parm.PageIndex = int.Parse(match.Groups["pageIndex"].Value); if (match.Groups["order"].Success) parm.OrderValue = int.Parse(match.Groups["order"].Value); if (match.Groups["brand"].Success) parm.BrandID = int.Parse(match.Groups["brand"].Value); if (match.Groups["price"].Success) parm.PriceRange = new decimal[2] { decimal.Parse(match.Groups["price"].Value.Split('~')[0]), decimal.Parse(match.Groups["price"].Value.Split('~')[1]) }; if (match.Groups["properity"].Success) { parm.Properities = new Hashtable(); foreach (string pv in match.Groups["properity"].Value.Split(',')) { parm.Properities.Add(pv.Split('-')[0],pv.Split('-')[1]); } } } if (parm.PageIndex == 0) parm.PageIndex = 1; return parm; }