Esempio n. 1
0
        private string GetOutputFileName(ReportParameters Report)
        {
            string OutputFileName = portfolio + "_";

            Regex  rgx             = new Regex("[^a-zA-Z0-9]");
            string cleanReportName = rgx.Replace(Report.Name, "");

            OutputFileName += cleanReportName + "_" + dtEndDate.ToString("yyyyMMdd") + "_" + ReportRunDate.ToString("yyyyMMddHHmmss");

            return(OutputFileName);
        }
Esempio n. 2
0
        public void PDFReport(ActivityRun ar, IGenevaActions genevaInstance, ReportParameters report)
        {
            reportName     = report.Name;
            ar.CurrentStep = "PDFReport";

            UpdateProgress("Running PDF - " + report.Name, ar);

            Exception rdlException = RunSSRSReport(report, ar, reportFormat.PDF);

            if (rdlException != null)
            {
                throw rdlException;
            }

            ar.SaveActivityStep(true, report.Name, report.OutputFilePath, "");
        }
Esempio n. 3
0
        public void CSVReport(ActivityRun ar, IGenevaActions genevaInstance, ReportParameters report)
        {
            reportName     = report.Name;
            ar.CurrentStep = "CSVReport";
            UpdateProgress("Running CSV - " + report.Name, ar);

            TextReader tReader;

            genevaInstance.ExecuteReport(report.FileName, report.ParameterList, ReportOutputFormat.CSV, out tReader);
            var data = tReader.ReadToEnd();

            tReader.Close();

            report.OutputFilePath = GetOutputFileName(report);
            string     FilePath = outputFolder + report.OutputFilePath + ".csv";
            TextWriter tWriter  = new StreamWriter(FilePath);

            tWriter.Write(data);
            tWriter.Close();

            ar.SaveActivityStep(true, report.Name, report.OutputFilePath, "");
        }
Esempio n. 4
0
        private Exception RunSSRSReport(ReportParameters Report, ActivityRun activityRun, reportFormat format)
        {
            rsExec     = new ReportExecutionService();
            rsExec.Url = Properties.Settings.Default.RE2005_ReportExecutionService;

            rsExec.UseDefaultCredentials = true;

            string historyID  = null;
            string deviceInfo = null;

            Byte[] results;
            string encoding  = String.Empty;
            string mimeType  = String.Empty;
            string extension = String.Empty;

            Warning[] warnings  = null;
            string[]  streamIDs = null;

            var p = "";

            for (int i = 0; i < Report.Parameters.Count; i++)
            {
                p = "Param[" + i.ToString() + "]" + Report.Parameters[i].Name + "|" + Report.Parameters[i].Value.ToString() + Environment.NewLine + p;
            }

            // Path of the Report - XLS, PDF etc.
            Report.OutputFilePath = GetOutputFileName(Report);
            string FilePath = outputFolder + Report.OutputFilePath + "." + format.ToString().ToLower();

            // Name of the report - Please note this is not the RDL file.
            string _reportName = @"/GenevaReports/" + Report.Name;

            try
            {
                ExecutionInfo    ei         = rsExec.LoadReport(_reportName, historyID);
                ParameterValue[] parameters = new ParameterValue[Report.Parameters.Count];

                for (int i = 0; i < Report.Parameters.Count; i++)
                {
                    parameters[i]       = new ParameterValue();
                    parameters[i].Name  = Report.Parameters[i].Name;
                    parameters[i].Value = (string)Report.Parameters[i].Value;
                }

                rsExec.SetExecutionParameters(parameters, "en-IE");

                DataSourceCredentials dataSourceCredentials2 = new DataSourceCredentials();
                dataSourceCredentials2.DataSourceName = Properties.Settings.Default.DataSourceName;
                dataSourceCredentials2.UserName       = Properties.Settings.Default.GenevaUser;
                dataSourceCredentials2.Password       = Properties.Settings.Default.GenevaPass;


                DataSourceCredentials[] _credentials2 = new DataSourceCredentials[] { dataSourceCredentials2 };

                var c = "";
                for (int i = 0; i < _credentials2.Length; i++)
                {
                    c = "_credentials2[" + i.ToString() + "]:" + _credentials2[i].DataSourceName + "|" +
                        _credentials2[i].UserName + "|" +
                        _credentials2[i].Password + "|" + Environment.NewLine + c;
                }

                rsExec.SetExecutionCredentials(_credentials2);
                //rsExec.UseDefaultCredentials = true;

                results = rsExec.Render(format.ToString(), deviceInfo, out extension,
                                        out encoding,
                                        out mimeType,
                                        out warnings,
                                        out streamIDs);

                using (FileStream stream = File.OpenWrite(FilePath))
                {
                    stream.Write(results, 0, results.Length);
                }
            }
            catch (Exception ex)
            {
                status = "--- ERROR ---" + Environment.NewLine +
                         "Running PDF Report: " + Report.Name + Environment.NewLine +
                         ex.Message + Environment.NewLine +
                         "--------------" + Environment.NewLine +
                         status + Environment.NewLine;
                return(new Exception(status));
            }

            return(null);
        }