public RateSetItem GetRateItem(int userID, UserPointType pointType) { User user = UserBO.Instance.GetUser(userID); RateSetItemCollection items = GetRateItems(pointType); RateSetItem tempRankItem = null; foreach (RateSetItem rankItem in items) { if (rankItem.PointType == pointType) { if (user.Roles.IsInRole(rankItem.RoleID)) { return(rankItem); } if (rankItem.RoleID == Guid.Empty) { tempRankItem = rankItem; } } } if (tempRankItem == null) { tempRankItem = new RateSetItem(); tempRankItem.PointType = pointType; } return(tempRankItem); }
/// <summary> /// 按优先级顺序 RoleID 为 Guid.Empty的 在集合最前面 /// </summary> /// <param name="pointType"></param> /// <returns></returns> public RateSetItemCollection GetRateItems(UserPointType pointType) { RateSetItemCollection tempRateItems = new RateSetItemCollection(); RateSetItem tempItem = null; foreach (RateSetItem item in RateItems) { if (item.PointType == pointType) { if (item.RoleID == Guid.Empty) { tempItem = item; continue; } int index = tempRateItems.Count; for (int i = 0; i < tempRateItems.Count; i++) { if (item.RoleSortOrder > tempRateItems[i].RoleSortOrder) { index = i; break; } } tempRateItems.Insert(index, item); } } if (tempItem == null) { tempItem = new RateSetItem(); tempItem.PointType = pointType; tempItem.RoleID = Guid.Empty; } RateSetItemCollection results = new RateSetItemCollection(); results.Add(tempItem); for (int i = tempRateItems.Count - 1; i >= 0; i--) { results.Add(tempRateItems[i]); } //tempRateItems.Insert(0, tempItem); return(results); }
/// <summary> /// 获取某个用户 可以评分的设置 (按顺序:积分1 积分2 ...,不包括未启用的积分,不包括不能评分的设置) /// </summary> /// <param name="userID"></param> /// <returns></returns> public RateSetItemCollection GetRateItems(int userID) { RateSetItemCollection rateItems = new RateSetItemCollection(); foreach (UserPoint userPoint in AllSettings.Current.PointSettings.UserPoints) { if (userPoint.Enable) { RateSetItem item = GetRateItem(userID, userPoint.Type); if (item.MinValue != 0 || item.MaxValue != 0) { rateItems.Add(item); } } } return(rateItems); }
public RateSet() { RateItems = new RateSetItemCollection(); }