public DataTable GetAuthorizedInputRegion(string userId) { ArrayList roleIds = GetRoleIdsByUserId(userId); //根据角色去绑定装置 string strSql = ""; bool isStarted = false; foreach (string roleId in roleIds) { if (isStarted) { strSql = strSql + " OR ROLE_ID = " + roleId; } else { strSql = "WHERE (ROLE_ID = " + roleId; isStarted = true; } } // if (!isStarted) { return(null); } strSql = strSql + ")"; strSql = "SELECT DISTINCT role_input.input_region_id FROM role_input " + strSql; strSql = "SELECT region_input.input_region_id, input_region_short_name, input_region_name, display_order " + "FROM region_input, (" + strSql + ") role " + "WHERE region_input.input_region_id = role.input_region_id " + "AND region_input.use_identifier != 0 " + "ORDER BY region_input.display_order"; OracleHelper helper = new OracleHelper(); IDbConnection oraConn = roleInputTable.GetConnection(); return(helper.ExecuteDatatable(oraConn, CommandType.Text, strSql)); }
public ArrayList GetRoleIdsByUserId(string strUserId) { HybridDictionary hTable = new HybridDictionary(); hTable.Add("USER_ID", strUserId); ArrayList GetRoleIdsByUserId = new ArrayList(); OracleDataReader myReader = (OracleDataReader)userRoleTable.ExecuteReader (CommandType.Text, "SelectRoleIdsByUserId", hTable); while (myReader.Read()) { GetRoleIdsByUserId.Add(myReader.GetString(0)); } myReader.Close(); OracleConnection myConnection = (OracleConnection)userRoleTable.GetConnection(); myConnection.Close(); return(GetRoleIdsByUserId); }