Exemplo n.º 1
0
        public void LogToCrissCrossHistory(CrcReportDefinition repDef, string username, string executionId)
        {
            string        crissCrossInstance    = GetAppRootUrl(false);
            string        reportPath            = repDef.ReportPath;
            var           converter             = new CrcParameterConverter();
            List <string> parametersListForUser = converter.GetReportParametersForUser(repDef, 0);
            string        parametersForUser     = string.Join(Environment.NewLine, parametersListForUser.ToArray());

            logger.DebugFormat("Logging report run to CrissCrossExecutionLog - executionid {0}", executionId);

            string sql = "insert into CrissCrossExecutionLog(ExecutionId, CrissCrossInstance, ReportPath, UserName, ParametersForUser) "
                         + "values(@ExecutionId, @CrissCrossInstance, @ReportPath, @UserName, @ParametersForUser)";

            using (SqlConnection conn = new SqlConnection(GetCrissCrossHistoryConnectionString()))
            {
                conn.Open();
                SqlCommand comm = new SqlCommand(sql, conn);
                comm.Parameters.Add("@ExecutionId", SqlDbType.NVarChar, 128).Value        = executionId;
                comm.Parameters.Add("@CrissCrossInstance", SqlDbType.NVarChar, 250).Value = crissCrossInstance;
                comm.Parameters.Add("@ReportPath", SqlDbType.NVarChar, 850).Value         = reportPath;
                comm.Parameters.Add("@UserName", SqlDbType.NVarChar, 520).Value           = username;
                comm.Parameters.Add("@ParametersForUser", SqlDbType.NVarChar).Value       = parametersForUser;
                comm.ExecuteNonQuery();
            }
        }
Exemplo 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())));
            }
        }
        public void GetReportParametersForSsrsReportViewer_CanReturnNullDate()
        {
            var repDefn   = MakeTestReportDefn(null, "S1");
            var converter = new CrcParameterConverter();

            var result = converter.GetReportParametersForSsrsReportViewer(repDefn);

            Assert.AreEqual(2, result.Count());
            viewer.ReportParameter param1 = result.FirstOrDefault(p => p.Name == "PretendDateParam");
            Assert.IsNotNull(param1);
            Assert.AreEqual(1, param1.Values.Count);
            Assert.AreEqual(null, param1.Values[0]);
            viewer.ReportParameter param2 = result.FirstOrDefault(p => p.Name == "PretendSingleSelect");
            Assert.IsNotNull(param2);
            Assert.AreEqual(1, param2.Values.Count);
            Assert.AreEqual("S1", param2.Values[0]);
        }
Exemplo n.º 4
0
        public void LogToCrissCrossHistory(CrcReportDefinition repDef, string username, string executionId)
        {
            string crissCrossInstance = GetAppRootUrl(false);
            string reportPath = repDef.ReportPath;
            var converter = new CrcParameterConverter();
            List<string> parametersListForUser = converter.GetReportParametersForUser(repDef, 0);
            string parametersForUser = string.Join(Environment.NewLine, parametersListForUser.ToArray());

            logger.DebugFormat("Logging report run to CrissCrossExecutionLog - executionid {0}", executionId);

            string sql = "insert into CrissCrossExecutionLog(ExecutionId, CrissCrossInstance, ReportPath, UserName, ParametersForUser) "
                + "values(@ExecutionId, @CrissCrossInstance, @ReportPath, @UserName, @ParametersForUser)";
            using (SqlConnection conn = new SqlConnection(GetCrissCrossHistoryConnectionString()))
            {
                conn.Open();
                SqlCommand comm = new SqlCommand(sql, conn);
                comm.Parameters.Add("@ExecutionId", SqlDbType.NVarChar, 128).Value = executionId;
                comm.Parameters.Add("@CrissCrossInstance", SqlDbType.NVarChar, 250).Value = crissCrossInstance;
                comm.Parameters.Add("@ReportPath", SqlDbType.NVarChar, 850).Value = reportPath;
                comm.Parameters.Add("@UserName", SqlDbType.NVarChar, 520).Value = username;
                comm.Parameters.Add("@ParametersForUser", SqlDbType.NVarChar).Value = parametersForUser;
                comm.ExecuteNonQuery();
            }
        }