Ejemplo n.º 1
0
 public ActionResult test()
 {
     //var userInfo = this.CurrentUser;
     var path = Server.MapPath("~/authority.xml");
     var authorityHelper = new AuthorityHelper();
     var menulist = authorityHelper.ReadAuthorityAll();
     var userId = "0505";
     var currentUrl = Request.Url.AbsolutePath;
     var list = authorityHelper.AuthorityFilterByUser(menulist, userId, currentUrl);
     return View();
 }
Ejemplo n.º 2
0
        protected bool HasActionPower(bool isShowMsg,string msg = "您没有权限访问该页面!", int width = 260, int height = 100)
        {
            string userId = this.CurrentUser.Userid;
            string controller = Request.RequestContext.RouteData.Values["controller"].ToString();
            string action = Request.RequestContext.RouteData.Values["action"].ToString();

            var autHelper = new AuthorityHelper();
            var isPower = autHelper.HasActionPower(userId, controller, action);
            if (!isPower)
            {
                this.ShowMessage(msg, "系统提示", width: width, height: height);
            }

            return isPower;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 验证是否有权限访问该页面
        /// </summary>
        protected void HasActionPower(string msg = "您没有权限访问该页面!")
        {
            string userId = this.CurrentUser.Userid;
            string controller = Request.RequestContext.RouteData.Values["controller"].ToString();
            string action = Request.RequestContext.RouteData.Values["action"].ToString();

            var autHelper = new AuthorityHelper();
            var isPower = autHelper.HasActionPower(userId, controller, action);
            if (!isPower)
            {
                var msgT = Server.UrlEncode(msg);
                var msgD = Server.UrlEncode(string.Empty);
                UrlHelper url = new UrlHelper(this.Request.RequestContext);
                this.Response.Redirect(url.Action("Index", "Error", new { msgTitle = msgT, msgDetail = msgD }));

            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 导航 权限加载
        /// </summary>
        /// <returns></returns>
        public ActionResult Menu()
        {
            var userId = this.CurrentUser.Userid;
            var controller = Request.RequestContext.RouteData.Values["controller"].ToString();
            var action = Request.RequestContext.RouteData.Values["action"].ToString();
            var url = string.Format("/{0}/{1}", controller, action);

            var authorityHelper = new AuthorityHelper();
            var menulist = authorityHelper.ReadAuthorityAll();
            var list = authorityHelper.AuthorityFilterByUser(menulist, userId, url);

            return View(list);
        }