예제 #1
0
        /// <summary>
        /// Obtiene los datos para el Reporte Cronicos en Recuperacion
        /// </summary>
        /// <returns> </returns>
        public List <ReporteCronicosRecuperacionInfo> GenerarReporteCronicosRecuperacion(int organizacionID, DateTime fechaInicial, DateTime fechaFinal)
        {
            List <ReporteCronicosRecuperacionInfo> lista = null;

            try
            {
                Logger.Info();
                var reporteCronicosRecuperacionDAL            = new ReporteCronicosRecuperacionDAL();
                ReporteCronicosRecuperacionDatos datosReporte = reporteCronicosRecuperacionDAL.GenerarReporteCronicosRecuperacion(organizacionID, fechaInicial,
                                                                                                                                  fechaFinal);
                if (datosReporte != null)
                {
                    lista = GenerarReporte(datosReporte);
                }
            }
            catch (ExcepcionGenerica)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            return(lista);
        }
예제 #2
0
 /// <summary>
 /// Obtiene los datos para el Reporte Venta Muerte
 /// </summary>
 /// <returns> </returns>
 internal ReporteCronicosRecuperacionDatos GenerarReporteCronicosRecuperacion(int organizacionID, DateTime fechaInicial, DateTime fechaFinal)
 {
     try
     {
         Logger.Info();
         Dictionary <string, object> parameters = AuxReporteCronicosRecuperacionDAL.ObtenerParametrosReporte(organizacionID, fechaInicial, fechaFinal);
         DataSet ds = Retrieve("ReporteCronicosRecuperacion_Obtener", parameters);
         ReporteCronicosRecuperacionDatos result = null;
         if (ValidateDataSet(ds))
         {
             result = MapReporteCronicosRecuperacionDAL.ObtenerDatosReporte(ds);
         }
         return(result);
     }
     catch (SqlException ex)
     {
         Logger.Error(ex);
         throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
     }
     catch (DataException ex)
     {
         Logger.Error(ex);
         throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
예제 #3
0
        /// <summary>
        /// Obtiene los datos del reporte
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        internal static ReporteCronicosRecuperacionDatos ObtenerDatosReporte(DataSet ds)
        {
            ReporteCronicosRecuperacionDatos resultado;

            try
            {
                Logger.Info();
                DataTable dtMovimientosEnfermeria   = ds.Tables[ConstantesDAL.DtMovimientosEnfermeria];
                DataTable dtMovimientosProduccion   = ds.Tables[ConstantesDAL.DtMovimientosProduccion];
                DataTable dtMovimientosTratamientos = ds.Tables[ConstantesDAL.DtTratamientos];
                DataTable dtFolios = ds.Tables[ConstantesDAL.DtFolios];

                resultado = new ReporteCronicosRecuperacionDatos
                {
                    MovimientosEnfermeria = (from movs in dtMovimientosEnfermeria.AsEnumerable()
                                             select new ReporteCronicosRecuperacionEnfermeria
                    {
                        AnimalID = movs.Field <int>("AnimalID"),
                        AnimalMovimientoID = movs.Field <long>("AnimalMovimientoID"),
                        Arete = movs.Field <string>("Arete"),
                        Causa = movs.Field <string>("Causa"),
                        CorralEnfermeria = movs.Field <string>("CorralEnfermeria"),
                        Detector = movs.Field <string>("Detector"),
                        Enfermeria = movs.Field <string>("Enfermeria"),
                        Fecha = movs.Field <DateTime>("Fecha"),
                        FechaAlta = movs.Field <DateTime?>("FechaAlta"),
                        Sexo = Convert.ToChar(movs.Field <string>("Sexo"))
                    }).ToList(),
                    MovimientosProduccion = (from movs in dtMovimientosProduccion.AsEnumerable()
                                             select new ReporteCronicosRecuperacionProduccion
                    {
                        AnimalID = movs.Field <int>("AnimalID"),
                        AnimalMovimientoID = movs.Field <long>("AnimalMovimientoID"),
                        CorralProduccion = movs.Field <string>("CorralProduccion"),
                        Fecha = movs.Field <DateTime>("Fecha")
                    }).ToList(),
                    Folios = (from movs in dtFolios.AsEnumerable()
                              select new ReporteCronicosRecuperacionFolio
                    {
                        AnimalID = movs.Field <long>("AnimalID"),
                        DiasEngorda = movs.Field <int>("DiasEngorda"),
                        FolioEntrada = movs.Field <long>("FolioEntrada"),
                        Organizacion = movs.Field <string>("Organizacion"),
                        OrganizacionID = movs.Field <int>("OrganizacionID"),
                        FechaLlegada = movs.Field <DateTime>("FechaLlegada")
                    }).ToList(),
                    Tratamientos = (from movs in dtMovimientosTratamientos.AsEnumerable()
                                    select new ReporteCronicosRecuperacionTratamiento
                    {
                        AnimalID = movs.Field <long>("AnimalID"),
                        AnimalMovimientoID = movs.Field <long>("AnimalMovimientoID"),
                        CodigoTratamiento = movs.Field <int>("CodigoTratamiento"),
                        FechaMovimiento = movs.Field <DateTime>("FechaMovimiento"),
                        Producto = movs.Field <string>("Producto"),
                    }).ToList()
                };
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
            return(resultado);
        }
예제 #4
0
        /// <summary>
        /// Genera los datos del reporte
        /// </summary>
        /// <param name="datosReporte"></param>
        /// <returns></returns>
        private List <ReporteCronicosRecuperacionInfo> GenerarReporte(ReporteCronicosRecuperacionDatos datosReporte)
        {
            var resultado = new List <ReporteCronicosRecuperacionInfo>();

            datosReporte.MovimientosEnfermeria.ForEach(animalEnfermo =>
            {
                var reporteCronicosRecuperacion = new ReporteCronicosRecuperacionInfo
                {
                    Arete      = animalEnfermo.Arete,
                    Causa      = animalEnfermo.Causa,
                    Enfermeria =
                        animalEnfermo.
                        Enfermeria,
                    Sexo          = animalEnfermo.Sexo.ToString(CultureInfo.InvariantCulture),
                    FechaGenerado = animalEnfermo.Fecha,
                    DateAlta      = animalEnfermo.FechaAlta.ToString(),
                    LugarDestino  = animalEnfermo.CorralEnfermeria,
                    Detector      = animalEnfermo.Detector,
                    CorralOrigen  = datosReporte.MovimientosProduccion.Where(
                        condicion =>
                        condicion.AnimalID == animalEnfermo.AnimalID).
                                    Select(corral => corral.CorralProduccion).
                                    FirstOrDefault()
                };

                reporteCronicosRecuperacion.LugarGeneracion =
                    reporteCronicosRecuperacion.CorralOrigen;

                int mes    = animalEnfermo.Fecha.Month;
                int semana = GetWeekOfYear(animalEnfermo.Fecha);

                reporteCronicosRecuperacion.Mes    = mes;
                reporteCronicosRecuperacion.Semana = semana;

                List <ReporteCronicosRecuperacionTratamiento> tratamientos =
                    datosReporte.Tratamientos.Where(
                        condicion =>
                        condicion.AnimalID == animalEnfermo.AnimalID).
                    Select(
                        tratamiento => tratamiento)
                    .ToList();
                if (tratamientos.Any())
                {
                    AsignarTratamientos(tratamientos, reporteCronicosRecuperacion);
                }

                ReporteCronicosRecuperacionFolio folio =
                    datosReporte.Folios.FirstOrDefault(
                        condicion =>
                        condicion.AnimalID == animalEnfermo.AnimalID);
                if (folio != null)
                {
                    reporteCronicosRecuperacion.Partida     = folio.FolioEntrada;
                    reporteCronicosRecuperacion.DiasEngorda = folio.DiasEngorda;
                    reporteCronicosRecuperacion.DateLlegada = folio.FechaLlegada.ToShortDateString();
                }

                resultado.Add(reporteCronicosRecuperacion);
            });
            return(resultado);
        }