/// <summary>
 /// 存储顶级导航分类
 /// </summary>
 /// <param name="session">数据库会话</param>
 /// <param name="container">导航分类容器</param>
 private void SaveNavigationContainer(Session session, NavigationContainer container)
 {
     _navCagotryDict.Clear();
     foreach (var category in container.Categories)
     {
         SaveNavigationContainer(session, category, 0);
     }
 }
        /// <summary>
        /// 注册导航
        /// </summary>
        /// <param name="session"></param>
        /// <param name="container">导航分类容器</param>
        internal void RegisterNavigation(Session session, NavigationContainer container)
        {
            var moduleOrderDict = new Dictionary<string, int>();
            AddModuleOrder(container.Categories, moduleOrderDict);

            var assembly = typeof(SystemActivity).Assembly;

            foreach (var type in assembly.GetExportedTypes())
            {
                if (type == null) continue;
                if (!type.FullName.EndsWith("Controller")) continue;

                var categoryAttrs = GetCategoryAttributes(type);
                if (categoryAttrs == null)
                {
                    _logger.Warn("{0}没有CategoryAttribute标记", type.FullName);
                    continue;
                }

                var moduleAttr = GetModuleAttribute(type);
                if (moduleAttr == null)
                {
                    _logger.Warn("{0}没有ModuleAttribute标记", type.FullName);
                    continue;
                }

                _logger.Info("处理控制器 {0}", type.FullName);

                var area = GetArea(type);

                // 隐藏
                if (categoryAttrs.Any(m => m.HideMenu)) continue;

                var categoryId = SaveNavigationCategory(session, categoryAttrs);

                var moduleOrderId = string.IsNullOrEmpty(moduleAttr.Name) ? 0 :
                    moduleOrderDict.ContainsKey(moduleAttr.Name) ? moduleOrderDict[moduleAttr.Name] : 0;

                var moduleId = SaveNavigation(session, moduleAttr, categoryId , moduleOrderId, type.Name.Replace("Controller", ""));
                var hasNormalMoudle = !string.IsNullOrEmpty(moduleAttr.Name);
                var foundDefaultModuleAction = false;

                var controller = type.Name.Replace("Controller", String.Empty);

                var validMethodsCount = 0;

                foreach (var mi in type.GetMethods())
                {
                    var action = mi.Name;
                    _logger.Debug("process Controller {0} Actioon {1}", controller, action);

                    // 更新模块的URL
                    if (hasNormalMoudle && !foundDefaultModuleAction && moduleAttr.DefaultAction != null && action.Equals(moduleAttr.DefaultAction))
                    {
                        foundDefaultModuleAction = true;
                        SaveNavigation(session, moduleId, GetUrl(area, controller, action));
                        continue;
                    }

                    var attr = GetPriviledgeAttribute(mi);
                    if (attr == null) continue;

                    if (!attr.NotCheck) validMethodsCount++;
                    SaveNavigation(session, attr, moduleId, area, controller, action);
                }

                if (validMethodsCount == 0)
                {
                    var count = session.Count<Navigation>(m => m.ParentId.Equals(categoryId));
                    if (count == 0)
                    {
                        if (!session.Delete<Navigation>(m => m.Id.Equals(categoryId))) throw new Exception("删除数据分类失败");
                    }
                }
                else
                {
                    var nav = session.Load<Navigation>(moduleId);
                    nav.AuthCode = Navigation.ShouldCheck;
                    if (!session.Update(nav)) throw new Exception("更新数据模块[NotCheck]失败");

                    if (moduleId != categoryId)
                    {
                        nav = session.Load<Navigation>(categoryId);
                        nav.AuthCode = Navigation.ShouldCheck;
                        if (!session.Update(nav)) throw new Exception("更新数据分类[NotCheck]失败");

                    }

                }
            }
        }