Exemple #1
0
        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);
            }
        }