Exemple #1
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 #2
0
        private void InsertData(MatchInfo matchInfo)
        {
            DAL dal = new DAL();
            dal.InsertMatchInformation(matchInfo);
            dal.InsertTeamStatistics(matchInfo.HomeTeamStatistics, matchInfo.League, matchInfo.id, true);
            dal.InsertTeamStatistics(matchInfo.AwayTeamStatistics, matchInfo.League, matchInfo.id, false);

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

            foreach (PlayerStatistics player in matchInfo.AwayTeamPlayerStatistics)
            {
                dal.InsertPlayerStatistics(player, matchInfo.AwayTeamStatistics.id, matchInfo.AwayTeamStatistics.name, matchInfo.League, matchInfo.id, false);
            }
        }