Beispiel #1
0
        /// <summary>
        /// Update PhenologicalStage
        /// </summary>
        /// <param name="pPhenologicalStage"></param>
        /// <returns></returns>
        public PhenologicalStage UpdatePhenologicalStage(PhenologicalStage pPhenologicalStage)
        {
            PhenologicalStage lReturn = null;
            Stage             lStage  = null;

            lReturn = ExistPhenologicalStage(pPhenologicalStage);
            if (lReturn != null)
            {
                lStage = this.FindStage(pPhenologicalStage.Stage.Name);
                if (lStage != null)
                {
                    lStage.Name        = pPhenologicalStage.Stage.Name;
                    lStage.ShortName   = pPhenologicalStage.Stage.ShortName;
                    lStage.Description = pPhenologicalStage.Stage.Description;
                    lStage.Order       = pPhenologicalStage.Stage.Order;
                }
                else
                {
                    //TODO throw exception "There is a Phenological Stage without Stage in StageList!! Error of data."
                }
                lReturn.UpdateStage(pPhenologicalStage.Stage.Name, pPhenologicalStage.Stage.ShortName,
                                    pPhenologicalStage.Stage.Description, pPhenologicalStage.Stage.Order);
                lReturn.MinDegree          = pPhenologicalStage.MinDegree;
                lReturn.MaxDegree          = pPhenologicalStage.MaxDegree;
                lReturn.Coefficient        = pPhenologicalStage.Coefficient;
                lReturn.RootDepth          = pPhenologicalStage.RootDepth;
                lReturn.HydricBalanceDepth = pPhenologicalStage.HydricBalanceDepth;
            }
            return(lReturn);
        }
Beispiel #2
0
        /// <summary>
        /// Update all the information about an existing PhenologicalStage,
        /// if not exist, return null
        /// </summary>
        /// <param name="pSpecie"></param>
        /// <param name="pStage"></param>
        /// <param name="pMinDegree"></param>
        /// <param name="pMaxDegree"></param>
        /// <param name="pCoefficient"></param>
        /// <param name="pRootDepth"></param>
        /// <param name="pHydricBalanceDepth"></param>
        /// <returns></returns>
        public PhenologicalStage UpdatePhenologicalStage(Specie pSpecie, Stage pStage,
                                                         Double pMinDegree, Double pMaxDegree, Double pCoefficient,
                                                         Double pRootDepth, Double pHydricBalanceDepth)
        {
            //Refactroing 2017/09/14 Changes in Phenological Table Modificable
            ///TODO ver si es mejor ingresar datos externos o calcular "lDegreesDaysInterval"
            bool   lPhenologicalStageIsUsed = true;
            Double lDegreesDaysInterval     = pMaxDegree - pMinDegree;

            PhenologicalStage lReturn = null;
            Stage             lStage  = null;

            try
            {
                PhenologicalStage lPhenologicalStage = new PhenologicalStage(0, pSpecie, pStage,
                                                                             pMinDegree, pMaxDegree, pCoefficient,
                                                                             pRootDepth, pHydricBalanceDepth,
                                                                             lPhenologicalStageIsUsed, lDegreesDaysInterval);
                lReturn = ExistPhenologicalStage(lPhenologicalStage);
                if (lReturn != null)
                {
                    lStage = this.FindStage(pStage.Name);
                    if (lStage != null)
                    {
                        lStage.Name        = pStage.Name;
                        lStage.ShortName   = pStage.ShortName;
                        lStage.Description = pStage.Description;
                    }
                    else
                    {
                        //TODO throw exception "There is a Phenological Stage without Stage in StageList!! Error of data."
                        logger.Error("Phenological Stage", "UpdatePhenologicalStage" + "\n"
                                     + "There is a Phenological Stage without Stage in StageList!! Error of data.");
                    }
                    lReturn.SpecieId = pSpecie.SpecieId;
                    lReturn.UpdateStage(pStage.Name, pStage.ShortName, pStage.Description, pStage.Order);
                    lReturn.MinDegree          = pMinDegree;
                    lReturn.MaxDegree          = pMaxDegree;
                    lReturn.Coefficient        = pCoefficient;
                    lReturn.RootDepth          = pRootDepth;
                    lReturn.HydricBalanceDepth = pHydricBalanceDepth;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in CropIrrigationWeather.UpdatePhenologicalStage " + "\n" + ex.Message + "\n" + ex.StackTrace);
                throw ex;
            }
            return(lReturn);
        }