private Th MakeTh(Match match, String content, Int32 number, MatchInfo matchInfo) { Th th = new Th(); th.Number = number; HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(content); var nodes = doc.DocumentNode.SelectNodes("//*[@class='tEx Ex2']"); if (nodes == null) { return null; } if (nodes.Count > 0) { // 초공격 th.AwayBats = MakeBatts(match, nodes[0].OuterHtml, number, matchInfo, ThType.초); } if (nodes.Count > 1) { // 말공격 th.HomeBats = MakeBatts(match, nodes[1].OuterHtml, number, matchInfo, ThType.말); } if(th.AwayBats == null && th.HomeBats == null) { return null; } return th; }
public Match MakeMatch(Situation_W situation, BoxScore_W boxScore) { // MatchInfo 만들기 var matchInfo = MakeMatchInfo(boxScore); // Make Match Match match = new Match(); match.GameId = situation.GameId; // MakeThs match.Ths = MakeThs(match, situation, matchInfo); return match; }
private List<Th> MakeThs(Match match, Situation_W situation, MatchInfo matchInfo) { String[] separator = new String[] { "회" }; List<Th> ths = new List<Th>(); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(situation.Content); for (Int32 i = 1; i <= 12; ++i) { String id = String.Format("sms{0:D2}", i); var allNode = doc.DocumentNode.SelectSingleNode(String.Format("//*[@id='{0}']", id)); if (allNode != null) { var th = MakeTh(match, allNode.OuterHtml, i, matchInfo); if (th != null) { ths.Add(th); } } } return ths; }
private List<Bat> MakeBatts(Match match, String content, Int32 number, MatchInfo matchInfo, ThType type) { List<Bat> bats = new List<Bat>(); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(content); var nodes = doc.DocumentNode.SelectNodes("/table[@class='tEx Ex2']/tbody[1]/tr/td"); if(nodes == null) { return null; } foreach (var node in nodes) { var bat = MakeBat(node.OuterHtml, number, matchInfo, type); if (bat != null) { bats.Add(bat); } } return bats; }