public static void sqlPush(Report report) //creates a row based on report { string connection_string = @"server=" + RootPage.getSecrets().server + ";userid=" + RootPage.getSecrets().userid + ";password="******";database=" + RootPage.getSecrets().database; var con = new MySqlConnection(connection_string); string command = "INSERT INTO reports " + "(team_key, report_key, event_key, auto_points, auto_skystone_delv, auto_skystone_delv_points, auto_stone_delv, auto_stone_delv_points, auto_repositioning, " + "auto_placing, auto_placing_points, auto_navigating, tele_points, tele_stone_delv, tele_stone_delv_points, tele_stone_placing, tele_stone_placing_points, end_points, end_tallest_sky, end_tallest_sky_points, end_capped, end_capped_lv, end_capping_points, end_foundation, parking, penalties)" + " VALUES (" + report.team_key + ", " + report.report_key + ", " + report.event_key + ", " + report.auto_points + ", " + report.auto_skystone_delv + ", " + report.auto_skystone_delv_points + ", " + report.auto_stone_delv + ", " + report.auto_stone_delv_points + ", " + report.auto_repositioning + ", " + report.auto_placing + ", " + report.auto_placing_points + ", " + report.auto_navigating + ", " + report.tele_points + ", " + report.tele_stone_delv + ", " + report.tele_stone_delv_points + ", " + report.tele_stone_placing + ", " + report.tele_stone_placing_points + ", " + report.end_points + ", " + report.end_tallest_sky + ", " + report.end_tallest_sky_points + ", " + report.end_capped + ", " + report.end_capped_lv + ", " + report.end_capping_points + ", " + report.end_foundation + ", " + report.parking + ", " + report.penalties + ");"; con.Open(); MySqlCommand cmd = new MySqlCommand(command, con); cmd.ExecuteNonQuery(); con.Close(); con.Dispose(); }
public List <Report> sqlCallsByEvent(string eventkey) //return multiple reports as a list { string sqlCommand = "SELECT * from reports WHERE event_key == " + eventkey; string connection_string = @"server=" + RootPage.getSecrets().server + ";userid=" + RootPage.getSecrets().userid + ";password="******";database=" + RootPage.getSecrets().database; var con = new MySqlConnection(connection_string); con.Open(); MySqlCommand cmd = new MySqlCommand(sqlCommand, con); MySqlDataReader rdr = cmd.ExecuteReader(); List <Report> reports = null; while (rdr.Read()) { reports.Add(assignReport(rdr)); } rdr.Close(); con.Close(); rdr.Dispose(); con.Dispose(); return(reports); }
public Report sqlCallByEvent(string eventkey) //return the first report by eventkey { string sqlCommand = "SELECT * from reports WHERE event_key == " + eventkey; string connection_string = @"server=" + RootPage.getSecrets().server + ";userid=" + RootPage.getSecrets().userid + ";password="******";database=" + RootPage.getSecrets().database; var con = new MySqlConnection(connection_string); con.Open(); MySqlCommand cmd = new MySqlCommand(sqlCommand, con); MySqlDataReader rdr = cmd.ExecuteReader(); Report report = null; while (rdr.Read()) { report = assignReport(rdr); } rdr.Close(); con.Close(); rdr.Dispose(); con.Dispose(); return(report); }
// === apiCall function === // public string apiCall(string path) { WebRequest request = WebRequest.Create(TOA_URL + path); request.Method = "GET"; request.ContentType = "application/json"; request.Headers["X-TOA-Key"] = RootPage.getSecrets().apiKey; request.Headers["X-Application-Origin"] = "RoboScout"; try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string responseFromServer = reader.ReadToEnd(); reader.Close(); dataStream.Close(); response.Close(); return(responseFromServer); } catch { return(""); } }