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; 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); }