Exemple #1
0
        public void InsertData(MatchInfo matchInfo)
        {
            InsertMatchInformation(matchInfo);
            InsertTeamStatistics(matchInfo.HomeTeamStatistics, matchInfo.League, matchInfo.id, true);
            InsertTeamStatistics(matchInfo.AwayTeamStatistics, matchInfo.League, matchInfo.id, false);

            foreach (PlayerStatistics player in matchInfo.HomeTeamPlayerStatistics)
            {
                InsertPlayerStatistics(player, matchInfo.HomeTeamStatistics.id, matchInfo.HomeTeamStatistics.name, matchInfo.League, matchInfo.id, true);
            }

            foreach (PlayerStatistics player in matchInfo.AwayTeamPlayerStatistics)
            {
                InsertPlayerStatistics(player, matchInfo.AwayTeamStatistics.id, matchInfo.AwayTeamStatistics.name, matchInfo.League, matchInfo.id, false);
            }
        }
Exemple #2
0
        public MatchInfo GetMatchInfo(int matchID, string league, string htmlContent)
        {
            MatchInfo matchInfo = new MatchInfo();
            matchInfo.id = matchID;
            matchInfo.League = league;

            string infoString = "";
            MatchCollection matches = Regex.Matches(htmlContent, matchInfoFilter, RegexOptions.Singleline);

            for (int i = 0; i < matches.Count; i++)
            {
                infoString += matches[i].Value;
            }

            string[] infos = infoString.Split(new Char[] { '[', ',', '\'', ']' }, StringSplitOptions.RemoveEmptyEntries);

            if (infos.Length == 12)
            {
                string homeTeamFilter = @"(?:\[" + int.Parse(infos[1]) + @",'" + infos[3] + @"',).*?(?:]]]],)";
                string homeTeamContent = Regex.Match(htmlContent, homeTeamFilter, RegexOptions.Singleline).Value;
                string awayTeamFilter = @"(?:,\[" + int.Parse(infos[2]) + @",'" + infos[4] + @"',).*?(?:]]]],)";
                string awayTeamContent = Regex.Match(htmlContent, awayTeamFilter, RegexOptions.Singleline).Value;

                TeamStatistics homeTeamStatistics = GetTeamStatistics(homeTeamContent);
                TeamStatistics awayTeamStatistics = GetTeamStatistics(awayTeamContent);

                homeTeamStatistics.id = int.Parse(infos[1]);
                homeTeamStatistics.name = infos[3];
                homeTeamStatistics.rating = float.Parse(homeTeamContent.Split(new Char[] { '[', ',' }, StringSplitOptions.RemoveEmptyEntries)[2]);
                awayTeamStatistics.id = int.Parse(infos[2]);
                awayTeamStatistics.name = infos[4];
                awayTeamStatistics.rating = float.Parse(awayTeamContent.Split(new Char[] { '[', ',' }, StringSplitOptions.RemoveEmptyEntries)[2]);

                matchInfo.StartTime = DateTime.Parse(infos[5]).ToString("yyyy/MM/dd HH:mm:ss");
                matchInfo.HomeTeamStatistics = homeTeamStatistics;
                matchInfo.AwayTeamStatistics = awayTeamStatistics;
                matchInfo.HomeTeamPlayerStatistics = GetPlayerStatisticsList(htmlContent, homeTeamStatistics.id, homeTeamStatistics.name,
                    ref matchInfo.ManOfTheMatchPlayerID, ref matchInfo.ManOfTheMatchPlayerName);
                matchInfo.AwayTeamPlayerStatistics = GetPlayerStatisticsList(htmlContent, awayTeamStatistics.id, awayTeamStatistics.name,
                    ref matchInfo.ManOfTheMatchPlayerID, ref matchInfo.ManOfTheMatchPlayerName);
            }

            return matchInfo;
        }
Exemple #3
0
        private static void InsertMatchInformation(MatchInfo matchInfo)
        {
            int homeTeamPoints = 0;
            int awayTeamPoints = 0;

            if (matchInfo.HomeTeamStatistics.goals > matchInfo.AwayTeamStatistics.goals)
            {
                homeTeamPoints = 3;
            }
            else if (matchInfo.HomeTeamStatistics.goals == matchInfo.AwayTeamStatistics.goals)
            {
                homeTeamPoints = 1;
                awayTeamPoints = 1;
            }
            else
            {
                awayTeamPoints = 3;
            }

            string playerStatisticsSQL = @"REPLACE INTO MatchInformation (match_id, start_time, league, home_team_id, home_team_name, home_team_rating, home_team_goals_for, home_team_points, away_team_id, away_team_name, away_team_rating, away_team_goals_for, away_team_points, man_of_the_match_player_id, man_of_the_match_player_name) VALUES (" + matchInfo.id + ", '" + matchInfo.StartTime + "', '" + matchInfo.League + "', " + matchInfo.HomeTeamStatistics.id + ", '" + matchInfo.HomeTeamStatistics.name + "', " + matchInfo.HomeTeamStatistics.rating + ", " + matchInfo.HomeTeamStatistics.goals + ", " + homeTeamPoints + ", " + matchInfo.AwayTeamStatistics.id + ", '" + matchInfo.AwayTeamStatistics.name + "', " + matchInfo.AwayTeamStatistics.rating + ", " + matchInfo.AwayTeamStatistics.goals + ", " + awayTeamPoints + ", " + matchInfo.ManOfTheMatchPlayerID + ", '" + matchInfo.ManOfTheMatchPlayerName + "')";
            int ret = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, playerStatisticsSQL, null);
        }