public RankData GetTopByPercent(int percent) { RankData result = new RankData(); result.Name = this.Name; if (this.Tag != null) { result.Tag = this.Tag; } foreach (string id in this.Keys) { decimal rank = (decimal)this[id].Rank; rank = rank / this.Count * 100; rank = decimal.Round(rank, 0, MidpointRounding.AwayFromZero); this[id].Rank = (int)rank; if (rank <= percent) { result.Add(id, this[id]); } } return(result); }
public RankData GetTopByRank(int rank) { RankData result = new RankData(); result.Name = this.Name; if (this.Tag != null) { result.Tag = this.Tag; } foreach (string id in this.Keys) { if (this[id].Rank <= rank) { result.Add(id, this[id]); } } return(result); }
public void Perform() { List <RankData> rankData = new List <RankData>(); foreach (RankData data in _rankData) { if (RankType == RankType.Class) { #region 班排名 Dictionary <string, RankData> classRankData = new Dictionary <string, RankData>(); foreach (string id in data.Keys) { JHStudentRecord student = _studentDict[id]; string className = string.Empty; if (student.Class != null) { className = student.Class.Name; } if (!classRankData.ContainsKey(className)) { classRankData.Add(className, new RankData()); } RankData eachClassRankData = classRankData[className]; eachClassRankData.Add(id, data[id]); } RankData all = new RankData(); all.Name = data.Name; if (data.Tag != null) { all.Tag = data.Tag; } foreach (RankData each in classRankData.Values) { all.Merge(_ranker.Perform(each)); } rankData.Add(all); #endregion } else if (RankType == RankType.GradeYear) { #region 年排名 Dictionary <string, RankData> gradeRankData = new Dictionary <string, RankData>(); foreach (string id in data.Keys) { JHStudentRecord student = _studentDict[id]; string gradeYear = string.Empty; if (student.Class != null) { gradeYear = "" + student.Class.GradeYear; } if (!gradeRankData.ContainsKey(gradeYear)) { gradeRankData.Add(gradeYear, new RankData()); } RankData eachGradeRankData = gradeRankData[gradeYear]; eachGradeRankData.Add(id, data[id]); } RankData all = new RankData(); all.Name = data.Name; foreach (RankData each in gradeRankData.Values) { all.Merge(_ranker.Perform(each)); } rankData.Add(all); #endregion } } _rankData.Clear(); _rankData = rankData; }