public int PerformSort(string paginationMode, string sortId, SortOptions sortDirection, bool clearSort, out string uniqueName)
        {
            this.SetProcessingCulture();
            ControlSnapshot snapshot = this.m_executionSession.Snapshot;

            try
            {
                this.m_executionSession.Snapshot = new ControlSnapshot();
                snapshot.PrepareExecutionSnapshot(this.m_executionSession.Snapshot, null);
                using (ProcessingStreamHandler @object = new ProcessingStreamHandler())
                {
                    this.m_itemContext.RSRequestParameters.PaginationModeValue = paginationMode;
                    ReportProcessing  reportProcessing = this.CreateAndConfigureReportProcessing();
                    ProcessingContext pc = this.CreateProcessingContext(@object.StreamCallback);
                    AspNetCore.ReportingServices.ReportProcessing.RenderingContext rc = this.CreateRenderingContext();
                    int result = default(int);
                    OnDemandProcessingResult onDemandProcessingResult = reportProcessing.ProcessUserSortEvent(sortId, sortDirection, clearSort, pc, rc, (IChunkFactory)snapshot, out uniqueName, out result);
                    if (onDemandProcessingResult != null && onDemandProcessingResult.SnapshotChanged)
                    {
                        this.m_executionSession.SaveProcessingResult(onDemandProcessingResult);
                    }
                    else
                    {
                        this.m_executionSession.Snapshot = snapshot;
                    }
                    return(result);
                }
            }
            catch
            {
                this.m_executionSession.Snapshot = snapshot;
                throw;
            }
        }
        private DataSetPublishingResult GetCompiledDataSet(DataSetInfo dataSetInfo, ICatalogItemContext dataSetContext)
        {
            StoredDataSet storedDataSet = this.m_catalogTempDB.GetCompiledDataSet(dataSetInfo);

            if (storedDataSet != null && !storedDataSet.Definition.SequenceEqual(dataSetInfo.Definition))
            {
                storedDataSet = null;
            }
            if (storedDataSet == null)
            {
                DataSetPublishingResult result = default(DataSetPublishingResult);
                try
                {
                    using (ControlSnapshot createChunkFactory = new ControlSnapshot())
                    {
                        ReportProcessing  reportProcessing = this.CreateAndConfigureReportProcessing();
                        PublishingContext sharedDataSetPublishingContext = new PublishingContext(dataSetContext, dataSetInfo.Definition, createChunkFactory, AppDomain.CurrentDomain, true, this.GetDataSourceForSharedDataSetHandler, reportProcessing.Configuration);
                        result = reportProcessing.CreateSharedDataSet(sharedDataSetPublishingContext);
                    }
                }
                catch (Exception inner)
                {
                    throw new DefinitionInvalidException(dataSetInfo.AbsolutePath, inner);
                }
                storedDataSet = new StoredDataSet(dataSetInfo.Definition, result);
                this.m_catalogTempDB.SetCompiledDataSet(dataSetInfo, storedDataSet);
            }
            return(storedDataSet.PublishingResult);
        }
        public void SetReportParameters(NameValueCollection userSpecifiedValues)
        {
            ParameterInfoCollection parameterInfoCollection = this.m_executionSession.ExecutionInfo.ReportParameters;

            if (parameterInfoCollection == null)
            {
                ControlSnapshot  controlSnapshot = default(ControlSnapshot);
                PublishingResult compiledReport  = this.GetCompiledReport(this.m_itemContext, false, out controlSnapshot);
                parameterInfoCollection = compiledReport.Parameters;
            }
            else if (userSpecifiedValues == null)
            {
                return;
            }
            ParameterInfoCollection parameterInfoCollection2;

            if (userSpecifiedValues != null)
            {
                ParameterInfoCollection newParameters = ParameterInfoCollection.DecodeFromNameValueCollectionAndUserCulture(userSpecifiedValues);
                parameterInfoCollection2 = ParameterInfoCollection.Combine(parameterInfoCollection, newParameters, true, false, false, false, Localization.ClientPrimaryCulture);
            }
            else
            {
                parameterInfoCollection2 = parameterInfoCollection;
            }
            ParameterInfoCollection parameterInfoCollection3 = new ParameterInfoCollection();

            parameterInfoCollection2.CopyTo(parameterInfoCollection3);
            this.ProcessAndStoreReportParameters(parameterInfoCollection3);
        }
Example #4
0
        public static PublishingResult CompileReport(ICatalogItemContext context, byte[] reportDefinition, bool generateExpressionHostWithRefusedPermissions, out ControlSnapshot snapshot)
        {
            PublishingResult publishingResult = null;

            snapshot = null;

            try
            {
                ReportProcessing reportProcessing = new ReportProcessing();
                snapshot = new ControlSnapshot();
                AppDomain         appDomain = AppDomain.CurrentDomain;
                PublishingContext reportPublishingContext = new PublishingContext(context, reportDefinition, snapshot, appDomain, generateExpressionHostWithRefusedPermissions,
                                                                                  snapshot.ReportProcessingFlags, reportProcessing.Configuration, DataProtectionLocal.Instance);
                return(reportProcessing.CreateIntermediateFormat(reportPublishingContext));
            }
            catch (Exception inner)
            {
                string text = context.ItemPathAsString;
                if (text == null)
                {
                    text = ProcessingStrings.MainReport;
                }
                throw new DefinitionInvalidException(text, inner);
            }
        }
        public PublishingResult CompileReport()
        {
            ControlSnapshot  compiledReport  = default(ControlSnapshot);
            PublishingResult compiledReport2 = this.GetCompiledReport(this.m_itemContext, true, out compiledReport);

            this.m_executionSession.CompiledReport = compiledReport;
            this.m_executionSession.ExecutionInfo.PageProperties = compiledReport2.PageProperties;
            this.m_executionSession.CompiledDataSources          = compiledReport2.DataSources;
            return(compiledReport2);
        }
        //https://stackoverflow.com/q/39411950
        private void btnScreenshot_Click(object sender, System.EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.DefaultExt = "jpg";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var bitmap = ControlSnapshot.Snapshot(chromeBrowser);
                bitmap.Save(dialog.FileName, ImageFormat.Jpeg);
            }
        }
        public string[] GetDataSetNames(PreviewItemContext itemContext)
        {
            if (this.DataRetrieval.SupportsQueries)
            {
                return(new string[0]);
            }
            ControlSnapshot  controlSnapshot = default(ControlSnapshot);
            PublishingResult compiledReport  = this.GetCompiledReport(itemContext ?? this.m_itemContext, false, out controlSnapshot);

            return(compiledReport.DataSetsName ?? new string[0]);
        }
        private void OnGetSubReportDataSources(ICatalogItemContext itemContext, string subreportPath, ReportProcessing.NeedsUpgrade upgradeCheck, out ICatalogItemContext subreportContext, out IChunkFactory getCompiledDefinition, out DataSourceInfoCollection dataSources, out DataSetInfoCollection dataSets)
        {
            subreportPath    = this.NormalizeSubReportPath(subreportPath);
            subreportContext = itemContext.GetSubreportContext(subreportPath);
            RSTrace.ReportPreviewTracer.Trace(TraceLevel.Info, "Getting datasources information for {0}.", subreportContext.ItemPathAsString);
            ControlSnapshot  controlSnapshot = default(ControlSnapshot);
            PublishingResult compiledReport  = this.GetCompiledReport((PreviewItemContext)subreportContext, false, out controlSnapshot);

            getCompiledDefinition = controlSnapshot;
            dataSources           = this.ResolveSharedDataSources(compiledReport.DataSources);
            dataSets = this.ResolveSharedDataSets(compiledReport.SharedDataSets);
        }
        private void ProcessAndStoreReportParameters(ParameterInfoCollection newParameters)
        {
            ControlSnapshot chunkFactory = default(ControlSnapshot);

            this.GetCompiledReport(this.m_itemContext, false, out chunkFactory);
            using (ProcessingStreamHandler @object = new ProcessingStreamHandler())
            {
                ProcessingContext pc = this.CreateProcessingContext(newParameters, null, this.m_executionSession.Credentials, chunkFactory, @object.StreamCallback, this.CreateSubreportCallbackHandler());
                ReportProcessing  reportProcessing = this.CreateAndConfigureReportProcessing();
                bool flag = default(bool);
                reportProcessing.ProcessReportParameters(DateTime.Now, pc, false, out flag);
                this.m_executionSession.ExecutionInfo.ReportParameters = newParameters;
            }
        }
 private void GetAllReportDataSourcesAndSharedDataSets(out RuntimeDataSourceInfoCollection runtimeDataSources, out RuntimeDataSetInfoCollection runtimeDataSets)
 {
     if (!this.DataRetrieval.SupportsQueries)
     {
         runtimeDataSources = new RuntimeDataSourceInfoCollection();
         runtimeDataSets    = new RuntimeDataSetInfoCollection();
     }
     else
     {
         ControlSnapshot          getCompiledDefinitionFactory = default(ControlSnapshot);
         PublishingResult         compiledReport        = this.GetCompiledReport(this.m_itemContext, false, out getCompiledDefinitionFactory);
         DataSourceInfoCollection existingDataSources   = this.ResolveSharedDataSources(compiledReport.DataSources);
         DataSetInfoCollection    dataSetInfoCollection = this.ResolveSharedDataSets(compiledReport.SharedDataSets);
         DataSourceInfoCollection dataSources           = this.CompileDataSetsAndCombineDataSources(dataSetInfoCollection, existingDataSources);
         ReportProcessing         reportProcessing      = this.CreateAndConfigureReportProcessing();
         reportProcessing.GetAllDataSources((ICatalogItemContext)this.m_itemContext, (IChunkFactory)getCompiledDefinitionFactory, (ReportProcessing.OnDemandSubReportDataSourcesCallback) this.OnGetSubReportDataSources, dataSources, dataSetInfoCollection, true, new ServerDataSourceSettings(true, true), out runtimeDataSources, out runtimeDataSets);
     }
 }
        private void OnGetSubReportDefinition(ICatalogItemContext reportContext, string subreportPath, string newChunkName, ReportProcessing.NeedsUpgrade upgradeCheck, ParameterInfoCollection parentQueryParameters, out ICatalogItemContext subreportContext, out string description, out IChunkFactory chunkFactory, out ParameterInfoCollection parameters)
        {
            if (reportContext == null)
            {
                throw new ArgumentException("OnGetSubReportDefinition: Invalid report context");
            }
            if (upgradeCheck(ReportProcessingFlags.OnDemandEngine))
            {
                throw new Exception("Subreport definition is not compatible with this version of viewer controls");
            }
            subreportContext = reportContext.GetSubreportContext(subreportPath);
            ControlSnapshot  controlSnapshot = default(ControlSnapshot);
            PublishingResult compiledReport  = this.GetCompiledReport((PreviewItemContext)subreportContext, false, out controlSnapshot);

            controlSnapshot.PrepareExecutionSnapshot(this.m_executionSession.Snapshot, newChunkName);
            description  = compiledReport.ReportDescription;
            chunkFactory = controlSnapshot;
            parameters   = compiledReport.Parameters;
        }
Example #12
0
        public void ScreenshotBrowser(string filename = "BrowserScreenshot.png")
        {
            Bitmap bitmap = ControlSnapshot.Snapshot(GlobalVar.Browser);

            bitmap.Save(filename);
        }
        private void btnCopyImage_Click(object sender, System.EventArgs e)
        {
            var bitmap = ControlSnapshot.Snapshot(chromeBrowser);

            Clipboard.SetImage(bitmap);
        }
        private PublishingResult GetCompiledReport(PreviewItemContext itemContext, bool rebuild, out ControlSnapshot snapshot)
        {
            StoredReport storedReport = null;

            if (!rebuild)
            {
                storedReport = this.m_catalogTempDB.GetCompiledReport(itemContext);
                if (storedReport != null && storedReport.GeneratedExpressionHostWithRefusedPermissions != this.GenerateExpressionHostWithRefusedPermissions)
                {
                    storedReport = null;
                }
            }
            if (storedReport == null)
            {
                byte[]           reportDefinition = this.m_catalog.GetReportDefinition(itemContext);
                PublishingResult publishingResult = ReportCompiler.CompileReport((ICatalogItemContext)itemContext, reportDefinition, this.GenerateExpressionHostWithRefusedPermissions, out snapshot);
                storedReport = new StoredReport(publishingResult, snapshot, this.GenerateExpressionHostWithRefusedPermissions);
                this.m_catalogTempDB.SetCompiledReport(itemContext, storedReport);
                foreach (DataSourceInfo dataSource in storedReport.PublishingResult.DataSources)
                {
                    if (!dataSource.IsReference && dataSource.CredentialsRetrieval != DataSourceInfo.CredentialsRetrievalOption.Integrated)
                    {
                        string text  = null;
                        string text2 = null;
                        this.m_catalog.GetReportDataSourceCredentials(itemContext, dataSource.Name, out text, out text2);
                        bool flag = !string.IsNullOrEmpty(text);
                        if (flag)
                        {
                            dataSource.SetUserName(text, DataProtectionLocal.Instance);
                        }
                        bool flag2 = text2 != null;
                        if (flag2)
                        {
                            dataSource.SetPassword(text2, DataProtectionLocal.Instance);
                        }
                        if (flag || flag2)
                        {
                            dataSource.CredentialsRetrieval = DataSourceInfo.CredentialsRetrievalOption.Store;
                        }
                        else if (string.IsNullOrEmpty(dataSource.Prompt))
                        {
                            dataSource.CredentialsRetrieval = DataSourceInfo.CredentialsRetrievalOption.None;
                        }
                        else
                        {
                            dataSource.CredentialsRetrieval = DataSourceInfo.CredentialsRetrievalOption.Prompt;
                        }
                    }
                }
            }
            this.m_securityValidator(itemContext, storedReport.PublishingResult);
            snapshot = storedReport.Snapshot;
            return(storedReport.PublishingResult);
        }
        private PublishingResult GetCompiledReport(PreviewItemContext itemContext, bool rebuild, out ControlSnapshot snapshot)
        {
            StoredReport storedReport = null;

            if (!rebuild)
            {
                storedReport = m_catalogTempDB.GetCompiledReport(itemContext);
                if (storedReport != null && storedReport.GeneratedExpressionHostWithRefusedPermissions != GenerateExpressionHostWithRefusedPermissions)
                {
                    storedReport = null;
                }
            }
            if (storedReport == null)
            {
                byte[] reportDefinition = m_catalog.GetReportDefinition(itemContext);
                storedReport = new StoredReport(ReportCompiler.CompileReport(itemContext, reportDefinition, GenerateExpressionHostWithRefusedPermissions, out snapshot), snapshot, GenerateExpressionHostWithRefusedPermissions);
                m_catalogTempDB.SetCompiledReport(itemContext, storedReport);
                ILocalCatalog2 localCatalog = m_catalog as ILocalCatalog2;
                foreach (DataSourceInfo dataSource in storedReport.PublishingResult.DataSources)
                {
                    string userName = null;
                    string password = null;
                    if (localCatalog != null && localCatalog.GetReportDataSourceCredentials(itemContext, dataSource, out userName, out password))
                    {
                        dataSource.SetUserName(userName, DataProtectionLocal.Instance);
                        dataSource.SetPassword(password, DataProtectionLocal.Instance);
                        dataSource.CredentialsRetrieval = DataSourceInfo.CredentialsRetrievalOption.Store;
                    }
                    else
                    {
                        if (dataSource.IsReference || dataSource.CredentialsRetrieval == DataSourceInfo.CredentialsRetrievalOption.Integrated)
                        {
                            continue;
                        }
                        if (localCatalog == null)
                        {
                            m_catalog.GetReportDataSourceCredentials(itemContext, dataSource.Name, out userName, out password);
                            bool num = !string.IsNullOrEmpty(userName);
                            if (num)
                            {
                                dataSource.SetUserName(userName, DataProtectionLocal.Instance);
                            }
                            bool flag = password != null;
                            if (flag)
                            {
                                dataSource.SetPassword(password, DataProtectionLocal.Instance);
                            }
                            if (num || flag)
                            {
                                dataSource.CredentialsRetrieval = DataSourceInfo.CredentialsRetrievalOption.Store;
                                continue;
                            }
                        }
                        if (string.IsNullOrEmpty(dataSource.Prompt))
                        {
                            dataSource.CredentialsRetrieval = DataSourceInfo.CredentialsRetrievalOption.None;
                        }
                        else
                        {
                            dataSource.CredentialsRetrieval = DataSourceInfo.CredentialsRetrievalOption.Prompt;
                        }
                    }
                }
            }
            m_securityValidator(itemContext, storedReport.PublishingResult);
            snapshot = storedReport.Snapshot;
            return(storedReport.PublishingResult);
        }
 public StoredReport(PublishingResult publishingResult, ControlSnapshot snapshot, bool generatedExpressionHostWithRefusedPermissions)
 {
     this.PublishingResult = publishingResult;
     this.Snapshot         = snapshot;
     this.GeneratedExpressionHostWithRefusedPermissions = generatedExpressionHostWithRefusedPermissions;
 }