Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public RateSettings()
        {
            RateSets = new RateSetCollection();
            RateSet set = new RateSet();

            set.RateItems = new RateSetItemCollection();
            RateSetItem item = new RateSetItem();

            item.MaxValue       = 50;
            item.MinValue       = -50;
            item.MaxValueInTime = 100;
            item.PointType      = UserPointType.Point1;
            item.RoleID         = Guid.Empty;
            set.RateItems.Add(item);

            item                = new RateSetItem();
            item.MaxValue       = 1000;
            item.MinValue       = -1000;
            item.MaxValueInTime = 100000;
            item.PointType      = UserPointType.Point1;
            item.RoleID         = Role.Owners.RoleID;
            item.RoleSortOrder  = 0;
            set.RateItems.Add(item);

            item                = new RateSetItem();
            item.MaxValue       = 1000;
            item.MinValue       = -1000;
            item.MaxValueInTime = 100000;
            item.PointType      = UserPointType.Point2;
            item.RoleID         = Role.Owners.RoleID;
            item.RoleSortOrder  = 0;
            set.RateItems.Add(item);

            RateSets.Add(set);
        }
Ejemplo n.º 3
0
        public object Clone()
        {
            RateSetItem item = new RateSetItem();

            item.MaxValue       = MaxValue;
            item.MaxValueInTime = MaxValueInTime;
            item.MinValue       = MinValue;
            item.PointType      = PointType;
            item.RoleID         = RoleID;
            item.RoleSortOrder  = RoleSortOrder;

            return(item);
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <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);
        }