/// <summary>
    /// 生成用户功能菜单
    /// </summary>
    public static MvcHtmlString CreateMenu(this HtmlHelper helper)
    {
        using (DBEntity db = new DBEntity())
        {
            int roleID = 1;
            IEnumerable<UserBrowseViewModel> modules = db.GetUserBrowse(roleID).AsEnumerable();

            string parentMenu = "<a href=\"#{0}\" class=\"nav-header\" data-toggle=\"collapse\"><i class=\"ico-menu ico-{1}\"></i>{2}</a>";
            string childMenu = "<ul id=\"{0}\" class=\"nav nav-list collapse in\">{1}</ul>";
            string childContent = "<li><a target=\"content\" href=\"/{0}\"><i class=\"ico-menu ico-{1}\"></i>{2}</a></li>";

            IList<UserBrowseViewModel> parentModules = modules.GetEntities(m => m.ParentId == null).ToList();
            IEnumerable<Module> childModules = null;
            StringBuilder strBuilder = new StringBuilder();
            StringBuilder childBuilder = new StringBuilder();
            foreach (var parent in parentModules)
            {
                strBuilder.AppendFormat(parentMenu, parent.Name + "-menu", parent.Code, parent.Name);
                childModules = db.Module.GetEntities(m => m.ParentId == parent.ID);
                foreach (var child in childModules)
                {
                    childBuilder.AppendFormat(childContent, child.Url, child.Code, child.Name);
                }

                strBuilder.AppendFormat(childMenu, parent.Name + "-menu", childBuilder.ToString());
                childBuilder.Clear();
            }

            return MvcHtmlString.Create(strBuilder.ToString());
        }
    }
 public override void OnAuthorization(AuthorizationContext filterContext)
 {
     //ToTest
     //int roleID = Convert.ToInt32(HttpContext.Current.Session["RoleID"]);
     int roleID = 1;
     using (DBEntity db = new DBEntity())
     {
         IEnumerable<UserBrowseViewModel> modules = db.GetUserBrowse(roleID).AsEnumerable();
         foreach (UserBrowseViewModel module in modules)
         {
             filterContext.SetViewData(module.Code, module.Name);
         }
     }
 }