Esempio n. 1
0
        public void RunReport()
        {
            var    crcRepDef   = GetReportDefinition(this.ReportPath);
            string paramString = uxHiddenParamString.Text;

            SetReportViewerSize();
            var choiceFactory    = new CrcParameterChoiceFactory();
            var choiceCollection = choiceFactory.Create(paramString);
            var mapResult        = crcRepDef.MapParameterChoices(choiceCollection);

            if (mapResult.MappingValid)
            {
                InitialiseReportViewer(this.ReportPath);

                logger.DebugFormat("RunReport: ReportPath: {0} User {1}", uxReportViewer.ServerReport.ReportPath, User.Identity.Name);
                var converter     = new CrcParameterConverter();
                var ssrsParamList = converter.GetReportParametersForSsrsReportViewer(crcRepDef);
                var userParamList = converter.GetReportParametersForUser(crcRepDef, 15);
                try
                {
                    uxReportViewer.ServerReport.SetParameters(ssrsParamList);
                }
                catch (ReportServerException rse)
                {
                    // check for problem with fixed user
                    if (rse.ErrorCode == "rsAccessDenied" && !this.GetImpersonateLoggedOnUser())
                    {
                        throw new ApplicationException(string.Format("ReportViewer is running as fixed user {0} but was passed a report {1} that it could not open",
                                                                     GetFixedSsrsUsername(), this.ReportPath));
                    }
                    else
                    {
                        throw rse;
                    }
                }
                string executionId = uxReportViewer.ServerReport.GetExecutionId();
                logger.DebugFormat("RunReport: running report, executionId is {0}", executionId);
                if (StoreCrissCrossHistory)
                {
                    // log executionid, logged in user and param description
                    var historyLogger = new CrissCrossLib.History.CrcHistoryLogger();
                    historyLogger.LogToCrissCrossHistory(crcRepDef, User.Identity.Name, executionId);
                }
                uxParamUserDescription.Text = string.Join("<br/>", userParamList.ToArray());
                uxResultsPanel.Visible      = true;
                uxParamSummaryPanel.Visible = true;
                this.RunningReport          = true;
            }
            else
            {
                // todo - friendly message back to ui
                throw new ApplicationException(string.Format("invalid params - could not map supplied values to definitions for report {0}. complaints: {1}",
                                                             crcRepDef.DisplayName, string.Join(", ", mapResult.Complaints.ToArray())));
            }
        }
Esempio n. 2
0
        public void RunReport()
        {
            var crcRepDef = GetReportDefinition(this.ReportPath);
            string paramString = uxHiddenParamString.Text;
            SetReportViewerSize();
            var choiceFactory = new CrcParameterChoiceFactory();
            var choiceCollection = choiceFactory.Create(paramString);
            var mapResult = crcRepDef.MapParameterChoices(choiceCollection);
            if (mapResult.MappingValid)
            {

                InitialiseReportViewer(this.ReportPath);

                logger.DebugFormat("RunReport: ReportPath: {0} User {1}", uxReportViewer.ServerReport.ReportPath, User.Identity.Name);
                var converter = new CrcParameterConverter();
                var ssrsParamList = converter.GetReportParametersForSsrsReportViewer(crcRepDef);
                var userParamList = converter.GetReportParametersForUser(crcRepDef, 15);
                try
                {
                    uxReportViewer.ServerReport.SetParameters(ssrsParamList);
                }
                catch (ReportServerException rse)
                {
                    // check for problem with fixed user
                    if (rse.ErrorCode == "rsAccessDenied" && !this.GetImpersonateLoggedOnUser())
                        throw new ApplicationException(string.Format("ReportViewer is running as fixed user {0} but was passed a report {1} that it could not open",
                            GetFixedSsrsUsername(), this.ReportPath));
                    else
                        throw rse;
                }
                string executionId = uxReportViewer.ServerReport.GetExecutionId();
                logger.DebugFormat("RunReport: running report, executionId is {0}", executionId);
                if (StoreCrissCrossHistory)
                {
                    // log executionid, logged in user and param description
                    var historyLogger = new CrissCrossLib.History.CrcHistoryLogger();
                    historyLogger.LogToCrissCrossHistory(crcRepDef, User.Identity.Name, executionId);
                }
                uxParamUserDescription.Text = string.Join("<br/>", userParamList.ToArray());
                uxResultsPanel.Visible = true;
                uxParamSummaryPanel.Visible = true;
                this.RunningReport = true;
            }
            else
            {
                // todo - friendly message back to ui
                throw new ApplicationException(string.Format("invalid params - could not map supplied values to definitions for report {0}. complaints: {1}",
                    crcRepDef.DisplayName, string.Join(", ", mapResult.Complaints.ToArray())));
            }
        }