示例#1
0
        /// <summary>
        /// Application_Start
        /// </summary>
        protected void Application_Start()
        {
            //MVC相关
            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            //初始化容器
            XCodeContainer.CreateInstance();
            ////DI 构造函数注入
            IocInitializeConstructor.Initialize();
            //属性注入
            //new IocInitializeProperties().Initialize();

            //数据库基础数据初始化
            DbInitService.Init();

            //定时任务
            //new EmailJobScheduler().Start();


            //AutoMapper
            AutoMapperConfiguration.Config();
            AutoMapperConfiguration.ConfigExt();
        }
 public static MvcHtmlString ActionPermissionLink(this HtmlHelper htmlHelper, string controllerName, string actionName, object routeValue)
 {
     if (XCodeContainer.Resolve <IPermissionService>().Authorize(""))
     {
         return(htmlHelper.ActionLink(controllerName, actionName, routeValue));
     }
     return(MvcHtmlString.Empty);
 }
 public static MvcHtmlString ActionPermissionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string permissionName)
 {
     if (XCodeContainer.Resolve <IPermissionService>().Authorize(permissionName))
     {
         return(htmlHelper.ActionLink(linkText, actionName));
     }
     return(MvcHtmlString.Empty);
 }
        public ActionResult Init()
        {
            var type_finder = XCodeContainer.Resolve <ITypeFinder>();

            var dr_types = type_finder.FindClassesOfType <Controller>();
            var types    = dr_types.Where(x => x.GetCustomAttributes(typeof(NavigateNameAttribute), true).Any());

            foreach (MenuName enmu_name in Enum.GetValues(typeof(MenuName)))
            {
                var parent = new NavigateDto()
                {
                    Name = enmu_name.value_name(),
                    Url  = "#",
                    Type = MenuType.Module
                };
                service.Add(parent);

                var nav_attr = types.Where(x => x.GetAttribute <NavigateNameAttribute>().ParentName == enmu_name);

                foreach (var type in nav_attr)
                {
                    var controller_name = type.Name.Substring(0, type.Name.Length - 10);
                    var test            = type.GetMethods().Where(x => x.IsPublic && x.GetCustomAttributes(typeof(NavigateNameAttribute), true).Any());
                    foreach (var method_info in test)
                    {
                        var tetssss = method_info.GetAttribute <NavigateNameAttribute>(false);

                        //service.add_children_nav(parent, new NavigateDto()
                        //{
                        //    Name = method_info.NavigateName(),
                        //    Type = tetssss.Type,
                        //    ControllerName = controller_name,
                        //    ActionName = method_info.Name,
                        //    Url = "/Adm/" + controller_name + "/" + method_info.Name
                        //});
                    }
                }
            }


            return(RedirectToAction("Index"));
        }