public static WhereClip GetEmpIDInWhere(WhereClip whereClip, Field fldBillDate, Field fldEmp, Field fldOrg, Field fldDept, SessionInfo sessionInfo) { WhereClip ret = whereClip; #region 获取人员的权限 Sys_EmpDataRightResult dataRight = new Sys_EmpDataRightResult(); _instarnce.SessionInfo = sessionInfo; dataRight = _instarnce.GetEmpDataRight(null); if (dataRight == null) { return(ret); } string[] arrRIds = new string[] { }; string[] arrEId = new string[] { }; string[] arrIds = new string[] { }; #region 绑定机构条件 if (!string.IsNullOrEmpty(dataRight.ReadOrgIDs)) { arrRIds = dataRight.ReadOrgIDs.Split(','); } if (!string.IsNullOrEmpty(dataRight.EditOrgIDs)) { arrEId = dataRight.EditOrgIDs.Split(','); } arrIds = arrRIds.Union(arrEId).Distinct().ToArray(); if (fldOrg != null) { if (arrRIds.Length > 0) { ret = ret && fldOrg.In(arrIds); } } #endregion #region 绑定部门条件 arrRIds = new string[] { }; arrIds = new string[] { }; if (!string.IsNullOrEmpty(dataRight.ReadDeptIDs)) { arrRIds = dataRight.ReadDeptIDs.Split(','); } if (!string.IsNullOrEmpty(dataRight.EditDeptIDs)) { arrEId = dataRight.EditDeptIDs.Split(','); } arrIds = arrRIds.Union(arrEId).Distinct().ToArray(); if (fldDept != null) { if (arrRIds.Length > 0) { ret = ret && fldDept.In(arrIds); } } #endregion #region 绑定员工条件 arrRIds = new string[] { }; arrIds = new string[] { }; if (!string.IsNullOrEmpty(dataRight.ReadEmpIDs)) { arrRIds = dataRight.ReadEmpIDs.Split(','); } if (!string.IsNullOrEmpty(dataRight.EditEmpIDs)) { arrEId = dataRight.EditEmpIDs.Split(','); } arrIds = arrRIds.Union(new string[] { sessionInfo.UserID.ToInt32().ToStringHasNull() }).Union(arrEId).Distinct().ToArray(); if (fldEmp != null) { if (arrRIds.Length > 0) { ret = ret && fldEmp.In(arrIds); } } #endregion #endregion return(ret); }
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); }