示例#1
0
        /// <summary>
        /// 获取当前用户具有的权限列表
        /// </summary>
        /// <returns></returns>
        public List <PermissionVM> GetCurrentPermission()
        {
            string key = string.Format("{0}_{1}", cache_permission, CurrentUser.SysNo.ToString());
            List <PermissionVM> permissionList = EngineContext.Current.CacheManager.Get(key, CurrentUser.SysNo.ToString())
                                                 as List <PermissionVM>;

            if (permissionList != null)
            {
                return(permissionList);
            }

            IPermissionBizProcess permissionProcess = EngineContext.Current.Resolve <IPermissionBizProcess>();

            permissionList = permissionProcess.GetPermissionByUserSysno(CurrentUser.SysNo);

            List <PermissionVM> invalidList = permissionList.FindAll(x => x.Status == CommonStatus.Invalid);

            if (invalidList != null && invalidList.Count > 0)
            {
                permissionList.RemoveAll(x =>
                {
                    return(invalidList.Exists(y => y.SysNo == x.ParentID));
                });
                permissionList.RemoveAll(x => x.Status == CommonStatus.Invalid);
            }

            EngineContext.Current.CacheManager.Add(key, CurrentUser.SysNo.ToString(),
                                                   permissionList, new TimeSpan(0, 0, 20, 0));

            return(permissionList);
        }
示例#2
0
        /// <summary>
        /// 返回easyUI 的treeGrid控件需要的数据
        /// </summary>
        /// <param name="roleID"></param>
        /// <returns></returns>
        public string GetTreeGridJsonData(Guid roleID)
        {
            List <PermissionVM> bindedList = GetBindedPermission(roleID);

            IPermissionBizProcess perBP       = EngineContext.Current.Resolve <IPermissionBizProcess>();
            List <PermissionVM>   permissions = perBP.GetAllPermissions();

            List <PermissionTreeGridData> root = permissions.Where(x => x.ParentID.HasValue == false)
                                                 .Select(y =>
            {
                PermissionTreeGridData gd = toPermissionTreeGridData(y);
                gd.ischecked = bindedList.Exists(e => e.SysNo == y.SysNo);
                return(gd);
            }).ToList();

            List <PermissionTreeGridData> resultData = new List <PermissionTreeGridData>();

            int identifier = 0;

            root.ForEach(x =>
            {
                x.Identifier = (++identifier).ToString();
                x.ischecked  = bindedList.Exists(y => y.SysNo == x.sysno);
                resultData.Add(x);

                List <PermissionTreeGridData> children = permissions.FindAll(y => y.ParentID.HasValue && y.ParentID.Value == x.sysno)
                                                         .Select(z =>
                {
                    PermissionTreeGridData gd = toPermissionTreeGridData(z);
                    gd.ischecked  = bindedList.Exists(e => e.SysNo == z.SysNo);
                    gd.Identifier = (++identifier).ToString();
                    gd._parentId  = x.Identifier.ToString();
                    return(gd);
                }).ToList();

                resultData.AddRange(children);
            });

            return("{\"rows\":" + JsonHelper.Serialize <List <PermissionTreeGridData> >(resultData) + "}");
        }
示例#3
0
 public PermissionController(IPermissionBizProcess permissionBizProcess)
 {
     _permissionBizProcess = permissionBizProcess;
 }