public byte[] RenderStream(string format, string deviceInfo, string streamID, out string mimeType)
 {
     if (m_executionSession.Snapshot != null)
     {
         Stream chunk = m_executionSession.Snapshot.GetChunk(streamID, ReportProcessing.ReportChunkTypes.StaticImage, out mimeType);
         if (chunk == null)
         {
             chunk = m_executionSession.Snapshot.GetChunk(streamID, ReportProcessing.ReportChunkTypes.Image, out mimeType);
         }
         if (chunk != null)
         {
             byte[] array = new byte[chunk.Length];
             chunk.Read(array, 0, (int)chunk.Length);
             return(array);
         }
     }
     using (StreamCache streamCache = new StreamCache())
     {
         m_itemContext.RSRequestParameters.SetRenderingParameters(deviceInfo);
         ReportProcessing    reportProcessing = CreateAndConfigureReportProcessing();
         IRenderingExtension newRenderer      = CreateRenderer(format, allowInternal: true);
         Microsoft.ReportingServices.ReportProcessing.RenderingContext rc = CreateRenderingContext();
         ProcessingContext        pc     = CreateProcessingContext(streamCache.StreamCallback);
         OnDemandProcessingResult result = reportProcessing.RenderSnapshotStream(newRenderer, streamID, rc, pc);
         m_executionSession.SaveProcessingResult(result);
         string encoding;
         string fileExtension;
         return(streamCache.GetMainStream(out encoding, out mimeType, out fileExtension));
     }
 }
        public byte[] RenderStream(string format, string deviceInfo, string streamID, out string mimeType)
        {
            if (this.m_executionSession.Snapshot != null)
            {
                Stream chunk = ((SnapshotBase)this.m_executionSession.Snapshot).GetChunk(streamID, ReportProcessing.ReportChunkTypes.StaticImage, out mimeType);
                if (chunk == null)
                {
                    chunk = ((SnapshotBase)this.m_executionSession.Snapshot).GetChunk(streamID, ReportProcessing.ReportChunkTypes.Image, out mimeType);
                }
                if (chunk != null)
                {
                    byte[] array = new byte[chunk.Length];
                    chunk.Read(array, 0, (int)chunk.Length);
                    return(array);
                }
            }
            using (StreamCache streamCache = new StreamCache())
            {
                this.m_itemContext.RSRequestParameters.SetRenderingParameters(deviceInfo);
                ReportProcessing    reportProcessing = this.CreateAndConfigureReportProcessing();
                IRenderingExtension newRenderer      = this.CreateRenderer(format, true);
                AspNetCore.ReportingServices.ReportProcessing.RenderingContext rc = this.CreateRenderingContext();
                ProcessingContext        pc     = this.CreateProcessingContext(streamCache.StreamCallback);
                OnDemandProcessingResult result = reportProcessing.RenderSnapshotStream(newRenderer, streamID, rc, pc);
                this.m_executionSession.SaveProcessingResult(result);

                string text2 = default(string);
                return(streamCache.GetMainStream(out Encoding text, out mimeType, out text2));
            }
        }
 protected void UpdateServerTotalPages(IRenderingExtension renderer, ref Hashtable renderProperties)
 {
     if (renderProperties != null && renderer != null && !(renderer is ITotalPages))
     {
         renderProperties["TotalPages"]            = 0;
         renderProperties["UpdatedPaginationMode"] = PaginationMode.Estimate;
     }
 }
        public ProcessingMessageList Render(string format, string deviceInfo, string paginationMode, bool allowInternalRenderers, IEnumerable dataSources, CreateAndRegisterStream createStreamCallback)
        {
            this.SetProcessingCulture();
            this.m_itemContext.RSRequestParameters.FormatParamValue = format;
            this.m_itemContext.RSRequestParameters.SetRenderingParameters(deviceInfo);
            this.m_itemContext.RSRequestParameters.PaginationModeValue = paginationMode;
            ReportProcessing    reportProcessing   = this.CreateAndConfigureReportProcessing();
            IRenderingExtension renderingExtension = this.CreateRenderer(format, allowInternalRenderers);
            //renderingExtension.Report = report;

            bool flag = false;

            if (format == null || this.m_executionSession.Snapshot == null)
            {
                this.ReinitializeSnapshot(null);
                flag = true;
            }
            SubreportCallbackHandler subreportHandler = this.CreateSubreportCallbackHandler();
            ProcessingContext        pc = this.CreateProcessingContext(this.m_executionSession.ExecutionInfo.ReportParameters, dataSources, this.m_executionSession.Credentials, this.m_executionSession.Snapshot, createStreamCallback, subreportHandler);

            AspNetCore.ReportingServices.ReportProcessing.RenderingContext rc = this.CreateRenderingContext();
            OnDemandProcessingResult onDemandProcessingResult = null;

            if (flag)
            {
                try
                {
                    if (renderingExtension == null)
                    {
                        onDemandProcessingResult = reportProcessing.CreateSnapshot(DateTime.Now, pc, null);
                    }
                    else
                    {
                        this.m_itemContext.RSRequestParameters.SetReportParameters(this.m_executionSession.ExecutionInfo.ReportParameters.AsNameValueCollectionInUserCulture);
                        onDemandProcessingResult = this.CreateSnapshotAndRender(reportProcessing, renderingExtension, pc, rc, subreportHandler, this.m_executionSession.ExecutionInfo.ReportParameters, this.m_executionSession.Credentials);
                    }
                }
                catch (Exception ex)
                {
                    this.m_executionSession.Snapshot = null;
                    throw;
                }
            }
            else if (renderingExtension != null)
            {
                onDemandProcessingResult = reportProcessing.RenderSnapshot(renderingExtension, rc, pc);
            }
            this.m_executionSession.SaveProcessingResult(onDemandProcessingResult);
            return(onDemandProcessingResult.Warnings);
        }
        internal static IRenderingExtension GetNewRenderer(string format, IExtensionFactory extFactory)
        {
            IRenderingExtension renderingExtension = null;

            try
            {
                return((IRenderingExtension)extFactory.GetNewRendererExtensionClass(format));
            }
            catch (Exception e)
            {
                if (AsynchronousExceptionDetection.IsStoppingException(e))
                {
                    throw;
                }
                throw new ReportProcessingException(ErrorCode.rsRenderingExtensionNotFound);
            }
        }
示例#6
0
 public void Render(IRenderingExtension export, StreamProvider streamProvider, NameValueCollection settings)
 {
     _viewer.Render(export, streamProvider, settings);
 }
 protected override bool InvokeRenderer(IRenderingExtension renderer, AspNetCore.ReportingServices.OnDemandReportRendering.Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, ref Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream)
 {
     return(renderer.RenderStream(this.m_streamName, report, reportServerParameters, deviceInfo, clientCapabilities, ref renderProperties, createAndRegisterStream));
 }
 protected virtual OnDemandProcessingResult CreateSnapshotAndRender(ReportProcessing repProc, IRenderingExtension renderer, ProcessingContext pc, AspNetCore.ReportingServices.ReportProcessing.RenderingContext rc, SubreportCallbackHandler subreportHandler, ParameterInfoCollection parameters, DatasourceCredentialsCollection credentials)
 {
     return(repProc.RenderReport(renderer, DateTime.Now, pc, rc, null));
 }
        public OnDemandProcessingResult Execute(IRenderingExtension newRenderer)
        {
            ExecutionLogContext executionLogContext = new ExecutionLogContext(m_publicProcessingContext.JobContext);

            executionLogContext.StartProcessingTimer();
            ProcessingErrorContext processingErrorContext = new ProcessingErrorContext();
            CultureInfo            currentCulture         = Thread.CurrentThread.CurrentCulture;

            try
            {
                bool                eventInfoChanged       = false;
                bool                renderingInfoChanged   = false;
                UserProfileState    userProfileState       = UserProfileState.None;
                Hashtable           renderProperties       = PublicRenderingContext.GetRenderProperties(IsSnapshotReprocessing);
                NameValueCollection reportServerParameters = FormServerParameterCollection(PublicRenderingContext.ReportContext.RSRequestParameters.CatalogParameters);
                PrepareForExecution();
                ProcessReport(processingErrorContext, executionLogContext, ref userProfileState);
                Microsoft.ReportingServices.OnDemandReportRendering.RenderingContext odpRenderingContext = null;
                try
                {
                    Microsoft.ReportingServices.OnDemandReportRendering.Report report = PrepareROM(out odpRenderingContext);
                    executionLogContext.StartRenderingTimer();
                    renderingInfoChanged = InvokeRenderer(newRenderer, report, reportServerParameters, RenderingParameters, PublicRenderingContext.ReportContext.RSRequestParameters.BrowserCapabilities, ref renderProperties, PublicProcessingContext.CreateStreamCallback);
                    UpdateServerTotalPages(newRenderer, ref renderProperties);
                    UpdateEventInfo(odpRenderingContext, PublicRenderingContext, ref eventInfoChanged);
                }
                catch (ReportProcessing.DataCacheUnavailableException)
                {
                    throw;
                }
                catch (ReportRenderingException rex)
                {
                    ReportProcessing.HandleRenderingException(rex);
                }
                catch (RSException)
                {
                    throw;
                }
                catch (Exception ex3)
                {
                    if (AsynchronousExceptionDetection.IsStoppingException(ex3))
                    {
                        throw;
                    }
                    throw new UnhandledReportRenderingException(ex3);
                }
                finally
                {
                    FinallyBlockForProcessingAndRendering(odpRenderingContext, executionLogContext);
                }
                CleanupSuccessfulProcessing(processingErrorContext);
                return(ConstructProcessingResult(eventInfoChanged, renderProperties, processingErrorContext, userProfileState, renderingInfoChanged, executionLogContext));
            }
            catch (ReportProcessing.DataCacheUnavailableException)
            {
                throw;
            }
            catch (RSException)
            {
                CleanupForException();
                throw;
            }
            catch (Exception innerException)
            {
                CleanupForException();
                throw new ReportProcessingException(innerException, processingErrorContext.Messages);
            }
            finally
            {
                FinalCleanup();
                ReportProcessing.UpdateHostingEnvironment(processingErrorContext, PublicProcessingContext.ReportContext, executionLogContext, RunningProcessingEngine, PublicProcessingContext.JobContext);
                if (currentCulture != null)
                {
                    Thread.CurrentThread.CurrentCulture = currentCulture;
                }
            }
        }
 protected virtual bool InvokeRenderer(IRenderingExtension renderer, Microsoft.ReportingServices.OnDemandReportRendering.Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, ref Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream)
 {
     return(renderer.Render(report, reportServerParameters, deviceInfo, clientCapabilities, ref renderProperties, createAndRegisterStream));
 }
示例#11
0
        private void exportButton_Click(object sender, EventArgs e)
        {
            var reportName = (string)reportsNames.SelectedItem;
            var exportType = (string)exportTypes.SelectedItem;
            IRenderingExtension renderingExtension = null;
            NameValueCollection settings           = null;
            var exporTypeLower = exportType.ToLower();

            switch (exporTypeLower)
            {
            case _pdf:
                renderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
                settings           = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
                break;

            case _xlsx:
                renderingExtension = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();
                ISettings excelSettings = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings()
                {
                    FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xlsx
                };
                settings = excelSettings.GetSettings();
                break;

            case _csv:
                settings = new GrapeCity.ActiveReports.Export.Text.Page.CsvRenderingExtension.Settings()
                {
                    ColumnsDelimiter = ",",
                    RowsDelimiter    = "\r\n",
                    QuotationSymbol  = '"',
                    Encoding         = Encoding.UTF8
                };
                renderingExtension = new GrapeCity.ActiveReports.Export.Text.Page.CsvRenderingExtension();
                break;

            case _docx:
                renderingExtension = new GrapeCity.ActiveReports.Export.Word.Page.WordRenderingExtension();
                settings           = new GrapeCity.ActiveReports.Export.Word.Page.Settings()
                {
                    FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.OOXML
                };

                break;

            case _mht:
                renderingExtension = new GrapeCity.ActiveReports.Export.Html.Page.HtmlRenderingExtension();
                settings           = new GrapeCity.ActiveReports.Export.Html.Page.Settings()
                {
                    MhtOutput = true, OutputTOC = true, Fragment = false
                };

                break;

            case _json:
                settings = new GrapeCity.ActiveReports.Export.Text.Page.JsonRenderingExtension.Settings()
                {
                    Formatted = true
                };
                renderingExtension = new GrapeCity.ActiveReports.Export.Text.Page.JsonRenderingExtension();
                break;
            }

            var report         = new PageReport(new FileInfo(@"..\..\..\..\Reports\" + reportName));
            var fileName       = Path.GetFileNameWithoutExtension(reportName);
            var saveFileDialog = new SaveFileDialog()
            {
                FileName = fileName + GetSaveDialogExtension(exporTypeLower),
                Filter   = GetSaveDialogFilter(exporTypeLower)
            };

            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var outputDirectory = new DirectoryInfo(Path.GetDirectoryName(saveFileDialog.FileName));
            var outputProvider  = new FileStreamProvider(outputDirectory, Path.GetFileNameWithoutExtension(saveFileDialog.FileName));

            outputProvider.OverwriteOutputFile = true;

            exportButton.Enabled = false;
            report.Document.Render(renderingExtension, outputProvider, settings);
            exportButton.Enabled = true;
        }