Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            m_Filter = PointLogFilter.GetFromFilter("filter");
            UserPointType pointType = _Request.Get <UserPointType>("point", Method.Get, UserPointType.Point1);

            PointLogBO.Instance.GetPointStatInfo(Filter, pointType, out Count, out ProduceCount, out ConsumeCount);
        }
Exemple #2
0
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            if (property.Name == "IntiveSerialPoint")
            {
                int           value = _Request.Get <int>("IntiveSerialPoint", Method.Post, 0);
                UserPointType type  = _Request.Get <UserPointType>("PointFieldIndex", Method.Post, UserPointType.Point1);
                UserPoint     point = AllSettings.Current.PointSettings.GetUserPoint(type);

                if (point.MaxValue < value)
                {
                    ThrowError(new CustomError("IntiveSerialPoint", "超出" + point.Name + "允许的最大值"));
                    return(false);
                }

                if (value <= 0)
                {
                    ThrowError(new CustomError("IntiveSerialPoint", "所需的积分值不能小于等于0"));
                    return(false);
                }
            }
            if (property.Name == "ShowRegisterInviteInput")
            {
                bool value = _Request.Get <bool>("ShowRegisterInviteInput", Method.Post, true);
                InvitationSettings temp = (InvitationSettings)setting;
                temp.ShowRegisterInviteInput = value;
                return(true);
            }

            return(base.SetSettingItemValue(setting, property));
        }
Exemple #3
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);
        }
        protected string GetExchangeProportion(UserPointType pointType, UserPointType targetPointType)
        {
            PointExchangeProportion proportion       = null;
            PointExchangeProportion targetProportion = null;

            foreach (PointExchangeProportion tempProportion in AllSettings.Current.PointSettings.ExchangeProportions)
            {
                if (tempProportion.UserPointType == pointType)
                {
                    proportion = tempProportion;
                    if (targetProportion != null)
                    {
                        break;
                    }
                }
                if (tempProportion.UserPointType == targetPointType)
                {
                    targetProportion = tempProportion;
                    if (proportion != null)
                    {
                        break;
                    }
                }
            }

            int greatestCommonDivisor = MathUtil.GetGreatestCommonDivisor(proportion.Proportion, targetProportion.Proportion);

            return(proportion.Proportion / greatestCommonDivisor + ":" + (targetProportion.Proportion / greatestCommonDivisor));
        }
 public UserPointOverMinValueError(string target, UserPointType pointType, int canReduceValue, int pointValue, int minPointValue)
     : base(target)
 {
     CanReduceValue  = canReduceValue < 0 ? 0 : canReduceValue;
     m_UserPointType = pointType;
     PointValue      = pointValue;
     MinPointValue   = minPointValue;
 }
        public PointExchangeRule GetRule(UserPointType pointType, UserPointType targetPointType)
        {
            PointExchangeRule rule = new PointExchangeRule();

            rule.PointType       = pointType;
            rule.TargetPointType = targetPointType;
            return(GetRule(rule.Key));
        }
 protected bool isEnd(UserPointType pointType, int index)
 {
     if (index == GetPointExchangeRules(pointType).Count - 1)
     {
         return(true);
     }
     return(false);
 }
 public UserPointOverMaxValueError(string target, UserPointType pointType, int canAddValue, int pointValue, int maxPointValue)
     : base(target)
 {
     m_UserPointType = pointType;
     CanAddValue     = canAddValue < 0 ? 0 : canAddValue;
     PointValue      = pointValue;
     MaxPointValue   = maxPointValue;
 }
 public UserPointOverMinValueError(string target, UserPointType pointType, int canReduceValue, int pointValue, int minPointValue)
     : base(target) 
 {
     CanReduceValue = canReduceValue < 0 ? 0 : canReduceValue;
     m_UserPointType = pointType;
     PointValue = pointValue;
     MinPointValue = minPointValue;
 }
 public UserPointOverMaxValueError(string target, UserPointType pointType, int canAddValue, int pointValue, int maxPointValue)
     : base(target) 
 {
     m_UserPointType = pointType;
     CanAddValue = canAddValue < 0 ? 0 : canAddValue;
     PointValue = pointValue;
     MaxPointValue = maxPointValue;
 }
Exemple #11
0
        /*
         * /// <summary>
         * ///
         * /// </summary>
         * /// <param name="throwOverMaxValueError"></param>
         * /// <param name="throwOverMinValueError"></param>
         * /// <param name="userID"></param>
         * /// <param name="points">正数加分 负数减分</param>
         * /// <param name="userPoints"></param>
         * /// <returns></returns>
         * public static bool CheckPoints(bool throwOverMaxValueError, bool throwOverMinValueError, int userID, int[] points, out int[] userPoints)
         * {
         *  return CheckPoints(throwOverMaxValueError, throwOverMinValueError, userID, points, true, out userPoints);
         * }
         * /// <summary>
         * /// 检查积分 上下限
         * /// </summary>
         * /// <param name="userID"></param>
         * /// <param name="points">要更新的积分值  8个</param>
         * /// <param name="isAdd">如果为false 则points就是最终的积分 而不是增加或减少的积分 </param>
         * /// <param name="resultPoints">如果检查成功 则返回用户更新后的积分</param>
         * /// <returns></returns>
         * public static bool CheckPoints(bool throwOverMaxValueError, bool throwOverMinValueError, int userID, int[] points, bool isAdd, out int[] userPoints)
         * {
         *
         *  User user = UserBO.Instance.GetUser(userID);
         *  userPoints = null;
         *  foreach (UserPoint userPoint in AllSettings.Current.PointSettings.UserPoints)
         *  {
         *      int pointID = (int)userPoint.Type;
         *
         *      if (userPoint.Enable)
         *      {
         *          int resultPoint;
         *          if (isAdd)
         *              resultPoint = user.ExtendedPoints[pointID] + points[pointID];
         *          else
         *              resultPoint = points[pointID];
         *          if (points[pointID] > 0)
         *          {
         *
         *              if (resultPoint > userPoint.MaxValue)
         *              {
         *                  if (throwOverMaxValueError)
         *                  {
         *                      Context.ThrowError<UserPointOverMaxValueError>(new UserPointOverMaxValueError("UserPointOverMaxValueError", userPoint.Type, userPoint.MaxValue - user.ExtendedPoints[pointID], user.ExtendedPoints[pointID] + points[pointID], userPoint.MaxValue));
         *                      return false;
         *                  }
         *                  if (isAdd)
         *                  {
         *                      if (user.ExtendedPoints[pointID] > userPoint.MaxValue)//原来已经大于上限  保留原值
         *                          points[pointID] = user.ExtendedPoints[pointID];
         *                      else
         *                          points[pointID] = userPoint.MaxValue;
         *                  }
         *                  else
         *                      points[pointID] = userPoint.MaxValue;
         *              }
         *              else
         *                  points[pointID] = resultPoint;
         *          }
         *          else if (points[pointID] < 0)
         *          {
         *              if (resultPoint < userPoint.MinValue)
         *              {
         *                  if (throwOverMinValueError)
         *                  {
         *                      Context.ThrowError<UserPointOverMinValueError>(new UserPointOverMinValueError("UserPointOverMinValueError", userPoint.Type, user.ExtendedPoints[pointID] - userPoint.MinValue, user.ExtendedPoints[pointID] + points[pointID], userPoint.MinValue));
         *                      return false;
         *                  }
         *                  if (isAdd)
         *                  {
         *                      if (user.ExtendedPoints[pointID] < userPoint.MinValue)//原来已经小于下限  保留原值
         *                          points[pointID] = user.ExtendedPoints[pointID];
         *                      else
         *                          points[pointID] = userPoint.MinValue;
         *                  }
         *                  else
         *                      points[pointID] = userPoint.MinValue;
         *              }
         *              else
         *                  points[pointID] = resultPoint;
         *          }
         *          else
         *          {
         *              if(isAdd)
         *                  points[pointID] = user.ExtendedPoints[pointID];
         *          }
         *      }
         *      else
         *      {
         *          if (isAdd)
         *              points[pointID] = user.ExtendedPoints[pointID];
         *      }
         *  }
         *  userPoints = points;
         *
         *  return true;
         * }
         */

        #region  积分相关设置
        public static bool AddPointExchangeRule(UserPointType pointType, UserPointType targetPointType)
        {
            PointExchangeRule rule = new PointExchangeRule();

            rule.PointType       = pointType;
            rule.TargetPointType = targetPointType;

            if (pointType == targetPointType)
            {
                Context.ThrowError <UserPointCannotExchangeError>(new UserPointCannotExchangeError("UserPointCannotExchangeError", rule.UserPoint.Name, rule.TargetUserPoint.Name));
                return(false);
            }

            if (rule.UserPoint.Enable == false)
            {
                Context.ThrowError <UserPointExchangeUnenabledPointError>(new UserPointExchangeUnenabledPointError("UserPointExchangeUnenabledPointError", rule.UserPoint.Name, rule.TargetUserPoint.Name, rule.UserPoint.Name));
                return(false);
            }

            if (rule.TargetUserPoint.Enable == false)
            {
                Context.ThrowError <UserPointExchangeUnenabledPointError>(new UserPointExchangeUnenabledPointError("UserPointExchangeUnenabledPointError", rule.UserPoint.Name, rule.TargetUserPoint.Name, rule.TargetUserPoint.Name));
                return(false);
            }


            PointExchangeRuleCollection rules = AllSettings.Current.PointSettings.PointExchangeRules;


            PointExchangeRuleCollection tempRules = new PointExchangeRuleCollection();

            foreach (PointExchangeRule tempRule in rules)
            {
                if (rule.Key == tempRule.Key)
                {
                    Context.ThrowError <UserPointIsExistsExchangeRuleError>(new UserPointIsExistsExchangeRuleError("UserPointIsExistsExchangeRuleError", rule.UserPoint.Name, rule.TargetUserPoint.Name));
                    return(false);
                }
                tempRules.Add(tempRule);
            }

            tempRules.Add(rule);

            if (HasUnCatchedError)
            {
                return(false);
            }

            PointSettings setting = SettingManager.CloneSetttings <PointSettings>(AllSettings.Current.PointSettings);

            setting.PointExchangeRules = tempRules;
            if (!SettingManager.SaveSettings(setting))
            {
                return(false);
            }
            //AllSettings.Current.PointSettings = setting;
            return(true);
        }
Exemple #12
0
        protected string GetPointIconUpdateDescription(UserPointType pointType)
        {
            string s = AllSettings.Current.PointSettings.PointIcons.GetPointIconUpgradeDescription(pointType);

            if (s != string.Empty)
                s = "(" + s + ")";

            return s;
        }
        private void ExchangePoint()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("password", "pointvalue", "pointtype", "targetpointtype");

            string password = _Request.Get("password", Method.Post, string.Empty, false);

            string valueString = _Request.Get("pointvalue", Method.Post, string.Empty);

            int pointValue;

            if (!int.TryParse(valueString, out pointValue))
            {
                msgDisplay.AddError("pointvalue", Lang_Error.User_UserPointExechangePointValueError);
            }

            valueString = _Request.Get("pointtype", Method.Post, string.Empty);
            if (string.Empty == valueString)
            {
                msgDisplay.AddError("pointtype", Lang_Error.User_UserPointEmptyExchangePointTypeError);
            }

            UserPointType pointType = StringUtil.TryParse <UserPointType>(valueString, UserPointType.Point1);

            valueString = _Request.Get("targetpointtype", Method.Post, string.Empty);
            if (string.Empty == valueString)
            {
                msgDisplay.AddError("targetpointtype", Lang_Error.User_UserPointEmptyExchangeTargetPointTypeError);
            }


            UserPointType targetPointType = StringUtil.TryParse <UserPointType>(valueString, UserPointType.Point1);

            if (msgDisplay.HasAnyError())
            {
                return;
            }

            try
            {
                if (!UserBO.Instance.ExechangePoint(My, password, pointType, targetPointType, pointValue))
                {
                    CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
                else
                {
                    _Request.Clear(Method.Post);
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddException(ex);
            }
        }
        protected PointRechargeRule GetRule(UserPointType type)
        {
            foreach (PointRechargeRule rule in Rules)
            {
                if (rule.UserPointType == type)
                    return rule;
            }

            return null;
        }
Exemple #15
0
 public UserPoint GetUserPoint(UserPointType pointType)
 {
     foreach (UserPoint userPoint in this)
     {
         if (userPoint.Type == pointType)
         {
             return(userPoint);
         }
     }
     return(null);
 }
Exemple #16
0
 public string GetPointIcon(UserPointType pointType, int pointValue)
 {
     foreach (PointIcon icon in this)
     {
         if (icon.PointType == pointType)
         {
             return(icon.GetPointIcon(pointValue));
         }
     }
     return(string.Empty);
 }
Exemple #17
0
 public string GetPointIconUpgradeDescription(UserPointType pointType)
 {
     foreach (PointIcon icon in this)
     {
         if (icon.PointType == pointType)
         {
             return(icon.GetPointIconUpgradeDescription);
         }
     }
     return(Lang.User_UserPointNotSetIcon);
 }
Exemple #18
0
        protected string GetPointIconUpdateDescription(UserPointType pointType)
        {
            string s = AllSettings.Current.PointSettings.PointIcons.GetPointIconUpgradeDescription(pointType);

            if (s != string.Empty)
            {
                s = "(" + s + ")";
            }

            return(s);
        }
Exemple #19
0
        /// <summary>
        /// 检查是否已经存在该规则
        /// </summary>
        /// <param name="rule"></param>
        /// <returns></returns>
        //public bool IsExists(PointExchangeRule rule)
        //{
        //    foreach (PointExchangeRule tempRule in this)
        //    {
        //        if (rule.Key == tempRule.Key)
        //            return true;
        //    }
        //    return false;
        //}

        public PointTransferRule GetRule(UserPointType pointType)
        {
            foreach (PointTransferRule tempRule in this)
            {
                if (tempRule.PointType == pointType)
                {
                    return(tempRule);
                }
            }
            return(null);
        }
        public void PointTransferRule(UserPointType userPointType, PointTransferRuleTemplate item)
        {
            PointTransferRule rule = AllSettings.Current.PointSettings.PointTransferRules.GetRule(userPointType);

            if (rule == null)
            {
                rule           = new PointTransferRule();
                rule.PointType = userPointType;
            }
            item(rule);
        }
        protected PointRechargeRule GetRule(UserPointType type)
        {
            foreach (PointRechargeRule rule in Rules)
            {
                if (rule.UserPointType == type)
                {
                    return(rule);
                }
            }

            return(null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="pointType"></param>
        /// <returns></returns>
        protected PointExchangeRuleCollection GetPointExchangeRules(UserPointType pointType)
        {
            PointExchangeRuleCollection rules = new PointExchangeRuleCollection();

            foreach (PointExchangeRule rule in AllSettings.Current.PointSettings.PointExchangeRules)
            {
                if (rule.PointType == pointType)
                {
                    rules.Add(rule);
                }
            }
            return(rules);
        }
Exemple #23
0
 public int this[UserPointType pointType]
 {
     get
     {
         foreach (PointExchangeProportion proportion in this)
         {
             if (proportion.UserPointType == pointType)
             {
                 return(proportion.Proportion);
             }
         }
         return(1);
     }
 }
        protected bool CanRecharge(UserPointType type)
        {
            if (AllSettings.Current.PaySettings.EnablePointRecharge == false)
                return false;

            foreach (PointRechargeRule temp in AllSettings.Current.PointSettings.PointRechargeRules)
            {
                if (type == temp.UserPointType && temp.Enable)
                {
                    return true;
                }
            }

            return false;
        }
Exemple #25
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);
        }
Exemple #26
0
        /// <summary>
        /// 获取 某个动作 会更新的积分类型  永远不为NULL
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="type"></param>
        /// <param name="actionType"></param>
        /// <returns>永远不为NULL</returns>
        public static UserPoint GetUserPoint <T>(int userId, string type, T actionType, int nodeID, out PointAction pointAction) //where T : struct
        {
            pointAction = null;
            UserPointType pointType = UserPointType.Point1;

            pointAction = AllSettings.Current.PointActionSettings.PointActions.GetPointAction(type, nodeID);
            if (pointAction == null)
            {
                pointAction = AllSettings.Current.PointActionSettings.PointActions.GetPointAction(type, 0);
            }

            pointType = pointAction.GetUserPointType(actionType.ToString(), userId);

            //foreach (PointAction tempPointAction in AllSettings.Current.PointActionSettings.PointActions)
            //{
            //    if (string.Compare(tempPointAction.Type, type) == 0)
            //    {
            //        pointAction = tempPointAction;
            //        pointType = tempPointAction.GetUserPointType(actionType.ToString(), userId);
            //        break;
            //    }
            //}
            //if (pointAction == null)
            //{
            //    pointAction = new PointAction();
            //}

            UserPoint userPoint = null;

            foreach (UserPoint tempUserPoint in AllSettings.Current.PointSettings.EnabledUserPoints)
            {
                if (userPoint == null)//如果 不存在指定类型的积分  则使用第一个
                {
                    userPoint = tempUserPoint;
                }
                if (tempUserPoint.Type == pointType)
                {
                    return(tempUserPoint);
                }
            }
            if (userPoint == null) //没有一个积分是启用的。。。
            {
                return(AllSettings.Current.PointSettings.UserPoints[0]);
            }
            return(userPoint);
        }
        protected bool CanRecharge(UserPointType type)
        {
            if (AllSettings.Current.PaySettings.EnablePointRecharge == false)
            {
                return(false);
            }

            foreach (PointRechargeRule temp in AllSettings.Current.PointSettings.PointRechargeRules)
            {
                if (type == temp.UserPointType && temp.Enable)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #28
0
        public void Add(UserPointType userPointType, int proportion)
        {
            bool have = false;

            foreach (PointExchangeProportion tempProportion in this)
            {
                if (tempProportion.UserPointType == userPointType)
                {
                    have = true;
                    tempProportion.Proportion = proportion;
                }
            }
            if (!have)
            {
                PointExchangeProportion tempProportion = new PointExchangeProportion();
                tempProportion.UserPointType = userPointType;
                tempProportion.Proportion    = proportion;
                base.Add(tempProportion);
            }
        }
Exemple #29
0
 public UserPoint GetUserPoint(UserPointType userPointType)
 {
     if (userPointType == UserPointType.GeneralPoint)
     {
         UserPoint point = new UserPoint();
         point.Name     = GeneralPointName;
         point.UnitName = string.Empty;
         point.Type     = userPointType;
         point.Enable   = true;
         point.Display  = DisplayGeneralPoint;
         return(point);
     }
     foreach (UserPoint userPoint in UserPoints)
     {
         if (userPointType == userPoint.Type)
         {
             return(userPoint);
         }
     }
     return(null);
 }
Exemple #30
0
        /// <summary>
        /// 删除等级图标设置
        /// </summary>
        /// <param name="pointType"></param>
        /// <returns></returns>
        public static bool DeletePointIcon(UserPointType pointType)
        {
            lock (AllSettings.Current.PointSettings)
            {
                PointSettings setting = SettingManager.CloneSetttings <PointSettings>(AllSettings.Current.PointSettings);

                for (int i = 0; i < setting.PointIcons.Count; i++)
                {
                    if (setting.PointIcons[i].PointType == pointType)
                    {
                        setting.PointIcons.RemoveAt(i);
                        break;
                    }
                }

                bool success = SettingManager.SaveSettings(setting);

                //if (success)
                //    AllSettings.Current.PointSettings = setting;
                return(success);
            }
        }
        private void AddExchangeRule()
        {
            MessageDisplay msgDisplay    = CreateMessageDisplay();
            int?           pointID       = _Request.Get <int>("points", Method.Post);
            int?           targetPointID = _Request.Get <int>("targetpoints", Method.Post);

            if (pointID == null)
            {
                msgDisplay.AddError(Lang_Error.User_UserPointNotSellectExchangePointError);
                return;
            }
            if (targetPointID == null)
            {
                msgDisplay.AddError(Lang_Error.User_UserPointNotSellectExchangeTargetPointError);
                return;
            }

            UserPointType pointType       = (UserPointType)pointID;
            UserPointType targetPointType = (UserPointType)targetPointID;


            try
            {
                if (!PointActionManager.AddPointExchangeRule(pointType, targetPointType))
                {
                    CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
 protected string GetPointIconUpdateDescription(UserPointType pointType)
 {
     return AllSettings.Current.PointSettings.PointIcons.GetPointIconUpgradeDescription(pointType);
 }
        protected string GetExchangeProportion(UserPointType pointType,UserPointType targetPointType)
        {
            PointExchangeProportion proportion = null;
            PointExchangeProportion targetProportion = null;
            foreach (PointExchangeProportion tempProportion in AllSettings.Current.PointSettings.ExchangeProportions)
            {
                if (tempProportion.UserPointType == pointType)
                {
                    proportion = tempProportion;
                    if (targetProportion != null)
                        break;
                }
                if (tempProportion.UserPointType == targetPointType)
                {
                    targetProportion = tempProportion;
                    if (proportion != null)
                        break;
                }
            }

            int greatestCommonDivisor = MathUtil.GetGreatestCommonDivisor(proportion.Proportion, targetProportion.Proportion);

            return proportion.Proportion / greatestCommonDivisor + ":" + (targetProportion.Proportion / greatestCommonDivisor);
        }
Exemple #34
0
 protected int GetPoint(UserPointType type)
 {
     return My.ExtendedPoints[(int)type];
 }
        private RateSetItem GetRankSetItem(UserPointType pointType, int id, bool isNew, MessageDisplay msgDisplay)
        {
            Guid roleID;
            string value;

            int sortOrder = 0;
            if (id == 0 && isNew == false)
                roleID = Guid.Empty;
            else
            {
                string roleIDName, sortOrderName;
                if (isNew)
                {
                    roleIDName = "new_role_" + pointType.ToString();
                    sortOrderName = "new_sortorder_" + pointType.ToString();
                }
                else
                {
                    roleIDName = "role_" + pointType.ToString() + "_" + id;
                    sortOrderName = "sortorder_" + pointType.ToString() + "_" + id;
                }

                roleID = _Request.Get<Guid>(roleIDName, Method.Post, Guid.Empty);
                if (roleID == Guid.Empty)
                {
                    if (isNew && _Request.Get("display_tr_" + pointType.ToString(), Method.Post, "0") == "1")
                    {
                        msgDisplay.AddError("new_" + pointType.ToString(), "请选择一个用户组");
                    }
                    else
                        return null;
                }
                value = _Request.Get(sortOrderName, Method.Post, string.Empty);

                if (!int.TryParse(value, out sortOrder))
                {
                    if (isNew)
                        msgDisplay.AddError("new_" + pointType.ToString(), "排序必须为整数");
                    else
                        msgDisplay.AddError(pointType.ToString(), id, "排序必须为整数");
                }
            }

            RateSetItem rankSetItem = new RateSetItem();
            rankSetItem.PointType = pointType;
            rankSetItem.RoleID = roleID;
            rankSetItem.RoleSortOrder = sortOrder;

            string minValueName,maxValueName,maxValueInTimeName;
            if (isNew)
            {
                minValueName = "new_minvalue_" + pointType.ToString();
                maxValueName = "new_maxvalue_" + pointType.ToString();
                maxValueInTimeName = "new_maxvalueintime_" + pointType.ToString();
            }
            else
            {
                minValueName = "minvalue_" + pointType.ToString() + "_" + id;
                maxValueName = "maxvalue_" + pointType.ToString() + "_" + id;
                maxValueInTimeName = "maxvalueintime_" + pointType.ToString() + "_" + id;
            }

            int minValue = 0, maxValue = 0, maxValueInTime = 0;

            StringBuilder errors = new StringBuilder();

            value = _Request.Get(minValueName, Method.Post, string.Empty);
            if (value == string.Empty)
            {
                minValue = 0;
            }
            else
            {
                if (!int.TryParse(value, out minValue))
                {
                    errors.Append("最小值,");
                }
            }

            value = _Request.Get(maxValueName, Method.Post, string.Empty);
            if (value == string.Empty)
            {
                maxValue = 0;
            }
            else
            {
                if (!int.TryParse(value, out maxValue))
                {
                    errors.Append("最大值,");
                }
            }

            value = _Request.Get(maxValueInTimeName, Method.Post, string.Empty);
            if (value == string.Empty)
            {
                maxValueInTime = 0;
            }
            else
            {
                if (ForumID == 0)//全局设置 才能设置最大评分数
                {
                    if (!int.TryParse(value, out maxValueInTime))
                    {
                        errors.Append("1天内最大评分数,");
                    }
                }
            }

            string errorName;
            if(isNew)
                errorName = "new_"+pointType.ToString();
            else
                errorName = pointType.ToString();

            if (errors.Length > 0)
            {
                msgDisplay.AddError(errorName, id, errors.ToString(0, errors.Length - 1) + "必须为整数");

                return null;
            }

            if (maxValue < minValue)
            {
                msgDisplay.AddError(errorName, id, "“评分最小值”不能大于“评分最大值”");
                return null;
            }

            if (maxValueInTime < 0)
            {
                msgDisplay.AddError(errorName, id, "1天内最大评分数必须大于0");
                return null;
            }

            if (Math.Abs(minValue) > maxValueInTime)
            {
                msgDisplay.AddError(errorName, id, "1天内最大评分数必须大等于“评分最小值”的绝对值");
                return null;
            }

            if (Math.Abs(maxValue) > maxValueInTime)
            {
                msgDisplay.AddError(errorName, id, "1天内最大评分数必须大等于“评分最大值”的绝对值");
                return null;
            }

            rankSetItem.MaxValue = maxValue;
            rankSetItem.MinValue = minValue;
            rankSetItem.MaxValueInTime = maxValueInTime;

            return rankSetItem;

        }
Exemple #36
0
 public UserPoint GetUserPoint(UserPointType userPointType)
 {
     if (userPointType == UserPointType.GeneralPoint)
     {
         UserPoint point = new UserPoint();
         point.Name = GeneralPointName;
         point.UnitName = string.Empty;
         point.Type = userPointType;
         point.Enable = true;
         point.Display = DisplayGeneralPoint;
         return point;
     }
     foreach (UserPoint userPoint in UserPoints)
     {
         if (userPointType == userPoint.Type)
             return userPoint;
     }
     return null;
 }
Exemple #37
0
        protected RateSetItemCollection GetRateSetItems(UserPointType pointType)
        {
            RateSetItemCollection rankItems = CurrentRateSet.GetRateItems(pointType);

            return(rankItems);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pointType"></param>
 /// <returns></returns>
 protected PointExchangeRuleCollection GetPointExchangeRules(UserPointType pointType)
 {
     PointExchangeRuleCollection rules = new PointExchangeRuleCollection();
     foreach (PointExchangeRule rule in AllSettings.Current.PointSettings.PointExchangeRules)
     {
         if (rule.PointType == pointType)
             rules.Add(rule);
     }
     return rules;
 }
 protected bool isEnd(UserPointType pointType,int index)
 {
     if (index == GetPointExchangeRules(pointType).Count - 1)
         return true;
     return false;
 }
Exemple #40
0
        private RateSetItem GetRankSetItem(UserPointType pointType, int id, bool isNew, MessageDisplay msgDisplay)
        {
            Guid   roleID;
            string value;

            int sortOrder = 0;

            if (id == 0 && isNew == false)
            {
                roleID = Guid.Empty;
            }
            else
            {
                string roleIDName, sortOrderName;
                if (isNew)
                {
                    roleIDName    = "new_role_" + pointType.ToString();
                    sortOrderName = "new_sortorder_" + pointType.ToString();
                }
                else
                {
                    roleIDName    = "role_" + pointType.ToString() + "_" + id;
                    sortOrderName = "sortorder_" + pointType.ToString() + "_" + id;
                }

                roleID = _Request.Get <Guid>(roleIDName, Method.Post, Guid.Empty);
                if (roleID == Guid.Empty)
                {
                    if (isNew && _Request.Get("display_tr_" + pointType.ToString(), Method.Post, "0") == "1")
                    {
                        msgDisplay.AddError("new_" + pointType.ToString(), "请选择一个用户组");
                    }
                    else
                    {
                        return(null);
                    }
                }
                value = _Request.Get(sortOrderName, Method.Post, string.Empty);

                if (!int.TryParse(value, out sortOrder))
                {
                    if (isNew)
                    {
                        msgDisplay.AddError("new_" + pointType.ToString(), "排序必须为整数");
                    }
                    else
                    {
                        msgDisplay.AddError(pointType.ToString(), id, "排序必须为整数");
                    }
                }
            }

            RateSetItem rankSetItem = new RateSetItem();

            rankSetItem.PointType     = pointType;
            rankSetItem.RoleID        = roleID;
            rankSetItem.RoleSortOrder = sortOrder;

            string minValueName, maxValueName, maxValueInTimeName;

            if (isNew)
            {
                minValueName       = "new_minvalue_" + pointType.ToString();
                maxValueName       = "new_maxvalue_" + pointType.ToString();
                maxValueInTimeName = "new_maxvalueintime_" + pointType.ToString();
            }
            else
            {
                minValueName       = "minvalue_" + pointType.ToString() + "_" + id;
                maxValueName       = "maxvalue_" + pointType.ToString() + "_" + id;
                maxValueInTimeName = "maxvalueintime_" + pointType.ToString() + "_" + id;
            }

            int minValue = 0, maxValue = 0, maxValueInTime = 0;

            StringBuilder errors = new StringBuilder();

            value = _Request.Get(minValueName, Method.Post, string.Empty);
            if (value == string.Empty)
            {
                minValue = 0;
            }
            else
            {
                if (!int.TryParse(value, out minValue))
                {
                    errors.Append("最小值,");
                }
            }

            value = _Request.Get(maxValueName, Method.Post, string.Empty);
            if (value == string.Empty)
            {
                maxValue = 0;
            }
            else
            {
                if (!int.TryParse(value, out maxValue))
                {
                    errors.Append("最大值,");
                }
            }

            value = _Request.Get(maxValueInTimeName, Method.Post, string.Empty);
            if (value == string.Empty)
            {
                maxValueInTime = 0;
            }
            else
            {
                if (ForumID == 0)//全局设置 才能设置最大评分数
                {
                    if (!int.TryParse(value, out maxValueInTime))
                    {
                        errors.Append("1天内最大评分数,");
                    }
                }
            }

            string errorName;

            if (isNew)
            {
                errorName = "new_" + pointType.ToString();
            }
            else
            {
                errorName = pointType.ToString();
            }

            if (errors.Length > 0)
            {
                msgDisplay.AddError(errorName, id, errors.ToString(0, errors.Length - 1) + "必须为整数");

                return(null);
            }

            if (maxValue < minValue)
            {
                msgDisplay.AddError(errorName, id, "“评分最小值”不能大于“评分最大值”");
                return(null);
            }

            if (maxValueInTime < 0)
            {
                msgDisplay.AddError(errorName, id, "1天内最大评分数必须大于0");
                return(null);
            }

            if (Math.Abs(minValue) > maxValueInTime)
            {
                msgDisplay.AddError(errorName, id, "1天内最大评分数必须大等于“评分最小值”的绝对值");
                return(null);
            }

            if (Math.Abs(maxValue) > maxValueInTime)
            {
                msgDisplay.AddError(errorName, id, "1天内最大评分数必须大等于“评分最大值”的绝对值");
                return(null);
            }

            rankSetItem.MaxValue       = maxValue;
            rankSetItem.MinValue       = minValue;
            rankSetItem.MaxValueInTime = maxValueInTime;

            return(rankSetItem);
        }
        protected RateSetItemCollection GetRateSetItems(UserPointType pointType)
        {
            RateSetItemCollection rankItems = CurrentRateSet.GetRateItems(pointType);

            return rankItems;
        }
Exemple #42
0
 public void GetPointStatInfo(PointLogFilter filter, UserPointType pointIndex, out int count, out int produceCount, out int consumeCount)
 {
     PointLogDao.Instance.GetPointStatInfo(filter, (int)pointIndex, out count, out produceCount, out consumeCount);
 }
Exemple #43
0
 public int GetUserPoint(UserPointType type)
 {
     return(My.ExtendedPoints[(int)type]);
 }
Exemple #44
0
 public int GetUserPoint(UserPointType type)
 {
     return My.ExtendedPoints[(int)type];
 }
 public void PointTransferRule(UserPointType userPointType,PointTransferRuleTemplate item)
 {
     PointTransferRule rule = AllSettings.Current.PointSettings.PointTransferRules.GetRule(userPointType);
     if (rule == null)
     {
         rule = new PointTransferRule();
         rule.PointType = userPointType;
     }
     item(rule);
 }