Example #1
0
        private void GuardarProyeccion(CheckListCorralInfo checkListCorral, CheckListCorralDAL checkListCorralDAL)
        {
            var loteProyeccion          = checkListCorralDAL.GenerarProyeccion(checkListCorral);
            var loteProyeccionBL        = new LoteProyeccionPL();
            var listaReimplantesGuardar = new List <LoteReimplanteInfo>();

            if (loteProyeccion == null)
            {
                return;
            }
            loteProyeccion.UsuarioCreacionID = checkListCorral.UsuarioCreacionID;
            loteProyeccion.RequiereRevision  = checkListCorral.RequiereRevision;
            var loteProyeccionID = loteProyeccionBL.Guardar(loteProyeccion);

            var primerReimplante = new LoteReimplanteInfo
            {
                LoteProyeccionID  = loteProyeccionID,
                NumeroReimplante  = loteProyeccion.Proyeccion.PrimerReimplante,
                FechaProyectada   = loteProyeccion.Proyeccion.FechaProyectada1,
                PesoProyectado    = loteProyeccion.Proyeccion.PesoProyectado1,
                UsuarioCreacionID = checkListCorral.UsuarioCreacionID
            };

            if (primerReimplante.NumeroReimplante != 0 && primerReimplante.FechaProyectada != DateTime.MinValue && primerReimplante.PesoProyectado != 0)
            {
                listaReimplantesGuardar.Add(primerReimplante);
            }

            var segundoReimplante = new LoteReimplanteInfo
            {
                LoteProyeccionID  = loteProyeccionID,
                NumeroReimplante  = loteProyeccion.Proyeccion.SegundoReimplante,
                FechaProyectada   = loteProyeccion.Proyeccion.FechaProyectada2,
                PesoProyectado    = loteProyeccion.Proyeccion.PesoProyectado2,
                UsuarioCreacionID = checkListCorral.UsuarioCreacionID
            };

            if (segundoReimplante.NumeroReimplante != 0 && segundoReimplante.FechaProyectada != DateTime.MinValue && segundoReimplante.PesoProyectado != 0)
            {
                listaReimplantesGuardar.Add(segundoReimplante);
            }

            var loteReimplanteBL = new LoteReimplanteBL();

            if (listaReimplantesGuardar.Count > 0)
            {
                loteReimplanteBL.GuardarListaReimplantes(listaReimplantesGuardar);
            }

            checkListCorral.FechaSacrificio  = loteProyeccion.FechaSacrificio;
            checkListCorral.Fecha1Reimplante = loteProyeccion.Proyeccion.FechaProyectada1;
            checkListCorral.Fecha2Reimplante = loteProyeccion.Proyeccion.FechaProyectada2;
            checkListCorral.DiasEngorda      = loteProyeccion.DiasEngorda;
        }
Example #2
0
        /// <summary>
        /// Metodo para Guardar/Modificar una entidad CheckListCorral
        /// </summary>
        /// <param name="info"></param>
        /// <param name="xml"></param>
        internal int Guardar(CheckListCorralInfo info, XDocument xml)
        {
            try
            {
                using (var transaction = new TransactionScope())
                {
                    Logger.Info();
                    var checkListCorralDAL = new CheckListCorralDAL();
                    int result             = info.CheckListCorralID;
                    GuardarProyeccion(info, checkListCorralDAL);
                    ArmarXML(info, xml);


                    if (info.CheckListCorralID == 0)
                    {
                        result = checkListCorralDAL.Crear(info);
                    }
                    else
                    {
                        checkListCorralDAL.Actualizar(info);
                    }

                    var loteBL             = new LoteBL();
                    var filtroCierreCorral = new FiltroCierreCorral
                    {
                        FechaSacrificio       = info.FechaSacrificio,
                        FechaCierre           = info.Fecha,
                        LoteID                = info.LoteID,
                        UsuarioModificacionID = info.UsuarioCreacionID
                    };
                    loteBL.ActualizaFechaCerrado(filtroCierreCorral);
                    transaction.Complete();
                    return(result);
                }
            }
            catch (ExcepcionGenerica)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Example #3
0
 /// <summary>
 /// Obtiene un registro de CheckListCorral
 /// </summary>
 /// <param name="loteID">identificador del Lote</param>
 /// <param name="organizacionID">identificador de la Organizacion</param>
 /// <returns></returns>
 internal CheckListCorralInfo ObtenerPorLote(int organizacionID, int loteID)
 {
     try
     {
         Logger.Info();
         var checkListCorralDAL     = new CheckListCorralDAL();
         CheckListCorralInfo result = checkListCorralDAL.ObtenerPorLote(organizacionID, loteID);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Example #4
0
 /// <summary>
 /// Obtiene una entidad CheckListCorral por su descripcion
 /// </summary>
 /// <param name="descripcion">Obtiene una entidad CheckListCorral por su Id</param>
 /// <returns></returns>
 internal CheckListCorralInfo ObtenerPorDescripcion(string descripcion)
 {
     try
     {
         Logger.Info();
         var checkListCorralDAL     = new CheckListCorralDAL();
         CheckListCorralInfo result = checkListCorralDAL.ObtenerPorDescripcion(descripcion);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Example #5
0
 /// <summary>
 /// Obtiene una lista filtrando por el estatus Activo = 1, Inactivo = 0
 /// </summary>
 /// <returns></returns>
 internal IList <CheckListCorralInfo> ObtenerTodos(EstatusEnum estatus)
 {
     try
     {
         Logger.Info();
         var checkListCorralDAL             = new CheckListCorralDAL();
         IList <CheckListCorralInfo> result = checkListCorralDAL.ObtenerTodos(estatus);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Example #6
0
 /// <summary>
 /// Obtiene un lista paginada
 /// </summary>
 /// <param name="pagina"></param>
 /// <param name="filtro"></param>
 /// <returns></returns>
 internal ResultadoInfo <CheckListCorralInfo> ObtenerPorPagina(PaginacionInfo pagina, CheckListCorralInfo filtro)
 {
     try
     {
         Logger.Info();
         var checkListCorralDAL = new CheckListCorralDAL();
         ResultadoInfo <CheckListCorralInfo> result = checkListCorralDAL.ObtenerPorPagina(pagina, filtro);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }