Ejemplo n.º 1
0
        private static void SetupLocalProcessing(ReportViewer reportViewer, ReportViewerParameters parameters, IReportViewerEventsHandler handlers)
        {
            reportViewer.ProcessingMode = ProcessingMode.Local;
            var localReport = reportViewer.LocalReport;
            localReport.ReportPath = parameters.ReportPath;

            if (parameters.ControlSettings?.UseCurrentAppDomainPermissionSet != null &&
                parameters.ControlSettings.UseCurrentAppDomainPermissionSet.Value)
            {
                localReport.SetBasePermissionsForSandboxAppDomain(AppDomain.CurrentDomain.PermissionSet.Copy());
            }

            if (parameters.ControlSettings?.EnableExternalImages != null &&
                parameters.ControlSettings.EnableExternalImages.Value)
            {
                localReport.EnableExternalImages = true;
            }

            if (parameters.ControlSettings?.EnableHyperlinks != null &&
                parameters.ControlSettings.EnableHyperlinks.Value)
            {
                localReport.EnableHyperlinks = true;
            }

            if (parameters.ReportParameters.Count > 0)
            {
                localReport.SetParameters(parameters.ReportParameters.Values);
            }

            if (handlers != null)
            {
                localReport.SubreportProcessing += (sender, e) => handlers.OnSubreportProcessing(reportViewer, e);
            }

            // If parameters.LocalReportDataSources then we should get report data source
            // from local data source provider (ignore it for Report Runner)
            if (parameters.LocalReportDataSources == null && !parameters.IsReportRunnerExecution)
            {
                if (parameters.ControlId == null)
                {
                    throw new MvcReportViewerException("MvcReportViewer control ID is missing");
                }

                var dataSourceProvider = LocalReportDataSourceProviderFactory.Current.Create();
                var dataSources = dataSourceProvider.Get((Guid)parameters.ControlId);
                localReport.DataSources.Clear();
                foreach (var dataSource in dataSources)
                {
                    localReport.DataSources.Add(dataSource);
                }
            }
            
        }
        private static void SetupLocalProcessing(ReportViewer reportViewer, ReportViewParamenters parameters,
                                                 IReportViewerEventsHandler handlers)
        {
            reportViewer.ProcessingMode = ProcessingMode.Local;
            var localReport = reportViewer.LocalReport;

            if (!string.IsNullOrWhiteSpace(parameters.EmbeddedResourcePath))
            {
                localReport.ReportEmbeddedResource = parameters.EmbeddedResourcePath;
            }
            else if (!string.IsNullOrWhiteSpace(parameters.LocalPath))
            {
                localReport.ReportPath = parameters.LocalPath;
            }
            else
            {
                localReport.LoadReportDefinition(parameters.EmbeddedResourceStream);
            }

            if (parameters.ControlSettings != null && parameters.ControlSettings.UseCurrentAppDomainPermissionSet != null &&
                parameters.ControlSettings.UseCurrentAppDomainPermissionSet.Value)
            {
                localReport.SetBasePermissionsForSandboxAppDomain(AppDomain.CurrentDomain.PermissionSet.Copy());
            }

            if (parameters.ControlSettings != null && parameters.ControlSettings.EnableExternalImages != null &&
                parameters.ControlSettings.EnableExternalImages.Value)
            {
                localReport.EnableExternalImages = true;
            }

            if (parameters.ControlSettings != null && parameters.ControlSettings.EnableHyperlinks != null &&
                parameters.ControlSettings.EnableHyperlinks.Value)
            {
                localReport.EnableHyperlinks = true;
            }

            if (parameters.ReportParameters.Count > 0)
            {
                localReport.SetParameters(parameters.ReportParameters.Values);
            }
            if (handlers != null)
            {
                localReport.SubreportProcessing += (sender, e) => handlers.OnSubreportProcessing(reportViewer, e);
            }

            // If parameters.LocalReportDataSources then we should get report data source
            // from local data source provider (ignore it for Report Runner)
            if (parameters.LocalReportDataSources == null && !parameters.IsGeradorReportViewerExecution)
            {
                if (parameters.ControlId == null)
                {
                    throw new ReportException("ReportViewer control ID is missing");
                }
                localReport.DataSources.Clear();
                if (parameters.LocalReportDataSources != null)
                {
                    foreach (var dataSource in parameters.LocalReportDataSources)
                    {
                        var reportDatasource = new ReportDataSource(dataSource.Key, dataSource.Value);
                        localReport.DataSources.Add(reportDatasource);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static void SetupLocalProcessing(ReportViewer reportViewer, ReportViewerParameters parameters, IReportViewerEventsHandler handlers)
        {
            reportViewer.ProcessingMode = ProcessingMode.Local;
            var localReport = reportViewer.LocalReport;

            localReport.ReportPath = parameters.ReportPath;

            if (parameters.ControlSettings?.UseCurrentAppDomainPermissionSet != null &&
                parameters.ControlSettings.UseCurrentAppDomainPermissionSet.Value)
            {
                localReport.SetBasePermissionsForSandboxAppDomain(AppDomain.CurrentDomain.PermissionSet.Copy());
            }

            if (parameters.ControlSettings?.EnableExternalImages != null &&
                parameters.ControlSettings.EnableExternalImages.Value)
            {
                localReport.EnableExternalImages = true;
            }

            if (parameters.ControlSettings?.EnableHyperlinks != null &&
                parameters.ControlSettings.EnableHyperlinks.Value)
            {
                localReport.EnableHyperlinks = true;
            }

            if (parameters.ReportParameters.Count > 0)
            {
                localReport.SetParameters(parameters.ReportParameters.Values);
            }

            if (handlers != null)
            {
                localReport.SubreportProcessing += (sender, e) => handlers.OnSubreportProcessing(reportViewer, e);
            }

            // If parameters.LocalReportDataSources then we should get report data source
            // from local data source provider (ignore it for Report Runner)
            if (parameters.LocalReportDataSources == null && !parameters.IsReportRunnerExecution)
            {
                if (parameters.ControlId == null)
                {
                    throw new MvcReportViewerException("MvcReportViewer control ID is missing");
                }

                var dataSourceProvider = LocalReportDataSourceProviderFactory.Current.Create();
                var dataSources        = dataSourceProvider.Get((Guid)parameters.ControlId);
                localReport.DataSources.Clear();
                foreach (var dataSource in dataSources)
                {
                    localReport.DataSources.Add(dataSource);
                }
            }
        }