private void InitMatch() { DateTime date = DateTime.Now; //排除1个月之前的比赛 var allMatch = EuropeMatchMgr.GetAllMatvch(date.AddDays(-30)); var allLogo = ConfigGambleiconMgr.GetAll(); _logoDic = allLogo.ToDictionary(r => r.Name.Trim(), r => r.Idx); _allMatch = new ConcurrentDictionary <DateTime, List <EuropeMatchEntity> >(); _oneMatch = new ConcurrentDictionary <int, EuropeMatchEntity>(); foreach (var item in allMatch) { item.HomeLogo = GetLogo(item.HomeName); item.AwayLogo = GetLogo(item.AwayName); item.MatchTimeTick = ShareUtil.GetTimeTick(item.MatchTime); if (!_allMatch.ContainsKey(item.MatchDate)) { _allMatch.TryAdd(item.MatchDate, new List <EuropeMatchEntity>()); } _allMatch[item.MatchDate].Add(item); _oneMatch.TryAdd(item.MatchId, item); } //是否有比赛 _matchInfoDic = new Dictionary <long, bool>(); for (int i = -7; i <= 7; i++) { var isMatch = EuropeMatchMgr.GetIsMatch(date.Date.AddDays(i)) > 0; _matchInfoDic.Add(ShareUtil.GetTimeTick(date.Date.AddDays(i)), isMatch); } }
private void BindData() { ClearData(); DateTime date = DateTime.Now; //排除1个月之前的比赛 var matchList = EuropeMatchMgr.GetAllMatvch(date.AddDays(-30)); if (matchList == null) { matchList = new List <EuropeMatchEntity>(); } matchList = matchList.OrderByDescending(r => r.MatchId).ToList(); foreach (var item in matchList) { if (item != null) { try { switch (item.ResultType) { case 0: item.ResultTypeString = "初始"; break; case 1: item.ResultTypeString = "主队获胜"; break; case 2: item.ResultTypeString = "平"; break; case 3: item.ResultTypeString = "客队获胜"; break; } switch (item.States) { case 0: item.StatusString = "初始"; break; case 1: item.StatusString = "可竞猜"; break; case 2: item.StatusString = "比赛中"; break; case 3: item.StatusString = "比赛完成"; break; case 4: item.StatusString = "发奖完成"; break; } } catch (Exception ex) { throw new Exception("match读取出错,id:" + item.MatchId); } } } datagrid1.DataSource = matchList; datagrid1.DataBind(); }