Exemple #1
0
        /// <summary>
        /// 获得某个角色分配的权限
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPower()
        {
            string                   CompanyID  = WebUtil.GetFormValue <string>("CompanyID", string.Empty);
            string                   RoleNum    = WebUtil.GetFormValue <string>("RoleNum", string.Empty);
            PowerProvider            provider   = new PowerProvider(CompanyID);
            List <SysResourceEntity> listResult = provider.GetRoleResource(RoleNum);
            DataResult <List <SysResourceEntity> > dataResult = new DataResult <List <SysResourceEntity> >()
            {
                Code    = (int)EResponseCode.Success,
                Message = "响应成功",
                Result  = listResult
            };

            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Exemple #2
0
        /// <summary>
        /// 设置导航信息
        /// </summary>
        private void SetNav()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<ul class=\"breadcrumb\">");
            sb.Append("<li>");
            sb.Append("<i class=\"icon-home\"></i>");
            sb.Append("<a href=\"/Home/Welcome\">首页</a>");
            sb.Append("<i class=\"icon-angle-right\"></i>");
            sb.Append("</li>");
            if (IsLogin() && !this.LoginUser.RoleNum.IsEmpty())
            {
                PowerProvider            provider            = new PowerProvider();
                SysResourceProvider      SysResourceProvider = new SysResourceProvider();
                List <SysResourceEntity> listSource          = SysResourceProvider.GetList();
                List <SysResourceEntity> list = provider.GetRoleResource(this.LoginUser.RoleNum);
                if (!list.IsNullOrEmpty())
                {
                    SysResourceEntity        item       = list.SingleOrDefault(a => a.Url.ToLower() == this.Path.ToLower());
                    List <SysResourceEntity> listResult = new List <SysResourceEntity>();
                    while (item != null)
                    {
                        listResult.Insert(0, item);

                        if (item.ParentNum.IsEmpty())
                        {
                            break;
                        }
                        else
                        {
                            if (listSource.Exists(a => a.ResNum == item.ParentNum))
                            {
                                item = listSource.First(a => a.ResNum == item.ParentNum);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    for (int i = 0; i < listResult.Count; i++)
                    {
                        if (i != listResult.Count - 1)
                        {
                            sb.Append("<li>");
                            sb.AppendFormat("<a href=\"{0}\">{1}</a>", listResult[i].Url.IsEmpty() ? "javascript:void(0)" : listResult[i].Url, listResult[i].ResName);
                            sb.Append("<i class=\"icon-angle-right\"></i>");
                            sb.Append("</li>");
                        }
                        else
                        {
                            sb.Append("<li>");
                            sb.AppendFormat("<a href=\"javascript:void(0)\">{0}</a>", listResult[i].ResName);
                            sb.Append("</li>");
                        }
                    }
                }
            }
            sb.Append("</ul>");
            ViewBag.NavMenu = sb.ToString();
        }