Exemplo n.º 1
0
 public DataTable GetHealthMointorWeather()
 {
     Serie serie = new Serie("", "", false, null, "");
     List<Serie> lst = new List<Serie>();
     lst.Add(new Serie("PrecipAmount_mm", "", false, null, ""));
     lst.Add(new Serie("RelHumidity", "", false, null, ""));
     lst.Add(new Serie("WindSpeedMax_ms", "", false, null, ""));
     lst.Add(new Serie("WindSpeed_ms", "", false, null, ""));
     lst.Add(new Serie("TempAir_C", "", false, null, ""));
     enumDataSource source = enumDataSource.glbStnFcst;
     enumTemporalAggregation tmpAggregation = enumTemporalAggregation.Hourly;
     fReq = new FeatureRequest(47.55, 7.583, 316, 250, 100);
     startDate = DateTime.Now;
     endDate = DateTime.Now.AddDays(1);
     wReq = new WeatherDataRequest(source, false, fReq, startDate, endDate, tmpAggregation, lst);
     wRes = wData.GetWeatherData(wReq);
     return wRes.WeatherData;
 }
Exemplo n.º 2
0
        public DataTable GetSeriesData(DataTable series, string aggregation, string dataSource, int start, int end, int startHours, int endHours)
        {
            //objLocInfo = LocationInfo.getLocationInfoObj;
            //objDataPoint = objLocInfo.DataPointInfo;
            populateObject();
            Serie serie = new Serie("", "", false, null, "");
            List<Serie> lst = new List<Serie>();

            enumDataSource source;
            switch (dataSource.ToUpper())
            {
                case "GLBSTNFCST":
                    source = enumDataSource.glbStnFcst;
                    break;
                case "GLB25ECMWF":
                    source = enumDataSource.glb25ECMWF;
                    break;
                case "GLB25OBS":
                    source = enumDataSource.glb25Obs;
                    break;
                case "GLB25OBSEXT":
                    source = enumDataSource.glbStnObsExt;
                    break;
                case "GLB25OBSSYN":
                    source = enumDataSource.glbStnObsSyn;
                    break;
                default:
                    source = enumDataSource.glbStnFcst;
                    break;
            }

            enumTemporalAggregation tmpAggregation;
            switch (aggregation.ToLower())
            {
                case "hourly":
                    tmpAggregation = enumTemporalAggregation.Hourly;
                    break;
                case "daily":
                    tmpAggregation = enumTemporalAggregation.Daily;
                    break;
                case "decade":
                    tmpAggregation = enumTemporalAggregation.Decade;
                    break;
                case "8hourly":
                    tmpAggregation = enumTemporalAggregation.EightHourly;
                    break;
                case "12hourly":
                    tmpAggregation = enumTemporalAggregation.TwelveHourly;
                    break;
                case "weekly":
                    tmpAggregation = enumTemporalAggregation.Weekly;
                    break;
                case "monthly":
                    tmpAggregation = enumTemporalAggregation.Monthly;
                    break;
                default:
                    tmpAggregation = enumTemporalAggregation.Hourly;
                    break;
            }
            foreach (DataRow dr in series.Rows)
            {
                if (tmpAggregation == enumTemporalAggregation.Daily || tmpAggregation == enumTemporalAggregation.Hourly)
                    lst.Add(
                       new Serie(
                          dr["Name"].ToString()
                          , ""
                          , false
                          , null
                          , ""));
                else
                    lst.Add(
                     new Serie(
                        dr["Name"].ToString()
                        , ""
                        , false
                        , (enumAggregationFunction)Enum.Parse(typeof(enumAggregationFunction), dr["aggregationfunction"].ToString(), true)
                        , ""));

            }
            startDate = current.AddDays(start);
            endDate = current.AddDays(end);
            if (startDate > endDate)
            {
                DateTime tmp = startDate;
                startDate = endDate;
                endDate = tmp;
            }

            startDate = startDate.AddHours(startHours);
            endDate = endDate.AddHours(endHours);

            fReq = new FeatureRequest(objDataPoint.stationLatitude, objDataPoint.stationLongitude, objDataPoint.altitude, objDataPoint.NearbyPointSettings.MaxAllowedAltitude, objDataPoint.NearbyPointSettings.MaxAllowedDistance);

            wReq = new WeatherDataRequest(source, false, fReq, startDate, endDate, tmpAggregation, lst);
            wRes = wData.GetWeatherData(wReq);
            return wRes.WeatherData;
        }
Exemplo n.º 3
0
        DataTable getData(DataTable series, string aggregation, string dataSource, int start, int end)
        {
            Serie serie = new Serie("", "", false, null, "");
            List<Serie> lst = new List<Serie>();
            enumDataSource source;
            switch (dataSource.ToUpper())
            {
                case "GLBSTNFCST":
                    source = enumDataSource.glbStnFcst;
                    break;
                case "GLB25ECMWF":
                    source = enumDataSource.glb25ECMWF;
                    break;
                case "GLB25OBS":
                    source = enumDataSource.glb25Obs;
                    break;
                case "GLB25OBSEXT":
                    source = enumDataSource.glbStnObsExt;
                    break;
                case "GLB25OBSSYN":
                    source = enumDataSource.glbStnObsSyn;
                    break;
                default:
                    source = enumDataSource.glbStnFcst;
                    break;
            }

            enumTemporalAggregation tmpAggregation;
            switch (aggregation.ToLower())
            {
                case "hourly":
                    tmpAggregation = enumTemporalAggregation.Hourly;
                    step = 1;
                    break;
                case "daily":
                    tmpAggregation = enumTemporalAggregation.Daily;
                    step = 24;
                    break;
                case "8hourly":
                    tmpAggregation = enumTemporalAggregation.EightHourly;
                    step = 8;
                    break;
                case "12hourly":
                    tmpAggregation = enumTemporalAggregation.TwelveHourly;
                    step = 12;
                    break;
                default:
                    tmpAggregation = enumTemporalAggregation.Hourly;
                    break;
            }
            tmpAggregation = enumTemporalAggregation.Hourly;
            foreach (DataRow dr in series.Rows)
            {

                if (tmpAggregation == enumTemporalAggregation.Daily || tmpAggregation == enumTemporalAggregation.Hourly)
                    lst.Add(
                       new Serie(
                          dr["Name"].ToString()
                          , ""
                          , false
                          , null
                          , ""));
                else
                    lst.Add(
                     new Serie(
                        dr["Name"].ToString()
                        , ""
                        , false
                        , (enumAggregationFunction)Enum.Parse(typeof(enumAggregationFunction), dr["aggregationfunction"].ToString(), true)
                        , ""));
            }

            startDate = current.AddDays(start);
            //endDate = current.AddDays(end > 0 ? end - 1 : end + 1);
            endDate = current.AddDays(end);
            if (startDate > endDate)
            {
                DateTime tmp = startDate;
                startDate = endDate;
                endDate = tmp;
            }

            fReq = new FeatureRequest(objDatapoint.stationLatitude, objDatapoint.stationLongitude, objDatapoint.altitude, objDatapoint.NearbyPointSettings.MaxAllowedAltitude, objDatapoint.NearbyPointSettings.MaxAllowedDistance);
            wReq = new WeatherDataRequest(source, false, fReq, startDate, endDate, tmpAggregation, lst);
            wRes = wData.GetWeatherData(wReq);
            return wRes.WeatherData;
        }
Exemplo n.º 4
0
 void InitialiseOutput()
 {
     so.FeatureResponse = new Response();
     objFR = new FeatureRequest();
     stnDet = new StationDetails();
     so.Charts = new List<Chart>();
     so.Icons = new List<Icons>();
     so.tables = new List<tables>();
     so.Legends = new List<Legend>();
 }
Exemplo n.º 5
0
        //public ServiceOutput getAgricastServiceData(string strToken, string xmlFeatureRequest, string strServiceID, string strModuleIDs, DateTime dStartDate, DateTime dEndDate, string strCultureCode)
        public ServiceOutput getAgricastServiceData(string strToken, string xmlFeatureRequest, string strServiceID, string strModuleIDs, string dStartDate, string dEndDate, string strCultureCode, string strUnit)
        {
            //HttpContext.Current.Session["MySessionState"] = "Try";
            WebServicePresenter objWebSvcPre = new WebServicePresenter(this);
            xmlFeatureRequest = HttpUtility.UrlDecode(xmlFeatureRequest);
            xmlFeatureRequest = HttpUtility.HtmlDecode(xmlFeatureRequest);
            DTOIcon objParam = new DTOIcon();
            DataSet ds = new DataSet();
            InitialiseOutput();

            /*** Used for Testing Webservice*/
            #region TestData
            //strToken = "agricast";
            //xmlFeatureRequest = "<FeatureRequest><Latitude>47.5</Latitude><Longitude>7.5</Longitude><Altitude>500</Altitude><MaxAltitudeDiff>200</MaxAltitudeDiff><MaxDistanceDiff>450</MaxDistanceDiff></FeatureRequest>";
            //strServiceID = "glbsip02o";
            //strModuleIDs = "vew_daily";
            //dStartDate = System.DateTime.Today.AddDays(-15).ToShortDateString();
            //dEndDate = System.DateTime.Today.AddDays(-11).ToShortDateString();
            //strCultureCode = "en-GB";
            //strUnit = "metric";

            #endregion
            /****End of Test Data****/

            /* IM01770145:New Agricast - AgricastService.svc - remove default token - Modify by Infosys-20140402-start*/
            //if (HttpUtility.HtmlDecode(strToken).ToLower() != "agricast")
            //    return so;

            strToken = HttpUtility.HtmlDecode(strToken);
            // check if the token is valid
            var validToken = Roles.FindUsersInRole(strServiceID, strToken);
            if (validToken.Length == 0)
                return so;

            /* IM01770145:New Agricast - AgricastService.svc - remove default token - Modify by Infosys-20140402-end*/

            //Deserialization of the XML file
            try
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(xmlFeatureRequest);

                XmlSerializer xSerializer = new XmlSerializer(typeof(FeatureRequest));
                System.IO.StringReader rdr = new StringReader(xmlFeatureRequest);
                objFR = (FeatureRequest)xSerializer.Deserialize(rdr);

                int iResultCount = 10;
                string timezone = objWebSvcPre.getTimeZoneOffset(objFR.Latitude, objFR.Longitude, (int)objFR.MaxDistanceDiff, (int)objFR.Altitude, iResultCount).ToString();
                string sunrise = objWebSvcPre.getSunrise(DateTime.Now.Date, objFR.Latitude, objFR.Longitude).ToString();
                string sunset = objWebSvcPre.getSunset(DateTime.Now.Date, objFR.Latitude, objFR.Longitude).ToString();

                Response res = new Response();
                res.FeatureRequest = objFR;
                res.Sunrise = sunrise;
                res.Sunset = sunset;
                res.TimeZoneOffset = timezone;
                so.FeatureResponse = res;

                DataTable dt = objWebSvcPre.getNeabyStations(objFR.Latitude, objFR.Longitude, (int)objFR.MaxDistanceDiff, (int)objFR.Altitude, iResultCount, HttpUtility.HtmlDecode(strCultureCode));

                stnDet.Name = dt.Rows[0]["Name"].ToString();
                stnDet.Altitude = Int32.Parse(dt.Rows[0]["Altitude"].ToString());
                stnDet.BearingDegrees = double.Parse(dt.Rows[0]["BearingDegrees"].ToString());
                stnDet.Distance = double.Parse(dt.Rows[0]["DistanceKm"].ToString());
                stnDet.Latitude = double.Parse(dt.Rows[0]["Latitude"].ToString());
                stnDet.Longitude = double.Parse(dt.Rows[0]["Longitude"].ToString());
                res.StationDetails = stnDet;
                objWebSvcPre.setServiceHandlerWebServiceValues(HttpUtility.HtmlDecode(strServiceID), "");
                DataTable dtNodes = objWebSvcPre.getNodeList(HttpUtility.HtmlDecode(strModuleIDs));
                /*Unit Implementation in Web Services - Begin*/
                if (string.IsNullOrEmpty(strUnit) || !strUnit.ToLower().Contains("imperial"))
                    /*Unit Implementation in Web Services - End*/
                    strUnit = "metric";

                for (int i = 0; i < dtNodes.Rows.Count; i++)
                {
                    switch (dtNodes.Rows[i]["Node"].ToString())
                    {
                        case "chart":
                            chart = new Chart();
                            DataTable dtChartData = new DataTable();
                            /*Unit Implementation in Web Services - Begin*/
                            dtChartData = objWebSvcPre.getChartData(stnDet.Latitude, stnDet.Longitude, (int)stnDet.Altitude, (int)objFR.MaxAltitudeDiff, (int)objFR.MaxDistanceDiff, dtNodes.Rows[i]["ModuleName"].ToString(), strServiceID, strCultureCode, strUnit);
                            /*Unit Implementation in Web Services - End*/
                            chart.ChartUrl = dtChartData.Rows[0][1].ToString();
                            chart.ModuleID = dtChartData.Rows[0][0].ToString();
                            so.Charts.Add(chart);
                            break;

                        case "icon":
                            icon = new Icons();
                            objWebSvcPre.setIconWebServiceValues(stnDet.Latitude, stnDet.Longitude, (int)stnDet.Altitude, (int)objFR.MaxAltitudeDiff, (int)objFR.MaxDistanceDiff, Convert.ToDateTime(sunrise), Convert.ToDateTime(sunset), strServiceID, dtNodes.Rows[i]["ModuleName"].ToString(), strCultureCode);
                            icon.ModuleID = dtNodes.Rows[i][1].ToString();
                            icon.IconList = objWebSvcPre.getWeatherIcons(objParam, dtNodes.Rows[i]["NodeName"].ToString());
                            so.Icons.Add(icon);
                            break;

                        case "tblDaysRows":
                            tbls = new tables();
                            tbls.tableList = new List<table>();
                            tbls.ModuleID = dtNodes.Rows[i][1].ToString();
                            tbls.tableList = objWebSvcPre.getTableData(stnDet.Latitude, stnDet.Longitude, (int)stnDet.Altitude, (int)objFR.MaxDistanceDiff, (int)objFR.MaxAltitudeDiff, this, dtNodes.Rows[i]["Node"].ToString(), dtNodes.Rows[i]["NodeName"].ToString(), strCultureCode, strServiceID, dtNodes.Rows[i]["ModuleName"].ToString(), HttpUtility.HtmlDecode(strCultureCode), strUnit);
                            so.tables.Add(tbls);
                            break;

                        case "tblSeriesRows":
                            tbls = new tables();
                            tbls.tableList = new List<table>();
                            tbls.ModuleID = dtNodes.Rows[i][1].ToString();

                            tbls.tableList = objWebSvcPre.getTableData(stnDet.Latitude, stnDet.Longitude, (int)stnDet.Altitude, (int)objFR.MaxDistanceDiff, (int)objFR.MaxAltitudeDiff, this, dtNodes.Rows[i]["Node"].ToString(), dtNodes.Rows[i]["NodeName"].ToString(), strCultureCode, strServiceID, dtNodes.Rows[i]["ModuleName"].ToString(), HttpUtility.HtmlDecode(strCultureCode), strUnit);
                            so.tables.Add(tbls);
                            break;

                        //case "nearbyDataPoint":
                        //    ds.Tables.Add(objWebSvcPre.getNeabyStations(objFR.Latitude, objFR.Longitude, (int)objFR.MaxDistanceDiff, (int)objFR.Altitude, iResultCount, HttpUtility.HtmlDecode(strCultureCode)));
                        //    ds.AcceptChanges();
                        //    break;

                        case "legend":
                            legs = new Legend();
                            legs = objWebSvcPre.getLegendData(dtNodes.Rows[i]["NodeName"].ToString());
                            so.Legends.Add(legs);
                            break;

                    }
                }
            }
            catch (Exception ex)
            {

                AgriCastException currEx = new AgriCastException(objWebSvcPre.GetServiceDetails(), ex);
                AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error);
                // HttpContext.Current.Session["ErrorMessage"] = objComUtil.getTransText(Constants.WS_GETSVCDATA_FAILURE) + " : " + ex.Message.ToString();
            }
            finally
            {
                IDictionary dictAudit = new Hashtable();
                dictAudit["userIP"] = "";// HttpContext.Current.Request.UserHostAddress;
                dictAudit["userID"] = "";
                dictAudit["token"] = strToken;
                dictAudit["referrer"] = "none";
                /* IM01770145:New Agricast - AgricastService.svc - remove default token - Modify by Infosys-20140402-start*/
                //dictAudit["entrancePath"] = "WebService";
                dictAudit["entrancePath"] = "AgricastService - getAgricastServiceData";
                /* IM01770145:New Agricast - AgricastService.svc - remove default token - Modify by Infosys-20140402-end*/
                dictAudit["culture"] = HttpUtility.HtmlDecode(strCultureCode);
                dictAudit["sessionID"] = "";// HttpContext.Current.Session.SessionID;
                dictAudit["service"] = strServiceID;
                dictAudit["module"] = strModuleIDs;
                dictAudit["locSearchType"] = "";
                dictAudit["locSearchStringType"] = "";
                dictAudit["locSearchString"] = xmlFeatureRequest;
                dictAudit["locSearchDatasource"] = "";
                dictAudit["numOfLocs"] = 0;
                if (objFR.Latitude == 0)
                    dictAudit["searchLat"] = DBNull.Value;
                else
                    dictAudit["searchLat"] = objFR.Latitude;
                if (objFR.Longitude == 0)
                    dictAudit["searchLong"] = DBNull.Value;
                else
                    dictAudit["searchLong"] = objFR.Longitude;
                dictAudit["countryName"] = "";
                dictAudit["locName"] = "";
                dictAudit["weatherDatasource"] = "";
                dictAudit["weatherLat"] = DBNull.Value;
                dictAudit["weatherLong"] = DBNull.Value;
                dictAudit["weatherDateFrom"] = "";
                dictAudit["weatherDateTo"] = "";
                dictAudit["weatherSeries"] = "";
                dictAudit["weatherParams"] = DBNull.Value;
                objWebSvcPre.SaveServiceAuditData(dictAudit);
            }

            return so;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Public constructor
 /// </summary>
 /// <param name="DataSource">Data source</param>
 /// <param name="GapFillSource">Gap fill source</param>
 /// <param name="FeatureRequest">FeatureRequest</param>
 /// <param name="StartDate">Start date</param>
 /// <param name="EndDate">End date</param>
 /// <param name="temporalAggregation">Temporal Aggregation</param>
 /// <param name="Series">Series</param>
 public WeatherDataRequest(enumDataSource dataSource, bool gapFillSource, FeatureRequest featureRequest,
     DateTime startDate, DateTime endDate, enumTemporalAggregation temporalAggregation, List<Serie> series)
 {
     this.DataSource = dataSource;
     this.GapFillSource = gapFillSource;
     this.FeatureRequest = featureRequest;
     this.StartDate = startDate;
     this.EndDate = endDate;
     this.Series = series;
     this.temporalAggregation = temporalAggregation;
 }
Exemplo n.º 7
0
        /// <summary>
        /// this is to get the results from AIS DB
        /// </summary>
        public Tuple<DataTable, FeatureResponse> getData(DataTable series, string aggregation, string dataSource, int start, int end, bool isAgriInfo)
        {
            Serie serie = new Serie("", "", false, enumAggregationFunction.avg, "");
            List<Serie> lst = new List<Serie>();
            bool NotWaterModel = true;

            if (HttpContext.Current != null && HttpContext.Current.Session != null)
            {
                if (agriInfo != null && isAgriInfo)
                {
                    startDate = DateTime.Parse(agriInfo["startDate"].ToString());
                    endDate = DateTime.Parse(agriInfo["endDate"].ToString());
                    /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - Start*/
                    if (cName.ToLower() == "watermodel")
                    {
                        /* UAT Issue - Data from Mar 1st & from Mar 6th, the moisture value are not correct - Jerrey - Start */
                        //you have to show data till todays date -2 days
                        //if (endDate.Date.Subtract(DateTime.Now.Date).Days > 0)
                        //    endDate = DateTime.Now.Date.AddDays(-2);
                        //if (startDate.Date.Subtract(DateTime.Now.Date).Days > 0
                        //    && endDate.Date.Subtract(DateTime.Now.Date).Days > 0)
                        //{
                        //    HttpContext.Current.Session["ErrorMessage"] = cUtil.getTransText(Constants.INVALID_DATE_RANGE);
                        //    throw new Exception(cUtil.getTransText(Constants.INVALID_DATE_RANGE));
                        //}
                        startDate = new DateTime(startDate.Year, 1, 1);
                        NotWaterModel = false;
                        /* UAT Issue - Data from Mar 1st & from Mar 6th, the moisture value are not correct - Jerrey - End */
                    }
                    //if (cName.ToLower() != "gdd")
                    if (cName.ToLower() != "gdd" && cName.ToLower() != "watermodel")
                        /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - End*/
                        aggregation = agriInfo["aggregation"].ToString();
                    else
                    {
                        aggregation = "daily";
                        NotWaterModel = false;
                    }
                }
                else
                {
                    startDate = current.AddDays(start);
                    //endDate = current.AddDays(end>0?end-1:end+1);
                    endDate = current.AddDays(end);
                }
            }
            else
            {
                startDate = current.AddDays(start);
                //endDate = current.AddDays(end >0 ? end-1:end+1);
                endDate = current.AddDays(end);
            }
            DataRow[] dt = null;
            /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - Start*/
            //if (isAgriInfo && (!bool.Parse(agriInfo["IsGDD"]) && cName.ToLower() != "gdd"))
            if (isAgriInfo && (!bool.Parse(agriInfo["IsGDD"])
                                && cName.ToLower() != "gdd" && cName.ToLower() != "watermodel"))
                /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - End*/
                dt = series.Select("", "panel asc");
            else
                dt = series.Select("");
            enumDataSource source = (enumDataSource)Enum.Parse(typeof(enumDataSource), dataSource, true);
            enumTemporalAggregation tmpAggregation;
            switch (aggregation.ToLower())
            {
                case "daily":
                    tmpAggregation = enumTemporalAggregation.Daily;
                    valuestep = 24;
                    break;
                case "decade":
                    tmpAggregation = enumTemporalAggregation.Decade;
                    valuestep = 10;
                    break;
                case "8hourly":
                    tmpAggregation = enumTemporalAggregation.EightHourly;
                    valuestep = 8;
                    break;
                case "12hourly":
                    tmpAggregation = enumTemporalAggregation.TwelveHourly;
                    valuestep = 12;
                    break;
                case "weekly":
                    tmpAggregation = enumTemporalAggregation.Weekly;
                    valuestep = 7;
                    break;
                case "monthly":
                    tmpAggregation = enumTemporalAggregation.Monthly;
                    valuestep = 30;
                    break;
                case "hourly":
                    tmpAggregation = enumTemporalAggregation.Hourly;
                    valuestep = 1;
                    break;
                default:
                    tmpAggregation = enumTemporalAggregation.Daily;
                    valuestep = 24;
                    break;
            }

            foreach (DataRow dr in dt)
            {

                if (tmpAggregation == enumTemporalAggregation.Daily || tmpAggregation == enumTemporalAggregation.Hourly)
                    lst.Add(
                       new Serie(
                          dr["Name"].ToString()
                          , ""
                          , ((dr["Name"].ToString().ToLower().Contains("tempair") && NotWaterModel && isAgriInfo && agriInfo["altitude"].ToString() != string.Empty) ? true : false)
                          , null
                          , ""));
                else
                    lst.Add(
                     new Serie(
                        dr["Name"].ToString()
                        , ""
                        , ((dr["Name"].ToString().ToLower().Contains("tempair") && NotWaterModel && isAgriInfo && agriInfo["altitude"].ToString() != string.Empty) ? true : false)
                        , (enumAggregationFunction)Enum.Parse(typeof(enumAggregationFunction), dr["aggregationfunction"].ToString(), true)
                        , ""));
            }

            if (startDate > endDate)
            {
                DateTime tmp = startDate;
                startDate = endDate;
                endDate = tmp;
            }

            //Get the altitude from the agriinfo object
            if (isAgriInfo)
            {
                fReq = new FeatureRequest(dpi.stationLatitude, dpi.stationLongitude, agriInfo["altitude"].ToString() != string.Empty ? Int32.Parse(agriInfo["altitude"].ToString()) : 0, dpi.NearbyPointSettings.MaxAllowedAltitude, dpi.NearbyPointSettings.MaxAllowedDistance);
            }
            else
            {
                fReq = new FeatureRequest(dpi.stationLatitude, dpi.stationLongitude, dpi.altitude, dpi.NearbyPointSettings.MaxAllowedAltitude, dpi.NearbyPointSettings.MaxAllowedDistance);
            }

            if (isAgriInfo)
            {
                DateTime newStartDate = startDate;
                DateTime newEndDate = endDate;
                /*IM01166165 -New Agricast - Agriinfo GDD IssueAfter providing planting date and start date and selecting GDD an error is being thrown. -BEGIN*/
                int iDateDiff = (newEndDate - newStartDate).Days;
                /*IM01166165 -New Agricast - Agriinfo GDD IssueAfter providing planting date and start date and selecting GDD an error is being thrown. -BEGIN*/
                /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - Start*/
                //if (bool.Parse(agriInfo["IsGDD"].ToString()) && cName.ToLower() == "gdd")
                if (bool.Parse(agriInfo["IsGDD"].ToString())
                    && (cName.ToLower() == "gdd" || cName.ToLower() == "watermodel"))
                /*3.1 UC – BodenWasser Modell - display webpage as IFrame - Jerrey - End*/
                {
                    if (agriInfo.ContainsKey("plantingDate") && agriInfo["plantingDate"] != "")
                        newStartDate = DateTime.Parse(agriInfo["plantingDate"]);
                    /*IM01166165 -New Agricast - Agriinfo GDD IssueAfter providing planting date and start date and selecting GDD an error is being thrown. -BEGIN*/
                    //newEndDate = newStartDate.AddDays(iDateDiff + 1 );
                    /*IM01166165 -New Agricast - Agriinfo GDD IssueAfter providing planting date and start date and selecting GDD an error is being thrown. -BEGIN*/
                }
                else
                {
                    int maxyear = 0;
                    int minyear = 0;
                    var year = from row in series.AsEnumerable()
                               where row.Field<string>("year") != ""
                               group row by 1 into grp
                               select new
                               {
                                   min = grp.Min(r => r.Field<string>("year")),
                                   max = grp.Max(r => r.Field<string>("year"))
                               };

                    if (year.ToList().Count > 0 && year.ToList()[0].min.ToString() != "")
                    {
                        minyear = Int32.Parse(year.ToList()[0].min.ToString());
                    }

                    if (year.ToList().Count > 0 && year.ToList()[0].max.ToString() != "")
                    {
                        maxyear = Int32.Parse(year.ToList()[0].max.ToString());
                    }

                    if (minyear != 0 && minyear < startDate.Year)
                        newStartDate = startDate.AddYears(minyear - startDate.Year);
                    if (maxyear != 0)
                    {
                        maxyear = maxyear + (endDate.Year - startDate.Year);
                        if (maxyear > endDate.Year)
                        {
                            newEndDate = endDate.AddYears(maxyear - endDate.Year);
                        }
                    }
                }
                wReq = new WeatherDataRequest(source, false, fReq, newStartDate, (newEndDate == newStartDate ? newEndDate.AddDays(1) : newEndDate), tmpAggregation, lst);
                if (NotWaterModel)
                    wRes = wData.GetWeatherData(wReq, true, dpi.DataPoint);
                else
                wRes = wData.GetWeatherData(wReq);
            }
            else
            {
                wReq = new WeatherDataRequest(source, false, fReq, startDate, (endDate == startDate ? endDate.AddDays(1) : endDate), tmpAggregation, lst);
                wRes = wData.GetWeatherData(wReq);
            }

            /*IM01166165 -New Agricast - Agriinfo GDD IssueAfter providing planting date and start date and selecting GDD an error is being thrown. -BEGIN*/

            if (wRes.WeatherData != null)
            {
                selectedEndDate = endDate;
            }
            //if (wRes.WeatherData.Rows.Count > 0)
            //{
            //    selectedEndDate = endDate;
            //    //if(endDate > DateTime.Parse(wRes.WeatherData.Select("date=max(date)")[0]["date"].ToString()))
            //    //  endDate = DateTime.Parse(wRes.WeatherData.Select("date=max(date)")[0]["date"].ToString());
            //}

            /*IM01166165 -New Agricast - Agriinfo GDD IssueAfter providing planting date and start date and selecting GDD an error is being thrown. -BEGIN*/

            return new Tuple<DataTable,FeatureResponse>(wRes.WeatherData,wRes.FeatureResponse);
        }