/// <summary> /// 判断该用户是否能访问这个资源, 如果找不到该资源返回 true; /// </summary> /// <param name="code"></param> /// <param name="operationCode"></param> /// <returns></returns> public bool HasResourceRight(string code, string operationCode) { if (!AvailableFunction.isAvailableFunction(operationCode)) { return(false); } string classCode = operationCode.Substring(0, 4); string resourceCode = BLL.ResourceRule.GetResourceCode(code, classCode); if (resourceCode == "") { return(true); } AccessRangeStrategyBuilder sb = new AccessRangeStrategyBuilder(); sb.AddStrategy(new Strategy(AccessRangeStrategyName.ResourceCode, resourceCode)); ArrayList ar = new ArrayList(); ar.Add(this.m_UserCode); ar.Add(BuildStationCodes()); sb.AddStrategy(new Strategy(AccessRangeStrategyName.AccessRelation1, ar)); sb.AddStrategy(new Strategy(AccessRangeStrategyName.OperationCode, operationCode)); QueryAgent qa = new QueryAgent(); string sql = sb.BuildMainQueryString(); EntityData entity = qa.FillEntityData("AccessRange", sql); qa.Dispose(); bool canAccess = entity.HasRecord(); entity.Dispose(); return(canAccess); }
/// <summary> /// 用户权限 /// </summary> /// <param name="code"></param> /// <returns></returns> public bool HasRight(string code) { // if ( code.Length == 2 ) // return HasModuleRight(code); // else if ( code.Length== 4 ) // return HasClassRight(code); // else if ( code.Length == 6 ) // return HasOperationRight(code); // else // return false; if (!AvailableFunction.isAvailableFunction(code)) { return(false); } return(m_OperationArray.Contains(code)); }
/// <summary> /// 对该项操作的类型是否有权限 /// </summary> /// <param name="operationCode">操作编号</param> /// <param name="typeCode">类型编号</param> /// <returns></returns> public bool HasTypeOperationRight(string operationCode, string typeCode) { if (!AvailableFunction.isAvailableFunction(operationCode)) { return(false); } try { string inputFullID = RmsPM.BLL.SystemGroupRule.GetSystemGroupFullID(typeCode); string stationCodes = BuildStationCodeString(this.BuildStationCodes()); string s0 = String.Format(" ( AccessRange.AccessRangeType=0 and AccessRange.relationCode = '{0}' ) " , this.UserCode); string s1 = ""; if (stationCodes != "") { s1 = String.Format(" or ( AccessRange.AccessRangeType=1 and AccessRange.relationCode in ( {0} ) ) " , stationCodes); } string sss = String.Format("select dbo.GetSystemGroupFullID ( groupCode) as GroupFullID from accessrange where operationcode='{0}' and isnull( groupCode ,'') <> '' and ( {1} {2} )" , new object[] { operationCode, s0, s1 }); QueryAgent qa = new QueryAgent(); DataSet entity = qa.ExecSqlForDataSet(sss); qa.Dispose(); bool isFounded = false; foreach (DataRow dr in entity.Tables[0].Rows) { string groupFullID = (string)dr["GroupFullID"]; if (inputFullID.IndexOf(groupFullID) == 0) { isFounded = true; break; } } entity.Dispose(); return(isFounded); } catch (Exception ex) { throw ex; } }
/// <summary> /// /// </summary> /// <param name="code"></param> /// <param name="className"></param> /// <param name="operationCode"></param> /// <returns></returns> public bool HasResourceRight(string code, string className, string operationCode) { if (!AvailableFunction.isAvailableFunction(operationCode)) { return(false); } try { bool hasRight = false; EntityData entity = GetOperationEntityData(code, className); if (entity.CurrentTable.Select(String.Format("OperationCode='{0}'", operationCode)).Length > 0) { hasRight = true; } return(hasRight); } catch (Exception ex) { throw ex; } }
/// <summary> /// 判断费用项权限 /// </summary> /// <param name="code"></param> /// <returns></returns> public bool GetCBSResourceRight(string code, string operationCode) { if (!AvailableFunction.isAvailableFunction(operationCode)) { return(false); } try { bool canAccess = false; DataSet ds = GetCBSOperationEntityData(code); if (ds.Tables[0].Select(String.Format("OperationCode='{0}'", operationCode)).Length > 0) { canAccess = true; } ds.Dispose(); return(canAccess); } catch (Exception ex) { throw ex; } }