Ejemplo n.º 1
0
 public static object[] GetDataForDualAxesLineAndColumnChart(string stationName, DateTime fromDate, DateTime toDate, string displayMode, string tempParam)
 {
     SmartCityEntities db = new SmartCityEntities();
     switch (tempParam)
     {
         case "AvgTemp":
             return db.fc_DualAxesLineAndColumn(stationName, fromDate, toDate, displayMode).Select(x => x.AvgTemp).ToArray().Cast<object>().ToArray();
         case "AvgRainFall":
             return db.fc_DualAxesLineAndColumn(stationName, fromDate, toDate, displayMode).Select(x => x.AvgRainFall).ToArray().Cast<object>().ToArray();
         default:
             return null;
     }
 }
Ejemplo n.º 2
0
 public static object[] GetMonlyAvgSeriesForAGivenYear(string stationName, int year, string param)
 {
     SmartCityEntities db = new SmartCityEntities();
     switch (param)
     {
         case "AirPolutionLevel":
             return db.Adm_Weather.Where(x => x.Station == stationName && x.WeatherDate.Year == year).Select(x => x.AirPolutionLevel).Take(12).ToArray().Cast<object>().ToArray();
         case "MinTemp":
             return db.Adm_Weather.Where(x => x.Station == stationName && x.WeatherDate.Year == year).Select(x => x.MinTemp).Take(12).ToArray().Cast<object>().ToArray();
         case "MaxTemp":
             return db.Adm_Weather.Where(x => x.Station == stationName && x.WeatherDate.Year == year).Select(x => x.MaxTemp).Take(12).ToArray().Cast<object>().ToArray();
         case "RainFall":
             return db.Adm_Weather.Where(x => x.Station == stationName && x.WeatherDate.Year == year).Select(x => x.RainFall).Take(12).ToArray().Cast<object>().ToArray();
         default:
             return null;
     }
 }
Ejemplo n.º 3
0
 public static object[] GetDataForBaseLineChart(string stationName, DateTime fromDate, DateTime toDate, string displayMode, string compareParam)
 {
     SmartCityEntities db = new SmartCityEntities();
     switch (compareParam)
     {
         case "AirPolutionLevel":
             return db.fc_BaseLine(stationName, fromDate, toDate, displayMode).Select(x => x.AirPolutionLevel).ToArray().Cast<object>().ToArray();
         case "MinTemp":
             return db.fc_BaseLine(stationName, fromDate, toDate, displayMode).Select(x => x.MinTemp).ToArray().Cast<object>().ToArray();
         case "MaxTemp":
             return db.fc_BaseLine(stationName, fromDate, toDate, displayMode).Select(x => x.MaxTemp).ToArray().Cast<object>().ToArray();
         case "RainFall":
             return db.fc_BaseLine(stationName, fromDate, toDate, displayMode).Select(x => x.RainFall).ToArray().Cast<object>().ToArray();
         default:
             return null;
     }
 }
Ejemplo n.º 4
0
        public void getInputDataToPredictSeries(DateTime date, double[] input, List<double[]> predictHistory, double airPollutionLevel)
        {
            SmartCityEntities _dbo = new SmartCityEntities();

            var tempinput = (from a in _dbo.fc_PreditInput(date, "Kathmandu")
                             select new WeatherSamples
                             {
                                 date = a.MeaureDate,
                                 station = a.Station,
                                 airPollutionLevel = a.AirPolutionLevel,
                                 rainfall = a.RainFall,
                                 maxTemp = a.MaxTemp,
                                 minTemp = a.MinTemp
                             }).ToList();

            foreach (double[] predict in predictHistory)
            {

                tempinput.RemoveAt(0);
                tempinput.Add(new WeatherSamples
               {
                   date = tempinput[8].date.AddDays(+1),
                   station = tempinput[8].station,
                   airPollutionLevel = airPollutionLevel,
                   rainfall = predict[2],
                   maxTemp = predict[1],
                   minTemp = predict[0]
               });

            }

            for (int i = 0; i < this.inputSize; i++)
            {
                WeatherSamples sample = (WeatherSamples)tempinput[i];
                input[i] = sample.airPollutionLevel;
                input[i + this.inputSize] = sample.minTemp;
                input[i + this.inputSize * 2] = sample.maxTemp;
                input[i + this.inputSize * 3] = sample.rainfall;
            }
        }
Ejemplo n.º 5
0
        //retutn inputset for prediction.
        public void getInputDataToPredict(DateTime date, double[] input)
        {
            SmartCityEntities _dbo = new SmartCityEntities();

            var tempinput = (from a in _dbo.fc_PreditInput(date, "Kathmandu")
                             select new WeatherSamples
                                    {
                                        date = a.MeaureDate,
                                        station = a.Station,
                                        airPollutionLevel = a.AirPolutionLevel,
                                        rainfall = a.RainFall,
                                        maxTemp = a.MaxTemp,
                                        minTemp = a.MinTemp
                                    }).ToList();

            for (int i = 0; i < this.inputSize; i++)
            {
                WeatherSamples sample = (WeatherSamples)tempinput[i];
                input[i] = sample.airPollutionLevel;
                input[i + this.inputSize] = sample.minTemp;
                input[i + this.inputSize * 2] = sample.maxTemp;
                input[i + this.inputSize * 3] = sample.rainfall;
            }
        }
Ejemplo n.º 6
0
 //Datebase connection to get the past records.
 public void load(string station = "Kathmandu")
 {
     SmartCityEntities _dbo = new SmartCityEntities();
     this.samples = (from a in _dbo.Adm_Weather
                     where a.Station == station
                     select new WeatherSamples { date = (DateTime)a.WeatherDate, station = a.Station, airPollutionLevel = a.AirPolutionLevel, rainfall = a.RainFall, maxTemp = a.MaxTemp, minTemp = a.MinTemp }).ToList();
 }
Ejemplo n.º 7
0
 public static IEnumerable<WeatherResultModel> GetWeathers()
 {
     SmartCityEntities db = new SmartCityEntities();
     return (from c in db.Adm_Weather select new WeatherResultModel
     { WeatherDate=c.WeatherDate, StationName=c.Station,MinTemp=c.MinTemp,MaxTemp=c.MaxTemp,RainFall=c.RainFall}).Take(100);
 }
Ejemplo n.º 8
0
        public static Series[] GetSeriesArray(string stationName, DateTime fromDate, DateTime toDate)
        {
            SmartCityEntities db = new SmartCityEntities();
            var rawData = db.sp_GetDataForColLineAndPie(stationName, fromDate, toDate).Select(x => x).ToArray();
            string[] measureParam=new string[] {"AirPollution","MinTemp","MaxTemp","RainFall"};
            Series[] seriesArray = new Series[rawData.Count()];
            for (int i = 0; i < rawData.Count(); i++)
            {
                sp_GetDataForColLineAndPie_Result tempObj = ((sp_GetDataForColLineAndPie_Result)rawData.GetValue(i));
                seriesArray[i] = new Series
                {
                    Type = i<rawData.Count()-1?ChartTypes.Column:ChartTypes.Spline,
                    Name = tempObj.Station,
                    Data = new Data(new object[]
                        {
                            tempObj.AvgAirPollutionLevel, tempObj.AvgMinTemp, tempObj.AvgMaxTemp, tempObj.AvgRainFall
                         }
                     )
                };
            }

            Series[] series = new[]
                           {
                               new Series
                               {
                                   Type = ChartTypes.Column,
                                   Name = "Kathmandu",
                                   Data = new Data(new object[] { 3, 2, 1, 3 })
                               },
                               new Series
                               {
                                   Type = ChartTypes.Column,
                                   Name = "Pokhara",
                                   Data = new Data(new object[] { 2, 3, 5, 7 })
                               },
                               new Series
                               {
                                   Type = ChartTypes.Column,
                                   Name = "Butwal",
                                   Data = new Data(new object[] { 4, 3, 3, 9 })
                               },
                               new Series
                               {
                                   Type = ChartTypes.Column,
                                   Name = "Bhairahawa",
                                   Data = new Data(new object[] { 3, 2.67, 3, 6.33})
                               }//,
                               // new Series
                               //{
                               //    Type = ChartTypes.Spline,
                               //    Name = "Average",
                               //    Data = new Data(new object[] { 3, 2.67, 3, 6.33, 3.33 })
                               //}//,
                               //new Series
                               //{
                               //    Type = ChartTypes.Pie,
                               //    Name = "Total consumption",
                               //    Data = new Data(new[]
                               //                    {
                               //                        new DotNet.Highcharts.Options.Point
                               //                        {
                               //                            Name = "Jane",
                               //                            Y = 13,
                               //                            Color = Color.FromName("Highcharts.getOptions().colors[0]")
                               //                        },
                               //                        new DotNet.Highcharts.Options.Point
                               //                        {
                               //                            Name = "John",
                               //                            Y = 23,
                               //                            Color = Color.FromName("Highcharts.getOptions().colors[1]")
                               //                        },
                               //                        new DotNet.Highcharts.Options.Point
                               //                        {
                               //                            Name = "Joe",
                               //                            Y = 19,
                               //                            Color = Color.FromName("Highcharts.getOptions().colors[2]")
                               //                        }
                               //                    }
                               //        )
                               //}
                           };
            return seriesArray;
        }
Ejemplo n.º 9
0
 public static IEnumerable<TabularModel> GetTabularReport(string stationName, DateTime fromDate, DateTime toDate, string displayMode, string compareParam = "")
 {
     SmartCityEntities db = new SmartCityEntities();
     switch (compareParam)
     {
         case "AirPolutionLevel":
             var a = (from c in db.fc_rpt_Tabular(stationName, fromDate, toDate, displayMode)
                      select new TabularModel
                      {
                          WeatherDate = c.MeaureDate,
                          Station=c.Station,
                          AirPolutionLevel = c.AirPolutionLevel
                      }
                         ).ToList();
             return (from c in db.fc_rpt_Tabular(stationName, fromDate, toDate, displayMode)
                     select new TabularModel
                     {
                         WeatherDate = c.MeaureDate,
                         Station=c.Station,
                         AirPolutionLevel = c.AirPolutionLevel
                     }
                         ).ToList();
         case "MinTemp":
             return (from c in db.fc_rpt_Tabular(stationName, fromDate, toDate, displayMode)
                     select new TabularModel
                     {
                         WeatherDate = c.MeaureDate,
                         Station = c.Station,
                         MinTemp = c.MinTemp
                     }
                         ).ToList();
         case "MaxTemp":
             return (from c in db.fc_rpt_Tabular(stationName, fromDate, toDate, displayMode)
                     select new TabularModel
                     {
                         WeatherDate = c.MeaureDate,
                         Station = c.Station,
                         MaxTemp = c.MaxTemp
                     }
                         ).ToList();
         case "RainFall":
             return (from c in db.fc_rpt_Tabular(stationName, fromDate, toDate, displayMode)
                     select new TabularModel
                     {
                         WeatherDate = c.MeaureDate,
                         Station = c.Station,
                         RainFall = c.RainFall
                     }
                         ).ToList();
         default:
             return (from c in db.fc_rpt_Tabular(stationName, fromDate, toDate, displayMode)
                     select new TabularModel
                     {
                         WeatherDate = c.MeaureDate,
                         Station = c.Station,
                         AirPolutionLevel = c.AirPolutionLevel,
                         MaxTemp = c.MaxTemp,
                         MinTemp = c.MinTemp,
                         RainFall = c.RainFall
                     }
                         ).ToList();
     }
 }