public bool TestMySQLCredentials() { try { var mySqlConnectionString = MySQLMethods.MakeMySqlConnectionString(); var conn = new MySqlConnection { ConnectionString = mySqlConnectionString }; conn.Open(); if (conn.Ping()) { conn.Close(); return(true); } conn.Close(); return(false); } catch (MySqlException ex) { mySqlDatabaseConnectionDisplay.BackColor = Color.Red; mySqlDatabaseConnectionDisplay.Text = "Connection: Failed"; ConsoleWindow.WriteLine("Error Code: " + ex.ErrorCode); ConsoleWindow.WriteLine("Error Message " + ex.Message); return(false); } }
private void matchScoutingDataToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog.InitialDirectory = assemblyPath + "\\Saves\\"; if (Home.internetAvailable) { if (MessageBox.Show("The importation of these files can take a long time, are you sure you want to continue?", "Are you sure you want to continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes) { if (openFileDialog.ShowDialog() == DialogResult.OK) { foreach (string t in openFileDialog.FileNames) { var match = JsonConvert.DeserializeObject <RecycleRush_Scout_Match>(File.ReadAllText(t)); try { var conn = new MySqlConnection(MySQLMethods.MakeMySqlConnectionString()); conn.Open(); MySqlCommand cmd = conn.CreateCommand(); string commandText = String.Format("Insert into RecycleRush_TroyAthens_Matches (EntryID,UniqueID,Author,TimeCreated,Team_Number,Team_Name,Match_Number,Alliance_Colour,Robot_Dead,Auto_Starting_X,Auto_Starting_Y,Auto_Drive_To_Autozone,Auto_Robot_Set,Auto_Tote_Set,Auto_Bin_Set,Auto_Stacked_Tote_Set,Auto_Acquired_Step_Bins,Auto_Fouls,Auto_Did_Nothing,Tele_Tote_Pickup_Upright,Tele_Tote_Pickup_Upside_Down,Tele_Tote_Pickup_Sideways,Tele_Bin_Pickup_Upright,Tele_Bin_Pickup_Upside_Down,Tele_Bin_Pickup_Sideways,Tele_Human_Station_Load_Totes,Tele_Human_Station_Stack_Totes,Tele_Human_Station_Insert_Litter,Tele_Human_Throwing_Litter,Tele_Pushed_Litter_To_Landfill,Tele_Fouls,Comments,Stacks,Coopertition_Set,Coopertition_Stack,Driver_Rating) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}');", (MySQLMethods.GetNumberOfRowsInATable() + 1), match.UniqueID, match.Author, match.TimeCreated, match.Team_Number, match.Team_Name, match.Match_Number, match.scoutingPosition, Convert.ToInt16(match.Robot_Dead), match.Auto_Starting_X, match.Auto_Starting_Y, Convert.ToInt16(match.Auto_Drive_To_Autozone), Convert.ToInt16(match.Auto_Robot_Set), Convert.ToInt16(match.Auto_Tote_Set), Convert.ToInt16(match.Auto_Bin_Set), Convert.ToInt16(match.Auto_Stacked_Tote_Set), match.Auto_Acquired_Step_Bins, match.Auto_Fouls, Convert.ToInt16(match.Auto_Did_Nothing), Convert.ToInt16(match.Tele_Tote_Pickup_Upright), Convert.ToInt16(match.Tele_Tote_Pickup_Upside_Down), Convert.ToInt16(match.Tele_Tote_Pickup_Sideways), Convert.ToInt16(match.Tele_Bin_Pickup_Upright), Convert.ToInt16(match.Tele_Bin_Pickup_Upside_Down), Convert.ToInt16(match.Tele_Bin_Pickup_Sideways), Convert.ToInt16(match.Tele_Human_Station_Load_Totes), Convert.ToInt16(match.Tele_Human_Station_Stack_Totes), Convert.ToInt16(match.Tele_Human_Station_Insert_Litter), Convert.ToInt16(match.Tele_Human_Throwing_Litter), Convert.ToInt16(match.Tele_Pushed_Litter_To_Landfill), match.Tele_Fouls, match.Comments, JsonConvert.SerializeObject(match.Stacks), Convert.ToInt16(match.Coopertition_Set), Convert.ToInt16(match.Coopertition_Stack), match.Driver_Rating); cmd.CommandText = commandText; cmd.ExecuteNonQuery(); conn.Close(); } catch (MySqlException exception) { Console.Write(exception.ToString()); ConsoleWindow.WriteLine(exception.ToString()); } } } } } else { MessageBox.Show("Internet is Required For Importation!", "Internet is Required!", MessageBoxButtons.OK); } }
private void scoutingSubmitButton_Click(object sender, EventArgs e) { scoutingSubmitButton.Enabled = false; Program.selectedEventName = "RecycleRush_TroyAthens"; int teamNo = Convert.ToInt32(teamNumberBeingScoutedNumericUpDown.Value); string teamName = currentTeamName; try { teamName = teamNameArray[Array.IndexOf(teamNumberArray, teamNo)]; } catch (Exception) { teamName = TheBlueAlliance.Teams.GetTeamInformation("frc" + teamNo).nickname; } int DS = Convert.ToInt32(scoutingPositionNumericUpDown.Value); string sP = allianceColour + DS; int autonScoreAprox = calcuateThisRobotsAutonScore(); int teleopScoreAprox = calcuateThisRobotsTeleopScore(); int coopScoreAprox = calculateThisRobotsCoopertitionScore(); int totalScoreAprox = calculateThisRobotsTotalScore(); var match = new RecycleRush_Scout_Match { Author = Settings.Default.username, TimeCreated = DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"), UniqueID = Guid.NewGuid().ToString(), Team_Number = teamNo, Team_Name = teamName, scoutingPosition = sP, Robot_Dead = scoutingDidTheRobotDieCheckBox.Checked, Auto_Starting_X = startingX, Auto_Starting_Y = startingY, Auto_Drive_To_Autozone = scoutingDriveToAutoZoneCheckBox.Checked, Auto_Can_Burgeled = scoutingCanBurgeledCheckbox.Checked, Auto_Cans_Grabbed = Convert.ToInt32(numCansGrabbedNumbericUpDown.Value), Auto_Robot_Set = scoutingRobotSetCheckBox.Checked, Auto_Tote_Set = scoutingToteSetCheckBox.Checked, Auto_Bin_Set = scoutingBinSetCheckBox.Checked, Auto_Stacked_Tote_Set = scoutingStackedToteSetCheckBox.Checked, Auto_Acquired_Step_Bins = Convert.ToInt32(scoutingAcquiredStepBinsNumUpDown.Value), Auto_Fouls = Convert.ToInt32(scoutingAutoFoulsNumUpDown.Value), Auto_Did_Nothing = scoutingDidNothingCheckBox.Checked, Tele_Tote_Pickup_Upright = scoutingTotePickupUprightCheckbox.Checked, Tele_Tote_Pickup_Upside_Down = scoutingTotePickupUpsideDownCheckBox.Checked, Tele_Tote_Pickup_Sideways = scoutingTotePickupSideWaysCheckBox.Checked, Tele_Bin_Pickup_Upright = scoutingBinPickupUprightCheckBox.Checked, Tele_Bin_Pickup_Upside_Down = scoutingBinPickupUpsideDownCheckBox.Checked, Tele_Bin_Pickup_Sideways = scoutingBinPickupSidewaysCheckBox.Checked, Tele_Human_Station_Load_Totes = scoutingHumanStationLoadTotesCheckBox.Checked, Tele_Human_Station_Stack_Totes = scoutingHumanStationStackTotesCheckBox.Checked, Tele_Human_Station_Insert_Litter = scoutingHumanStationInsertLitterCheckBox.Checked, Tele_Human_Throwing_Litter = Convert.ToInt32(litterThrownNumUpDown.Value), Tele_Pushed_Litter_To_Landfill = Convert.ToInt32(litterPushedToLandFillNumUpDown.Value), Tele_Fouls = Convert.ToInt32(scoutingTeleFoulPointsNumUpDown.Value), Comments = scoutingCommentsRichTextBox.Text, Stacks = matchStacks, Coopertition_Set = scoutingCoopertitionSetCheckBox.Checked, Coopertition_Stack = scoutingCoopertitionStackCheckBox.Checked, Driver_Rating = driverRating, Aprox_Robots_Auton_Score = Convert.ToInt32(autonScoreAprox), Aprox_Robots_Teleop_Score = Convert.ToInt32(teleopScoreAprox), Aprox_Robots_Coopertition_Score = Convert.ToInt32(coopScoreAprox), Aprox_Robots_Total_Score = Convert.ToInt32(totalScoreAprox) }; if (match.Comments.Contains(";")) { match.Comments = Regex.Replace(match.Comments, "[;]", string.Empty); } try { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves"); string jsonText = JsonConvert.SerializeObject(match, Formatting.Indented); string matchLocation = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\RecycleRush_TroyAthens_" + "Match" + Convert.ToInt32(scoutingMatchNumberNumericUpDown.Value) + "_" + sP + "_" + teamNo + ".json"); File.WriteAllText(matchLocation, jsonText); } catch (Exception exception) { Console.Write("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); Notifications.ReportCrash(exception); } try { var conn = new MySqlConnection(MySQLMethods.MakeMySqlConnectionString()); conn.Open(); MySqlCommand cmd = conn.CreateCommand(); string commandText = String.Format("Insert into RecycleRush_TroyAthens_Matches (EntryID,UniqueID,Author,TimeCreated,Team_Number,Team_Name,Match_Number,scoutingPositon,Robot_Dead,Auto_Starting_X,Auto_Starting_Y,Auto_Drive_To_Autozone,Auto_Robot_Set,Auto_Tote_Set,Auto_Bin_Set,Auto_Stacked_Tote_Set,Auto_Acquired_Step_Bins,Auto_Fouls,Auto_Did_Nothing,Tele_Tote_Pickup_Upright,Tele_Tote_Pickup_Upside_Down,Tele_Tote_Pickup_Sideways,Tele_Bin_Pickup_Upright,Tele_Bin_Pickup_Upside_Down,Tele_Bin_Pickup_Sideways,Tele_Human_Station_Load_Totes,Tele_Human_Station_Stack_Totes,Tele_Human_Station_Insert_Litter,Tele_Human_Throwing_Litter,Tele_Pushed_Litter_To_Landfill,Tele_Fouls,Comments,Stacks,Coopertition_Set,Coopertition_Stack,Driver_Rating) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}');", (MySQLMethods.GetNumberOfRowsInATable() + 1), match.UniqueID, match.Author, match.TimeCreated, match.Team_Number, match.Team_Name, match.Match_Number, Convert.ToInt16(match.Robot_Dead), match.Auto_Starting_X, match.Auto_Starting_Y, Convert.ToInt16(match.Auto_Drive_To_Autozone), Convert.ToInt16(match.Auto_Robot_Set), Convert.ToInt16(match.Auto_Tote_Set), Convert.ToInt16(match.Auto_Bin_Set), Convert.ToInt16(match.Auto_Stacked_Tote_Set), match.Auto_Acquired_Step_Bins, match.Auto_Fouls, Convert.ToInt16(match.Auto_Did_Nothing), Convert.ToInt16(match.Tele_Tote_Pickup_Upright), Convert.ToInt16(match.Tele_Tote_Pickup_Upside_Down), Convert.ToInt16(match.Tele_Tote_Pickup_Sideways), Convert.ToInt16(match.Tele_Bin_Pickup_Upright), Convert.ToInt16(match.Tele_Bin_Pickup_Upside_Down), Convert.ToInt16(match.Tele_Bin_Pickup_Sideways), Convert.ToInt16(match.Tele_Human_Station_Load_Totes), Convert.ToInt16(match.Tele_Human_Station_Stack_Totes), Convert.ToInt16(match.Tele_Human_Station_Insert_Litter), Convert.ToInt16(match.Tele_Human_Throwing_Litter), Convert.ToInt16(match.Tele_Pushed_Litter_To_Landfill), match.Tele_Fouls, match.Comments, JsonConvert.SerializeObject(match.Stacks), Convert.ToInt16(match.Coopertition_Set), Convert.ToInt16(match.Coopertition_Stack), match.Driver_Rating); cmd.CommandText = commandText; cmd.ExecuteNonQuery(); conn.Close(); } catch (Exception exception) { //Do Nothing: /* Console.Write("Error Occured: " + exception.Message); * ConsoleWindow.WriteLine("Error Occured: " + exception.Message); * Notifications.ReportCrash(exception); */ } ResetScoutingInterface(); scoutingSubmitButton.Enabled = true; }
private void teamSelector_SelectedIndexChanged(object sender, EventArgs e) { currentTeamName = teamNameArray[teamSelector.SelectedIndex]; currentTeamNumber = teamNumberArray[teamSelector.SelectedIndex]; Program.selectedTeamNumber = currentTeamNumber; teamInformationTeamName.Text = ("Team Name: " + teamNameArray[teamSelector.SelectedIndex]); teamInformationTeamNumber.Text = ("Team Number: " + teamNumberArray[teamSelector.SelectedIndex]); ResetMatchBreakdownInterface(); try { object teamImage = Resources.ResourceManager.GetObject("FRC" + teamNumberArray[teamSelector.SelectedIndex]); teamInformationLogo.Image = (Image)teamImage; } catch (Exception exception) { Console.Write("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); } if (Home.internetAvailable) { string url = ("http://www.thebluealliance.com/api/v2/team/frc"); url = url + Convert.ToString(teamNumberArray[teamSelector.SelectedIndex]); string downloadedData; var wc = new WebClient(); wc.Headers.Add("X-TBA-App-Id", "3710-xNovax:FRC_Scouting_V2:" + Assembly.GetExecutingAssembly().GetName().Version); try { downloadedData = (wc.DownloadString(url)); var deserializedData = JsonConvert.DeserializeObject <AerialAssist_RahChaCha.TeamInformationJSONData>(downloadedData); teamInformationTeamLocation.Text = "Team Location: " + Convert.ToString(deserializedData.location); teamInformationRookieYear.Text = "Rookie Year: " + Convert.ToString(deserializedData.rookie_year); teamInformationWebsiteLinkLabel.Text = Convert.ToString(deserializedData.website); } catch (Exception webError) { Console.WriteLine("Error Message: " + webError.Message); ConsoleWindow.WriteLine("Error Message: " + webError.Message); } } else { teamInformationTeamLocation.Text = "Team Location: "; teamInformationRookieYear.Text = "Rookie Year: "; teamInformationWebsiteLinkLabel.Text = ""; } if (Home.internetAvailable) { try { var conn = new MySqlConnection(MySQLMethods.MakeMySqlConnectionString()); MySqlCommand cmd = conn.CreateCommand(); MySqlDataReader reader; cmd.CommandText = String.Format("SELECT * FROM RecycleRush_TroyAthens_Matches WHERE Team_Number = '{0}'", Program.selectedTeamNumber); conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { var match = new RecycleRush_Scout_Match { Author = reader["Author"].ToString(), TimeCreated = reader["TimeCreated"].ToString(), Match_Number = Convert.ToInt32(reader["Match_Number"]), scoutingPosition = Convert.ToString(reader["stringPosition"]), Robot_Dead = Convert.ToBoolean(reader["Robot_Dead"]), Auto_Starting_X = Convert.ToInt32(reader["Auto_Starting_X"]), Auto_Starting_Y = Convert.ToInt32(reader["Auto_Starting_Y"]), Auto_Drive_To_Autozone = Convert.ToBoolean(reader["Auto_Drive_To_Autozone"]), Auto_Can_Burgeled = Convert.ToBoolean(reader["Auto_Can_Burgeled"]), Auto_Cans_Grabbed = Convert.ToInt32(reader["Auto_Cans_Grabbed"]), Auto_Robot_Set = Convert.ToBoolean(reader["Auto_Robot_Set"]), Auto_Tote_Set = Convert.ToBoolean(reader["Auto_Tote_Set"]), Auto_Bin_Set = Convert.ToBoolean(reader["Auto_Bin_Set"]), Auto_Stacked_Tote_Set = Convert.ToBoolean(reader["Auto_Stacked_Tote_Set"]), Auto_Acquired_Step_Bins = Convert.ToInt32(reader["Auto_Acquired_Step_Bins"]), Auto_Fouls = Convert.ToInt32(reader["Auto_Fouls"]), Auto_Did_Nothing = Convert.ToBoolean(reader["Auto_Did_Nothing"]), Tele_Tote_Pickup_Upright = Convert.ToBoolean(reader["Tele_Tote_Pickup_Upright"]), Tele_Tote_Pickup_Upside_Down = Convert.ToBoolean(reader["Tele_Tote_Pickup_Upside_Down"]), Tele_Tote_Pickup_Sideways = Convert.ToBoolean(reader["Tele_Tote_Pickup_Sideways"]), Tele_Bin_Pickup_Upright = Convert.ToBoolean(reader["Tele_Bin_Pickup_Upright"]), Tele_Bin_Pickup_Upside_Down = Convert.ToBoolean(reader["Tele_Bin_Pickup_Upside_Down"]), Tele_Bin_Pickup_Sideways = Convert.ToBoolean(reader["Tele_Bin_Pickup_Sideways"]), Tele_Human_Station_Load_Totes = Convert.ToBoolean(reader["Tele_Human_Station_Load_Totes"]), Tele_Human_Station_Stack_Totes = Convert.ToBoolean(reader["Tele_Human_Station_Stack_Totes"]), Tele_Human_Station_Insert_Litter = Convert.ToBoolean(reader["Tele_Human_Station_Insert_Litter"]), Tele_Human_Throwing_Litter = Convert.ToInt32(reader["Tele_Human_Throwing_Litter"]), Tele_Pushed_Litter_To_Landfill = Convert.ToInt32(reader["Tele_Pushed_Litter_To_Landfill"]), Tele_Fouls = Convert.ToInt32(reader["Tele_Fouls"]), Comments = Convert.ToString(reader["Comments"]), Stacks = JsonConvert.DeserializeObject <List <RecycleRush_Stack> >(reader["Stacks"].ToString()), Coopertition_Set = Convert.ToBoolean(reader["Coopertition_Set"]), Coopertition_Stack = Convert.ToBoolean(reader["Coopertition_Stack"]), Driver_Rating = Convert.ToInt32(reader["Driver_Rating"]), Aprox_Robots_Auton_Score = Convert.ToInt32(calcuateThisRobotsAutonScore()), Aprox_Robots_Teleop_Score = Convert.ToInt32(calcuateThisRobotsTeleopScore()), Aprox_Robots_Coopertition_Score = Convert.ToInt32(calculateThisRobotsCoopertitionScore()), Aprox_Robots_Total_Score = Convert.ToInt32(calculateThisRobotsTotalScore()) }; teamsMatches.Add(match); matchBreakdownMatchList.Items.Add("Match Number: " + reader["Match_Number"]); } conn.Close(); } catch (MySqlException exception) { Console.Write("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); } } }
private void submitDataButton_Click(object sender, EventArgs e) { submitDataButton.Enabled = false; if (Settings.Default.allowExportToTextFile) { //Write to TextFile if (saveFileDialog.ShowDialog() == DialogResult.OK) { var writer = new StreamWriter(saveFileDialog.FileName); writer.WriteLine("=========================================================="); writer.WriteLine("-===============+ Human Readable Portion +===============-"); writer.WriteLine("=========================================================="); writer.WriteLine("Time Created: " + Time.GetCurrentTime()); writer.WriteLine("Scouted By: " + Settings.Default.username); writer.WriteLine("Match #: " + Convert.ToString(matchNumber)); writer.WriteLine("Did the robot die?: " + Convert.ToBoolean(didRobotDie)); writer.WriteLine("Team Colour: " + teamColour); writer.WriteLine("Team Name: " + Program.selectedTeamName); writer.WriteLine("Team Number: " + Program.selectedTeamNumber); writer.WriteLine("#########################################################"); writer.WriteLine("Auto High: Goal: " + Convert.ToString(autoHighGoal) + " Miss: " + Convert.ToString(autoHighMiss)); writer.WriteLine("Auto Low: Goal: " + Convert.ToString(autoLowGoal) + " Miss: " + Convert.ToString(autoLowMiss)); writer.WriteLine("Controlled High: Goal: " + Convert.ToString(controlledHighGoal) + " Miss: " + Convert.ToString(controlledHighMiss)); writer.WriteLine("Controlled Low: Goal: " + Convert.ToString(controlledLowGoal) + " Miss: " + Convert.ToString(controlledLowMiss)); writer.WriteLine("Hot: Goal: " + Convert.ToString(hotGoal) + " Miss: " + Convert.ToString(hotMiss)); writer.WriteLine("3-Assist: Goal: " + Convert.ToString(tripleAssistGoal) + " Miss: " + Convert.ToString(tripleAssistMiss)); writer.WriteLine("Auto Pickup: Successful: " + Convert.ToString(autoBallPickup) + " Unsuccessful: " + Convert.ToString(autoBallPickupMiss)); writer.WriteLine("Controlled Pickup: Successful: " + Convert.ToString(controlledBallPickup) + " Unsuccessful: " + Convert.ToString(controlledBallPickupMiss)); writer.WriteLine("Pickup From Human: Successful: " + Convert.ToString(pickupFromHuman) + " Unsuccessful: " + Convert.ToString(pickupFromHumanMiss)); writer.WriteLine("Pass To Another Robot: Successful: " + Convert.ToString(passToOtherRobot) + " Unsuccessful: " + Convert.ToString(passToOtherRobotMiss)); writer.WriteLine("Truss Shot: Successful: " + Convert.ToString(successfulTruss) + " Unsuccessful: " + Convert.ToString(unsuccessfulTruss)); writer.WriteLine("Starting Location: X: " + Convert.ToString(xStarting) + " Y: " + Convert.ToString(yStarting)); writer.WriteLine("Driver Rating: " + driverRating); writer.WriteLine("Auto Movement: " + Convert.ToBoolean(autoMovement)); writer.WriteLine("Comments: " + Convert.ToString(comments)); writer.WriteLine("#########################################################"); writer.WriteLine("========================================================="); writer.WriteLine("-=============+ Computer Readable Portion +=============-"); writer.WriteLine("========================================================="); writer.WriteLine(Convert.ToString(Program.selectedTeamNumber)); writer.WriteLine(Convert.ToString(Program.selectedTeamName)); writer.WriteLine(Convert.ToString(teamColour)); writer.WriteLine(Convert.ToString(matchNumber)); writer.WriteLine(Convert.ToString(autoHighGoal)); writer.WriteLine(Convert.ToString(autoHighMiss)); writer.WriteLine(Convert.ToString(autoLowGoal)); writer.WriteLine(Convert.ToString(autoLowMiss)); writer.WriteLine(Convert.ToString(controlledHighGoal)); writer.WriteLine(Convert.ToString(controlledHighMiss)); writer.WriteLine(Convert.ToString(controlledLowGoal)); writer.WriteLine(Convert.ToString(controlledLowMiss)); writer.WriteLine(Convert.ToString(hotGoal)); writer.WriteLine(Convert.ToString(hotMiss)); writer.WriteLine(Convert.ToString(tripleAssistGoal)); writer.WriteLine(Convert.ToString(tripleAssistMiss)); writer.WriteLine(Convert.ToString(autoBallPickup)); writer.WriteLine(Convert.ToString(autoBallPickupMiss)); writer.WriteLine(Convert.ToString(controlledBallPickup)); writer.WriteLine(Convert.ToString(controlledBallPickupMiss)); writer.WriteLine(Convert.ToString(pickupFromHuman)); writer.WriteLine(Convert.ToString(pickupFromHumanMiss)); writer.WriteLine(Convert.ToString(passToOtherRobot)); writer.WriteLine(Convert.ToString(passToOtherRobotMiss)); writer.WriteLine(Convert.ToString(successfulTruss)); writer.WriteLine(Convert.ToString(unsuccessfulTruss)); writer.WriteLine(Convert.ToString(xStarting)); writer.WriteLine(Convert.ToString(yStarting)); writer.WriteLine(Convert.ToBoolean(didRobotDie)); writer.WriteLine(Convert.ToInt16(driverRating)); writer.WriteLine(Convert.ToBoolean(autoMovement)); writer.WriteLine(Convert.ToString(comments)); writer.WriteLine("END OF FILE"); writer.Close(); } } //MySQL Database //MySQL Database Connection Info string mySqlConnectionString = MySQLMethods.MakeMySqlConnectionString(); try { //Creating the connection to the database and opening the connection var conn = new MySqlConnection { ConnectionString = mySqlConnectionString }; conn.Open(); //Checking if the connection is successful if (conn.Ping()) { Console.WriteLine("The connection to your database has been made successfully."); ConsoleWindow.WriteLine("The connection to your database has been made successfully."); } //Creating the MySQLCommand object MySqlCommand cmd = conn.CreateCommand(); if (tableCreated == false) { //Trying to create the table try { string createTable = String.Format( "CREATE TABLE `{0}` (`EntryID` int(11) NOT NULL DEFAULT '0',`TeamNumber` int(11) NOT NULL DEFAULT '0',`TeamName` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Default',`TeamColour` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Not Selected',`MatchNumber` int(11) NOT NULL DEFAULT '0',`AutoHighGoal` int(11) NOT NULL DEFAULT '0',`AutoHighMiss` int(11) NOT NULL DEFAULT '0',`AutoLowGoal` int(11) NOT NULL DEFAULT '0',`AutoLowMiss` int(11) NOT NULL DEFAULT '0',`ControlledHighGoal` int(11) NOT NULL DEFAULT '0',`ControlledHighMiss` int(11) NOT NULL DEFAULT '0',`ControlledLowGoal` int(11) NOT NULL DEFAULT '0',`ControlledLowMiss` int(11) NOT NULL DEFAULT '0',`HotGoals` int(11) NOT NULL DEFAULT '0',`HotGoalMiss` int(11) NOT NULL DEFAULT '0',`3AssistGoal` int(11) NOT NULL DEFAULT '0',`3AssistMiss` int(11) NOT NULL DEFAULT '0',`AutoBallPickup` int(11) NOT NULL DEFAULT '0',`AutoBallPickupMiss` int(11) NOT NULL DEFAULT '0',`ControlledBallPickup` int(11) NOT NULL DEFAULT '0',`ControlledBallPickupMiss` int(11) NOT NULL DEFAULT '0',`PickupFromHuman` int(11) NOT NULL DEFAULT '0',`MissedPickupFromHuman` int(11) NOT NULL DEFAULT '0',`PassToAnotherRobot` int(11) NOT NULL DEFAULT '0',`MissedPassToAnotherRobot` int(11) NOT NULL DEFAULT '0',`SuccessfulTruss` int(11) NOT NULL DEFAULT '0',`UnsuccessfulTruss` int(11) NOT NULL DEFAULT '0',`StartingX` int(11) NOT NULL DEFAULT '0',`StartingY` int(11) NOT NULL DEFAULT '0',`DidRobotDie` tinyint(4) NOT NULL DEFAULT '0',`DriverRating` int(11) NOT NULL DEFAULT '0',`AutoMovement` tinyint(4) NOT NULL DEFAULT '0',`Comments` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL,PRIMARY KEY (`EntryID`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", Program.selectedEventName); cmd.CommandText = createTable; cmd.ExecuteNonQuery(); Console.WriteLine("The table: " + Program.selectedEventName + " has been created."); ConsoleWindow.WriteLine("The table: " + Program.selectedEventName + " has been created."); //end of creating the table } catch (MySqlException createException) { Console.WriteLine("If there is an error it is most likely because the table is already made."); Console.WriteLine("Errorcode: " + createException.ErrorCode); Console.WriteLine(createException.Message); ConsoleWindow.WriteLine( "If there is an error it is most likely because the table is already made."); ConsoleWindow.WriteLine("Errorcode: " + createException.ErrorCode); ConsoleWindow.WriteLine(createException.Message); } tableCreated = true; } //Submit data into the database string insertDataString = String.Format( "Insert into {0} (EntryID,TeamNumber,TeamName,TeamColour,MatchNumber,AutoHighGoal,AutoHighMiss, AutoLowGoal, AutoLowMiss, ControlledHighGoal, ControlledHighMiss, ControlledLowGoal, ControlledLowMiss, HotGoals, HotGoalMiss, 3AssistGoal, 3AssistMiss, AutoBallPickup, AutoBallPickupMiss, ControlledBallPickup, ControlledBallPickupMiss, PickupFromHuman, MissedPickupFromHuman, PassToAnotherRobot, MissedPassToAnotherRobot, SuccessfulTruss, UnsuccessfulTruss, StartingX, StartingY, DidRobotDie, DriverRating, AutoMovement, Comments) values('{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}');", Program.selectedEventName, (MySQLMethods.GetNumberOfRowsInATable() + 1), Program.selectedTeamNumber, Program.selectedTeamName, teamColour, matchNumber, autoHighGoal, autoHighMiss, autoLowGoal, autoLowMiss, controlledHighGoal, controlledHighMiss, controlledLowGoal, controlledLowMiss, hotGoal, hotMiss, tripleAssistGoal, tripleAssistMiss, autoBallPickup, autoBallPickupMiss, controlledBallPickup, controlledBallPickupMiss, pickupFromHuman, pickupFromHumanMiss, passToOtherRobot, passToOtherRobotMiss, successfulTruss, unsuccessfulTruss, xStarting, yStarting, didRobotDie, driverRating, Convert.ToInt16(autoMovement), comments); cmd.CommandText = insertDataString; cmd.ExecuteNonQuery(); Console.WriteLine("Data has been inserted into the database!"); ConsoleWindow.WriteLine("Data has been inserted into the database!"); //Closing the connection conn.Close(); cmd.Dispose(); } catch (MySqlException ex) { Console.WriteLine("Error Code: " + ex.ErrorCode); Console.WriteLine(ex.Message); ConsoleWindow.WriteLine("Error Code: " + ex.ErrorCode); ConsoleWindow.WriteLine(ex.Message); } Notifications.ShowInformationMessage("You have successfully inserted your scouting data for Match #: " + matchNumber); //Clearing the values after you submit the data autoHighGoal = 0; autoHighMiss = 0; autoLowGoal = 0; autoLowMiss = 0; controlledHighGoal = 0; controlledHighMiss = 0; controlledLowGoal = 0; controlledLowMiss = 0; hotGoal = 0; hotMiss = 0; tripleAssistGoal = 0; tripleAssistMiss = 0; autoBallPickup = 0; autoBallPickupMiss = 0; controlledBallPickup = 0; controlledBallPickupMiss = 0; pickupFromHuman = 0; pickupFromHumanMiss = 0; passToOtherRobot = 0; passToOtherRobotMiss = 0; successfulTruss = 0; unsuccessfulTruss = 0; BlankPanel(); didRobotDie = 0; didRobotDieCheckBox.Checked = false; matchNumberUpDown.Value++; totalGoal = 0; totalMiss = 0; totalGoodControl = 0; totalMissControl = 0; xStarting = 0; yStarting = 0; startingLocationXYDisplay.Text = ("X: 0 Y: 0"); comments = (""); commentsTextBox.Text = ("Comments: Any other information that may be needed"); autoMovement = false; autonomousMovementCheckBox.Checked = false; driverRating = 0; driverRatingButton1.Enabled = true; driverRatingButton1.Checked = false; driverRatingButton2.Enabled = true; driverRatingButton2.Checked = false; driverRatingButton3.Enabled = true; driverRatingButton3.Checked = false; driverRatingButton4.Enabled = true; driverRatingButton4.Checked = false; UpdateLabels(); submitDataButton.Enabled = true; }
private void scoutingSubmitButton_Click(object sender, EventArgs e) { scoutingSubmitButton.Enabled = false; Program.selectedEventName = "RecycleRush_GTR_East"; var match = new RecycleRush_Scout_Match { Author = Settings.Default.username, TimeCreated = DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"), UniqueID = Guid.NewGuid().ToString(), Team_Number = currentTeamNumber, Team_Name = currentTeamName, Match_Number = Convert.ToInt32(scoutingMatchNumberNumericUpDown.Value), Alliance_Colour = allianceColour, Robot_Dead = scoutingDidTheRobotDieCheckBox.Checked, Auto_Starting_X = startingX, Auto_Starting_Y = startingY, Auto_Drive_To_Autozone = scoutingDriveToAutoZoneCheckBox.Checked, Auto_Robot_Set = scoutingRobotSetCheckBox.Checked, Auto_Tote_Set = scoutingToteSetCheckBox.Checked, Auto_Bin_Set = scoutingBinSetCheckBox.Checked, Auto_Stacked_Tote_Set = scoutingStackedToteSetCheckBox.Checked, Auto_Acquired_Step_Bins = Convert.ToInt32(scoutingAcquiredStepBinsNumUpDown.Value), Auto_Fouls = Convert.ToInt32(scoutingAutoFoulsNumUpDown.Value), Auto_Did_Nothing = scoutingDidNothingCheckBox.Checked, Tele_Tote_Pickup_Upright = scoutingTotePickupUprightCheckbox.Checked, Tele_Tote_Pickup_Upside_Down = scoutingTotePickupUpsideDownCheckBox.Checked, Tele_Tote_Pickup_Sideways = scoutingTotePickupSideWaysCheckBox.Checked, Tele_Bin_Pickup_Upright = scoutingBinPickupUprightCheckBox.Checked, Tele_Bin_Pickup_Upside_Down = scoutingBinPickupUpsideDownCheckBox.Checked, Tele_Bin_Pickup_Sideways = scoutingBinPickupSidewaysCheckBox.Checked, Tele_Human_Station_Load_Totes = scoutingHumanStationLoadTotesCheckBox.Checked, Tele_Human_Station_Stack_Totes = scoutingHumanStationStackTotesCheckBox.Checked, Tele_Human_Station_Insert_Litter = scoutingHumanStationInsertLitterCheckBox.Checked, Tele_Human_Throwing_Litter = scoutingHumanThrowingLitterCheckBox.Checked, Tele_Pushed_Litter_To_Landfill = scoutingPushedLitterToLandfill.Checked, Tele_Fouls = Convert.ToInt32(scoutingTeleFoulPointsNumUpDown.Value), Comments = scoutingCommentsRichTextBox.Text, Stacks = matchStacks, Coopertition_Set = scoutingCoopertitionSetCheckBox.Checked, Coopertition_Stack = scoutingCoopertitionStackCheckBox.Checked, Final_Score_Red = Convert.ToInt32(scoutingRedAllianceFinalScoreNumUpDown.Value), Final_Score_Blue = Convert.ToInt32(scoutingBlueAllianceFinalScoreNumUpDown.Value), Driver_Rating = driverRating }; if (match.Comments.Contains(";")) { match.Comments = Regex.Replace(match.Comments, "[;]", string.Empty); } try { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves"); string jsonText = JsonConvert.SerializeObject(match, Formatting.Indented); string matchLocation = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\RecycleRush_GTR_East_" + Convert.ToInt32(scoutingMatchNumberNumericUpDown.Value) + "_" + currentTeamName + ".json"); File.WriteAllText(matchLocation, jsonText); } catch (Exception exception) { Console.Write("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); Notifications.ReportCrash(exception); } try { var conn = new MySqlConnection(MySQLMethods.MakeMySqlConnectionString()); conn.Open(); MySqlCommand cmd = conn.CreateCommand(); string commandText = String.Format("Insert into RecycleRush_GTR_East_Matches (EntryID,UniqueID,Author,TimeCreated,Team_Number,Team_Name,Match_Number,Alliance_Colour,Robot_Dead,Auto_Starting_X,Auto_Starting_Y,Auto_Drive_To_Autozone,Auto_Robot_Set,Auto_Tote_Set,Auto_Bin_Set,Auto_Stacked_Tote_Set,Auto_Acquired_Step_Bins,Auto_Fouls,Auto_Did_Nothing,Tele_Tote_Pickup_Upright,Tele_Tote_Pickup_Upside_Down,Tele_Tote_Pickup_Sideways,Tele_Bin_Pickup_Upright,Tele_Bin_Pickup_Upside_Down,Tele_Bin_Pickup_Sideways,Tele_Human_Station_Load_Totes,Tele_Human_Station_Stack_Totes,Tele_Human_Station_Insert_Litter,Tele_Human_Throwing_Litter,Tele_Pushed_Litter_To_Landfill,Tele_Fouls,Comments,Stacks,Coopertition_Set,Coopertition_Stack,Final_Score_Red,Final_Score_Blue,Driver_Rating) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}');", (MySQLMethods.GetNumberOfRowsInATable() + 1), match.UniqueID, match.Author, match.TimeCreated, match.Team_Number, match.Team_Name, match.Match_Number, match.Alliance_Colour, Convert.ToInt16(match.Robot_Dead), match.Auto_Starting_X, match.Auto_Starting_Y, Convert.ToInt16(match.Auto_Drive_To_Autozone), Convert.ToInt16(match.Auto_Robot_Set), Convert.ToInt16(match.Auto_Tote_Set), Convert.ToInt16(match.Auto_Bin_Set), Convert.ToInt16(match.Auto_Stacked_Tote_Set), match.Auto_Acquired_Step_Bins, match.Auto_Fouls, Convert.ToInt16(match.Auto_Did_Nothing), Convert.ToInt16(match.Tele_Tote_Pickup_Upright), Convert.ToInt16(match.Tele_Tote_Pickup_Upside_Down), Convert.ToInt16(match.Tele_Tote_Pickup_Sideways), Convert.ToInt16(match.Tele_Bin_Pickup_Upright), Convert.ToInt16(match.Tele_Bin_Pickup_Upside_Down), Convert.ToInt16(match.Tele_Bin_Pickup_Sideways), Convert.ToInt16(match.Tele_Human_Station_Load_Totes), Convert.ToInt16(match.Tele_Human_Station_Stack_Totes), Convert.ToInt16(match.Tele_Human_Station_Insert_Litter), Convert.ToInt16(match.Tele_Human_Throwing_Litter), Convert.ToInt16(match.Tele_Pushed_Litter_To_Landfill), match.Tele_Fouls, match.Comments, JsonConvert.SerializeObject(match.Stacks), Convert.ToInt16(match.Coopertition_Set), Convert.ToInt16(match.Coopertition_Stack), match.Final_Score_Red, match.Final_Score_Blue, match.Driver_Rating); cmd.CommandText = commandText; cmd.ExecuteNonQuery(); conn.Close(); } catch (Exception exception) { Console.Write("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); Notifications.ReportCrash(exception); } ResetScoutingInterface(); scoutingSubmitButton.Enabled = true; }