internal static bool ContainsPermission(DEContainerAndPermissionCollection permissions, string containerID, string permission) { if (permissions == null || string.IsNullOrEmpty(containerID)) { return(false); } else { return(permissions.ContainsKey(containerID, permission)); } }
/// <summary> /// 根据userID和一组ContainerID,加载该Member所拥有的权限 /// </summary> /// <param name="userID"></param> /// <param name="containerIDs"></param> /// <returns></returns> public DEContainerAndPermissionCollection LoadCurrentContainerAndPermissions(string userID, IEnumerable <string> containerIDs) { var ids = (from s in containerIDs select s).ToArray(); DEContainerAndPermissionCollection result = null; if (ids.Length > 0) { var timeConditon1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("A."); var timeConditon2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("U."); var condition = new WhereSqlClauseBuilder(); condition.AppendItem("A.Status", (int)SchemaObjectStatus.Normal); condition.AppendItem("U.Status", (int)SchemaObjectStatus.Normal); condition.AppendItem("U.UserID", userID); InSqlClauseBuilder inSql = new InSqlClauseBuilder("A.ContainerID"); inSql.AppendItem(ids); var sql = string.Format( "SELECT A.* FROM SC.Acl_Current A INNER JOIN SC.UserAndContainerSnapshot_Current U ON U.ContainerID = A.MemberID WHERE {0} ORDER BY SortID ", new ConnectiveSqlClauseCollection(timeConditon1, condition, inSql).ToSqlString(TSqlBuilder.Instance)); result = new DEContainerAndPermissionCollection(); using (DbContext context = DbContext.GetContext(this.GetConnectionName())) { using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName())) { while (reader.Read()) { string containerID = (string)reader["ContainerID"]; string permission = (string)reader["ContainerPermission"]; if (result.ContainsKey(containerID, permission) == false) { result.Add(new DEContainerAndPermission() { ContainerID = containerID, ContainerPermission = permission }); } } return(result); } } } else { result = new DEContainerAndPermissionCollection(); } return(result); }