Ejemplo n.º 1
0
        private byte[] CreatePDF(int ticketId)
        {
            ReportExecutionService rs = new ReportExecutionService();

            string format = "PDF";
            string reportPath = "/Reports/TicketReport";
            string mimeType = "application/pdf";

            var parameters = new[]
            {
                new ParameterValue
                {
                    Name = "TicketNumber",
                    Value = ticketId.ToString()
                }
            };

            return RenderReport(rs, format, mimeType, reportPath, parameters);
        }
Ejemplo n.º 2
0
        private static byte[] RenderReport(ReportExecutionService rs, string format, string mimeType, string reportPath,
			ParameterValue[] parameters)
        {
            rs.Credentials = CredentialCache.DefaultCredentials;

            string deviceInfo = string.Empty;
            string extension;
            string encoding;
            Warning[] warnings;
            string[] streamIDs;

            rs.LoadReport(reportPath, null);
            rs.SetExecutionParameters(parameters, "en-us");
            var results = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

            return results;
        }