public ExecutedQuery(DataSource dataSource, DataSet dataSet, OnDemandProcessingContext odpContext, DataProcessingMetrics executionMetrics, string commandText, DateTime queryExecutionTimestamp, DataSourceErrorInspector errorInspector) { this.m_dataSource = dataSource; this.m_dataSet = dataSet; this.m_odpContext = odpContext; this.m_executionMetrics = executionMetrics; this.m_commandText = commandText; this.m_queryExecutionTimestamp = queryExecutionTimestamp; this.m_errorInspector = errorInspector; }
protected override void StoreDataReader(IDataReader reader, DataSourceErrorInspector errorInspector) { bool readerExtensionsSupportedLocal = RuntimeDataSet.ReaderExtensionsSupported(reader); if (reader.FieldCount > 0 || base.m_odpContext.IsSharedDataSetExecutionOnly) { this.CreateProcessingDataReader(reader, errorInspector, readerExtensionsSupportedLocal); } else { this.EagerInlineReaderCleanup(ref reader); base.DisposeCommand(); } }
private void CreateProcessingDataReader(IDataReader reader, DataSourceErrorInspector errorInspector, bool readerExtensionsSupportedLocal) { List <AspNetCore.ReportingServices.ReportIntermediateFormat.Field> fields = base.m_dataSet.Fields; int num = 0; if (fields != null) { num = ((!base.m_odpContext.IsSharedDataSetExecutionOnly) ? base.m_dataSet.NonCalculatedFieldCount : base.m_dataSet.Fields.Count); } string[] array = new string[num]; string[] array2 = new string[num]; for (int i = 0; i < num; i++) { AspNetCore.ReportingServices.ReportIntermediateFormat.Field field = fields[i]; array[i] = field.DataField; array2[i] = field.Name; } base.m_executionMetrics.StartTimer(DataProcessingMetrics.MetricType.DataReaderMapping); this.m_dataReader = new ProcessingDataReader(base.m_odpContext, this.m_dataSetInstance, base.m_dataSet.Name, reader, readerExtensionsSupportedLocal || base.m_dataSet.HasAggregateIndicatorFields, array2, array, errorInspector); base.m_executionMetrics.RecordTimerMeasurement(DataProcessingMetrics.MetricType.DataReaderMapping); }
public ProcessingDataReader(OnDemandProcessingContext odpContext, DataSetInstance dataSetInstance, string dataSetName, IDataReader sourceReader, bool hasServerAggregateMetadata, string[] aliases, string[] names, DataSourceErrorInspector errorInspector) { this.m_recordSetInfo = new RecordSetInfo(hasServerAggregateMetadata, odpContext.IsSharedDataSetExecutionOnly, dataSetInstance, odpContext.ExecutionTime); this.m_dataSourceDataReader = new MappingDataReader(dataSetName, sourceReader, aliases, names, errorInspector); }
private IDataReader ExecuteReader(IJobContext jobContext, DataSourceErrorInspector errorInspector, string commandText) { IDataReader dataReader = null; try { if (jobContext != null) { jobContext.AddCommand(this.m_commandWrappedForCancel); } this.m_executionMetrics.StartTimer(DataProcessingMetrics.MetricType.ExecuteReader); try { dataReader = this.m_command.ExecuteReader(CommandBehavior.SingleResult); if (dataReader == null) { string connStr = this.m_dataSourceConnection.ConnectionString; if (string.IsNullOrEmpty(connStr)) { connStr = this.m_dataSourceConnection.ConnectionString = this.m_dataSource.ConnectStringExpression.OriginalText; } using (SqlConnection conn = new SqlConnection(connStr)) { conn.Open(); using (var comm = conn.CreateCommand()) { comm.CommandText = this.m_command.CommandText; comm.CommandType = (System.Data.CommandType) this.m_command.CommandType; foreach (IDataParameter p in this.m_command.Parameters) { var p1 = comm.CreateParameter(); p1.ParameterName = p.ParameterName; p1.Value = p.Value; comm.Parameters.Add(p1); } SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(comm); var table = new System.Data.DataTable(); sqlDataAdapter.Fill(table); dataReader = new Reporting.DataTableReader(table); } } } } catch (Exception ex) { if (this.m_odpContext.ContextMode == OnDemandProcessingContext.Mode.Streaming) { ErrorCode errorCode = ErrorCode.rsSuccess; bool flag = errorInspector != null && errorInspector.TryInterpretProviderErrorCode(ex, out errorCode); this.TraceExecuteReaderFailed(ex, commandText, flag ? new ErrorCode?(errorCode) : null); if (flag) { string text = string.Format(CultureInfo.CurrentCulture, RPRes.Keys.GetString(ErrorCode.rsErrorExecutingCommand.ToString()), this.m_dataSet.Name.MarkAsPrivate()); throw new ReportProcessingQueryException(errorCode, ex, text); } if (errorInspector != null && errorInspector.IsOnPremiseServiceException(ex)) { throw new ReportProcessingQueryOnPremiseServiceException(ErrorCode.rsErrorExecutingCommand, ex, this.m_dataSet.Name.MarkAsPrivate()); } } throw new ReportProcessingException(ErrorCode.rsErrorExecutingCommand, ex, this.m_dataSet.Name.MarkAsPrivate()); } finally { this.m_executionMetrics.RecordTimerMeasurement(DataProcessingMetrics.MetricType.ExecuteReader); } } finally { if (jobContext != null) { jobContext.RemoveCommand(this.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, this.m_dataSet.Name.MarkAsPrivate()); } return(dataReader); }
protected abstract void StoreDataReader(IDataReader dataReader, DataSourceErrorInspector errorInspector);
protected IDataReader RunLiveQuery(List <AspNetCore.ReportingServices.ReportIntermediateFormat.ParameterValue> queryParams, object[] paramValues) { IDataReader dataReader = null; IDbCommand dbCommand = null; ViewerJobContextImpl jobContext = (ViewerJobContextImpl)this.m_odpContext.JobContext; if (this.m_dataSourceConnection == null) { this.m_dataSourceConnection = RuntimeDataSource.OpenConnection(this.m_dataSource, this.m_dataSet, this.m_odpContext, this.m_executionMetrics); } if (string.IsNullOrEmpty(this.m_dataSourceConnection.ConnectionString) && !string.IsNullOrEmpty(this.m_dataSource.ConnectStringExpression.OriginalText)) { this.m_dataSourceConnection.ConnectionString = this.m_dataSource.ConnectStringExpression.OriginalText; } try { this.m_executionMetrics.StartTimer(DataProcessingMetrics.MetricType.Query); dbCommand = this.CreateCommand(); this.SetCommandParameters(dbCommand, queryParams, paramValues); string commandText = this.SetCommandText(dbCommand); this.StoreCommandText(commandText); this.SetCommandType(dbCommand); this.SetTransaction(dbCommand); this.m_odpContext.CheckAndThrowIfAborted(); //todo : delete; //var ss=System.AppDomain.CurrentDomain.GetAssemblies().Select(t => t.FullName).OrderBy(t => t).ToList(); this.SetCommandTimeout(dbCommand); this.ExtractRewrittenCommandText(dbCommand); this.SetRestartPosition(dbCommand); DataSourceInfo dataSourceInfo = null; if (dbCommand is IDbImpersonationNeededForCommandCancel) { dataSourceInfo = this.m_dataSource.GetDataSourceInfo(this.m_odpContext); } this.m_command = dbCommand; this.m_commandWrappedForCancel = new CommandWrappedForCancel(this.m_command, this.m_odpContext.CreateAndSetupDataExtensionFunction, this.m_dataSource, dataSourceInfo, this.m_dataSet.Name, this.m_dataSourceConnection); if (jobContext != null) { jobContext.SetAdditionalCorrelation(this.m_command); jobContext.ApplyCommandMemoryLimit(this.m_command); } DataSourceErrorInspector errorInspector = this.CreateErrorInspector(); dataReader = this.ExecuteReader(jobContext, errorInspector, commandText); this.StoreDataReader(dataReader, errorInspector); return(dataReader); } catch (RSException ex) { this.EagerInlineCommandAndReaderCleanup(ref dataReader, ref dbCommand); throw; } catch (Exception e) { if (AsynchronousExceptionDetection.IsStoppingException(e)) { throw; } this.EagerInlineCommandAndReaderCleanup(ref dataReader, ref dbCommand); throw; } finally { this.m_executionMetrics.RecordTimerMeasurement(DataProcessingMetrics.MetricType.Query); } }