public List <SolarData> getSolarDataValuationDay(List <String> pData) { string day = pData[0]; int num = day.Length; string dayS = day.Substring(0, 2); string monthS = day.Substring(3, 2); string yearS = day.Substring(day.Length - 4); string actualData = yearS + "-" + monthS + "-" + dayS; DateTime d = DateTime.Parse(actualData).Date; DateTime dt = d.Date; // string actualDate = ///change date formst List <SolarData> p = new List <SolarData>(); using (SqlConnection con = new SqlConnection(getConnectionString())) { //string query = "SELECT DISTINCT PlantSectionID, SUM(Yield) AS TOTAL FROM SolarProduction WHERE (SELECT YEAR(DATE) AS y) =@year GROUP BY PlantSectionID"; SqlCommand cmd = new SqlCommand("spgetSolarbyDay", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@date", dt); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { SolarData spDatat = new SolarData(); spDatat.PlantName = dr["PlantName"].ToString(); spDatat.solarYield = Convert.ToInt32(dr["TOTAL"].ToString()); p.Add(spDatat); } } } return(p); }
public List <SolarData> getSolarDataMonth(List <string> pData) { List <String> months = new List <string>(); months.Add("January"); months.Add("February"); months.Add("March"); months.Add("April"); months.Add("May"); months.Add("June"); months.Add("July"); months.Add("August"); months.Add("September"); months.Add("October"); months.Add("November"); months.Add("December"); string m = pData[0]; int year = int.Parse(pData[1]); int mon = months.IndexOf(m); int month = mon + 1; List <SolarData> p = new List <SolarData>(); using (SqlConnection con = new SqlConnection(getConnectionString())) { //string query = "SELECT DISTINCT PlantSectionID, SUM(Yield) AS TOTAL FROM SolarProduction WHERE (SELECT YEAR(DATE) AS y) =@year GROUP BY PlantSectionID"; SqlCommand cmd = new SqlCommand("spgetSolarbyMonth", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@month", month); cmd.Parameters.AddWithValue("@ySolar", year); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { SolarData spDatat = new SolarData(); spDatat.PlantName = dr["PlantName"].ToString(); spDatat.solarYield = Convert.ToInt32(dr["TOTAL"].ToString()); p.Add(spDatat); } } } return(p); }
public List <SolarData> getSolarDataReportMonth(List <string> pData) { List <String> months = new List <string>(); months.Add("January"); months.Add("February"); months.Add("March"); months.Add("April"); months.Add("May"); months.Add("June"); months.Add("July"); months.Add("August"); months.Add("September"); months.Add("October"); months.Add("November"); months.Add("December"); string mOne = pData[0]; string mTwo = pData[2]; int yearOne = int.Parse(pData[1]); int yearTwo = int.Parse(pData[3]); int monOne = months.IndexOf(mOne) + 1; int monTwo = months.IndexOf(mTwo) + 1; List <SolarData> p = new List <SolarData>(); SolarData solarDataOne = new SolarData(); solarDataOne.dateName = mOne; solarDataOne.solarYield = getOneMonthData(monOne, yearOne); solarDataOne.drilldown = true; SolarData solarDataTwo = new SolarData(); solarDataTwo.dateName = mTwo; solarDataTwo.solarYield = getOneMonthData(monTwo, yearTwo); solarDataTwo.drilldown = true; p.Add(solarDataOne); p.Add(solarDataTwo); return(p); }