Beispiel #1
0
        private void testConnectionToDatabaseButton_Click(object sender, EventArgs e)
        {
            try
            {
                string mySqlConnectionString = MySQLMethods.MakeMySqlConnectionString();
                var    conn = new MySqlConnection {
                    ConnectionString = mySqlConnectionString
                };

                conn.Open();

                if (conn.Ping())
                {
                    Console.WriteLine("You have successfully connected to your database!");
                    ConsoleWindow.WriteLine("You have successfully connected to your database!");
                    connectionDisplay.BackColor = Color.Chartreuse;
                    connectionDisplay.Text      = ("Successfully Connected to Database.");
                    try
                    {
                        MySQLMethods.InitializeDatabases();
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine("Error Message: " + exception.Message);
                        ConsoleWindow.WriteLine("Error Message: " + exception.Message);
                    }
                }
                else
                {
                    Console.WriteLine("You have unsuccessfully connected to your database!");
                    ConsoleWindow.WriteLine("You have unsuccessfully connected to your database!");
                    connectionDisplay.BackColor = Color.Red;
                    connectionDisplay.Text      = ("Connection to Database Failed.");
                }

                conn.Close();
            }
            catch (MySqlException ex)
            {
                connectionDisplay.BackColor = Color.Red;
                connectionDisplay.Text      = ("Connection to Database Failed.");
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Message " + ex.Message);
                ConsoleWindow.WriteLine("Error Code: " + ex.ErrorCode);
                ConsoleWindow.WriteLine("Error Message " + ex.Message);
            }
        }
Beispiel #2
0
 private void timer_Tick(object sender, EventArgs e)
 {
     if (internetAvailable)
     {
         isInternetConnectedLabel.Text      = ("Internet Connected");
         isInternetConnectedLabel.ForeColor = Color.DarkGreen;
         ConsoleWindow.WriteLine("Internet Connected");
     }
     else
     {
         if (internetAvailable == false)
         {
             isInternetConnectedLabel.Text      = ("Internet Not Connected");
             isInternetConnectedLabel.ForeColor = Color.Red;
             ConsoleWindow.WriteLine("Internet Disconnected");
         }
     }
 }
Beispiel #3
0
 private void timer_Tick(object sender, EventArgs e)
 {
     if (Network.CheckForInternetConnection())
     {
         isInternetConnectedLabel.Text      = "Internet Connected";
         isInternetConnectedLabel.ForeColor = Color.DarkGreen;
         ConsoleWindow.WriteLine("Internet Connected");
     }
     else
     {
         if (Network.CheckForInternetConnection() == false)
         {
             isInternetConnectedLabel.Text      = "Internet Not Connected";
             isInternetConnectedLabel.ForeColor = Color.Red;
             ConsoleWindow.WriteLine("Internet Disconnected");
         }
     }
 }
Beispiel #4
0
        public static void InitializeDatabases()
        {
            try
            {
                var conn = new MySqlConnection(MakeMySqlConnectionString());
                conn.Open();
                var cmd = new MySqlCommand {
                    Connection = conn
                };
                var commands = Globals.mySQLTableCreationCommands;

                for (var i = 0; i < commands.Count; i++)
                {
                    try
                    {
                        cmd.CommandText = commands[i];
                        cmd.ExecuteNonQuery();
                        var numDone = i + 1;
                        ConsoleWindow.WriteLine("Successfully initialized: " + numDone + " of " + commands.Count);
                    }
                    catch (MySqlException error)
                    {
                        ConsoleWindow.WriteLine("Error Code: " + error.ErrorCode);
                        ConsoleWindow.WriteLine(error.Message);
                    }
                }
                conn.Close();

                //SQLiteConnection.CreateFile("database.sqlite");
                //var m_dbConnection = new SQLiteConnection("Data Source=database.sqlite;Version=3;");
                //m_dbConnection.Open();
                //string sql = "CREATE TABLE RecycleRush_NorthBay_Teams (name VARCHAR(300), teamNumber INT)";
                //var command = new SQLiteCommand(sql, m_dbConnection);
                //command.ExecuteNonQuery();
                //m_dbConnection.Close();
                //ConsoleWindow.WriteLine("Team List Database Successfully Initialized");
            }
            catch (MySqlException ex)
            {
                ConsoleWindow.WriteLine("Error Code: " + ex.ErrorCode);
                ConsoleWindow.WriteLine(ex.Message);
            }
        }
Beispiel #5
0
        private void Home_Load(object sender, EventArgs e)
        {
            ConsoleWindow.WriteLine("Started FRC_Scouting_V2_" + Assembly.GetExecutingAssembly().GetName().Version);
            internetTestTH.Start();
            timer.Start();
            eventSelector.Items.Add("RecycleRush | IRI | 2015");
            eventSelector.Items.Add("RecycleRush | Troy Athens | 2015 (Old/Debug)");

            if (Settings.Default.firstTimeLoad)
            {
                if (MessageBox.Show("Since this is the first time you have used this program please take a look at the settings page. This will prevent any headaches when trying to use the program. Do you want to be taken to the settings page now?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    var settingsPage = new MainSettings();
                    settingsPage.Show();
                    WindowState = FormWindowState.Minimized;
                }
                Settings.Default.firstTimeLoad = false;
                Settings.Default.Save();
            }

            myWebsiteRichTextBox.SelectionAlignment = HorizontalAlignment.Center;
        }
Beispiel #6
0
 private void reCacheDefaultTBADataToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("This downloads the default files needed for Offline scouting. The downloading of these files may take a long time, and these files may take up a lot of storage space. Are you sure you want to continue?", "Are you sure you want to continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes)
     {
         Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves");
         Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\DefaultData\\");
         string    basePath       = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\DefaultData\\");
         string    teamListPath   = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\DefaultData\\" + "TeamList.html");
         int       year           = 2015;
         string    yearEventsPath = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\DefaultData\\" + year + "YearEvents.html");
         WebClient client         = new WebClient();
         int[]     thousands      = { 1, 2, 3, 4, 5 };
         try
         {
             //Part 1: Cache basic team list
             for (int i = 0; i < thousands.Length; i++)
             {
                 cacheAllTeamsListOffline(client, teamListPath, thousands[i]);
             }
             //Add headers for TBA API calls
             client.Headers.Add("X-TBA-App-Id", "3710-xNovax:FRC_Scouting_V2:" + Assembly.GetExecutingAssembly().GetName().Version);
             //Part 2: Cache all of this year's events
             Uri    siteUri         = new Uri("http://www.thebluealliance.com/api/v2/events/" + year);
             byte[] siteData        = client.DownloadData(siteUri);
             string siteDataEncoded = Encoding.ASCII.GetString(siteData);
             File.WriteAllText(yearEventsPath, siteDataEncoded);
             MessageBox.Show(("Completed saving the default offline TBA data to " + basePath + "."), "Completed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         }
         catch (Exception exception)
         {
             Console.Write("Error Occured: " + exception.Message);
             ConsoleWindow.WriteLine("Error Occured: " + exception.Message);
             Notifications.ReportCrash(exception);
         }
     }
 }
Beispiel #7
0
 private void cacheOneEventsMatchTBADataToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //Only thing: Caches one matches data from one event
     Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves");
     Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\");
     try
     {
         var client = new WebClient();
         client.Headers.Add("X-TBA-App-Id", "3710-xNovax:FRC_Scouting_V2:" + Assembly.GetExecutingAssembly().GetName().Version);
         string matchKey        = Interaction.InputBox("What is the match key for the event that you want to cache?", "Get Match Key to Cache", "(year) + (cmp_) + (f1m1)", -1, -1);
         Uri    siteUri         = new Uri("http://www.thebluealliance.com/api/v2/match/" + matchKey);
         string path            = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + matchKey + "MatchInfo.html");
         byte[] siteData        = client.DownloadData(siteUri);
         string siteDataEncoded = Encoding.ASCII.GetString(siteData);
         File.WriteAllText(path, siteDataEncoded);
         MessageBox.Show(("Completed saving the data of: " + matchKey + " matches's data to " + path + "."), "Completed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     catch (Exception exception)
     {
         Console.Write("Error Occured: " + exception.Message);
         ConsoleWindow.WriteLine("Error Occured: " + exception.Message);
         Notifications.ReportCrash(exception);
     }
 }
        private void submitDataButton_Click(object sender, EventArgs e)
        {
            UpdateLabels();

            if (Settings.Default.allowExportToTextFile)
            {
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    var writer = new StreamWriter(saveFileDialog.FileName);
                    writer.WriteLine("Time Created: " + Time.GetCurrentTime());
                    writer.WriteLine("FRC_Scouting_V2 Match #: " + Convert.ToString(matchNumber));
                    writer.WriteLine("Did the robot die?: " + didRobotDie);
                    writer.WriteLine("===============================================");
                    writer.WriteLine("Team Name: " + Convert.ToString(Program.selectedTeamName));
                    writer.WriteLine("Team Number: " + Convert.ToString(Program.selectedTeamNumber));
                    writer.WriteLine("Team Color During Match: " + teamColour);
                    writer.WriteLine("===============================================");
                    writer.WriteLine();
                    writer.WriteLine("Points Scored");
                    writer.WriteLine("Auto High Tally: " + Convert.ToString(autoHighTally));
                    writer.WriteLine("Auto Low Tally: " + Convert.ToString(autoLowTally));
                    writer.WriteLine("Manually Controlled High Tally: " + Convert.ToString(controlledHighTally));
                    writer.WriteLine("Manually Controlled Low Tally: " + Convert.ToString(controlledLowTally));
                    writer.WriteLine("Hot Goals Scored: " + Convert.ToString(hotGoalTally));
                    writer.WriteLine("===============================================");
                    writer.WriteLine("Ball Control");
                    writer.WriteLine("Autonomous Ball Pickups: " + Convert.ToString(autoPickupTally));
                    writer.WriteLine("Controlled Ball Pickups: " + Convert.ToString(controlledPickupTally));
                    writer.WriteLine("Missed Pickups/Loads: " + Convert.ToString(missedPickupsTally));
                    writer.WriteLine("===============================================");
                    writer.WriteLine("Comments");
                    writer.WriteLine(Convert.ToString(comments));
                    writer.WriteLine("===============================================");
                    writer.WriteLine("Starting Location");
                    writer.WriteLine("X Starting Location: " + Convert.ToString(xStarting));
                    writer.WriteLine("Y Starting Location: " + Convert.ToString(yStarting));
                    writer.WriteLine("===============================================");
                    writer.WriteLine("END OF FILE");
                    writer.Close();
                }
            }

            //MySQL Database
            //MySQL Database Connection Info
            var 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())
                {
                    ConsoleWindow.WriteLine("The connection to your database has been made successfully.");
                }

                //Creating the MySQLCommand object
                var cmd = conn.CreateCommand();

                //Trying to create the table
                try
                {
                    var createTable =
                        string.Format(
                            "CREATE TABLE `{0}` (`EntryID` int(11) NOT NULL,`TeamName` varchar(45) NOT NULL DEFAULT 'Default', `TeamNumber` int(11) NOT NULL DEFAULT '0',`TeamColour` varchar(45) NOT NULL DEFAULT 'Default',`MatchNumber` int(11) NOT NULL DEFAULT '0',`AutoHighTally` int(11) NOT NULL DEFAULT '0',`AutoLowTally` int(11) NOT NULL DEFAULT '0',`ControlledHighTally` int(11) NOT NULL DEFAULT '0',`ControlledLowTally` int(11) NOT NULL DEFAULT '0',`HotGoalTally` int(11) NOT NULL DEFAULT '0',`AutoPickup` int(11) NOT NULL DEFAULT '0',`ControlledPickup` int(11) NOT NULL DEFAULT '0',`MissedPickups` int(11) NOT NULL DEFAULT '0',`StartingLocationX` int(11) NOT NULL DEFAULT '0',`StartingLocationY` int(11) NOT NULL DEFAULT '0',`Comments` varchar(45) DEFAULT 'No Comment',`DidRobotDie` tinyint(4) NOT NULL DEFAULT '0',PRIMARY KEY (`EntryID`)) ENGINE=InnoDB DEFAULT CHARSET=utf8",
                            Program.selectedEventName);
                    cmd.CommandText = createTable;
                    cmd.ExecuteNonQuery();
                    ConsoleWindow.WriteLine("The table: " + Program.selectedEventName + " has been created.");
                    //end of creating the table
                }
                catch (MySqlException createException)
                {
                    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);
                }

                //Submit data into the database
                var insertDataString =
                    string.Format(
                        "Insert into {0} (EntryID,TeamName,TeamNumber,TeamColour,MatchNumber,AutoHighTally,AutoLowTally,ControlledHigHTally,ControlledLowTally,HotGoalTally,AutoPickup,ControlledPickup,MissedPickups,StartingLocationX,StartingLocationY,Comments,DidRobotDie) values('{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}');",
                        Program.selectedEventName, CountRowsInDatabase() + 1,
                        Program.selectedTeamName,
                        Program.selectedTeamNumber, teamColour, matchNumber, autoHighTally, autoLowTally,
                        controlledHighTally, controlledLowTally, hotGoalTally, autoPickupTally, controlledPickupTally,
                        missedPickupsTally, xStarting, yStarting, comments, didRobotDieINT);

                cmd.CommandText = insertDataString;
                cmd.ExecuteNonQuery();

                ConsoleWindow.WriteLine("Data has been inserted into the database!");
                contextDisplayLabel.Text = "Your data has been inserted into the database!";

                //Closing the connection
                conn.Close();
                cmd.Dispose();
            }
            catch (MySqlException ex)
            {
                contextDisplayLabel.Text = "An error has occured!";
                ConsoleWindow.WriteLine("Error Code: " + ex.ErrorCode);
                ConsoleWindow.WriteLine(ex.Message);
            }
        }
Beispiel #9
0
 private void showConsoleWindowToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var Console = new ConsoleWindow();
     Console.Show();
 }
Beispiel #10
0
 private void cacheATeamsTBADataToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("This downloads the file(s) for ONE FRC team from TBA. The downloading of these file(s) may take a long time, and these files may take up a lot of storage space. Are you sure you want to continue?", "Are you sure you want to continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes)
     {
         try
         {
             Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves");
             Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\");
             getTeamNum : string teamNum = Interaction.InputBox("What is the team number for the team's info that you want to cache?", "Get Team Num's Info to Cache", "(226)", -1, -1);
             string path              = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + "Team" + (Convert.ToInt32(teamNum)) + "\\*");
             string path0             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + "Team" + (Convert.ToInt32(teamNum)) + "AllInfo.html");
             string path1             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + "Team" + (Convert.ToInt32(teamNum)) + "Info.html");
             string path2             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + "Team" + (Convert.ToInt32(teamNum)) + "AwardsAt");
             string path3             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + "Team" + (Convert.ToInt32(teamNum)) + "MatchesAt");
             string path4             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + "Team" + (Convert.ToInt32(teamNum)) + "EventsDuring");
             string path5             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + "Team" + (Convert.ToInt32(teamNum)) + "HistoricalAwards.html");
             string path6             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + "Team" + (Convert.ToInt32(teamNum)) + "HistoricalEvents.html");
             string path7             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + "Team" + (Convert.ToInt32(teamNum)) + "MediaLocationsDuring");
             string appendedUriString = "http://www.thebluealliance.com/team/" + (Convert.ToInt32(teamNum));
             TheBlueAlliance.Models.TeamInformation teamInfo = TheBlueAlliance.Teams.GetTeamInformation("frc" + (Convert.ToInt32(teamNum)));
             string tmp     = teamInfo.nickname;
             string teamKey = teamInfo.key;
             if (MessageBox.Show(("Is the team: " + tmp + " (Team " + (Convert.ToInt32(teamNum)) + "), correct?"), "Correct event?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes)
             {
                 //Part 1: Cache base (all?) info
                 Uri       siteUri         = new Uri(appendedUriString);
                 WebClient client          = new WebClient();
                 byte[]    siteData        = client.DownloadData(siteUri);
                 string    siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path0, siteDataEncoded);
                 //Add headers for TBA API
                 client.Headers.Add("X-TBA-App-Id", "3710-xNovax:FRC_Scouting_V2:" + Assembly.GetExecutingAssembly().GetName().Version);
                 //Redo: Cache basic info using the API
                 string url = ("http://www.thebluealliance.com/api/v2/team/" + teamKey);
                 siteData        = client.DownloadData(new Uri(url));
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path1, siteDataEncoded);
                 //Get event name:
                 getEventName : string eventCode = Interaction.InputBox("What is the event key for the team's info at that event that you want to cache?", "Get Event Key's Event Info to Cache", "(year) + (code)", -1, -1);
                 TheBlueAlliance.Models.Event.EventInformation eventInfo = TheBlueAlliance.Events.GetEventInformation(eventCode);
                 tmp = eventInfo.short_name;
                 if (System.String.IsNullOrWhiteSpace(tmp))
                 {
                     tmp = eventCode.ToUpper().Substring(4);
                 }
                 if (!(MessageBox.Show(("Is the event: " + tmp + " (With team Team " + (Convert.ToInt32(teamNum)) + "), correct?"), "Correct event?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes))
                 {
                     goto getEventName;
                 }
                 //Part 2: Cache a teams awards at one event
                 url = ("http://www.thebluealliance.com/api/v2/team/" + teamKey + "/event/" + eventCode + "/awards");
                 string thisPath = path2 + eventCode + ".html";
                 siteData        = client.DownloadData(new Uri(url));
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(thisPath, siteDataEncoded);
                 //Part 3: Cache a teams matches at one event
                 url = ("http://www.thebluealliance.com/api/v2/team/" + teamKey + "/event/" + eventCode +
                        "/matches");
                 thisPath        = path3 + eventCode + ".html";
                 siteData        = client.DownloadData(new Uri(url));
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(thisPath, siteDataEncoded);
                 //Part 4: Get a teams events for one year
                 string year = Interaction.InputBox("What is the year for the team's info at that event that you want to cache?", "Get Year To Cache Team Info For", "2015", -1, -1);
                 url             = ("http://www.thebluealliance.com/api/v2/team/" + teamKey + "/" + year + "/events");
                 thisPath        = path4 + year + ".html";
                 siteData        = client.DownloadData(new Uri(url));
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(thisPath, siteDataEncoded);
                 //Part 5: Get a teams media locations for one year
                 url             = ("http://www.thebluealliance.com/api/v2/team/" + teamKey + "/" + year + "/media");
                 thisPath        = path7 + year + ".html";
                 siteData        = client.DownloadData(new Uri(url));
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(thisPath, siteDataEncoded);
                 //Part 6: Get a teams historical awards
                 url             = ("http://www.thebluealliance.com/api/v2/team/" + teamKey + "/history/awards");
                 siteData        = client.DownloadData(new Uri(url));
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path5, siteDataEncoded);
                 //Part 7: Get a teams historical events
                 url             = ("http://www.thebluealliance.com/api/v2/team/" + teamKey + "/history/events");
                 siteData        = client.DownloadData(new Uri(url));
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path6, siteDataEncoded);
                 MessageBox.Show(("Completed saving the data of: " + appendedUriString + " to " + path + "."), "Completed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             }
             else
             {
                 goto getTeamNum;
             }
         }
         catch (Exception exception)
         {
             Console.Write("Error Occured: " + exception.Message);
             ConsoleWindow.WriteLine("Error Occured: " + exception.Message);
             Notifications.ReportCrash(exception);
         }
     }
 }
Beispiel #11
0
 private void cacheTBAEventData(object sender, EventArgs e)
 {
     if (MessageBox.Show("This downloads the file(s) for ONE FRC event from TBA. The downloading of these file(s) may take a long time, and these files may take up a lot of storage space. Are you sure you want to continue?", "Are you sure you want to continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes)
     {
         try
         {
             Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves");
             Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\");
             getEvent : string eventCode = Interaction.InputBox("What is the event code for the event that you want to cache?", "Get Event Info to Cache", "(year) + eventName", -1, -1);
             if (!(eventCode.Length > 4))
             {
                 goto getEvent;
             }
             string path              = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + eventCode + "\\*");
             string path0             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + eventCode + "AllInfo.html");
             string path1             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + eventCode + ".html");
             string path2             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + eventCode + "Awards.html");
             string path3             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + eventCode + "Matches.html");
             string path4             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + eventCode + "Rankings.html");
             string path5             = (AppDomain.CurrentDomain.BaseDirectory + "\\Saves\\TBA\\" + eventCode + "Teamlist.html");
             string appendedUriString = "http://www.thebluealliance.com/event/" + eventCode;
             TheBlueAlliance.Models.Event.EventInformation eventInfo = TheBlueAlliance.Events.GetEventInformation(eventCode);
             string tmp = eventInfo.short_name;
             if (System.String.IsNullOrWhiteSpace(tmp))
             {
                 tmp = eventCode.ToUpper().Substring(4);
             }
             if (MessageBox.Show(("Is the event: " + tmp + " (" + eventCode + "), correct?"), "Correct event?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes)
             {
                 Uri       siteUri = new Uri(appendedUriString);
                 WebClient client  = new WebClient();
                 //Part 1: Cache base (all?) info
                 byte[] siteData        = client.DownloadData(siteUri);
                 string siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path0, siteDataEncoded);
                 //Add headers for TBA API calls
                 client.Headers.Add("X-TBA-App-Id", "3710-xNovax:FRC_Scouting_V2:" + Assembly.GetExecutingAssembly().GetName().Version);
                 //Redo: Cache basic info using the API
                 siteUri         = new Uri("http://www.thebluealliance.com/api/v2/event/" + eventCode);
                 siteData        = client.DownloadData(siteUri);
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path1, siteDataEncoded);
                 //Part 2: Cache event awards
                 siteUri         = new Uri("http://www.thebluealliance.com/api/v2/event/" + eventCode + "/awards");
                 siteData        = client.DownloadData(siteUri);
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path2, siteDataEncoded);
                 //Part 3: Cache event matches
                 siteUri         = new Uri("http://www.thebluealliance.com/api/v2/event/" + eventCode + "/matches");
                 siteData        = client.DownloadData(siteUri);
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path3, siteDataEncoded);
                 //Part 4: Cache event rankings
                 siteUri         = new Uri("http://www.thebluealliance.com/api/v2/event/" + eventCode + "/rankings");
                 siteData        = client.DownloadData(siteUri);
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path4, siteDataEncoded);
                 //Part 5: Cache event team list
                 siteUri         = new Uri("http://www.thebluealliance.com/api/v2/event/" + eventCode + "/teams");
                 siteData        = client.DownloadData(siteUri);
                 siteDataEncoded = Encoding.ASCII.GetString(siteData);
                 File.WriteAllText(path5, siteDataEncoded);
                 MessageBox.Show(("Completed saving the data of: " + tmp + " event's data to " + path + "."), "Completed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             }
             else
             {
                 goto getEvent;
             }
         }
         catch (Exception exception)
         {
             Console.Write("Error Occured: " + exception.Message);
             ConsoleWindow.WriteLine("Error Occured: " + exception.Message);
             Notifications.ReportCrash(exception);
         }
     }
 }
Beispiel #12
0
        private void showConsoleWindowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var Console = new ConsoleWindow();

            Console.Show();
        }
Beispiel #13
0
        private void MainSettings_Load(object sender, EventArgs e)
        {
            if (Settings.Default.clickToEmptyTextBoxes)
            {
                clickEmptyTextBoxChecker.Checked = true;
            }
            else
            {
                if (Settings.Default.clickToEmptyTextBoxes == false)
                {
                    clickEmptyTextBoxChecker.Checked = false;
                }
            }

            if (Settings.Default.minimizeHomeWentEventLoads)
            {
                minimizeHomeCheckbox.Checked = true;
            }
            else
            {
                if (Settings.Default.minimizeHomeWentEventLoads == false)
                {
                    minimizeHomeCheckbox.Checked = false;
                }
            }

            if (Settings.Default.clearConsoleOnToggle)
            {
                clearConsoleOnToggleCheckBox.Checked = true;
            }
            else
            {
                if (Settings.Default.clearConsoleOnToggle == false)
                {
                    clearConsoleOnToggleCheckBox.Checked = false;
                }
            }

            if (Settings.Default.allowExportToTextFile)
            {
                allowExportToTextFileCheckBox.Checked = true;
            }
            else
            {
                if (Settings.Default.allowExportToTextFile == false)
                {
                    allowExportToTextFileCheckBox.Checked = false;
                }
            }

            if (Settings.Default.showQuestionButtons)
            {
                showQuestionButtonsCheckBox.Checked = true;
            }
            else
            {
                if (Settings.Default.showQuestionButtons == false)
                {
                    showQuestionButtonsCheckBox.Checked = false;
                }
            }

            if (Settings.Default.colourTeamComparisonStatistics)
            {
                colourTeamComparisonStatisticsCheckBox.Checked = true;
            }
            else
            {
                if (Settings.Default.colourTeamComparisonStatistics == false)
                {
                    colourTeamComparisonStatisticsCheckBox.Checked = false;
                }
            }

            teamComparisonEqualValueColourDisplay.BackColor = Settings.Default.teamComparisonEqualValueColour;
            usernameTextBox.Text         = Settings.Default.username;
            databaseIPTextBox.Text       = Settings.Default.databaseIP;
            databasePortTextBox.Text     = Settings.Default.databasePort;
            databaseUsernameTextBox.Text = Settings.Default.databaseUsername;
            databasePasswordTextBox.Text = Security.DeCryptString(Settings.Default.databasePassword);
            databaseNameTextBox.Text     = Settings.Default.databaseName;

            try
            {
                string mySqlConnectionString = MySQLMethods.MakeMySqlConnectionString();
                var    conn = new MySqlConnection {
                    ConnectionString = mySqlConnectionString
                };

                conn.Open();

                if (conn.Ping())
                {
                    Console.WriteLine("You have successfully connected to your database!");
                    ConsoleWindow.WriteLine("You have successfully connected to your database!");
                    connectionDisplay.BackColor = Color.Chartreuse;
                    connectionDisplay.Text      = ("Successfully Connected to Database.");
                }
                else
                {
                    Console.WriteLine("You have unsuccessfully connected to your database!");
                    ConsoleWindow.WriteLine("You have unsuccessfully connected to your database!");
                    connectionDisplay.BackColor = Color.Red;
                    connectionDisplay.Text      = ("Connection to Database Failed.");
                }

                conn.Close();
            }
            catch (MySqlException ex)
            {
                connectionDisplay.BackColor = Color.Red;
                connectionDisplay.Text      = ("Connection to Database Failed.");
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Message " + ex.Message);
                ConsoleWindow.WriteLine("Error Code: " + ex.ErrorCode);
                ConsoleWindow.WriteLine("Error Message " + ex.Message);
            }
        }
Beispiel #14
0
 private void Home_FormClosing(object sender, FormClosingEventArgs e)
 {
     ConsoleWindow.ExportToCSV_Timestamp();
 }