using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Xml; using System.Diagnostics; using System.IO; // File Read/Write using System.Collections; namespace NCAABK { public partial class Form1 : Form { // Store the Game IDs here and make available to all classes ArrayList totalGameIDs = new ArrayList(); public Form1() { // the array of game IDs string totalGameIDsString; // fox feed containing dates of play string feedstring_dates = "CBK.XML"; //"http://feeds.foxsports.com/scores/CBK.XML"; // for parsing the Fox XML feeds XmlDocument document = new XmlDocument(); document.Load(feedstring_dates); // Select the Node Hierarchy XmlNodeList gameIDs = document.SelectNodes("//game"); // Total of all game IDs for the game, populate the ArrayList foreach (XmlElement game_ids in gameIDs) { // check for NULL exception ... // Iterate and get a single game ID totalGameIDsString = game_ids.GetAttribute("gameId"); // Store Game ID into an ArrayList totalGameIDs.Add(totalGameIDsString); //totalGameIDs.Add("200803300349"); //totalGameIDs.Add("200703150173"); } // For Testing Only // totalGameIDs[0] = "200803300349"; InitializeComponent(); } // END CONSTRUCTOR private void button1_Click(object sender, EventArgs e) { // Call entry point constructor to initiate the Game IDs //EntryPoint ep = new EntryPoint(); // this is the Feed String from FoxSports, pass it to all the Stats Methods // the Game ID is passed from an Array of Game IDs string feedstring; // Instantiate GameStats class, this is where all methods are located for // analyzing the game stats GameStats gs = new GameStats(); // Open a tab delimited text file to write test results to FileStream SpreadSheetFileRW = new FileStream(@"troy.xls", FileMode.Create, FileAccess.Write); // Create a File Stream Writer StreamWriter sw; // Prepare the SpreadSheet file for writing, pass this handle to the methods sw = new StreamWriter(SpreadSheetFileRW); // Total of all game IDs for the game foreach (string gid in totalGameIDs) { // This feedstring contains the game stats and requires that a Game ID // be appended to it // For Example: "http://feeds.foxsports.com/nugget/42_200803300349" feedstring = "http://feeds.foxsports.com/nugget/42_" + gid; // Show the feed in the Spreadsheet for test results gs.ShowFoxSportsXMLFeed(feedstring, sw, listBox1); /// Handle Rebounds /// gs.GetVisitingTeamRebounds(feedstring, sw, listBox1); gs.AnalyzeVisitingTeamRebounds(gid, sw, listBox1); // ep.totalGameIDs[count], sw); //Console.WriteLine("\n\n"); gs.GetHomeTeamRebounds(feedstring, sw, listBox1); gs.AnalyzeHomeTeamRebounds(gid, sw, listBox1); // ep.totalGameIDs[count], sw); //Console.WriteLine("\n\n"); /// Handle Assists /// gs.GetVisitingTeamAssists(feedstring, sw, listBox1); gs.AnalyzeVisitingTeamAssists(gid, sw, listBox1); // ep.totalGameIDs[count], sw); //Console.WriteLine("\n\n"); gs.GetHomeTeamAssists(feedstring, sw, listBox1); gs.AnalyzeHomeTeamAssists(gid, sw, listBox1); // ep.totalGameIDs[count], sw); //Console.WriteLine("\n\n"); /// Handle Points /// gs.GetVisitingTeamPoints(feedstring, sw, listBox1); gs.AnalyzeVisitingTeamPoints(gid, sw, listBox1); // ep.totalGameIDs[count], sw); //Console.WriteLine("\n\n"); gs.GetHomeTeamPoints(feedstring, sw, listBox1); gs.AnalyzeHomeTeamPoints(gid, sw, listBox1); // ep.totalGameIDs[count], sw);// was gameID ... see above //Console.WriteLine("\n\n"); /// Reset all Variables to -1 between passes /// this flags an instance where a feed has no assists/rebounds/points data /// and doesn't populate the variable, this it would leave the old value in place /// unless I change it to -1 between passes. This -1 tells me there was a feed problem gs.ResetVariables(); } // Close the Spreadsheet after all writing is complete sw.Close(); } private void QuitButton_Click(object sender, EventArgs e) { Close(); } } /// /// Opens an XML file to retrieve the Game Stats and Player Stats for a NCAABK game. /// public class GameStats { // Rebounds int totalVisitingTeamOffensiveRebounds; int totalVisitingTeamDefensiveRebounds; int totalVisitingTeamRebounds; // as reported by XML file int totalSumVisitingTeamRebounds; // as summed individually int totalHomeTeamOffensiveRebounds; int totalHomeTeamDefensiveRebounds; int totalHomeTeamRebounds; // as reported by XML file int totalSumHomeTeamRebounds; // as summed individually // Assists int totalVisitingTeamPlayerAssists; int totalVisitingTeamAssists; int totalSumVisitingTeamAssists; int totalHomeTeamPlayerAssists; int totalHomeTeamAssists; int totalSumHomeTeamAssists; // Points int totalVisitingTeamPlayerPoints; int totalVisitingTeamPoints; int totalSumVisitingTeamPoints; int totalHomeTeamPlayerPoints; int totalHomeTeamPoints; int totalSumHomeTeamPoints; #region Show Feedstring in Spreadsheet // Show the Feed String at the top of the document public void ShowFoxSportsXMLFeed(string feedstring, StreamWriter sw, ListBox lb) { sw.WriteLine(feedstring); sw.WriteLine(); lb.Items.Add(feedstring); lb.Items.Add(""); } #endregion #region RunWebBrowser() to display error pages // Pass in the CFID from the Analyze Method to determine visiting and home teams // CFID = 1 for home teams and 2 for visiting teams // append this to the webBrowserSuffixString public void RunBrowser(string gameid, string cfid, StreamWriter sw, ListBox lb) { // Build a string to pass to the web browser with the offending GameID embedded. // This will be the sports site being tested on (msn-ppe, msn-int, etc.) string webBrowserPrefixString = "http://sports.mobile.msn-ppe.com/en-us/ncaabk/gt/stats.aspx?gmid="; string gameID = gameid; string webBrowserSuffixString = "&tid=&tsid=" + cfid; // the cfid is the home and visiting team ID // and is equal to &cfid=1 or &cfid=2 respectively // The Fox Sports Game Feed for CBK "nugget/42_" string feedStringPrefix = "http://feeds.foxsports.com/nugget/42_"; string feedString = feedStringPrefix + gameID; // REMOVE TO HAVE WEB BROWSER SHOW PAGES WITH ERRORS // This can cause several pages to load and can be annoying // Process WebBrowser; // WebBrowser = Process.Start("iexplore.exe", webBrowserPrefixString + gameID + webBrowserSuffixString); // WebBrowser.Close(); // write the URL of the bad page to the SpreadSheet sw.Write(webBrowserPrefixString + gameID + webBrowserSuffixString + "\n\n"); lb.Items.Add(webBrowserPrefixString + gameID + webBrowserSuffixString); lb.Items.Add(""); lb.Items.Add(""); } #endregion #region Get Visiting Team Rebounds // Get the rebounds for the Visiting Team public void GetVisitingTeamRebounds(string feedString, StreamWriter sw, ListBox lb) { // Visiting Offensive and Defensive Rebounds int totalVOR = 0; int totalVDR = 0; XmlDocument document = new XmlDocument(); document.Load(feedString); // Select the Node Hierarchy XmlNodeList reboundsTotal = document.SelectNodes("//visiting-team-stats/rebounds"); // Total of all rebounds for the game foreach (XmlElement item in reboundsTotal) { totalVisitingTeamRebounds = Int32.Parse(item.GetAttribute("total")); Console.WriteLine("Total Visiting Team Rebounds, Offensive and Defensive = {0}", totalVisitingTeamRebounds); // Write to the SpreadSheet sw.WriteLine("Total Visiting Team Rebounds, Offensive and Defensive = {0}", totalVisitingTeamRebounds); lb.Items.Add("Total Visiting Team Rebounds, Offensive and Defensive = " + totalVisitingTeamRebounds.ToString()); } // Select the Node Hierarchy Visiting Player Rebounds XmlNodeList rebounds = document.SelectNodes("//visiting-player-stats/rebounds"); // Total individual Visiting Team Offensive Rebounds Console.WriteLine("\n[Visiting Team Offensive Rebounds]"); sw.WriteLine("[Visiting Team Offensive Rebounds]"); lb.Items.Add("[Visiting Team Offensive Rebounds]"); foreach (XmlElement item in rebounds) { // Get an individual rebound totalVisitingTeamOffensiveRebounds = Int32.Parse(item.GetAttribute("offensive")); // Write it to the Console Console.Write("{0} ", totalVisitingTeamOffensiveRebounds); // Write it to a SpreadSheet file //sw.Write("{0} ", totalVisitingTeamOffensiveRebounds); // And get a running Total totalVOR += totalVisitingTeamOffensiveRebounds; } // Write a newline in Spreadsheet for formatting //sw.Write("\n"); Console.WriteLine("Total Offensive Rebounds = {0}", totalVOR); sw.WriteLine("Total Offensive Rebounds = {0}", totalVOR); lb.Items.Add("Total Offensive Rebounds = " + totalVOR.ToString()); // Total individual Visiting Team Defensive Rebounds Console.WriteLine("\n[Visiting Team Defensive Rebounds]"); sw.WriteLine("[Visiting Team Defensive Rebounds]"); lb.Items.Add("[Visiting Team Defensive Rebounds]"); foreach (XmlElement item in rebounds) { totalVisitingTeamDefensiveRebounds = Int32.Parse(item.GetAttribute("defensive")); // Write it to the Console Console.Write("{0} ", totalVisitingTeamDefensiveRebounds); // Write it to a SpreadSheet file //sw.Write("{0} ", totalVisitingTeamDefensiveRebounds); // And get a running Total totalVDR += totalVisitingTeamDefensiveRebounds; } // Write a newline in Spreadsheet for formatting //sw.Write("\n"); Console.WriteLine("Total Defensive Rebounds = {0}", totalVDR); sw.WriteLine("Total Defensive Rebounds = {0}", totalVDR); lb.Items.Add("Total Defensive Rebounds = " + totalVDR.ToString()); // Add the accumulated rebounds together for the sum total totalSumVisitingTeamRebounds = totalVOR + totalVDR; } #endregion #region Get Home Team Rebounds // Get the rebounds for the Home Team public void GetHomeTeamRebounds(string feedString, StreamWriter sw, ListBox lb) { // Home Offensive and Defensive Rebounds int totalHOR = 0; int totalHDR = 0; XmlDocument document = new XmlDocument(); document.Load(feedString); // Select the Node Hierarchy XmlNodeList reboundsTotal = document.SelectNodes("//home-team-stats/rebounds"); // Total of all rebounds for the game foreach (XmlElement item in reboundsTotal) { totalHomeTeamRebounds = Int32.Parse(item.GetAttribute("total")); Console.WriteLine("Total Home Team Rebounds, Offensive and Defensive = {0}", totalHomeTeamRebounds); sw.WriteLine("Total Home Team Rebounds, Offensive and Defensive = {0}", totalHomeTeamRebounds); lb.Items.Add("Total Home Team Rebounds, Offensive and Defensive = " + totalHomeTeamRebounds.ToString()); } // Select the Node Hierarchy XmlNodeList rebounds = document.SelectNodes("//home-player-stats/rebounds"); // Total individual Home Team Offensive Rebounds Console.WriteLine("\n[Home Team Offensive Rebounds]"); sw.WriteLine("[Home Team Offensive Rebounds]"); lb.Items.Add("[Home Team Offensive Rebounds]"); foreach (XmlElement item in rebounds) { totalHomeTeamOffensiveRebounds = Int32.Parse(item.GetAttribute("offensive")); Console.Write("{0} ", totalHomeTeamOffensiveRebounds); // Write it to a SpreadSheet file //sw.Write("{0} ", totalHomeTeamOffensiveRebounds); totalHOR += totalHomeTeamOffensiveRebounds; } // Write a newline in Spreadsheet for formatting //sw.Write("\n"); Console.WriteLine("Total Offensive Rebounds = {0}", totalHOR); sw.WriteLine("Total Offensive Rebounds = {0}", totalHOR); lb.Items.Add("Total Offensive Rebounds = " + totalHOR.ToString()); // Total individual Home Team Defensive Rebounds Console.WriteLine("\n[Home Team Defensive Rebounds]"); sw.WriteLine("[Home Team Defensive Rebounds]"); lb.Items.Add("[Home Team Defensive Rebounds]"); foreach (XmlElement item in rebounds) { totalHomeTeamDefensiveRebounds = Int32.Parse(item.GetAttribute("defensive")); Console.Write("{0} ", totalHomeTeamDefensiveRebounds); // Write it to a SpreadSheet file //sw.Write("{0} ", totalHomeTeamDefensiveRebounds); totalHDR += totalHomeTeamDefensiveRebounds; } // Write a newline in Spreadsheet for formatting //sw.Write("\n"); Console.WriteLine("Total Defensive Rebounds = {0}", totalHDR); sw.WriteLine("Total Defensive Rebounds = {0}", totalHDR); lb.Items.Add("Total Defensive Rebounds = " + totalHDR.ToString()); // Add the accumulated rebounds together for the sum total totalSumHomeTeamRebounds = totalHOR + totalHDR; } #endregion #region Analyze the Rebounds for Home and Visiting Teams // Analyze Rebounds for Home and Visiting Teams public void AnalyzeVisitingTeamRebounds(string gameid, StreamWriter sw, ListBox lb) { // This show the stats for cfid = 1 => Visiting Team string cfid = "&cfid=1"; if (totalSumVisitingTeamRebounds != totalVisitingTeamRebounds) { Console.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumVisitingTeamRebounds, totalVisitingTeamRebounds); sw.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumVisitingTeamRebounds, totalVisitingTeamRebounds); lb.Items.Add("Sum = " + totalSumVisitingTeamRebounds.ToString() + "Total = " + totalVisitingTeamRebounds.ToString() + "... FAIL"); RunBrowser(gameid, cfid, sw, lb); } else { Console.WriteLine("\n{0} = {1} -> PASS", totalSumVisitingTeamRebounds, totalVisitingTeamRebounds); sw.WriteLine("\n{0} = {1} -> PASS", totalSumVisitingTeamRebounds, totalVisitingTeamRebounds); lb.Items.Add(totalSumVisitingTeamRebounds.ToString() + "=" + totalVisitingTeamRebounds.ToString() + "-> PASS"); } sw.WriteLine("\n\n"); lb.Items.Add(""); lb.Items.Add(""); } public void AnalyzeHomeTeamRebounds(string gameid, StreamWriter sw, ListBox lb) { // This show the stats for cfid = 2 => Home Team string cfid = "&cfid=2"; if (totalSumHomeTeamRebounds != totalHomeTeamRebounds) { Console.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumHomeTeamRebounds, totalHomeTeamRebounds); sw.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumHomeTeamRebounds, totalHomeTeamRebounds); lb.Items.Add("Sum = " + totalSumHomeTeamRebounds.ToString() + "Total = " + totalHomeTeamRebounds.ToString() + "... FAIL"); RunBrowser(gameid, cfid, sw, lb); } else { Console.WriteLine("\n{0} = {1} -> PASS", totalSumHomeTeamRebounds, totalHomeTeamRebounds); sw.WriteLine("\n{0} = {1} -> PASS", totalSumHomeTeamRebounds, totalHomeTeamRebounds); lb.Items.Add(totalSumHomeTeamRebounds.ToString() + "=" + totalHomeTeamRebounds.ToString() + "-> PASS"); } sw.WriteLine("\n\n"); lb.Items.Add(""); lb.Items.Add(""); } #endregion #region Get Visiting Team Assists // Get the assists for the Visiting Team public void GetVisitingTeamAssists(string feedString, StreamWriter sw, ListBox lb) { // Visiting Team Assists int totalVA = 0; XmlDocument document = new XmlDocument(); document.Load(feedString); // Select the Node Hierarchy XmlNodeList assistsTotal = document.SelectNodes("//visiting-team-stats/assists"); // Total of all assists for the game foreach (XmlElement item in assistsTotal) { totalVisitingTeamAssists = Int32.Parse(item.GetAttribute("assists")); Console.WriteLine("Total Visiting Team Assists = {0}\n", totalVisitingTeamAssists); sw.WriteLine("Total Visiting Team Assists = {0}", totalVisitingTeamAssists); lb.Items.Add("Total Visiting Team Assists = " + totalVisitingTeamAssists.ToString()); } // Select the Node Hierarchy XmlNodeList assists = document.SelectNodes("//visiting-player-stats/assists"); // Total individual Visiting Team Assists Console.WriteLine("[Visiting Team Assists]"); sw.WriteLine("[Visiting Team Assists]"); lb.Items.Add("[Visiting Team Assists]"); foreach (XmlElement item in assists) { totalVisitingTeamPlayerAssists = Int32.Parse(item.GetAttribute("assists")); Console.Write("{0} ", totalVisitingTeamPlayerAssists); //sw.Write("{0} ", totalVisitingTeamPlayerAssists); totalVA += totalVisitingTeamPlayerAssists; } Console.WriteLine("Total Visiting Team Player Assists = {0}", totalVA); sw.WriteLine("Total Visiting Team Player Assists = {0}", totalVA); lb.Items.Add("Total Visiting Team Player Assists = " + totalVA.ToString()); // Add the accumulated assists together for the sum total totalSumVisitingTeamAssists = totalVA; } #endregion #region Get Home Team Assists // Get the assists for the Home Team public void GetHomeTeamAssists(string feedString, StreamWriter sw, ListBox lb) { // Home Team Assists int totalHA = 0; XmlDocument document = new XmlDocument(); document.Load(feedString); // Select the Node Hierarchy XmlNodeList assistsTotal = document.SelectNodes("//home-team-stats/assists"); // Total of all assists for the game foreach (XmlElement item in assistsTotal) { totalHomeTeamAssists = Int32.Parse(item.GetAttribute("assists")); Console.WriteLine("Total Home Team Assists = {0}\n", totalHomeTeamAssists); sw.WriteLine("Total Home Team Assists = {0}", totalHomeTeamAssists); lb.Items.Add("Total Home Team Assists = " + totalHomeTeamAssists.ToString()); } // Select the Node Hierarchy XmlNodeList assists = document.SelectNodes("//home-player-stats/assists"); // Total individual Home Team Assists Console.WriteLine("[Home Team Assists]"); sw.WriteLine("[Home Team Assists]"); lb.Items.Add("[Home Team Assists]"); foreach (XmlElement item in assists) { totalHomeTeamPlayerAssists = Int32.Parse(item.GetAttribute("assists")); Console.Write("{0} ", totalHomeTeamPlayerAssists); //sw.Write("{0} ", totalHomeTeamPlayerAssists); totalHA += totalHomeTeamPlayerAssists; } Console.WriteLine("Total Home Team Player Assists = {0}", totalHA); sw.WriteLine("Total Home Team Player Assists = {0}", totalHA); lb.Items.Add("Total Home Team Player Assists = " + totalHA.ToString()); // Add the accumulated assists together for the sum total totalSumHomeTeamAssists = totalHA; } #endregion #region Analyze the Assists for Home and Visiting Teams // Analyze Assists for Home and Visiting Teams public void AnalyzeVisitingTeamAssists(string gameid, StreamWriter sw, ListBox lb) { // This show the stats for cfid = 1 => Visiting Team string cfid = "&cfid=1"; if (totalSumVisitingTeamAssists != totalVisitingTeamAssists) { Console.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumVisitingTeamAssists, totalVisitingTeamAssists); sw.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumVisitingTeamAssists, totalVisitingTeamAssists); lb.Items.Add("Sum = " + totalSumVisitingTeamAssists.ToString() + "Total = " + totalVisitingTeamAssists.ToString() + "... FAIL"); RunBrowser(gameid, cfid, sw, lb); } else { Console.WriteLine("\n{0} = {1} -> PASS", totalSumVisitingTeamAssists, totalVisitingTeamAssists); sw.WriteLine("\n{0} = {1} -> PASS", totalSumVisitingTeamAssists, totalVisitingTeamAssists); lb.Items.Add(totalSumVisitingTeamAssists.ToString() + "=" + totalVisitingTeamAssists.ToString() + "-> PASS"); } sw.WriteLine("\n\n"); lb.Items.Add(""); lb.Items.Add(""); } public void AnalyzeHomeTeamAssists(string gameid, StreamWriter sw, ListBox lb) { // This show the stats for cfid = 2 => Home Team string cfid = "&cfid=2"; if (totalSumHomeTeamAssists != totalHomeTeamAssists) { Console.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumHomeTeamAssists, totalHomeTeamAssists); sw.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumHomeTeamAssists, totalHomeTeamAssists); lb.Items.Add("Sum = " + totalSumHomeTeamAssists.ToString() + "Total = " + totalHomeTeamAssists.ToString() + "... FAIL"); RunBrowser(gameid, cfid, sw, lb); } else { Console.WriteLine("\n{0} = {1} -> PASS", totalSumHomeTeamAssists, totalHomeTeamAssists); sw.WriteLine("\n{0} = {1} -> PASS", totalSumHomeTeamAssists, totalHomeTeamAssists); lb.Items.Add(totalSumHomeTeamAssists.ToString() + "=" + totalHomeTeamAssists.ToString() + "-> PASS"); } sw.WriteLine("\n\n"); lb.Items.Add(""); lb.Items.Add(""); } #endregion #region Get Visiting Team Points // Get the points for the Visiting Team public void GetVisitingTeamPoints(string feedString, StreamWriter sw, ListBox lb) { // Visiting Team Points int totalVP = 0; XmlDocument document = new XmlDocument(); document.Load(feedString); // Select the Node Hierarchy XmlNodeList pointsTotal = document.SelectNodes("//visiting-team-stats/points"); // Total of all points for the game foreach (XmlElement item in pointsTotal) { totalVisitingTeamPoints = Int32.Parse(item.GetAttribute("points")); Console.WriteLine("Total Visiting Team Points = {0} ", totalVisitingTeamPoints); sw.WriteLine("Total Visiting Team Points = {0} ", totalVisitingTeamPoints); lb.Items.Add("Total Visiting Team Points = " + totalVisitingTeamPoints.ToString()); } // Select the Node Hierarchy XmlNodeList points = document.SelectNodes("//visiting-player-stats/points"); // Total individual Visiting Team Points Console.WriteLine("\n[Visiting Team Points]"); sw.WriteLine("[Visiting Team Points]"); lb.Items.Add("[Visiting Team Points]"); foreach (XmlElement item in points) { totalVisitingTeamPlayerPoints = Int32.Parse(item.GetAttribute("points")); Console.Write("{0} ", totalVisitingTeamPlayerPoints); //sw.Write("{0} ", totalVisitingTeamPlayerPoints); totalVP += totalVisitingTeamPlayerPoints; } Console.WriteLine("Total Visiting Team Player Points = {0}", totalVP); sw.WriteLine("Total Visiting Team Player Points = {0}", totalVP); lb.Items.Add("Total Visiting Team Player Points = " + totalVP.ToString()); // Add the accumulated assists together for the sum total totalSumVisitingTeamPoints = totalVP; } #endregion #region Get Home Team Points // Get the points for the Home Team public void GetHomeTeamPoints(string feedString, StreamWriter sw, ListBox lb) { // Home Team Points int totalHP = 0; XmlDocument document = new XmlDocument(); document.Load(feedString); // Select the Node Hierarchy XmlNodeList pointsTotal = document.SelectNodes("//home-team-stats/points"); // Total of all points for the game foreach (XmlElement item in pointsTotal) { totalHomeTeamPoints = Int32.Parse(item.GetAttribute("points")); Console.WriteLine("Total Home Team Points = {0} ", totalHomeTeamPoints); sw.WriteLine("Total Home Team Points = {0} ", totalHomeTeamPoints); lb.Items.Add("Total Home Team Points = " + totalHomeTeamPoints.ToString()); } // Select the Node Hierarchy XmlNodeList points = document.SelectNodes("//home-player-stats/points"); // Total individual Home Team Points Console.WriteLine("\n[Home Team Points]"); sw.WriteLine("[Home Team Points]"); lb.Items.Add("[Home Team Points]"); foreach (XmlElement item in points) { totalHomeTeamPlayerPoints = Int32.Parse(item.GetAttribute("points")); Console.Write("{0} ", totalHomeTeamPlayerPoints); //sw.Write("{0} ", totalHomeTeamPlayerPoints); totalHP += totalHomeTeamPlayerPoints; } Console.WriteLine("Total Home Team Player Points = {0}", totalHP); sw.WriteLine("Total Home Team Player Points = {0}", totalHP); lb.Items.Add("Total Home Team Player Points = " + totalHP.ToString()); // Add the accumulated points together for the sum total totalSumHomeTeamPoints = totalHP; } #endregion #region Analyze the Points for Home and Visiting Teams // Analyze Points for Home and Visiting Teams public void AnalyzeVisitingTeamPoints(string gameid, StreamWriter sw, ListBox lb) { // This show the stats for cfid = 1 => Visiting Team string cfid = "&cfid=1"; if (totalSumVisitingTeamPoints != totalVisitingTeamPoints) { Console.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumVisitingTeamPoints, totalVisitingTeamPoints); sw.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumVisitingTeamPoints, totalVisitingTeamPoints); lb.Items.Add("Sum = " + totalSumVisitingTeamPoints.ToString() + "Total =" + totalVisitingTeamPoints.ToString() + "... FAIL"); RunBrowser(gameid, cfid, sw, lb); } else { Console.WriteLine("\n{0} = {1} -> PASS", totalSumVisitingTeamPoints, totalVisitingTeamPoints); sw.WriteLine("\n{0} = {1} -> PASS", totalSumVisitingTeamPoints, totalVisitingTeamPoints); lb.Items.Add(totalSumVisitingTeamPoints.ToString() + "=" + totalVisitingTeamPoints.ToString() + "-> PASS"); } sw.WriteLine("\n\n"); lb.Items.Add(""); lb.Items.Add(""); } public void AnalyzeHomeTeamPoints(string gameid, StreamWriter sw, ListBox lb) { // This show the stats for cfid = 2 => Home Team string cfid = "&cfid=2"; if (totalSumHomeTeamPoints != totalHomeTeamPoints) { Console.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumHomeTeamPoints, totalHomeTeamPoints); sw.WriteLine("\nSum = {0}, Total = {1} ... FAIL", totalSumHomeTeamPoints, totalHomeTeamPoints); lb.Items.Add("Sum = " + totalSumHomeTeamPoints.ToString() + "total =" + totalHomeTeamPoints.ToString() + "... FAIL"); RunBrowser(gameid, cfid, sw, lb); } else { Console.WriteLine("\n{0} = {1} -> PASS", totalSumHomeTeamPoints, totalHomeTeamPoints); sw.WriteLine("\n{0} = {1} -> PASS", totalSumHomeTeamPoints, totalHomeTeamPoints); lb.Items.Add(totalSumHomeTeamPoints.ToString() + "=" + totalHomeTeamPoints.ToString() + "-> PASS"); } sw.WriteLine("\n\n"); lb.Items.Add(""); lb.Items.Add(""); } #endregion public void ResetVariables() { // Rebounds totalVisitingTeamOffensiveRebounds = -1; totalVisitingTeamDefensiveRebounds = -1; totalVisitingTeamRebounds = -1; // as reported by XML file totalSumVisitingTeamRebounds = -1; // as summed individually totalHomeTeamOffensiveRebounds = -1; totalHomeTeamDefensiveRebounds = -1; totalHomeTeamRebounds = -1; // as reported by XML file totalSumHomeTeamRebounds = -1; // as summed individually // Assists totalVisitingTeamPlayerAssists = -1; totalVisitingTeamAssists = -1; totalSumVisitingTeamAssists = -1; totalHomeTeamPlayerAssists = -1; totalHomeTeamAssists = -1; totalSumHomeTeamAssists = -1; // Points totalVisitingTeamPlayerPoints = -1; totalVisitingTeamPoints = -1; totalSumVisitingTeamPoints = -1; totalHomeTeamPlayerPoints = -1; totalHomeTeamPoints = -1; totalSumHomeTeamPoints = -1; } } }