Imports System.IO

Public Class wfReporteEmpleos
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then

            Dim pString As String = Request.QueryString("p")
            Dim rString As String = Request.QueryString("r")
            If Not String.IsNullOrEmpty(rString) Then
                Select Case rString
                    Case "concurso"

                        If Not String.IsNullOrEmpty(pString) AndAlso IsNumeric(pString) Then
                            Try
                                ' Create a new report.                
                                Dim Report As New xrConcurso()
                                Report.Parameters("ParametroPlaza").Value = CInt(pString)

                                ' Create a new memory stream and export the report into it as PDF.
                                Dim Mem As New MemoryStream()
                                Report.ExportToPdf(Mem)
                                Mem.Seek(0, SeekOrigin.Begin)
                                Dim re As Byte() = Mem.ToArray()
                                Page.Response.ContentType = "application/pdf"
                                Page.Response.AddHeader("Content-Disposition", String.Format("inline;filename=Concurso-{0}.pdf", pString))
                                Page.Response.Clear()
                                Page.Response.OutputStream.Write(re, 0, re.Length)
                                Page.Response.End()
                                ' Close the memory stream.
                                Mem.Close()

                            Catch ex As Exception

                            End Try

                        End If

                    Case "postulanteCodigo"

                        If Not String.IsNullOrEmpty(pString) AndAlso IsNumeric(pString) Then
                            Try
                                Dim Report As New xrPreseleccionadosCodigo

                                Report.Parameters("idPlaza").Value = CInt(pString)

                                ' Create a new memory stream and export the report into it as PDF.
                                Dim Mem As New MemoryStream()
                                Report.ExportToPdf(Mem)
                                Mem.Seek(0, SeekOrigin.Begin)
                                Dim re As Byte() = Mem.ToArray()
                                Page.Response.ContentType = "application/pdf"
                                Page.Response.AddHeader("Content-Disposition", String.Format("inline;filename=Preseleccionados-{0}.pdf", pString))
                                Page.Response.Clear()
                                Page.Response.OutputStream.Write(re, 0, re.Length)
                                Page.Response.End()
                                ' Close the memory stream.
                                Mem.Close()

                            Catch ex As Exception

                            End Try


                        End If
                    Case "postulante"

                        If Not String.IsNullOrEmpty(pString) AndAlso IsNumeric(pString) Then
                            Try
                                Dim Report As New xrPreseleccionados

                                Report.Parameters("idPlaza").Value = CInt(pString)

                                ' Create a new memory stream and export the report into it as PDF.
                                Dim Mem As New MemoryStream()
                                Report.ExportToPdf(Mem)
                                Mem.Seek(0, SeekOrigin.Begin)
                                Dim re As Byte() = Mem.ToArray()
                                Page.Response.ContentType = "application/pdf"
                                Page.Response.AddHeader("Content-Disposition", String.Format("inline;filename=Preseleccionados-{0}.pdf", pString))
                                Page.Response.Clear()
                                Page.Response.OutputStream.Write(re, 0, re.Length)
                                Page.Response.End()
                                ' Close the memory stream.
                                Mem.Close()

                            Catch ex As Exception

                            End Try


                        End If
                    Case "ingresadosCodigo"

                        If Not String.IsNullOrEmpty(pString) AndAlso IsNumeric(pString) Then
                            Try
                                Dim Report As New xrIngresadosCodigo
                                Report.Parameters("idPlaza").Value = CInt(pString)
                                ' Create a new memory stream and export the report into it as PDF.
                                Dim Mem As New MemoryStream()
                                Report.ExportToPdf(Mem)
                                Mem.Seek(0, SeekOrigin.Begin)
                                Dim re As Byte() = Mem.ToArray()
                                Page.Response.ContentType = "application/pdf"
                                Page.Response.AddHeader("Content-Disposition", String.Format("inline;filename=Ingresados-{0}.pdf", pString))
                                Page.Response.Clear()
                                Page.Response.OutputStream.Write(re, 0, re.Length)
                                Page.Response.End()
                                ' Close the memory stream.
                                Mem.Close()

                            Catch ex As Exception

                            End Try
                        End If
                    Case "ingresados"

                        If Not String.IsNullOrEmpty(pString) AndAlso IsNumeric(pString) Then
                            Try
                                Dim Report As New xrIngresados
                                Report.Parameters("idPlaza").Value = CInt(pString)
                                ' Create a new memory stream and export the report into it as PDF.
                                Dim Mem As New MemoryStream()
                                Report.ExportToPdf(Mem)
                                Mem.Seek(0, SeekOrigin.Begin)
                                Dim re As Byte() = Mem.ToArray()
                                Page.Response.ContentType = "application/pdf"
                                Page.Response.AddHeader("Content-Disposition", String.Format("inline;filename=Ingresados-{0}.pdf", pString))
                                Page.Response.Clear()
                                Page.Response.OutputStream.Write(re, 0, re.Length)
                                Page.Response.End()
                                ' Close the memory stream.
                                Mem.Close()

                            Catch ex As Exception

                            End Try
                        End If
                    Case "competencias"

                        If Not String.IsNullOrEmpty(pString) AndAlso IsNumeric(pString) Then
                            Try
                                Dim Report As New xrCalificaciones
                                Report.Parameters("idPlaza").Value = CInt(pString)
                                ' Create a new memory stream and export the report into it as PDF.
                                Dim Mem As New MemoryStream()
                                Report.ExportToPdf(Mem)
                                Mem.Seek(0, SeekOrigin.Begin)
                                Dim re As Byte() = Mem.ToArray()
                                Page.Response.ContentType = "application/pdf"
                                Page.Response.AddHeader("Content-Disposition", String.Format("inline;filename=Calificaciones-{0}.pdf", pString))
                                Page.Response.Clear()
                                Page.Response.OutputStream.Write(re, 0, re.Length)
                                Page.Response.End()
                                ' Close the memory stream.
                                Mem.Close()

                            Catch ex As Exception

                            End Try
                        End If
                End Select

            End If

        End If
    End Sub

End Class