コード例 #1
0
        /// <summary>
        /// Add WeatherData to WeatherDataList
        /// If Exist the record it will update it.
        /// </summary>
        /// <param name="pCurrentDateTime"></param>
        /// <param name="pTemperature"></param>
        /// <param name="pSolarRadiation"></param>
        /// <param name="pTemMax"></param>
        /// <param name="pTemMin"></param>
        /// <param name="pEvapotranspiration"></param>
        public void AddWeatherDataToList(DateTime pDateTime, Double pTemperature, Double pSolarRadiation, Double pTemMax,
                                         Double pTemMin, Double pEvapotranspiration, Double pWindSpeed,
                                         String pObservations, Utils.WeatherDataInputType pWeatherDataInputType)
        {
            try
            {
                WeatherData lWeatherData;

                lWeatherData = this.AddWeatherData(pDateTime, pTemperature, pTemMax, pTemMin,
                                                   pSolarRadiation, pEvapotranspiration, pWindSpeed,
                                                   pObservations, pWeatherDataInputType);

                if (lWeatherData == null)
                {
                    this.UpdateWeatherData(pDateTime, pTemperature, pTemMax, pTemMin,
                                           pSolarRadiation, pEvapotranspiration, pWindSpeed,
                                           pObservations, pWeatherDataInputType);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in WeatherStation.AddWeatherDataToList " + "\n" + ex.Message + "\n" + ex.StackTrace);
                throw ex;
            }
        }
コード例 #2
0
 /// <summary>
 /// Constructor with all parameters
 /// </summary>
 /// <param name="pWeatherDataId"></param>
 /// <param name="pWeatherStationId"></param>
 /// <param name="pDate"></param>
 /// <param name="pTemperature"></param>
 /// <param name="pTemperatureMax"></param>
 /// <param name="pTemperatureMin"></param>
 /// <param name="pTemperatureDewPoint"></param>
 /// <param name="pHumidity"></param>
 /// <param name="pHumidityMax"></param>
 /// <param name="pHumidityMin"></param>
 /// <param name="pBarometer"></param>
 /// <param name="pBarometerMax"></param>
 /// <param name="pBarometerMin"></param>
 /// <param name="pSolarRadiation"></param>
 /// <param name="pUVRadiation"></param>
 /// <param name="pRainDay"></param>
 /// <param name="pRainStorm"></param>
 /// <param name="pRainMonth"></param>
 /// <param name="pRainYear"></param>
 /// <param name="pEvapotranspiration"></param>
 /// <param name="pEvapotranspirationMonth"></param>
 /// <param name="pEvapotranspirationYear"></param>
 /// <param name="pObservations"></param>
 /// <param name="pWeatherDataType"></param>
 /// <param name="pWeatherDataInputType"></param>
 public WeatherData(long pWeatherDataId, long pWeatherStationId, DateTime pDate,
                    Double pTemperature, Double pTemperatureMax, Double pTemperatureMin, Double pTemperatureDewPoint,
                    Double pHumidity, Double pHumidityMax, Double pHumidityMin, Double pBarometer, Double pBarometerMax, Double pBarometerMin,
                    Double pSolarRadiation, Double pUVRadiation, Double pRainDay, Double pRainStorm, Double pRainMonth, Double pRainYear,
                    Double pEvapotranspiration, Double pEvapotranspirationMonth, Double pEvapotranspirationYear, Double pWindSpeed,
                    String pObservations, Utils.WeatherDataType pWeatherDataType, Utils.WeatherDataInputType pWeatherDataInputType)
 {
     this.WeatherDataId           = pWeatherDataId;
     this.WeatherStationId        = pWeatherStationId;
     this.Date                    = pDate;
     this.Temperature             = pTemperature;
     this.TemperatureMax          = pTemperatureMax;
     this.TemperatureMin          = pTemperatureMin;
     this.TemperatureDewPoint     = pTemperatureDewPoint;
     this.Humidity                = pHumidity;
     this.HumidityMax             = pHumidityMax;
     this.HumidityMin             = pHumidityMin;
     this.Barometer               = pBarometer;
     this.BarometerMax            = pBarometerMax;
     this.BarometerMin            = pBarometerMin;
     this.SolarRadiation          = pSolarRadiation;
     this.UVRadiation             = pUVRadiation;
     this.RainDay                 = pRainDay;
     this.RainStorm               = pRainStorm;
     this.RainMonth               = pRainMonth;
     this.RainYear                = pRainYear;
     this.Evapotranspiration      = pEvapotranspiration;
     this.EvapotranspirationMonth = pEvapotranspirationMonth;
     this.EvapotranspirationYear  = pEvapotranspirationYear;
     this.WindSpeed               = pWindSpeed;
     this.Observations            = pObservations;
     this.WeatherDataType         = pWeatherDataType;
     this.WeatherDataInputType    = pWeatherDataInputType;
 }
コード例 #3
0
 /// <summary>
 /// Constructor without parameters
 /// </summary>
 public WeatherData()
 {
     this.WeatherDataId           = 0;
     this.WeatherStationId        = 0;
     this.Date                    = DateTime.Now;
     this.Temperature             = 0;
     this.TemperatureMax          = 0;
     this.TemperatureMin          = 0;
     this.TemperatureDewPoint     = 0;
     this.Humidity                = 0;
     this.HumidityMax             = 0;
     this.HumidityMin             = 0;
     this.Barometer               = 0;
     this.BarometerMax            = 0;
     this.BarometerMin            = 0;
     this.SolarRadiation          = 0;
     this.UVRadiation             = 0;
     this.RainDay                 = 0;
     this.RainStorm               = 0;
     this.RainMonth               = 0;
     this.RainYear                = 0;
     this.Evapotranspiration      = 0;
     this.EvapotranspirationMonth = 0;
     this.EvapotranspirationYear  = 0;
     this.WindSpeed               = 0;
     this.Observations            = "";
     this.WeatherDataType         = Utils.WeatherDataType.AllData;
     this.WeatherDataInputType    = Utils.WeatherDataInputType.CodeInsert;
 }
コード例 #4
0
        /// <summary>
        /// Update an existing WeatherData,
        /// if not exists, return null.
        /// </summary>
        /// <param name="pCurrentDateTime"></param>
        /// <param name="pTemperature"></param>
        /// <param name="pSolarRadiation"></param>
        /// <param name="pTemMax"></param>
        /// <param name="pTemMin"></param>
        /// <param name="pEvapotranspiration"></param>
        /// <returns></returns>
        public WeatherData UpdateWeatherData(DateTime pDateTime,
                                             Double pTemperature, Double pTemperatureMax, Double pTemperatureMin,
                                             Double pSolarRadiation, Double pEvapotranspiration, Double pWindSpeed,
                                             String pObservations, Utils.WeatherDataInputType pWeatherDataInputType)
        {
            WeatherData lReturn;
            WeatherData lWeatherData = null;

            Utils.WeatherDataType lWeatherDataType;

            try
            {
                lWeatherDataType = this.WeatherDataType;
                lWeatherData     = new WeatherData(this.GetNewWeatherDataListId(), this.WeatherStationId,
                                                   pDateTime, pTemperature, pTemperatureMax, pTemperatureMin,
                                                   pSolarRadiation, pEvapotranspiration, pWindSpeed,
                                                   pObservations, lWeatherDataType, pWeatherDataInputType);

                lReturn = ExistWeatherData(lWeatherData);
                //if input type is from Predictin or Web Insert, can be modified.
                if (lReturn != null && (pWeatherDataInputType == lReturn.WeatherDataInputType ||
                                        lReturn.WeatherDataInputType == Utils.WeatherDataInputType.Prediction ||
                                        lReturn.WeatherDataInputType == Utils.WeatherDataInputType.WebInsert))
                {
                    lReturn.WeatherStationId     = this.WeatherStationId;
                    lReturn.Date                 = pDateTime;
                    lReturn.Temperature          = pTemperature;
                    lReturn.SolarRadiation       = pSolarRadiation;
                    lReturn.TemperatureMax       = pTemperatureMax;
                    lReturn.TemperatureMin       = pTemperatureMin;
                    lReturn.Evapotranspiration   = pEvapotranspiration;
                    lReturn.WindSpeed            = pWindSpeed;
                    lReturn.Observations         = pObservations;
                    lReturn.WeatherDataInputType = pWeatherDataInputType;
                    lWeatherDataType             = SetWeatherDataTypeByWeatherInformation(lReturn);
                }
                if (lReturn != null && (lReturn.WeatherDataInputType == Utils.WeatherDataInputType.GetWeatherInfoService ||
                                        lReturn.WeatherDataInputType == Utils.WeatherDataInputType.IniaWeatherService))
                {
                    //Do not update data, is real data from weather pages
                    lWeatherDataType = SetWeatherDataTypeByWeatherInformation(lReturn);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in WeatherStation.UpdateWeatherData " + "\n" + ex.Message + "\n" + ex.StackTrace);
                throw ex;
            }
            return(lReturn);
        }
コード例 #5
0
        /// <summary>
        /// Add a new WeatherData and return it,
        /// if exists returns null.
        /// </summary>
        /// <param name="pCurrentDateTime"></param>
        /// <param name="pTemperature"></param>
        /// <param name="pSolarRadiation"></param>
        /// <param name="pTemMax"></param>
        /// <param name="pTemMin"></param>
        /// <param name="pEvapotranspiration"></param>
        /// <returns></returns>
        public WeatherData AddWeatherData(DateTime pDateTime,
                                          Double pTemperature, Double pTemperatureMax, Double pTemperatureMin,
                                          Double pSolarRadiation, Double pEvapotranspiration, Double pWindSpeed,
                                          String pObservations, Utils.WeatherDataInputType pWeatherDataInputType)
        {
            WeatherData lReturn;
            WeatherData lWeatherData = null;

            Utils.WeatherDataType lWeatherDataType;

            long lWeatherDataId = 0;

            try
            {
                lWeatherDataId   = this.GetNewWeatherDataListId();
                lWeatherDataType = this.WeatherDataType;

                lWeatherData = new WeatherData(lWeatherDataId, this.WeatherStationId, pDateTime,
                                               pTemperature, pTemperatureMax, pTemperatureMin,
                                               pSolarRadiation, pEvapotranspiration, pWindSpeed,
                                               pObservations, lWeatherDataType, pWeatherDataInputType);

                lWeatherDataType = SetWeatherDataTypeByWeatherInformation(lWeatherData);

                if (this.ExistWeatherData(lWeatherData) == null)
                {
                    this.WeatherDataList.Add(lWeatherData);
                }
                else
                {
                    //If Exists return null
                    lWeatherData = null;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in WeatherStation.AddWeatherData " + "\n" + ex.Message + "\n" + ex.StackTrace);
                throw ex;
            }

            lReturn = lWeatherData;
            return(lReturn);
        }