public ActionResult InitSystemButton()
        {
            List <SystemButton>      btnlist    = new List <SystemButton>();
            IList <ActionPermission> allActions = new unity().GetAllActionByAssembly();

            foreach (ActionPermission ap in allActions)
            {
                //这种方法会产生垃圾数据,比如废弃的action或controller、area会一直存在Systembutton表
                SystemButton btn = new SystemButton();
                btn = _SystemButtonService.GetWhere(b => b.ButtonCode == ap.AreaName + "." + ap.ControllerName + "." + ap.ActionName).FirstOrDefault();
                if (btn == null)
                {
                    btn                = new SystemButton();
                    btn.ActionName     = ap.ActionName;
                    btn.AreaName       = ap.AreaName;
                    btn.ControllerName = ap.ControllerName;
                    btn.Description    = ap.Description;
                    btn.Title          = ap.Description;
                    btn.ButtonCode     = ap.AreaName + "." + ap.ControllerName + "." + ap.ActionName;
                    _SystemButtonService.Add(btn);
                    _SystemButtonService.Save();
                }
                else
                {
                    btn.Description = ap.Description;
                    btn.Title       = ap.Description;
                    _SystemButtonService.Save();
                }
            }

            return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult RoleButton(string roleid)
        {
            if (!string.IsNullOrEmpty(roleid))
            {
                IList <ActionPermission> allActions = new unity().GetAllActionByAssembly();
                SystemRole role = _SystemRoleService.GetKey(roleid);

                List <ActionPermission> hasButtons = new List <ActionPermission>();
                List <SystemButton>     listButton = role.Button.ToList();
                foreach (SystemButton button in listButton)
                {
                    ActionPermission ap = new AppCode.ActionPermission();
                    ap.ActionName     = button.ActionName;
                    ap.AreaName       = button.AreaName;
                    ap.ControllerName = button.ControllerName;
                    ap.Description    = button.Description;
                    hasButtons.Add(ap);
                }
                ViewBag.hasButtons = hasButtons;
                ViewBag.RoleName   = role.RoleName;
                ViewBag.RoleID     = role.Id;
                return(View(allActions));
            }
            return(View());
        }
Example #3
0
        static void Main(string[] args)
        {
            //autoMapper autoMap = new autoMapper();

            autoFac autoFa = new autoFac();
            unity   unitty = new unity();

            Console.ReadKey();
        }
        public IList <ActionPermission> QueryActionPlist(string query, int start, int limit, out long total)
        {
            IList <ActionPermission> allActions = new unity().GetAllActionByAssembly();

            total = (from a in allActions
                     where a.ActionName.ToLower().Contains(query.ToLower())
                     select a).Count();

            var result = (from a in allActions
                          where a.ActionName.ToLower().Contains(query.ToLower())
                          select a).Skip(start).Take(limit);

            return(new List <ActionPermission>(result));
        }
        public ActionResult MenuPro()
        {
            List <ActionPermission> allActions = new unity().GetAllActionByAssembly();
            List <ActionPermission> newActions = new List <ActionPermission>();

            newActions = (from a in allActions
                          orderby a.FirstPath_Spell, a.SecoundPath_Spell
                          select a).ToList();

            //allActions.OrderBy(a => a.FirstPath);
            //allActions.Sort();

            //List<Article> list = GetArticleList();
            //allActions.Sort((x, y) =>
            //{
            //    int value = x.FirstPath_Spell.CompareTo(y.FirstPath_Spell);
            //    if (value == 0)
            //        value = x.FirstPath_Spell.CompareTo(y.FirstPath_Spell);
            //    return value;
            //});
            //foreach (ActionPermission ap in allActions)
            //{

            //}



            string hasButtons = "";

            List <SystemButton> listButton = _SystemButtonService.GetAll().ToList();

            foreach (SystemButton button in listButton)
            {
                hasButtons += button.AreaName + "." + button.ControllerName + "." + button.ActionName + "|";
            }

            ViewBag.hasButtons = hasButtons;
            return(View(newActions));
        }