Ejemplo n.º 1
1
        public SSRSPrintPreview(SSRSCommon.ReportExecutionService.ReportExecutionService rep_exec_svc, SSRSCommon.ReportService2005.ReportingService2005 rep_svc, string surl, string rpath, SSRSCommon.RDLMetaData rdlmetadata)
        {
            InitializeComponent();

            this.rep_exec_svc = rep_exec_svc;
            this.rep_svc = rep_svc;
            this.ReportServerURL = surl;
            this.ReportPath = rpath;
            this.rdlmd = rdlmetadata;
            
            this.rep_viewer_ctrl = new Microsoft.Reporting.WinForms.ReportViewer();
            this.rep_viewer_ctrl.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;

            var report = this.rep_viewer_ctrl.ServerReport;
            report.ReportServerUrl = new System.Uri( this.ReportServerURL );
            report.ReportPath = this.ReportPath;

            this.rep_viewer_ctrl.RefreshReport();

            

            // get the metafiles
            // In this sample we are getting only the first metafile
            preparemetafiles();

            this.UpdateUI();

        }
Ejemplo n.º 2
0
        public static string GetReportServerUrl(SSRSCommon.ReportExecutionService.ReportExecutionService svc)
        {
            var s      = svc.Url;
            var tokens = s.Split(new char[] { '/' });

            return(string.Join("/", tokens.Take(tokens.Length - 1).ToArray()) + "/");
        }
Ejemplo n.º 3
0
        public SSRSPrintPreview(SSRSCommon.ReportExecutionService.ReportExecutionService rep_exec_svc, SSRSCommon.ReportService2005.ReportingService2005 rep_svc, string surl, string rpath, SSRSCommon.RDLMetaData rdlmetadata)
        {
            InitializeComponent();

            this.rep_exec_svc    = rep_exec_svc;
            this.rep_svc         = rep_svc;
            this.ReportServerURL = surl;
            this.ReportPath      = rpath;
            this.rdlmd           = rdlmetadata;

            this.rep_viewer_ctrl = new Microsoft.Reporting.WinForms.ReportViewer();
            this.rep_viewer_ctrl.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;

            var report = this.rep_viewer_ctrl.ServerReport;

            report.ReportServerUrl = new System.Uri(this.ReportServerURL);
            report.ReportPath      = this.ReportPath;

            this.rep_viewer_ctrl.RefreshReport();



            // get the metafiles
            // In this sample we are getting only the first metafile
            preparemetafiles();

            this.UpdateUI();
        }
Ejemplo n.º 4
0
        public FormReportPicker(SSRSCommon.ReportExecutionService.ReportExecutionService rep_exec_svc, SSRSCommon.ReportService2005.ReportingService2005 rep_svc, string surl, string path)
        {
            InitializeComponent();

            this.rep_exec_svc = rep_exec_svc;
            this.rep_svc = rep_svc;
            this.ReportServerURL = surl;
            this.Path = path;

            var children = this.rep_svc.ListChildren(this.Path, false);
            foreach (var child in children)
            {
                this.listView1.Items.Add(child.Name);
            }
        }
Ejemplo n.º 5
0
        public FormReportPicker(SSRSCommon.ReportExecutionService.ReportExecutionService rep_exec_svc, SSRSCommon.ReportService2005.ReportingService2005 rep_svc, string surl, string path)
        {
            InitializeComponent();

            this.rep_exec_svc    = rep_exec_svc;
            this.rep_svc         = rep_svc;
            this.ReportServerURL = surl;
            this.Path            = path;

            var children = this.rep_svc.ListChildren(this.Path, false);

            foreach (var child in children)
            {
                this.listView1.Items.Add(child.Name);
            }
        }
Ejemplo n.º 6
0
        public static List <System.Drawing.Imaging.Metafile> RenderMetafilesForReport(
            SSRSCommon.ReportService2005.ReportingService2005 rep_svc,
            SSRSCommon.ReportExecutionService.ReportExecutionService rep_exec_svc, string reportpath, EMFRenderPrefs userprintprefs, int FirstNPages)
        {
            var exec_header = new SSRSCommon.ReportExecutionService.ExecutionHeader();

            rep_exec_svc.ExecutionHeaderValue = exec_header;
            string historyid = null;

            Console.WriteLine("Loading Report");
            var exec_info = rep_exec_svc.LoadReport(reportpath, historyid);

            //rs2.SetExecutionParameters(parameters, "en-us");

            var session_id = rep_exec_svc.ExecutionHeaderValue.ExecutionID;

            Console.WriteLine("Session ID: {0}", rep_exec_svc.ExecutionHeaderValue.ExecutionID);

            var    streams       = new List <System.IO.Stream>();
            var    metafiles     = new List <System.Drawing.Imaging.Metafile>();
            string render_format = "IMAGE";

            int cur_page_count = 0;

            try
            {
                // Create the Viewer and Bind it to the Server Report
                Console.WriteLine("Creating the ReportViewer Control");
                var viewer = new Microsoft.Reporting.WinForms.ReportViewer();
                viewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
                var server_report = viewer.ServerReport;
                Console.WriteLine("Server Report DisplayName: {0}", server_report.DisplayName);
                Console.WriteLine("Server Report ReportPath: {0}", server_report.ReportPath);
                Console.WriteLine("Server Report ReportServerUrl: {0}", server_report.ReportServerUrl);
                Console.WriteLine("Server Report Timeout: {0}", server_report.Timeout);


                viewer.ServerReport.ReportServerUrl = new Uri(get_correct_url(rep_svc.Url));
                viewer.ServerReport.ReportPath      = reportpath;
                Console.WriteLine("Report Viewer ProcessingMode: {0}", viewer.ProcessingMode);
                Console.WriteLine("Report Viewer ReportServerUrl: {0}", viewer.ServerReport.ReportServerUrl);
                Console.WriteLine("Report Viewer ReportPath: {0}", viewer.ServerReport.ReportPath);

                // Setup URL Parameters
                Console.WriteLine("Creating the URL Parameters");
                var url_params = new System.Collections.Specialized.NameValueCollection();
                url_params.Add("rs:PersistStreams", "True");

                // Create DeviceInfo XML
                var devinfo = new SSRSCommon.DeviceInfo();
                devinfo.OutputFormat = "EMF"; // force it to emf
                devinfo.Toolbar      = false;
                devinfo.PrintDpiX    = emf_render_dpi.Width;
                devinfo.PrintDpiY    = emf_render_dpi.Height;
                // Finished with DeviceInfo XML

                string device_info = devinfo.ToString();
                Console.WriteLine("DeviceInfo: {0}", device_info);

                // render first stream
                Console.WriteLine("Starting Rendering First Stream");

                string rendered_mimetype;
                string rendered_extension;

                var rendered_stream = server_report.Render(
                    render_format,
                    device_info,
                    url_params,
                    out rendered_mimetype,
                    out rendered_extension);

                Console.WriteLine("Finished Rendering First Stream");

                streams.Add(rendered_stream);

                cur_page_count++;
                // Handle the addtional streams

                Console.WriteLine("Retrieving Additional Streams");
                url_params.Remove("rs:PersistStreams");
                url_params.Add("rs:GetNextStream", "True");
                do
                {
                    // Check to see if user only wanted the first N pages of the report

                    if (FirstNPages > 0)
                    {
                        if (cur_page_count >= FirstNPages)
                        {
                            break;
                        }
                    }

                    // ------------
                    Console.WriteLine("Starting Rendering Additional Stream");
                    rendered_stream = server_report.Render(
                        render_format,
                        device_info,
                        url_params,
                        out rendered_mimetype,
                        out rendered_extension);

                    if (rendered_stream.Length != 0)
                    {
                        Console.WriteLine("Storing stream");
                        streams.Add(rendered_stream);
                    }
                    else
                    {
                        Console.WriteLine("Received stream of length zero");
                    }

                    Console.WriteLine("Finished Rendering Additional Stream");
                    cur_page_count++;
                } while (rendered_stream.Length > 0);
                Console.WriteLine("Finished Retrieving Additional Streams");
            }
            catch (System.Web.Services.Protocols.SoapException err)
            {
                Console.WriteLine("Caught SoapException");
                Console.WriteLine("Message: {0}", err.Message);
                throw err;
            }
            finally
            {
                // Convert each stream into a metafile

                foreach (var stream in streams)
                {
                    try
                    {
                        Console.WriteLine("Stream type: {0}", stream.GetType());
                        Console.WriteLine("Converting to metafile");

                        var memstream = (System.IO.MemoryStream)stream;
                        Console.WriteLine("memstream size: {0}", memstream.Length);
                        var metafile = new System.Drawing.Imaging.Metafile(memstream);
                        metafiles.Add(metafile);
                        Console.WriteLine("metafile size: {0}", metafile.Size);
                    }
                    finally
                    {
                        // Get rid of the steams
                        stream.Close();
                        stream.Dispose();
                    }
                }

                streams = null;
            }
            return(metafiles);
        }