public static List<FlashGameMin> GetPlayedList(int topCount,int userId) { List<FlashGameMin> fgmList = new List<FlashGameMin>(); bizRecordRank biz = new bizRecordRank(); List<RecordRankRelationQuery> list = biz.GetPlayedList(userId); if (list != null) { for (int i = 0; i < list.Count && i < topCount; i++) { FlashGameMin fgm = new FlashGameMin(); fgm.GameId = list[i].fid; fgm.GameName = list[i].GameName; AddToFlashGameMin(fgmList, fgm); } } if (fgmList.Count < topCount) { List<RecordRank_HistoryRelationQuery> list_history = biz.GetPlayedHistoryList(userId); if (list_history != null) { int k = topCount - fgmList.Count; for (int i =0; i < list_history.Count && i < k; i++) { FlashGameMin fgm = new FlashGameMin(); fgm.GameId = list_history[i].fid; fgm.GameName = list_history[i].GameName; AddToFlashGameMin(fgmList, fgm); } } } return fgmList; }
private static void AddToFlashGameMin(List<FlashGameMin> fgmList,FlashGameMin fgm) { if (fgmList == null) { fgmList = new List<FlashGameMin>(); } foreach (FlashGameMin model in fgmList) { if (model.GameId == fgm.GameId) { return; } } fgmList.Add(fgm); }