public override async Task MapReaderData(OracleDataReader reader, CancellationToken cancellationToken) { while (await reader.ReadAsynchronous(cancellationToken)) { var degreeOfParallelismRaw = (string)reader["DEGREE"]; var indexDetails = new IndexDetailsModel { Owner = (string)reader["OWNER"], Name = (string)reader["INDEX_NAME"], Type = TextInfo.ToTitleCase(((string)reader["INDEX_TYPE"]).ToLowerInvariant()), IsUnique = (string)reader["UNIQUENESS"] == "UNIQUE", Compression = TextInfo.ToTitleCase(((string)reader["COMPRESSION"]).ToLowerInvariant()), PrefixLength = OracleReaderValueConvert.ToInt32(reader["PREFIX_LENGTH"]), Logging = OracleReaderValueConvert.ToString(reader["LOGGING"]) == "LOGGING", ClusteringFactor = OracleReaderValueConvert.ToInt64(reader["CLUSTERING_FACTOR"]), Status = TextInfo.ToTitleCase(((string)reader["STATUS"]).ToLowerInvariant()), Rows = OracleReaderValueConvert.ToInt64(reader["NUM_ROWS"]), SampleRows = OracleReaderValueConvert.ToInt64(reader["SAMPLE_SIZE"]), DistinctKeys = OracleReaderValueConvert.ToInt64(reader["DISTINCT_KEYS"]), LastAnalyzed = OracleReaderValueConvert.ToDateTime(reader["LAST_ANALYZED"]), Blocks = OracleReaderValueConvert.ToInt32(reader["BLOCKS"]), LeafBlocks = OracleReaderValueConvert.ToInt32(reader["LEAF_BLOCKS"]), Bytes = OracleReaderValueConvert.ToInt64(reader["BYTES"]), DegreeOfParallelism = degreeOfParallelismRaw == "DEFAULT" ? (int?)null : Convert.ToInt32(degreeOfParallelismRaw.Trim()), TablespaceName = OracleReaderValueConvert.ToString(reader["TABLESPACE_NAME"]) }; DataModel.IndexDetails.Add(indexDetails); } }
private static void MapPartitionSegmentData(IDataRecord reader, PartitionDetailsModelBase model) { var highValue = OracleReaderValueConvert.ToString(reader["HIGH_VALUE"]); model.HighValue = highValue.Length > HighValueMaxLength ? $"{highValue.Substring(0, HighValueMaxLength)}{CellValueConverter.Ellipsis}" : highValue; model.TablespaceName = OracleReaderValueConvert.ToString(reader["TABLESPACE_NAME"]); model.Logging = (string)reader["LOGGING"] == "YES"; model.Compression = TextInfo.ToTitleCase(((string)reader["COMPRESSION"]).ToLowerInvariant()); model.RowCount = OracleReaderValueConvert.ToInt64(reader["NUM_ROWS"]); model.SampleRows = OracleReaderValueConvert.ToInt64(reader["SAMPLE_SIZE"]); model.LastAnalyzed = OracleReaderValueConvert.ToDateTime(reader["LAST_ANALYZED"]); model.BlockCount = OracleReaderValueConvert.ToInt32(reader["BLOCKS"]); model.AverageRowSize = OracleReaderValueConvert.ToInt32(reader["AVG_ROW_LEN"]); model.InMemoryCompression = OracleReaderValueConvert.ToString(reader["INMEMORY_COMPRESSION"]); }
public override async Task MapReaderData(OracleDataReader reader, CancellationToken cancellationToken) { if (!await reader.ReadAsynchronous(cancellationToken)) { return; } DataModel.AccountStatus = (string)reader["ACCOUNT_STATUS"]; DataModel.LockDate = OracleReaderValueConvert.ToDateTime(reader["LOCK_DATE"]); DataModel.ExpiryDate = OracleReaderValueConvert.ToDateTime(reader["EXPIRY_DATE"]); DataModel.DefaultTablespace = (string)reader["DEFAULT_TABLESPACE"]; DataModel.TemporaryTablespace = (string)reader["TEMPORARY_TABLESPACE"]; DataModel.Profile = (string)reader["PROFILE"]; DataModel.EditionsEnabled = String.Equals((string)reader["EDITIONS_ENABLED"], "Y"); DataModel.AuthenticationType = (string)reader["AUTHENTICATION_TYPE"]; DataModel.LastLogin = OracleReaderValueConvert.ToDateTime(reader["LAST_LOGIN"]); }
public override async Task MapReaderData(OracleDataReader reader, CancellationToken cancellationToken) { if (!await reader.ReadAsynchronous(cancellationToken)) { return; } var loggingRaw = reader["LOGGING"]; DataModel.RowCount = OracleReaderValueConvert.ToInt32(reader["NUM_ROWS"]); DataModel.LastAnalyzed = OracleReaderValueConvert.ToDateTime(reader["LAST_ANALYZED"]); DataModel.AverageRowSize = OracleReaderValueConvert.ToInt32(reader["AVG_ROW_LEN"]); DataModel.BlockCount = OracleReaderValueConvert.ToInt32(reader["BLOCKS"]); DataModel.Compression = OracleReaderValueConvert.ToString(reader["COMPRESSION"]); DataModel.Organization = OracleReaderValueConvert.ToString(reader["ORGANIZATION"]); DataModel.ParallelDegree = OracleReaderValueConvert.ToString(reader["DEGREE"]); DataModel.ClusterName = OracleReaderValueConvert.ToString(reader["CLUSTER_NAME"]); DataModel.TablespaceName = OracleReaderValueConvert.ToString(reader["TABLESPACE_NAME"]); DataModel.SampleRows = OracleReaderValueConvert.ToInt64(reader["SAMPLE_SIZE"]); DataModel.Logging = loggingRaw == DBNull.Value ? (bool?)null : String.Equals((string)loggingRaw, "YES"); DataModel.IsTemporary = (string)reader["TEMPORARY"] == "Y"; }
public async Task <DatabaseSessions> GetAllSessionDataAsync(CancellationToken cancellationToken) { var databaseSessions = new DatabaseSessions(); using (var connection = new OracleConnection(BackgroundConnectionString)) { using (var command = connection.CreateCommand()) { command.CommandText = OracleDatabaseCommands.SelectBasicSessionInformationCommandText; await connection.OpenAsynchronous(cancellationToken); connection.ModuleName = "Database monitor"; using (var reader = await command.ExecuteReaderAsynchronous(CommandBehavior.Default, cancellationToken)) { databaseSessions.ColumnHeaders = DatabaseSessionColumnHeaders; var sessions = new Dictionary <int, DatabaseSession>(); while (await reader.ReadAsynchronous(cancellationToken)) { var oracleSession = new OracleSessionValues { Process = OracleReaderValueConvert.ToString(reader["PROCESS"]), ExecutionId = OracleReaderValueConvert.ToInt32(reader["SQL_EXEC_ID"]), Type = (string)reader["TYPE"], Id = Convert.ToInt32(reader["SID"]), ExecutionStart = OracleReaderValueConvert.ToDateTime(reader["SQL_EXEC_START"]), Action = OracleReaderValueConvert.ToString(reader["ACTION"]), State = (string)reader["STATE"], Status = (string)reader["STATUS"], AuditingSessionId = Convert.ToInt64(reader["AUDSID"]), ChildNumber = OracleReaderValueConvert.ToInt32(reader["SQL_CHILD_NUMBER"]), ClientInfo = OracleReaderValueConvert.ToString(reader["CLIENT_INFO"]), CurrentCommandText = OracleReaderValueConvert.ToString(await reader.GetValueAsynchronous(reader.GetOrdinal("CURRENT_COMMAND_TEXT"), cancellationToken)), Event = (string)reader["EVENT"], FailedOver = (string)reader["FAILED_OVER"], FailoverMethod = (string)reader["FAILOVER_METHOD"], FailoverType = (string)reader["FAILOVER_TYPE"], LockWait = OracleReaderValueConvert.ToString(reader["LOCKWAIT"]), LogonTime = (DateTime)reader["LOGON_TIME"], Machine = OracleReaderValueConvert.ToString(reader["MACHINE"]), Module = OracleReaderValueConvert.ToString(reader["MODULE"]), OperatingSystemUser = OracleReaderValueConvert.ToString(reader["OSUSER"]), ParallelDdlStatus = (string)reader["PDDL_STATUS"], ParallelDmlEnabled = (string)reader["PDML_ENABLED"], ParallelDmlStatus = (string)reader["PDML_STATUS"], ParallelQueryStatus = (string)reader["PQ_STATUS"], Parameter1 = Convert.ToDecimal(reader["P1"]), Parameter1Text = OracleReaderValueConvert.ToString(reader["P1TEXT"]), Parameter2 = Convert.ToDecimal(reader["P2"]), Parameter2Text = OracleReaderValueConvert.ToString(reader["P2TEXT"]), Parameter3 = Convert.ToDecimal(reader["P3"]), Parameter3Text = OracleReaderValueConvert.ToString(reader["P3TEXT"]), OwnerSessionId = OracleReaderValueConvert.ToInt32(reader["OWNER_SID"]), Port = OracleReaderValueConvert.ToInt32(reader["PORT"]), PrecedingChildNumber = OracleReaderValueConvert.ToInt32(reader["PREV_CHILD_NUMBER"]), PrecedingCommandText = OracleReaderValueConvert.ToString(await reader.GetValueAsynchronous(reader.GetOrdinal("PRECEDING_COMMAND_TEXT"), cancellationToken)), PrecedingExecutionId = OracleReaderValueConvert.ToInt32(reader["PREV_EXEC_ID"]), PrecedingExecutionStart = OracleReaderValueConvert.ToDateTime(reader["PREV_EXEC_START"]), PrecedingSqlId = OracleReaderValueConvert.ToString(reader["PREV_SQL_ID"]), ProcessAddress = (string)reader["PADDR"], Program = OracleReaderValueConvert.ToString(reader["PROGRAM"]), RemainingTimeMicroseconds = OracleReaderValueConvert.ToInt64(reader["TIME_REMAINING_MICRO"]), ResourceConsumeGroup = OracleReaderValueConvert.ToString(reader["RESOURCE_CONSUMER_GROUP"]), SchemaName = OracleReaderValueConvert.ToString(reader["SCHEMANAME"]), Serial = Convert.ToInt32(reader["SERIAL#"]), Server = (string)reader["SERVER"], ServiceName = OracleReaderValueConvert.ToString(reader["SERVICE_NAME"]), Instance = Convert.ToInt32(reader["INSTANCE_ID"]), SessionAddress = (string)reader["SADDR"], SqlId = OracleReaderValueConvert.ToString(reader["SQL_ID"]), SqlTrace = (string)reader["SQL_TRACE"], TimeSinceLastWaitMicroseconds = OracleReaderValueConvert.ToInt64(reader["TIME_SINCE_LAST_WAIT_MICRO"]), TransactionAddress = OracleReaderValueConvert.ToString(reader["TADDR"]), UserName = OracleReaderValueConvert.ToString(reader["USERNAME"]), WaitClass = (string)reader["WAIT_CLASS"], WaitTime = OracleReaderValueConvert.ToInt64(reader["WAIT_TIME"]), WaitTimeMicroseconds = OracleReaderValueConvert.ToInt64(reader["WAIT_TIME_MICRO"]), ProcessIdentifier = OracleReaderValueConvert.ToInt32(reader["PID"]), OperatingSystemIdentifier = OracleReaderValueConvert.ToInt32(reader["SOSID"]), OperatingSystemProcessIdentifier = OracleReaderValueConvert.ToInt32(reader["SPID"]), TraceId = OracleReaderValueConvert.ToString(reader["TRACEID"]), TraceFile = OracleReaderValueConvert.ToString(reader["TRACEFILE"]), ProgramGlobalAreaUsedMemoryBytes = OracleReaderValueConvert.ToInt64(reader["PGA_USED_MEM"]), ProgramGlobalAreaAllocatedMemoryBytes = OracleReaderValueConvert.ToInt64(reader["PGA_ALLOC_MEM"]), ProgramGlobalAreaFreeableMemoryBytes = OracleReaderValueConvert.ToInt64(reader["PGA_FREEABLE_MEM"]), ProgramGlobalAreaMaximumMemoryBytes = OracleReaderValueConvert.ToInt64(reader["PGA_MAX_MEM"]) }; var databaseSession = new DatabaseSession { Id = oracleSession.Id, ProviderValues = oracleSession, Type = String.Equals(oracleSession.Type, "User") ? SessionType.User : SessionType.System, IsActive = Convert.ToString(oracleSession.Status) == "Active" }; sessions.Add(databaseSession.Id, databaseSession); } foreach (var session in sessions.Values) { var ownerSid = ((OracleSessionValues)session.ProviderValues).OwnerSessionId; if (ownerSid.HasValue && sessions.TryGetValue(ownerSid.Value, out var ownerSession)) { session.Owner = ownerSession; ownerSession.ChildSessions.Add(session); } } databaseSessions.Rows = sessions.Values.ToArray(); } } await connection.CloseAsynchronous(cancellationToken); } return(databaseSessions); }