private void ProcessGameLine(string line, Week weekData) { string[] raw = line.Split(','); if (raw.Length == 2) { Game gameData = new Game(); gameData.Week = weekData; weekData.Games.Add(gameData); TeamScore homeScoreData = new TeamScore(); homeScoreData.Game = gameData; ProcessTeam(raw[0], homeScoreData, 0); gameData.Home = homeScoreData; TeamScore awayScoreData = new TeamScore(); awayScoreData.Game = gameData; ProcessTeam(raw[1], awayScoreData, 1); gameData.Away = awayScoreData; } else { if (line.Contains("@") || line.Contains(" v ") || line.Contains(" v. ")) { return; } throw new Exception(); } }
private void ProcessTeam(string teamline, TeamScore scoreData, int pos) { string raw = teamline.Trim(); int scoreIndex = raw.Length; while (char.IsDigit(raw[--scoreIndex])) { ; } scoreIndex++; string team = raw.Substring(0, scoreIndex).Trim(); string score = raw.Substring(scoreIndex).Trim(); if (scoreData.Game.Week.Name == "Week 12" && scoreData.Game.Week.Season.Year == 2008 && score == "" && team == "Fighting Calrissians") { // there is no score data for FC this week, so this was calculated by totaling the // results of all games and subtracting the seaons points for. score = "819"; } if (scoreData.Game.Week.Name == "Week 1" && scoreData.Game.Week.Season.Year == 2003 && team == "Phantom") { // in 2003 the team was called the Phantoms, but was recorded as // phantom team = "Phantom120"; } int scoreInt = Convert.ToInt32(score); Team teamData = teamResolver.GetTeamByName(team); teamData.Games.Add(scoreData.Game); scoreData.Team = teamData; scoreData.Score = scoreInt; }
private void ProcessGameLine(string line, Week weekData) { if (string.IsNullOrEmpty(line)) { return; } string[] raw = line.Split(','); if (raw.Length == 2) { Game gameData = new Game(); gameData.Week = weekData; weekData.Games.Add(gameData); TeamScore homeScoreData = new TeamScore(); homeScoreData.Game = gameData; ProcessTeam(raw[0], homeScoreData, 0); gameData.Home = homeScoreData; TeamScore awayScoreData = new TeamScore(); awayScoreData.Game = gameData; ProcessTeam(raw[1], awayScoreData, 1); gameData.Away = awayScoreData; } else { int x = 0; while (!char.IsDigit(line[x++])) { ; } while (char.IsDigit(line[x++])) { ; } string newline = line.Substring(0, x) + "," + line.Substring(x); ProcessGameLine(newline, weekData); } }
private void ProcessTeam(string teamline, TeamScore scoreData, int pos) { string raw = teamline.Trim(); int scoreIndex = raw.Length; while (char.IsDigit(raw[--scoreIndex])) { ; } scoreIndex++; string team = raw.Substring(0, scoreIndex).Trim(); string score = raw.Substring(scoreIndex).Trim(); int scoreInt = Convert.ToInt32(score); Team teamData = _teamResolver.GetTeamByName(team); teamData.Games.Add(scoreData.Game); scoreData.Team = teamData; scoreData.Score = scoreInt; }