//, Type dateType) /// <summary> /// Creates a Table by a given "Sorted Measure List" with one date time column and one column for each inverter. /// </summary> /// <param name="kwhTable">Creates google data table compatible conent</param> /// <param name="yMode">Use Euro or kwh as y-axis</param> /// <param name="xMode">type of x-axis</param> /// <returns>Google DataTable content</returns> public string BuildGoogleDataTable(SortedKwhTable kwhTable, E_EurKwh yMode, E_TimeMode xMode) { //create datatable and add time column System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("Zeit", typeof(string)).Caption = "Zeit"; //add one column for each inverter ID foreach (var inverterInfo in kwhTable.KnownInverters) { string caption = GetRowName(inverterInfo.Value); dt.Columns.Add(caption, typeof(System.Double)).Caption = caption; } //Add the data foreach (var row in kwhTable.Rows.Values) { //create a new row and add the time first (key) var rowToAdd = dt.NewRow(); rowToAdd[0] = GetTimeCaption(row.Index, xMode); //add the values foreach inverter foreach (var measure in row.kwhValues) { rowToAdd[GetRowName(measure.PublicInverterId)] = measure.Value * GetPerEuroFactor(yMode, measure.PublicInverterId); } //add the new row to the datatable dt.Rows.Add(rowToAdd); } GoogleDataTable gdt = new Bortosky.Google.Visualization.GoogleDataTable(dt); return gdt.GetJson(); }
public JsonResult DecadeData(int plantId, E_EurKwh yMode) { string googleTableContent = _dataProvider.GoogleDataTableContent(new DateTime(2010, 1, 1), new DateTime(2020, 1, 1), plantId, yMode, E_TimeMode.year); return Json(new { tableContent = googleTableContent } , JsonRequestBehavior.AllowGet); }
//DatatableConverter dtConverter = new DatatableConverter(); internal string GoogleDataTableContent(DateTime startDate, DateTime endDate, int plantId, E_EurKwh yMode, E_TimeMode xMode) { //Get kwhdays from database var dailyResult = _kwhRepository.GetDayKwhByDateRange(startDate, endDate, plantId); //Fill up the month for the chart data var kwhTable = KwhCalculator.SummarizeKwh(dailyResult, startDate, endDate, xMode, true); // calculate roi if neccesary and convert to Google Data Table return GenerateGoogleDataTableContent(plantId, yMode, kwhTable, xMode); }
private string GenerateGoogleDataTableContent(int plantId, E_EurKwh yMode, SortedKwhTable kwhTable, E_TimeMode xMode) { DatatableConverter dtConverter = new DatatableConverter(); //include money per kwh mapping if neccessary if (yMode == E_EurKwh.money) { IncludeEuroPerKwhMapping(plantId, dtConverter); } //create google data table content string return dtConverter.BuildGoogleDataTable(kwhTable, yMode, xMode); }
private double GetPerEuroFactor(E_EurKwh yMode, int inverterID) { switch (yMode) { case E_EurKwh.money: return _euroPerKwH[inverterID]; case E_EurKwh.kwh: return 1; case E_EurKwh.watts: return 1; default: throw new ApplicationException(); } }
public JsonResult MonthData(int plantId, int month, int year, E_EurKwh yMode) { var startDate = Utils.FirstDayOfMonth(month, year); var endDate = startDate.AddMonths(1); string googleTableContent = _dataProvider.GoogleDataTableContent(startDate, endDate, plantId, yMode, E_TimeMode.day); return Json(new { tableContent = googleTableContent, monthName = Utils.GetMonthName(month), year = year } , JsonRequestBehavior.AllowGet); }
public JsonResult YearData(int plantId, int year, E_EurKwh yMode) { string googleTableContent = _dataProvider.GoogleDataTableContent(Utils.FirstDayOfYear(year), Utils.FirstDayOfYear(year + 1), plantId, yMode, E_TimeMode.month); return Json(new { tableContent = googleTableContent } , JsonRequestBehavior.AllowGet); }