Beispiel #1
0
        public List <Sys_FormRightResult> GetEmpWindowRight(Sys_FormRightParam param)
        {
            #region 判断
            this.CheckSession();
            if (param.NameSpace.ToStringHasNull() == "")
            {
                throw new WarningException("请指定命名空间!");
            }
            if (param.FormEngName.ToStringHasNull() == "")
            {
                throw new WarningException("请指定窗体名称!");
            }
            #endregion
            #region 员工所拥有权限设置
            List <Sys_FormRightResult> ret = new List <Sys_FormRightResult>();
            WhereClip where = Sys_FormRight._.IsDeleted == false;
            List <Sys_EmpRight> lstEmpRight = new List <Sys_EmpRight>();
            lstEmpRight = this.SelectList <Sys_EmpRight>(Sys_EmpRight._.EmpID == this.SessionInfo.UserID && Sys_EmpRight._.GCompanyID == this.SessionInfo.CompanyID && Sys_EmpRight._.IsDeleted == false);
            #endregion
            #region 员工所在角色
            Sys_EmpDataRightBLL    empDataRightBll = new Sys_EmpDataRightBLL();
            Sys_EmpDataRightResult empDataRightRst = new Sys_EmpDataRightResult();
            empDataRightBll.SessionInfo = this.SessionInfo;
            empDataRightRst             = empDataRightBll.GetEmpDataRight(new Sys_EmpDataRightParam()
            {
            });
            string roleIDs = empDataRightRst.RoleIDs;
            List <Sys_RoleRightResult> roleRightList = new List <Sys_RoleRightResult>();
            Sys_RoleRightResult        findRoleRight = new Sys_RoleRightResult();
            WhereClip whereClip = Sys_RoleRight._.IsDeleted == false;
            if (roleIDs.ToStringHasNull().Trim() != "")
            {
                int?[] arrRoleIds = roleIDs.Split(',').Where(a => a != "").Select(a => (int?)a.ToInt32()).ToArray();
                whereClip     = whereClip && Sys_RoleRight._.RoleID.In(arrRoleIds);
                roleRightList = this.SelectList <Sys_RoleRightResult>(whereClip);
            }
            #endregion

            #region 窗体控件集合
            List <Sys_FormRightResult> lstForm = new List <Sys_FormRightResult>();
            ret = this.SelectList <Sys_FormRightResult>(Sys_FormRight._.NameSpace == param.NameSpace && Sys_FormRight._.FormEngName == param.FormEngName && Sys_FormRight._.IsDeleted == false);
            #endregion
            #region 判断窗体控件是否有权限
            string[] arrActionForm = new string[] { };
            bool     existRight    = false;
            foreach (Sys_FormRightResult info in ret)
            {
                #region 判断是否拥有权限
                arrActionForm = info.ActionCode.ToStringHasNull().Split(',');
                if (arrActionForm.Length <= 0)
                {
                    info.PropertyValue = false;
                }
                else
                {
                    existRight = false;
                    foreach (string s in arrActionForm)
                    {
                        if (lstEmpRight.Exists(a => a.ActionCode.ToStringHasNull().Split(',').Contains(s) && a.ModuleID == info.ModuleID) ||
                            roleRightList.Exists(a => a.ActionCode.ToStringHasNull().Split(',').Contains(s) && a.ModuleID == info.ModuleID))
                        {
                            existRight = true;
                            break;
                        }
                    }
                    info.PropertyValue = existRight;
                }
                #endregion
            }
            #endregion

            return(ret);
        }