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(); Front_Picture = null; Left_Side_Picture = null; Left_Isometric_Picture = null; Other_Picture = null; pitScoutingEditorFrontPictureLabel.Text = "Front Picture:"; pitScoutingEditorSidePictureLabel.Text = "Side Picture:"; pitScoutingEditorSideIsometricPictureLabel.Text = "Side Isometric Picture:"; pitScoutingEditorOtherPictureLabel.Text = "Other Picture:"; try { object teamImage = Resources.ResourceManager.GetObject("FRC" + teamNumberArray[teamSelector.SelectedIndex]); teamInformationLogo.Image = (Image) teamImage; } catch (Exception exception) { Console.WriteLine("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_Northbay_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"]), Alliance_Colour = Convert.ToString(reader["Alliance_Colour"]), 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_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.ToBoolean(reader["Tele_Human_Throwing_Litter"]), Tele_Pushed_Litter_To_Landfill = Convert.ToBoolean(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"]), Final_Score_Red = Convert.ToInt32(reader["Final_Score_Red"]), Final_Score_Blue = Convert.ToInt32(reader["Final_Score_Blue"]), Driver_Rating = Convert.ToInt32(reader["Driver_Rating"]) }; teamsMatches.Add(match); matchBreakdownMatchList.Items.Add("Match Number: " + reader["Match_Number"]); } conn.Close(); } catch (MySqlException exception) { Console.WriteLine("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); } try { ResetPitScoutingViewerInterface(); ResetPitScoutingEditorInterface(); var conn = new MySqlConnection(MySQLMethods.MakeMySqlConnectionString()); MySqlCommand cmd = conn.CreateCommand(); MySqlDataReader reader; cmd.CommandText = String.Format("SELECT * FROM RecycleRush_Northbay_Pits WHERE Team_Number = '{0}'", Program.selectedTeamNumber); conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { var pitScout = new RecycleRush_Pit_Scouting_Team { Author = reader["Author"].ToString(), Time_Created = reader["Time_Created"].ToString(), UniqueID = reader["UniqueID"].ToString(), Team_Number = Convert.ToInt32(reader["Team_Number"]), Team_Name = reader["Team_Name"].ToString(), Drive_Train = reader["Drive_Train"].ToString(), Number_Of_Robots = Convert.ToInt32(reader["Number_Of_Robots"]), Does_It_have_A_Ramp = Convert.ToBoolean(reader["Does_It_have_A_Ramp"]), Can_It_Manipulate_Totes = Convert.ToBoolean(reader["Can_It_Manipulate_Totes"]), Can_It_Manipulate_Bins = Convert.ToBoolean(reader["Can_It_Manipulate_Bins"]), Can_It_Manipulate_Litter = Convert.ToBoolean(reader["Can_It_Manipulate_Litter"]), Needs_Special_Starting_Position = Convert.ToBoolean(reader["Needs_Special_Starting_Position"]), Special_Starting_Position = reader["Special_Starting_Position"].ToString(), Max_Stack_Height = Convert.ToInt32(reader["Max_Stack_Height"]), Max_Bin_On_Stack_Height = Convert.ToInt32(reader["Max_Bin_On_Stack_Height"]), Human_Tote_Loading = Convert.ToBoolean(reader["Human_Tote_Loading"]), Human_Litter_Loading = Convert.ToBoolean(reader["Human_Litter_Loading"]), Human_Litter_Throwing = Convert.ToBoolean(reader["Human_Litter_Throwing"]), Comments = reader["Comments"].ToString(), Front_Picture = reader["Front_Picture"] as byte[], Left_Side_Picture = reader["Left_Side_Picture"] as byte[], Left_Isometric_Picture = reader["Left_Isometric_Picture"] as byte[], Other_Picture = reader["Other_Picture"] as byte[], }; currentTeamPit = pitScout; } conn.Close(); try { pitScoutingViewerEntryInformationAuthorDisplay.Text = currentTeamPit.Author; pitScoutingViewerEntryInformationTimeCreatedDisplay.Text = currentTeamPit.Time_Created; pitScoutingViewerManipulationTotesDisplay.Text = currentTeamPit.Can_It_Manipulate_Totes.ToString(); pitScoutingViewerManipulationBinsDisplay.Text = currentTeamPit.Can_It_Manipulate_Bins.ToString(); pitScoutingViewerManipulationLitterDisplay.Text = currentTeamPit.Can_It_Manipulate_Litter.ToString(); pitScoutingViewerRobotSpecsNumRobotsDisplay.Text = currentTeamPit.Number_Of_Robots.ToString(); pitScoutingViewerRobotSpecsDriveTrainTextBox.Text = "Drive Train: " + currentTeamPit.Drive_Train; pitScoutingViewerRobotSpecsDoesItHaveARampDisplay.Text = currentTeamPit.Does_It_have_A_Ramp.ToString(); pitScoutingViewerStartingLocationDoesItNeedSpecificStartingLocationDisplay.Text = currentTeamPit.Needs_Special_Starting_Position.ToString(); pitScoutingViewerStartingLocationSpecificStartingLocationTextBox.Text = "If so where? " + currentTeamPit.Special_Starting_Position; pitScoutingViewerStackInformationMaxStackHeightDisplay.Text = currentTeamPit.Max_Stack_Height.ToString(); pitScoutingViewerStackInformationMaxHeightWithBinDisplay.Text = currentTeamPit.Max_Bin_On_Stack_Height.ToString(); pitScoutingViewerPictureBox.Image = null; pitScoutingViewerHumanInteractionToteLoadingDisplay.Text = currentTeamPit.Human_Tote_Loading.ToString(); pitScoutingViewerHumanInteractionLitterLoadingDisplay.Text = currentTeamPit.Human_Litter_Loading.ToString(); pitScoutingViewerHumanInteractionLitterThrowingDisplay.Text = currentTeamPit.Human_Litter_Throwing.ToString(); pitScoutingViewerCommentsBox.Text = "Comments: " + currentTeamPit.Comments; } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); ConsoleWindow.WriteLine("Error: " + ex.Message); } } catch (MySqlException exception) { Console.WriteLine("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); } } }
private void pitScoutingEditorSubmitButton_Click(object sender, EventArgs e) { pitScoutingEditorSubmitButton.Enabled = false; var pitScout = new RecycleRush_Pit_Scouting_Team { Author = Settings.Default.username, Time_Created = DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"), UniqueID = Guid.NewGuid().ToString(), Team_Number = currentTeamNumber, Team_Name = currentTeamName, Drive_Train = pitScoutingEditorRobotSpecsDriveTrainTextBox.Text, Number_Of_Robots = Convert.ToInt32(pitScoutingEditorRobotSpecsNumberOfRobotsNumUpDown.Value), Does_It_have_A_Ramp = pitScoutingEditorRobotSpecsDoTheyHaveARampCheckBox.Checked, Can_It_Manipulate_Totes = pitScoutingEditorManipulationTotesCheckBox.Checked, Can_It_Manipulate_Bins = pitScoutingEditorManipulationBinsCheckBox.Checked, Can_It_Manipulate_Litter = pitScoutingEditorManipulationLitterCheckBox.Checked, Needs_Special_Starting_Position = pitScoutingEditorStartingLocationSpecificLocationCheckBox.Checked, Special_Starting_Position = pitScoutingEditorStartingLocationSpecificStartingLocationTextBox.Text, Max_Stack_Height = Convert.ToInt32(pitScoutingEditorStackInformationMaxStackHeightNumUpDown.Value), Max_Bin_On_Stack_Height = Convert.ToInt32(pitScoutingEditorStackInformationMaxStackWithBinNumUpDown.Value), Human_Tote_Loading = pitScoutingEditorHumanInteractionToteLoadingCheckBox.Checked, Human_Litter_Loading = pitScoutingEditorHumanInteractionLitterLoadingCheckBox.Checked, Human_Litter_Throwing = pitScoutingEditorHumanInteractionLitterThrowingCheckBox.Checked, Comments = pitScoutingEditorCommentsTextBox.Text, Front_Picture = Front_Picture, Left_Side_Picture = Left_Side_Picture, Left_Isometric_Picture = Left_Isometric_Picture, Other_Picture = Other_Picture }; try { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\Pits"); string jsonText = JsonConvert.SerializeObject(pitScout, Formatting.Indented); string pitLocation = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\Pits\\RecycleRush_Northbay_" + currentTeamName + ".json"); File.WriteAllText(pitLocation, jsonText); } catch (Exception exception) { Console.WriteLine("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); Notifications.ReportCrash(exception); } try { //Removes entries for a team before adding new info! if (GetNumberOfPitEntriesForATeam(currentTeamNumber) == 1) { try { var conn = new MySqlConnection(MySQLMethods.MakeMySqlConnectionString()); conn.Open(); string commandText = string.Format("DELETE FROM RecycleRush_Northbay_Pits WHERE `Team_Number`='{0}';", currentTeamNumber); var cmd = new MySqlCommand(commandText, conn); cmd.ExecuteNonQuery(); conn.Close(); } catch (Exception exception) { Console.WriteLine("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); Notifications.ReportCrash(exception); } } using (var con = new MySqlConnection(MySQLMethods.MakeMySqlConnectionString())) { string query = "INSERT INTO `RecycleRush_Northbay_Pits`(`UniqueID`,`Author`,`Time_Created`,`Team_Number`,`Team_Name`,`Drive_Train`,`Number_Of_Robots`,`Can_It_Manipulate_Totes`,`Can_It_Manipulate_Bins`,`Can_It_Manipulate_Litter`,`Needs_Special_Starting_Position`,`Special_Starting_Position`,`Max_Stack_Height`,`Max_Bin_On_Stack_Height`,`Human_Tote_Loading`,`Human_Litter_Loading`,`Human_Litter_Throwing`,`Does_It_have_A_Ramp`,`Comments`,`Front_Picture`,`Left_Side_Picture`,`Left_Isometric_Picture`,`Other_Picture`)VALUES(@UniqueID,@Author,@Time_Created,@Team_Number,@Team_Name,@Drive_Train,@Number_Of_Robots,@Can_It_Manipulate_Totes,@Can_It_Manipulate_Bins,@Can_It_Manipulate_Litter,@Needs_Special_Starting_Position,@Special_Starting_Position,@Max_Stack_Height,@Max_Bin_On_Stack_Height,@Human_Tote_Loading,@Human_Litter_Loading,@Human_Litter_Throwing,@Does_It_have_A_Ramp,@Comments,@Front_Picture,@Left_Side_Picture,@Left_Isometric_Picture,@Other_Picture);"; using (var cmd = new MySqlCommand(query, con)) { cmd.Parameters.AddWithValue("@UniqueID", pitScout.UniqueID); cmd.Parameters.AddWithValue("@Author", pitScout.Author); cmd.Parameters.AddWithValue("@Time_Created", pitScout.Time_Created); cmd.Parameters.AddWithValue("@Team_Number", pitScout.Team_Number); cmd.Parameters.AddWithValue("@Team_Name", pitScout.Team_Name); cmd.Parameters.AddWithValue("@Drive_Train", pitScout.Drive_Train); cmd.Parameters.AddWithValue("@Number_Of_Robots", pitScout.Number_Of_Robots); cmd.Parameters.AddWithValue("@Can_It_Manipulate_Totes", pitScout.Can_It_Manipulate_Totes); cmd.Parameters.AddWithValue("@Can_It_Manipulate_Bins", pitScout.Can_It_Manipulate_Bins); cmd.Parameters.AddWithValue("@Can_It_Manipulate_Litter", pitScout.Can_It_Manipulate_Litter); cmd.Parameters.AddWithValue("@Needs_Special_Starting_Position", pitScout.Needs_Special_Starting_Position); cmd.Parameters.AddWithValue("@Special_Starting_Position", pitScout.Special_Starting_Position); cmd.Parameters.AddWithValue("@Max_Stack_Height", pitScout.Max_Stack_Height); cmd.Parameters.AddWithValue("@Max_Bin_On_Stack_Height", pitScout.Max_Bin_On_Stack_Height); cmd.Parameters.AddWithValue("@Human_Tote_Loading", pitScout.Human_Tote_Loading); cmd.Parameters.AddWithValue("@Human_Litter_Loading", pitScout.Human_Litter_Loading); cmd.Parameters.AddWithValue("@Human_Litter_Throwing", pitScout.Human_Litter_Throwing); cmd.Parameters.AddWithValue("@Does_It_have_A_Ramp", pitScout.Does_It_have_A_Ramp); cmd.Parameters.AddWithValue("@Comments", pitScout.Comments); cmd.Parameters.AddWithValue("@Front_Picture", pitScout.Front_Picture); cmd.Parameters.AddWithValue("@Left_Side_Picture", pitScout.Left_Side_Picture); cmd.Parameters.AddWithValue("@Left_Isometric_Picture", pitScout.Left_Isometric_Picture); cmd.Parameters.AddWithValue("@Other_Picture", pitScout.Other_Picture); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } Notifications.ShowInformationMessage("Successfully submitted pit scouting data!"); } catch (Exception exception) { Console.WriteLine("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); Notifications.ReportCrash(exception); } try { ResetPitScoutingViewerInterface(); var conn = new MySqlConnection(MySQLMethods.MakeMySqlConnectionString()); MySqlCommand cmd = conn.CreateCommand(); MySqlDataReader reader; cmd.CommandText = String.Format("SELECT * FROM RecycleRush_Northbay_Pits WHERE Team_Number = '{0}'", Program.selectedTeamNumber); conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { var currentPitScout = new RecycleRush_Pit_Scouting_Team { Author = reader["Author"].ToString(), Time_Created = reader["Time_Created"].ToString(), UniqueID = reader["UniqueID"].ToString(), Team_Number = Convert.ToInt32(reader["Team_Number"]), Team_Name = reader["Team_Name"].ToString(), Drive_Train = reader["Drive_Train"].ToString(), Number_Of_Robots = Convert.ToInt32(reader["Number_Of_Robots"]), Does_It_have_A_Ramp = Convert.ToBoolean(reader["Does_It_have_A_Ramp"]), Can_It_Manipulate_Totes = Convert.ToBoolean(reader["Can_It_Manipulate_Totes"]), Can_It_Manipulate_Bins = Convert.ToBoolean(reader["Can_It_Manipulate_Bins"]), Can_It_Manipulate_Litter = Convert.ToBoolean(reader["Can_It_Manipulate_Litter"]), Needs_Special_Starting_Position = Convert.ToBoolean(reader["Needs_Special_Starting_Position"]), Special_Starting_Position = reader["Special_Starting_Position"].ToString(), Max_Stack_Height = Convert.ToInt32(reader["Max_Stack_Height"]), Max_Bin_On_Stack_Height = Convert.ToInt32(reader["Max_Bin_On_Stack_Height"]), Human_Tote_Loading = Convert.ToBoolean(reader["Human_Tote_Loading"]), Human_Litter_Loading = Convert.ToBoolean(reader["Human_Litter_Loading"]), Human_Litter_Throwing = Convert.ToBoolean(reader["Human_Litter_Throwing"]), Comments = reader["Comments"].ToString(), Front_Picture = reader["Front_Picture"] as byte[], Left_Side_Picture = reader["Left_Side_Picture"] as byte[], Left_Isometric_Picture = reader["Left_Isometric_Picture"] as byte[], Other_Picture = reader["Other_Picture"] as byte[], }; currentTeamPit = currentPitScout; } conn.Close(); try { pitScoutingViewerEntryInformationAuthorDisplay.Text = currentTeamPit.Author; pitScoutingViewerEntryInformationTimeCreatedDisplay.Text = currentTeamPit.Time_Created; pitScoutingViewerManipulationTotesDisplay.Text = currentTeamPit.Can_It_Manipulate_Totes.ToString(); pitScoutingViewerManipulationBinsDisplay.Text = currentTeamPit.Can_It_Manipulate_Bins.ToString(); pitScoutingViewerManipulationLitterDisplay.Text = currentTeamPit.Can_It_Manipulate_Litter.ToString(); pitScoutingViewerRobotSpecsNumRobotsDisplay.Text = currentTeamPit.Number_Of_Robots.ToString(); pitScoutingViewerRobotSpecsDriveTrainTextBox.Text = "Drive Train: " + currentTeamPit.Drive_Train; pitScoutingViewerRobotSpecsDoesItHaveARampDisplay.Text = currentTeamPit.Does_It_have_A_Ramp.ToString(); pitScoutingViewerStartingLocationDoesItNeedSpecificStartingLocationDisplay.Text = currentTeamPit.Needs_Special_Starting_Position.ToString(); pitScoutingViewerStartingLocationSpecificStartingLocationTextBox.Text = "If so where? " + currentTeamPit.Special_Starting_Position; pitScoutingViewerStackInformationMaxStackHeightDisplay.Text = currentTeamPit.Max_Stack_Height.ToString(); pitScoutingViewerStackInformationMaxHeightWithBinDisplay.Text = currentTeamPit.Max_Bin_On_Stack_Height.ToString(); pitScoutingViewerPictureBox.Image = null; pitScoutingViewerHumanInteractionToteLoadingDisplay.Text = currentTeamPit.Human_Tote_Loading.ToString(); pitScoutingViewerHumanInteractionLitterLoadingDisplay.Text = currentTeamPit.Human_Litter_Loading.ToString(); pitScoutingViewerHumanInteractionLitterThrowingDisplay.Text = currentTeamPit.Human_Litter_Throwing.ToString(); pitScoutingViewerCommentsBox.Text = "Comments: " + currentTeamPit.Comments; } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); ConsoleWindow.WriteLine("Error: " + ex.Message); } } catch (MySqlException exception) { Console.WriteLine("Error Occured: " + exception.Message); ConsoleWindow.WriteLine("Error Occured: " + exception.Message); } pitScoutingEditorSubmitButton.Enabled = true; }