public async Task <IActionResult> OnGetAsync(string id) { if (id == null) { return(NotFound()); } Controller = await _context.Controllers.FirstOrDefaultAsync(m => m.Id == id); if (Controller == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } Controller = await _context.Controllers.FindAsync(id); if (Controller != null) { _context.Controllers.Remove(Controller); await _context.SaveChangesAsync(); } return(RedirectToPage("./AddController")); }
public async Task <IActionResult> OnGetAsync(string id) { if (id == null) { return(NotFound()); } controller = await _context.Controllers.FirstOrDefaultAsync(m => m.Id == id); string[] values = controller.Values; if (values.Length == 0) { return(Page()); } int start_point = 0; // create data table to store data DataTable ChartData = new DataTable(); // Add columns to data table if (controller.Type == "humidity") { ChartData.Columns.Add("time", typeof(System.String)); ChartData.Columns.Add("mm/pt", typeof(System.Double)); foreach (var item in values) { if (item != "") { ChartData.Rows.Add(start_point, item.Split('|')[1]); start_point += 10; } } } else if (controller.Type == "temperature") { ChartData.Columns.Add("time", typeof(System.String)); ChartData.Columns.Add("Degrees", typeof(System.Double)); foreach (var item in values) { double dd = 0; if (item != "") { ChartData.Rows.Add(start_point, item.Split('|')[1]); start_point += 10; } } } else if (controller.Type == "pressure") { ChartData.Columns.Add("time", typeof(System.String)); ChartData.Columns.Add("bar", typeof(System.Double)); foreach (var item in values) { //DateTime dt = DateTime.Parse(item.Split('|')[0]); ChartData.Rows.Add(start_point, item.Split('|')[3]); start_point += 10; } start_point = 0; } else if (controller.Type == "movement") { ChartData.Columns.Add("time", typeof(System.String)); ChartData.Columns.Add("actions", typeof(System.Double)); foreach (var item in values) { if (item != "") { //DateTime dt = DateTime.Parse(item.Split('|')[0]); int value = 0; if (item.Split('|')[1] == "true") { value = 1; } ChartData.Rows.Add(start_point, value); start_point += 10; } } } else if (controller.Type == "lightning") { ChartData.Columns.Add("time", typeof(System.String)); ChartData.Columns.Add("lux", typeof(System.Double)); foreach (var item in values) { if (item != "") { //DateTime dt = DateTime.Parse(item.Split('|')[0]); ChartData.Rows.Add(start_point, item.Split('|')[1]); start_point += 10; } } } else { ChartData.Columns.Add("sample", typeof(System.String)); ChartData.Columns.Add("sample2", typeof(System.Double)); } // Add rows to data table //ChartData.Rows.Add("Java", 62000); //ChartData.Rows.Add("Python", 46000); //ChartData.Rows.Add("Javascript", 38000); //ChartData.Rows.Add("C++", 31000); //ChartData.Rows.Add("C#", 27000); //ChartData.Rows.Add("PHP", 14000); //ChartData.Rows.Add("Perl", 14000); // Create static source with this data table StaticSource source = new StaticSource(ChartData); // Create instance of DataModel class DataModel model = new DataModel(); // Add DataSource to the DataModel model.DataSources.Add(source); // Instantiate Column Chart Charts.ColumnChart column = new Charts.ColumnChart("first_chart"); // Set Chart's width and height column.Width.Pixel(700); column.Height.Pixel(400); // Set DataModel instance as the data source of the chart column.Data.Source = model; // Set Chart Title column.Caption.Text = controller.Type; // Set chart sub title // hide chart Legend column.Legend.Show = false; // set XAxis Text column.XAxis.Text = "Time"; // Set YAxis title column.YAxis.Text = "Value"; // set chart theme column.ThemeName = FusionChartsTheme.ThemeName.FUSION; // set chart rendering json ChartJson = column.Render(); if (controller == null) { return(NotFound()); } return(Page()); }