// 分配SeasonTable任务 public void SeasonTableAssignTask(BRBaseParam param, Dictionary <string, List <string> > taskDic) { foreach (var kv in taskDic) { if (kv.Key == "add") { kv.Value.ForEach(o => { SeasonTableParam st = param.CopyCreateParam <SeasonTableParam>(); st.SeasonTypeId = "21"; st.TableId = o; LeagueManager.AddOrUpdateParam(st); }); } else { kv.Value.ForEach(o => { SeasonTableParam st = param.CopyCreateParam <SeasonTableParam>(); st.SeasonTypeId = "21"; st.TableId = o; LeagueManager.RemoveParam(st); }); } } }
// 分配SeasonType任务 public void SeasonTypeAssignTask(BRBaseParam param, Dictionary <string, List <string> > taskDic) { // 更新SeasonType任务,除了21类型,将在后面添加,因为需要tableId参数 foreach (var kv in taskDic) { if (kv.Key == "add") { kv.Value.ForEach(o => { SeasonTypeParam st = param.CopyCreateParam <SeasonTypeParam>(); st.SeasonTypeId = o; if (o != "21") { LeagueManager.AddOrUpdateParam(st); } }); } else { kv.Value.ForEach(o => { SeasonTypeParam st = param.CopyCreateParam <SeasonTypeParam>(); st.SeasonTypeId = o; LeagueManager.RemoveParam(st); }); } } }
private void NextAssignTask(OrganizerEntity entity, Dictionary <string, List <string> > taskDic) { foreach (var kv in taskDic) { if (kv.Key == "add") { foreach (var sid in kv.Value) { SeasonParam sp = new SeasonParam() { SeasonId = sid, SportId = entity.SportId, ContinentId = entity.ContinentId, OrganizerId = entity.OrganizerId }; #region 测试只加入指定的联赛任务 //一般联赛有积分的情况 //if (sid == "42556") //杯赛无积分的情况 //if (sid == "42240") //世锦赛分组积分的情况 //if (sid == "10876") //世界杯分组积分的情况 //if (sid == "48238") //其他指定测试 //if (sid == "51035") #endregion LeagueManager.AddOrUpdateParam(sp); } } else if (kv.Key == "del") { foreach (var sid in kv.Value) { SeasonParam sp = new SeasonParam() { SeasonId = sid, SportId = entity.SportId, ContinentId = entity.ContinentId, OrganizerId = entity.OrganizerId }; LeagueManager.RemoveParam(sp); } } } }
public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; TeamParam param = bd.Param as TeamParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } var xml = new XmlHelper(txt); // 解析成各个数据块 var cdataFlag = "//c"; var cdata = xml.GetValues(cdataFlag); // 解析队伍基本信息 TeamEntity te = new TeamEntity(); te.TeamId = param.TeamId; te.Mark = "https://ls.betradar.com/ls/crest/big/" + param.TeamId + ".png"; var teamInfo = cdata[2]; var root = GetHtmlRoot(teamInfo); var teamName = root.SelectSingleNode("//thead/tr").InnerText; te.TeamName = teamName; var trsTeam = root.SelectNodes("//tbody/tr"); if (trsTeam.Count == 2) { te.Manager = trsTeam[1].LastChild.InnerText; } else if (trsTeam.Count > 2) { te.Manager = trsTeam[1].LastChild.InnerText; te.Venue = trsTeam[2].LastChild.InnerText; } var teamEntity = TeamEntityManager.AddOrGetCacheEntity <TeamEntity>(te.TeamId); teamEntity.CompareSetTeamEntity(te); #region 队伍球员相关信息 // 解析进球数获得队员的点球个数,更新到队员点球信息缓存中 if (cdata.Count < 16) { return; // 此队伍无队员信息,克罗地亚乙级联赛->卢科 } var penGoals = GetDataLikeKey(cdata, "normaltable toplist"); if (string.IsNullOrEmpty(penGoals)) { return; } root = GetHtmlRoot(penGoals); var trsPenGoals = root.SelectNodes("//tbody/tr"); if (trsPenGoals != null) { foreach (var tr in trsPenGoals) { var player = tr.SelectSingleNode("td[@class='player']"); if (player == null) { continue; } var playerId = RegexGetStr(player.InnerHtml, "playerid', '", "',"); var pen = tr.LastChild.InnerText; PlayerPenalties pp = PlayerPenaltiesManager.AddOrGetCacheEntity <PlayerPenalties>(playerId + "_" + param.SeasonId); pp.PlayerId = playerId; pp.SeasonId = param.SeasonId; pp.ComparePlayerPenalties(pen); } } // 解析全部名单,并添加球员任务 var playersData = cdata.FirstOrDefault(o => o.Contains("teampage_squad")); if (playersData == null) { return; } root = GetHtmlRoot(playersData); var trsPlayer = root.SelectNodes("//tbody/tr"); if (trsPlayer != null) { List <string> list = new List <string>(); foreach (var tr in trsPlayer) { var s = tr.Attributes["onclick"].Value; var playerId = RegexGetStr(s, "playerid', '", "',"); list.Add(playerId); } var tp = TeamPlayersManager.AddOrGetCacheEntity <TeamPlayers>(param.TeamId + "_" + param.SeasonId); tp.TeamId = param.TeamId; tp.SeasonId = param.SeasonId; var dic = tp.CompareSetPlayerIdList(list); NextAssignTask(param, dic); } #endregion // 如果有添加获取伤停的任务 if (txt.IndexOf("o=\"1003\"") > 0) { InjuryParam ip = param.CopyCreateParam <InjuryParam>(); LeagueManager.AddOrUpdateParam(ip); } }
public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; SeasonParam param = bd.Param as SeasonParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } // 首先添加联赛层级的比赛任务 MatchParam mp = param.CopyCreateParam <MatchParam>(); LeagueManager.AddOrUpdateParam(mp); if (param.CurrentUrlKey == "tableIds") { ProcessTableIdsTxt(param, txt); return; } else if (param.CurrentUrlKey == "teamIds") { ProcessTeamIdsTxt(param, txt); return; } var xml = new XmlHelper(txt); // 获取赛季名称 var title = xml.GetAttributeValue("//page", "title"); var seasonName = title.Split('>').Last(); SeasonEntity currentSeasonEntity = new SeasonEntity(); currentSeasonEntity.SportId = param.SportId; currentSeasonEntity.SeasonId = param.SeasonId; currentSeasonEntity.SeasonName = seasonName; // 获取积分数据块 var cdataFlag = "//c"; var cdata = xml.GetValues(cdataFlag); if (cdata.Count == 0) { // 杯赛没有积分数据的,添加获取所有队伍Id的任务 param = param.CopyCreateParam <SeasonParam>(); param.SetCurrentUrlKey("teamIds"); LeagueManager.AddOrUpdateParam(param); return; } var teamRankData = ""; if (cdata.Count > 5) { teamRankData = cdata[4]; } if (string.IsNullOrEmpty(teamRankData)) { return; } var currentRound = RegexGetStr(cdata[0], "sb-current\"><div class=\"label\">", "<"); currentSeasonEntity.CurrentRound = currentRound; SeasonEntity se = SeasonEntityManager.AddOrGetCacheEntity <SeasonEntity>(param.SeasonId); se.CompareSetSeasonInfo(currentSeasonEntity); // 解析积分数据,并添加队伍任务,添加队伍积分数据,其他数据可由已经结束的比赛结果计算 List <string> teamIdList = new List <string>(); List <SeasonTeamRank> trList = new List <SeasonTeamRank>(); var root = GetHtmlRoot(teamRankData); var tables = root.SelectNodes("//table[@class='normaltable']/tbody"); if (tables.Count == 0) { return; } if (tables.Count > 1) { // 多个积分榜数据,有分组别的,添加获取所有组别Id的任务 param = param.CopyCreateParam <SeasonParam>(); param.SetCurrentUrlKey("tableIds"); LeagueManager.AddOrUpdateParam(param); // 同时添加获取全部队伍Id的任务 param = param.CopyCreateParam <SeasonParam>(); param.SetCurrentUrlKey("teamIds"); LeagueManager.AddOrUpdateParam(param); return; } foreach (var node in tables[0].ChildNodes) { var teamId = RegexGetStr(node.ChildNodes[2].InnerHtml, "teamid','", "',"); teamIdList.Add(teamId); var trDataArr = node.ChildNodes.Select(o => o.InnerText).ToArray(); SeasonTeamRank tr = new SeasonTeamRank() { SeasonId = param.SeasonId, TeamId = teamId, TeamPoints = trDataArr[11], Description = trDataArr[12] }; trList.Add(tr); } SeasonTeams st = SeasonTeamsManager.AddOrGetCacheEntity <SeasonTeams>(param.SeasonId); st.CompareSetTeamRank(trList); // 要分配的队伍任务 var teamTaskDic = se.CompareSetTeamIdList(teamIdList); TeamAssignTask(param, teamTaskDic); }
public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; MatchParam param = bd.Param as MatchParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } var xml = new XmlHelper(txt); // 解析成各个数据块 var cdataFlag = "//c"; var cdata = xml.GetValues(cdataFlag); // 获取历史赛季Id,添加到联赛任务,只抓取一次 var historySeasonIdData = GetDataLikeKey(cdata, "sb-wrapper", "lang-1"); var seasonIdList = new List <string>(); if (historySeasonIdData != null) { var rootHistory = GetHtmlRoot(historySeasonIdData); var ul = rootHistory.SelectSingleNode("//div[@class='sb-scrollbox']/ul"); foreach (var li in ul.ChildNodes) { var id = RegexGetStr(li.OuterHtml, "'5_", ","); seasonIdList.Add(id); var sp = param.CopyCreateParam <SeasonParam>(); sp.IsHistoryParam = true; sp.SeasonId = id; LeagueManager.AddOrUpdateParam(sp); } } if (!param.IsHistoryParam && seasonIdList.Any()) { var le = LeagueEntityManager.AddOrGetCacheEntity <LeagueEntity>(param.SeasonId); le.CompareSetSeasonIds(seasonIdList); } // 解析比赛 var matchData = GetDataLikeKey(cdata, "normaltable fixtures"); if (string.IsNullOrEmpty(matchData)) { return; } var root = GetHtmlRoot(matchData); bool isTitle = true; string round = ""; foreach (var node in root.ChildNodes) { switch (node.Name) { case "#text": continue; case "h2": if (isTitle) { isTitle = false; } else { round = node.InnerText; } continue; case "table": ParseMatch(round, node, param); continue; } } }