public RSExecutionInfo SetExecutionCredentials(RSDataSourceCredentials[] Credentials)
        {
            DataSourceCredentials[] dsCredentials = (DataSourceCredentials[])Converter.Convert(Credentials);
            ExecutionInfo           outval        = rs.SetExecutionCredentials(dsCredentials);

            return((RSExecutionInfo)Converter.Convert(outval));
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ReportExecutionService rs = new ReportExecutionService();

            //set parameters and report settings
            string reportPath = "/StudentHistory";

            rs.Url = "http://sunflower.arvixe.com/ReportServer_SQL_Service/ReportExecution2005.asmx?wsdl";

            DataSourceCredentials credentials = new DataSourceCredentials();

            credentials.DataSourceName = "sunflower.arvixe.com";
            credentials.UserName       = "******";
            credentials.Password       = "******";

            rs.SetExecutionCredentials(new DataSourceCredentials[] { credentials });

            ExecutionInfo   info = new ExecutionInfo();
            ExecutionHeader header = new ExecutionHeader();
            string          historyId = "", extension = "", mimeType = "", encoding = "", devInfo = "False";

            string[]  streamId;
            Warning[] warning;
            byte[]    result;

            ParameterValue param = new ParameterValue();

            param.Name  = "@auditionOrgId";
            param.Value = "1036";

            rs.ExecutionHeaderValue = header;
            info = rs.LoadReport(reportPath, historyId);
            rs.SetExecutionParameters(new ParameterValue[] { param }, "en-us");
            result = rs.Render("PDF", devInfo, out extension, out mimeType, out encoding,
                               out warning, out streamId);

            Response.ClearContent();
            Response.AppendHeader("content-length", result.Length.ToString());
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(result);
            Response.End();
            Response.Flush();
        }
Example #3
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);
        }