using CP.Model; using System; using System.Collections.Generic; using System.Linq; using System.Web; using CP.Common; using System.Configuration; using System.Linq.Expressions; namespace CP.Kjh.Models { public class RouteHelper { #region 配置 private static readonly Lazy> routeList = new Lazy>(() => { var data = OtherHelper.ConvertXMLToObject(HttpContext.Current.Server.MapPath($@"{ConfigurationManager.AppSettings["RouteXml"]}")); data.ForEach(p => { if (p.ViewNewName.IsEmpty()) p.ViewNewName = p.OldName; }); return data; }); private static readonly Lazy> homeRouteList = new Lazy>(() => OtherHelper.ConvertXMLToObject(HttpContext.Current.Server.MapPath($@"{ConfigurationManager.AppSettings["HomeRouteXml"]}"))); /// /// 彩种类型配置数据 /// public static List RouteList { get { return routeList.Value; } } /// /// 首页的路由配置数据 /// public static List HomeRouteList { get { return homeRouteList.Value; } } #endregion /// /// 得到新版类型名称 /// /// /// public static string GetNewTypeName(string oldTypeName) { var list = RouteList.Where(p => p.OldName == oldTypeName).ToList(); if (list.Count > 0) return list[0].NewName; return oldTypeName; } /// /// 得到旧版类型名称 /// /// /// public static string GetOldTypeName(string newTypeName) { var list = RouteList.Where(p => p.NewName == newTypeName).ToList(); if (list.Count > 0) return list[0].OldName; return newTypeName; } /// /// 得到路由集合 /// /// public static List GetRouteList(CzTypeEnum? czTypeEnum) { if (czTypeEnum.HasValue) return RouteList.Where(p => p.CzTypeEnum == (int)czTypeEnum && p.IsShow == true).ToList(); return RouteList; } /// /// 得到首页的路由集合 /// /// public static List GetHomeRouteList() { return HomeRouteList; } } }