protected IDataReader RunLiveQuery(List <Microsoft.ReportingServices.ReportIntermediateFormat.ParameterValue> queryParams, object[] paramValues) { IDataReader reader = null; IDbCommand command = null; IJobContext jobContext = m_odpContext.JobContext; if (m_dataSourceConnection == null) { m_dataSourceConnection = RuntimeDataSource.OpenConnection(m_dataSource, m_dataSet, m_odpContext, m_executionMetrics); } try { m_executionMetrics.StartTimer(DataProcessingMetrics.MetricType.Query); command = CreateCommand(); SetCommandParameters(command, queryParams, paramValues); string commandText = SetCommandText(command); StoreCommandText(commandText); SetCommandType(command); SetTransaction(command); m_odpContext.CheckAndThrowIfAborted(); SetCommandTimeout(command); ExtractRewrittenCommandText(command); SetRestartPosition(command); DataSourceInfo dataSourceInfo = null; if (command is IDbImpersonationNeededForCommandCancel) { dataSourceInfo = m_dataSource.GetDataSourceInfo(m_odpContext); } m_command = command; m_commandWrappedForCancel = new CommandWrappedForCancel(m_command, m_odpContext.CreateAndSetupDataExtensionFunction, m_dataSource, dataSourceInfo, m_dataSet.Name, m_dataSourceConnection); if (jobContext != null) { jobContext.SetAdditionalCorrelation(m_command); jobContext.ApplyCommandMemoryLimit(m_command); } DataSourceErrorInspector errorInspector = CreateErrorInspector(); reader = ExecuteReader(jobContext, errorInspector, commandText); StoreDataReader(reader, errorInspector); return(reader); } catch (RSException) { EagerInlineCommandAndReaderCleanup(ref reader, ref command); throw; } catch (Exception e) { if (AsynchronousExceptionDetection.IsStoppingException(e)) { throw; } EagerInlineCommandAndReaderCleanup(ref reader, ref command); throw; } finally { m_executionMetrics.RecordTimerMeasurement(DataProcessingMetrics.MetricType.Query); } }
internal ExecutedQuery(DataSource dataSource, DataSet dataSet, OnDemandProcessingContext odpContext, DataProcessingMetrics executionMetrics, string commandText, DateTime queryExecutionTimestamp, DataSourceErrorInspector errorInspector) { m_dataSource = dataSource; m_dataSet = dataSet; m_odpContext = odpContext; m_executionMetrics = executionMetrics; m_commandText = commandText; m_queryExecutionTimestamp = queryExecutionTimestamp; m_errorInspector = errorInspector; }
protected override void StoreDataReader(IDataReader reader, DataSourceErrorInspector errorInspector) { bool readerExtensionsSupportedLocal = ReaderExtensionsSupported(reader); if (reader.FieldCount > 0 || m_odpContext.IsSharedDataSetExecutionOnly) { CreateProcessingDataReader(reader, errorInspector, readerExtensionsSupportedLocal); return; } EagerInlineReaderCleanup(ref reader); DisposeCommand(); }
private IDataReader ExecuteReader(IJobContext jobContext, DataSourceErrorInspector errorInspector, string commandText) { IDataReader dataReader = null; try { jobContext?.AddCommand(m_commandWrappedForCancel); m_executionMetrics.StartTimer(DataProcessingMetrics.MetricType.ExecuteReader); try { dataReader = m_command.ExecuteReader(CommandBehavior.SingleResult); } catch (Exception ex) { if (m_odpContext.ContextMode == OnDemandProcessingContext.Mode.Streaming) { ErrorCode errorCode = ErrorCode.rsSuccess; bool flag = errorInspector?.TryInterpretProviderErrorCode(ex, out errorCode) ?? false; TraceExecuteReaderFailed(ex, commandText, flag ? new ErrorCode?(errorCode) : null); if (flag) { string text = string.Format(CultureInfo.CurrentCulture, RPRes.Keys.GetString(ErrorCode.rsErrorExecutingCommand.ToString()), m_dataSet.Name.MarkAsPrivate()); throw new ReportProcessingQueryException(errorCode, ex, text); } if (errorInspector != null && errorInspector.IsOnPremiseServiceException(ex)) { throw new ReportProcessingQueryOnPremiseServiceException(ErrorCode.rsErrorExecutingCommand, ex, m_dataSet.Name.MarkAsPrivate()); } } throw new ReportProcessingException(ErrorCode.rsErrorExecutingCommand, ex, m_dataSet.Name.MarkAsPrivate()); } finally { m_executionMetrics.RecordTimerMeasurement(DataProcessingMetrics.MetricType.ExecuteReader); } } finally { jobContext?.RemoveCommand(m_commandWrappedForCancel); } if (dataReader == null) { if (Global.Tracer.TraceError) { Global.Tracer.Trace(TraceLevel.Error, "The source data reader is null. Cannot read results."); } throw new ReportProcessingException(ErrorCode.rsErrorCreatingDataReader, m_dataSet.Name.MarkAsPrivate()); } return(dataReader); }
private void CreateProcessingDataReader(IDataReader reader, DataSourceErrorInspector errorInspector, bool readerExtensionsSupportedLocal) { List <Microsoft.ReportingServices.ReportIntermediateFormat.Field> fields = m_dataSet.Fields; int num = 0; if (fields != null) { num = ((!m_odpContext.IsSharedDataSetExecutionOnly) ? m_dataSet.NonCalculatedFieldCount : m_dataSet.Fields.Count); } string[] array = new string[num]; string[] array2 = new string[num]; for (int i = 0; i < num; i++) { Microsoft.ReportingServices.ReportIntermediateFormat.Field field = fields[i]; array[i] = field.DataField; array2[i] = field.Name; } m_executionMetrics.StartTimer(DataProcessingMetrics.MetricType.DataReaderMapping); m_dataReader = new ProcessingDataReader(m_odpContext, m_dataSetInstance, m_dataSet.Name, reader, readerExtensionsSupportedLocal || m_dataSet.HasAggregateIndicatorFields, array2, array, errorInspector); m_executionMetrics.RecordTimerMeasurement(DataProcessingMetrics.MetricType.DataReaderMapping); }
internal ProcessingDataReader(OnDemandProcessingContext odpContext, DataSetInstance dataSetInstance, string dataSetName, IDataReader sourceReader, bool hasServerAggregateMetadata, string[] aliases, string[] names, DataSourceErrorInspector errorInspector) { m_recordSetInfo = new RecordSetInfo(hasServerAggregateMetadata, odpContext.IsSharedDataSetExecutionOnly, dataSetInstance, odpContext.ExecutionTime); m_dataSourceDataReader = new MappingDataReader(dataSetName, sourceReader, aliases, names, errorInspector); }
protected abstract void StoreDataReader(IDataReader dataReader, DataSourceErrorInspector errorInspector);