public void GenerarReporte() { try { var lVisitantesTramite = new List <cVisitanteTramite>(); var centro = new cCentro().Obtener(GlobalVar.gCentro).FirstOrDefault(); var datosReporte = new List <cReporteDatos>(); datosReporte.Add(new cReporteDatos() { Encabezado1 = Parametro.ENCABEZADO1.Trim(), Encabezado2 = Parametro.ENCABEZADO2.Trim(), Encabezado3 = Parametro.ENCABEZADO3.Trim(), Titulo = "RELACIÓN DE INTERNOS", Logo1 = Parametro.REPORTE_LOGO1, Logo2 = Parametro.REPORTE_LOGO2, Centro = centro.DESCR.Trim().ToUpper(), }); var visitante_ingreso = new cVisitanteIngreso(); lVisitantesTramite = visitante_ingreso.ObtenerTodosFecha(). AsEnumerable(). Select(s => new cVisitanteTramite() { Anio = s.ID_ANIO, Id_Imputado = s.ID_IMPUTADO, Materno_Ingreso = !string.IsNullOrEmpty(s.INGRESO.IMPUTADO.MATERNO) ? s.INGRESO.IMPUTADO.MATERNO.TrimEnd() : string.Empty, Materno_Visitante = !string.IsNullOrEmpty(s.VISITANTE.PERSONA.MATERNO) ? s.VISITANTE.PERSONA.MATERNO.TrimEnd() : string.Empty, Nombre_Ingreso = !string.IsNullOrEmpty(s.INGRESO.IMPUTADO.NOMBRE) ? s.INGRESO.IMPUTADO.NOMBRE.TrimEnd() : string.Empty, NumeroVisita = s.ID_PERSONA, Parentesco = s.TIPO_REFERENCIA != null ? (!string.IsNullOrEmpty(s.TIPO_REFERENCIA.DESCR) ? s.TIPO_REFERENCIA.DESCR.TrimEnd() : "SIN DEFINIR") : "SIN DEFINIR" }) .ToList(); Application.Current.Dispatcher.Invoke((Action)(delegate { Reporte.LocalReport.ReportPath = "Reportes/rVisitantesTramite.rdlc"; Reporte.LocalReport.DataSources.Clear(); ReportDataSource ReportDataSource = new ReportDataSource(); ReportDataSource.Name = "DataSet2"; ReportDataSource.Value = lVisitantesTramite; ReportDataSource ReportDataSource_Encabezado = new ReportDataSource(); ReportDataSource_Encabezado.Name = "DataSet1"; ReportDataSource_Encabezado.Value = datosReporte; Reporte.LocalReport.DataSources.Add(ReportDataSource); Reporte.LocalReport.DataSources.Add(ReportDataSource_Encabezado); Reporte.LocalReport.SetParameters(new ReportParameter("Fecha", Fechas.GetFechaDateServer.ToString())); Reporte.Refresh(); Reporte.RefreshReport(); })); } catch (Exception ex) { throw new ApplicationException(ex.Message); } }
public async void GenerarReporte() { var lInternos = new List <cInternoVisitantes>(); var datosReporte = new List <cReporteDatos>(); var centro = new CENTRO(); await StaticSourcesViewModel.CargarDatosMetodoAsync(() => { Application.Current.Dispatcher.Invoke((Action)(delegate { ReportViewerVisible = Visibility.Collapsed; })); try { centro = new cCentro().Obtener(GlobalVar.gCentro).FirstOrDefault(); datosReporte.Add(new cReporteDatos() { Encabezado1 = Parametro.ENCABEZADO1.Trim(), Encabezado2 = Parametro.ENCABEZADO2.Trim(), Encabezado3 = Parametro.ENCABEZADO3.Trim(), Titulo = "VISITA FAMILIAR", Logo1 = Parametro.REPORTE_LOGO1, Logo2 = Parametro.REPORTE_LOGO2, Centro = centro.DESCR.Trim().ToUpper(), }); var ingresos = new cVisitanteIngreso(). ObtenerTodosIngresos(). Select(s => new { s.ID_CENTRO, s.ID_ANIO, s.ID_IMPUTADO, s.ID_INGRESO }). Distinct().OrderBy(o => o.ID_CENTRO).ThenBy(t => t.ID_ANIO).ThenBy(t => t.ID_IMPUTADO).ThenBy(t => t.ID_INGRESO).ToList(); var consulta_ingreso = new cIngreso(); foreach (var ingreso in ingresos) { var visitantes_registrados = new cVisitanteIngreso(). ObtenerVisitantesIngreso(ingreso.ID_CENTRO, ingreso.ID_ANIO, ingreso.ID_IMPUTADO, ingreso.ID_INGRESO). Select(s => new { s.ID_PERSONA }). Distinct().OrderBy(o => o.ID_PERSONA).ToList(); if (visitantes_registrados.Count() != 0) { var visitantes_aduana = new cAduana(). ObtenerTodosVisitantesIngreso(ingreso.ID_CENTRO, ingreso.ID_ANIO, ingreso.ID_IMPUTADO, ingreso.ID_INGRESO, SelectedFechaInicial, SelectedFechaFinal). Select(s => new { s.ID_PERSONA }). Distinct().OrderBy(o => o.ID_PERSONA).ToList(); foreach (var visitante in visitantes_aduana) { visitantes_registrados.Remove(visitante); } var ultimo_ingreso = consulta_ingreso.ObtenerUltimoIngreso(GlobalVar.gCentro, ingreso.ID_ANIO, ingreso.ID_IMPUTADO); if (visitantes_registrados.Count() != 0) { lInternos.Add( new cInternoVisitantes() { Anio = ingreso != null ? ingreso.ID_ANIO : new int(), Celda = ultimo_ingreso != null ? ultimo_ingreso.CAMA != null ? ultimo_ingreso.CAMA.ID_CELDA : string.Empty : string.Empty, Edificio = ultimo_ingreso != null ? ultimo_ingreso.CAMA != null ? ultimo_ingreso.CAMA.CELDA != null ? ultimo_ingreso.CAMA.CELDA.SECTOR != null ? ultimo_ingreso.CAMA.CELDA.SECTOR.EDIFICIO != null ? !string.IsNullOrEmpty(ultimo_ingreso.CAMA.CELDA.SECTOR.EDIFICIO.DESCR) ? ultimo_ingreso.CAMA.CELDA.SECTOR.EDIFICIO.DESCR.Trim() : string.Empty : string.Empty : string.Empty : string.Empty : string.Empty : string.Empty, Id_Imputado = ingreso != null ? ingreso.ID_IMPUTADO : new int(), Materno = ultimo_ingreso != null ? ultimo_ingreso.IMPUTADO != null ? !string.IsNullOrEmpty(ultimo_ingreso.IMPUTADO.MATERNO) ? ultimo_ingreso.IMPUTADO.MATERNO.Trim() : string.Empty : string.Empty : string.Empty, Nombre = ultimo_ingreso != null ? ultimo_ingreso.IMPUTADO != null ? !string.IsNullOrEmpty(ultimo_ingreso.IMPUTADO.NOMBRE) ? ultimo_ingreso.IMPUTADO.NOMBRE.Trim() : string.Empty : string.Empty : string.Empty, Paterno = ultimo_ingreso != null ? ultimo_ingreso.IMPUTADO != null ? !string.IsNullOrEmpty(ultimo_ingreso.IMPUTADO.PATERNO) ? ultimo_ingreso.IMPUTADO.PATERNO.Trim() : string.Empty : string.Empty : string.Empty, Sector = ultimo_ingreso != null ? ultimo_ingreso.CAMA != null ? ultimo_ingreso.CAMA.CELDA != null ? ultimo_ingreso.CAMA.CELDA.SECTOR != null ? !string.IsNullOrEmpty(ultimo_ingreso.CAMA.CELDA.SECTOR.DESCR) ? ultimo_ingreso.CAMA.CELDA.SECTOR.DESCR.Trim() : string.Empty : string.Empty : string.Empty : string.Empty : string.Empty, VisitantesRegistrados = visitantes_registrados != null ? visitantes_registrados.Any() ? visitantes_registrados.Count : new int() : new int(), }); } } } } catch (Exception ex) { throw new ApplicationException(ex.Message); } Application.Current.Dispatcher.Invoke((Action)(delegate { ReportViewerVisible = Visibility.Visible; })); }); Reporte.LocalReport.ReportPath = "Reportes/rVisitantesRegistradosXInterno.rdlc"; Reporte.LocalReport.DataSources.Clear(); ReportDataSource ReportDataSource_Encabezado = new ReportDataSource(); ReportDataSource_Encabezado.Name = "DataSet1"; ReportDataSource_Encabezado.Value = datosReporte; ReportDataSource ReportDataSource = new ReportDataSource(); ReportDataSource.Name = "DataSet2"; ReportDataSource.Value = lInternos; Reporte.LocalReport.DataSources.Add(ReportDataSource_Encabezado); Reporte.LocalReport.DataSources.Add(ReportDataSource); Reporte.LocalReport.SetParameters(new ReportParameter(("FechaInicial"), string.Format("{0}/{1}/{2}", SelectedFechaInicial.Day, SelectedFechaInicial.Month, SelectedFechaInicial.Year))); Reporte.LocalReport.SetParameters(new ReportParameter(("FechaFinal"), string.Format("{0}/{1}/{2}", SelectedFechaFinal.Day, SelectedFechaFinal.Month, SelectedFechaFinal.Year))); Reporte.Refresh(); Reporte.RefreshReport(); }
private void GenerarReporte() { try { Application.Current.Dispatcher.Invoke((Action)(delegate { Repositorio.Visibility = Visibility.Collapsed; })); var centro = new cCentro().Obtener(GlobalVar.gCentro).FirstOrDefault(); var datosReporte = new List <cReporteDatos>(); datosReporte.Add(new cReporteDatos() { Encabezado1 = Parametro.ENCABEZADO1.Trim(), Encabezado2 = Parametro.ENCABEZADO2.Trim(), Encabezado3 = Parametro.ENCABEZADO3.Trim(), Titulo = "Bitacora de Tiempos", Logo1 = Parametro.REPORTE_LOGO1, Logo2 = Parametro.REPORTE_LOGO2, Centro = centro.DESCR.Trim().ToUpper(), }); #region Reporte var lista = new List <cTiempoTramiteVisita>(); var promedio = new List <cTiempoTramiteVisitaPromedio>(); var hoy = Fechas.GetFechaDateServer; var datos = new cVisitanteIngreso().ObtenerTodos(FFechaInicio, FFechaFin).Select(w => new cTiempoTramiteVisita() { Fecha = w.FEC_ALTA.Value, UNombre = w.USUARIO.EMPLEADO.PERSONA.NOMBRE, UPaterno = w.USUARIO.EMPLEADO.PERSONA.PATERNO, UMaterno = w.USUARIO.EMPLEADO.PERSONA.MATERNO, VNombre = w.VISITANTE.PERSONA.NOMBRE, VPaterno = w.VISITANTE.PERSONA.PATERNO, VMaterno = w.VISITANTE.PERSONA.MATERNO, FechaInicio = w.INICIO_REGISTRO.HasValue ? w.INICIO_REGISTRO : hoy, FechaFin = w.FIN_REGISTRO.HasValue ? w.FIN_REGISTRO : hoy, }).ToList(); //datos.ForEach(w => w.Tiempo = w.FechaFin.Value.Subtract(w.FechaInicio.Value).Seconds); if (datos != null) { TimeSpan ts; foreach (var d in datos) { ts = d.FechaFin.Value.Subtract(d.FechaInicio.Value); d.aux = ts; if (ts.Days > 0) { d.Diferencia = ts.Days.ToString(); } if (ts.Hours > 0) { d.Diferencia = string.IsNullOrEmpty(d.Diferencia) ? ts.Hours.ToString() : string.Format("{0} {1}", d.Diferencia, ts.Hours); } d.Diferencia = string.IsNullOrEmpty(d.Diferencia) ? ts.Minutes.ToString() : string.Format("{0}:{1}", d.Diferencia, ts.Minutes); d.Diferencia = string.IsNullOrEmpty(d.Diferencia) ? ts.Seconds.ToString() : string.Format("{0}:{1}", d.Diferencia, ts.Seconds); } double x = datos.Average(w => w.aux.Ticks); long y = Convert.ToInt64(x); var z = new TimeSpan(y); var prom = string.Empty; if (z.Days > 0) { prom = z.Days.ToString(); } if (z.Hours > 0) { prom = string.IsNullOrEmpty(prom) ? z.Hours.ToString() : string.Format("{0} {1}", prom, z.Hours); } prom = string.IsNullOrEmpty(prom) ? z.Minutes.ToString() : string.Format("{0}:{1}", prom, z.Minutes); prom = string.IsNullOrEmpty(prom) ? z.Seconds.ToString() : string.Format("{0}:{1}", prom, z.Seconds); promedio.Add(new cTiempoTramiteVisitaPromedio() { Promedio = prom }); } datos = new List <cTiempoTramiteVisita>(datos); #endregion //ARMAMOS EL REPORTE Reporte.LocalReport.ReportPath = "../../Reportes/rTiempoTramiteVisita.rdlc"; Reporte.LocalReport.DataSources.Clear(); Microsoft.Reporting.WinForms.ReportDataSource rds1 = new Microsoft.Reporting.WinForms.ReportDataSource(); rds1.Name = "DataSet1"; rds1.Value = datos; Reporte.LocalReport.DataSources.Add(rds1); Microsoft.Reporting.WinForms.ReportDataSource rds2 = new Microsoft.Reporting.WinForms.ReportDataSource(); rds2.Name = "DataSet2"; rds2.Value = promedio; Reporte.LocalReport.DataSources.Add(rds2); Microsoft.Reporting.WinForms.ReportDataSource rds3 = new Microsoft.Reporting.WinForms.ReportDataSource(); rds3.Name = "DataSet3"; rds3.Value = datosReporte; Reporte.LocalReport.DataSources.Add(rds3); Application.Current.Dispatcher.Invoke((Action)(delegate { Repositorio.Visibility = Visibility.Visible; Reporte.Refresh(); Reporte.RefreshReport(); })); } catch (Exception ex) { StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al generar reporte", ex); } }