public ActionResult GenerarReporteContenedorNoDevuelto(string requestExportar) { try { var filtros = new RequestReporteContenedorNoDevueltoViewModel(); var filtro = GR.Frameworks.Helper.ConvertirJsonAObjeto <ReporteContenedorNoDevueltoRequestViewModel>(requestExportar); filtros.filtro = filtro; var listaContNoDev = new AcuerdoComercialAgente().ConsultarReporteContenedorNoDevuelto(filtros); LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath("~/Content/Reportes/Contenedores.rdlc"); ContenedoresNoDevueltos1.ContenedoresDataTable contenedoresDataTable = new ContenedoresNoDevueltos1.ContenedoresDataTable(); ContenedoresNoDevueltos1.CabeceraDataTable cabeceraDataTable = new ContenedoresNoDevueltos1.CabeceraDataTable(); if (listaContNoDev.LiquidacionesNoDevueltas.Count > 0) { listaContNoDev.LiquidacionesNoDevueltas.ForEach(x => { contenedoresDataTable.AddContenedoresRow( x.NombreSucursal, "NumeroTransaccion", x.FechaTransaccion, x.CodigoNave, x.NombreNave, x.NumeroViaje, x.PuertoOrigen, x.PuertoEmbarque, x.PuertoDescarga, x.PuertoFinal, x.CodigoLinea, x.NumeroBL, x.Consignatario, x.Notificante, x.CodigoContenedor, x.UDL, x.DiasSob.ToString(), x.FechaArribo, x.ServicioBL, x.TipoContenedor ); }); } cabeceraDataTable.AddCabeceraRow( "", "", filtros.filtro.NombreLinea, "", string.Format("{0:dd/MM/yyyy}", filtros.filtro.Desde) + " - " + string.Format("{0:dd/MM/yyyy}", filtros.filtro.Hasta), filtros.filtro.CodigoCotenedor, "Reporte Contenedores No Liquidados", ""); ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "ContenedoresDataSet"; reportDataSource.Value = contenedoresDataTable; localReport.DataSources.Add(reportDataSource); reportDataSource = new ReportDataSource(); reportDataSource.Name = "CabeceraDataSet"; reportDataSource.Value = cabeceraDataTable; localReport.DataSources.Add(reportDataSource); string reportType = "PDF"; string mimeType; string encoding; string fileNameExtension; string deviceInfo = "<DeviceInfo>" + " <OutputFormat>PDF</OutputFormat>" + " <PageWidth></PageWidth>" + " <PageHeight></PageHeight>" + " <MarginTop></MarginTop>" + " <MarginLeft></MarginLeft>" + " <MarginRight></MarginRight>" + " <MarginBottom></MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return(File(renderedBytes, mimeType)); } catch (Exception ex) { (new ManejadorLog()).RegistrarEvento(MethodBase.GetCurrentMethod().Name, ex.Message, ex.StackTrace); return(Json(MethodBase.GetCurrentMethod().Name + ";" + ex.Message + ";" + ex.StackTrace, JsonRequestBehavior.AllowGet)); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { /* * ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reportes/Contenedores.rdlc"); * ReportViewer1.LocalReport.DataSources.Clear(); * * List<ContenedoresNoDevueltos1> lstContenedore = new List<ContenedoresNoDevueltos1>(); * * // ReportDataSource rdc = new ReportDataSource("ContenedoresNoDevueltos", lstContenedore); * ReportDataSource reportDataSource = new ReportDataSource(); * reportDataSource.Name = "ContenedoresDataSet"; * ReportViewer1.LocalReport.DataSources.Add(reportDataSource); * * reportDataSource = new ReportDataSource(); * reportDataSource.Name = "CabeceraDataSet"; * ReportViewer1.LocalReport.DataSources.Add(reportDataSource); * * * ReportViewer1.LocalReport.Refresh(); */ /* * LocalReport localReport = new LocalReport(); * * localReport.ReportPath = string.Format(@"{0}\Reportes/Contenedores.rdlc", AppDomain.CurrentDomain.BaseDirectory); * * ContenedoresNoDevueltos1.ContenedoresDataTable contenedoresDataTable = new ContenedoresNoDevueltos1.ContenedoresDataTable(); * * * ContenedoresNoDevueltos1.CabeceraDataTable cabeceraDataTable = new ContenedoresNoDevueltos1.CabeceraDataTable(); * * cabeceraDataTable.AddCabeceraRow("Ransa", "TipoCliente", "linea", "bl", "contenedor", "rangoFecha", "titulo", "nave"); * * ReportDataSource reportDataSource = new ReportDataSource(); * reportDataSource.Name = "ContenedoresDataSet"; * reportDataSource.Value = contenedoresDataTable; * localReport.DataSources.Add(reportDataSource); * * reportDataSource = new ReportDataSource(); * reportDataSource.Name = "CabeceraDataSet"; * reportDataSource.Value = cabeceraDataTable; * localReport.DataSources.Add(reportDataSource); * * ReportViewer1.LocalReport.Refresh(); */ ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reportes/Contenedores.rdlc"); ReportViewer1.LocalReport.DataSources.Clear(); ContenedoresNoDevueltos1.ContenedoresDataTable contenedoresDataTable = new ContenedoresNoDevueltos1.ContenedoresDataTable(); ContenedoresNoDevueltos1.CabeceraDataTable cabeceraDataTable = new ContenedoresNoDevueltos1.CabeceraDataTable(); cabeceraDataTable.AddCabeceraRow("Ransa", "TipoCliente", "linea", "bl", "contenedor", "rangoFecha", "titulo", "nave"); // ReportDataSource rdc = new ReportDataSource("ContenedoresNoDevueltos", lstContenedore); ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "ContenedoresDataSet"; reportDataSource.Value = contenedoresDataTable; ReportViewer1.LocalReport.DataSources.Add(reportDataSource); reportDataSource = new ReportDataSource(); reportDataSource.Name = "CabeceraDataSet"; reportDataSource.Value = cabeceraDataTable; ReportViewer1.LocalReport.DataSources.Add(reportDataSource); ReportViewer1.LocalReport.Refresh(); } catch (Exception ex) { } } }