private void fetchClick(object sender, RoutedEventArgs e) { string dbQuery = "SELECT * FROM " + sensorLocation + " WHERE '" + dayBefore + "' < time" + " and time < '" + dayAfter + "'"; try { JObject parseResults = JObject.Parse(NetworkClass.serverResponse(dbQuery)); JArray jsonArray = (JArray)parseResults.SelectToken("points"); JArray jsonArrayLabels = (JArray)parseResults.SelectToken("columns"); textBoxOut.Text = dbQuery; fetchGraph.RemoveGraph(); fetchGraph.AddData(ref jsonArray, ref jsonArrayLabels); fetchGraph.PlotGraph(); fetchGraph.SetStatistics(true); fetchTime.Text = "Fetch Time: " + DateTime.Now.ToString("yyyy-MM-dd h:mm:ss tt"); //h:mm:ss tt } catch (Exception) { MessageBox.Show("Fetch Error, Try Again"); textBoxOut.Text = dbQuery; } }
private void importClick(object sender, RoutedEventArgs e) { string initialData = ""; List <double> rawData = new List <double>(); PlottingClass importGraph = new PlottingClass(this); // Open dialog menu OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "WeatherSpot files (*.ws)|*.ws"; // User successfully opened a file if (openFileDialog.ShowDialog() == true) { importGraph.RemoveGraph(); initialData = File.ReadAllText(openFileDialog.FileName); string[] stringTokens = initialData.Split(';'); for (int i = 0; i < stringTokens.Length; i++) { initialData = stringTokens[i]; if (i % 5 == 0) { importGraph.AddX(Convert.ToDouble(initialData)); } if (i % 5 == 1) { importGraph.AddY(Convert.ToDouble(initialData)); } if (i % 5 == 2) { importGraph.AddYhum(Convert.ToDouble(initialData)); } if (i % 5 == 3) { importGraph.AddYpress(Convert.ToDouble(initialData)); } if (i % 5 == 4) { importGraph.AddYlight(Convert.ToDouble(initialData)); } } importGraph.PlotGraph(); importGraph.SetStatistics(true); fetchTime.Text = "Data Imported"; } }
private void importClick(object sender, RoutedEventArgs e) { string initialData = ""; List<double> rawData = new List<double>(); PlottingClass importGraph = new PlottingClass(this); // Open dialog menu OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "WeatherSpot files (*.ws)|*.ws"; // User successfully opened a file if (openFileDialog.ShowDialog() == true) { importGraph.RemoveGraph(); initialData = File.ReadAllText(openFileDialog.FileName); string[] stringTokens = initialData.Split(';'); for (int i = 0; i < stringTokens.Length; i++) { initialData = stringTokens[i]; if (i % 5 == 0) { importGraph.AddX(Convert.ToDouble(initialData)); } if (i % 5 == 1) { importGraph.AddY(Convert.ToDouble(initialData)); } if (i % 5 == 2) { importGraph.AddYhum(Convert.ToDouble(initialData)); } if (i % 5 == 3) { importGraph.AddYpress(Convert.ToDouble(initialData)); } if (i % 5 == 4) { importGraph.AddYlight(Convert.ToDouble(initialData)); } } importGraph.PlotGraph(); importGraph.SetStatistics(true); fetchTime.Text = "Data Imported"; } }