Example #1
0
        /// <summary>
        /// 根据积分公式更新用户积分,并且受分数变动影响有可能会更改用户所属的用户组
        /// <param name="uid">用户ID</param>
        /// </summary>
        public static int UpdateUserCredits(int uid)
        {
            UserInfo tmpUserInfo = Users.GetUserInfo(uid);

            if (tmpUserInfo == null)
            {
                return(0);
            }

            DatabaseProvider.GetInstance().UpdateUserCredits(uid, Scoresets.GetScoreCalFormula());
            tmpUserInfo = Users.GetUserInfo(uid);
            UserGroupInfo tmpUserGroupInfo = UserGroups.GetUserGroupInfo(tmpUserInfo.Groupid);

            if (tmpUserGroupInfo != null && tmpUserGroupInfo.System == 0 && tmpUserGroupInfo.Radminid == 0)
            {
                tmpUserGroupInfo = GetCreditsUserGroupID(tmpUserInfo.Credits);
                DatabaseProvider.GetInstance().UpdateUserGroup(uid, tmpUserGroupInfo.Groupid);
                OnlineUsers.UpdateGroupid(uid, tmpUserGroupInfo.Groupid);
            }
            else
            {
                //当用户是已删除的特殊组成员时,则运算相应积分,并更新该用户所属组信息
                if (tmpUserGroupInfo != null && tmpUserGroupInfo.Groupid == 7 && tmpUserInfo.Adminid == -1)
                {
                    tmpUserGroupInfo = GetCreditsUserGroupID(tmpUserInfo.Credits);
                    DatabaseProvider.GetInstance().UpdateUserGroup(uid, tmpUserGroupInfo.Groupid);
                    OnlineUsers.UpdateGroupid(uid, tmpUserGroupInfo.Groupid);
                }
            }
            return(1);
        }
Example #2
0
        /// <summary>
        /// 根据用户信息重新计算用户积分
        /// </summary>
        /// <param name="shortUserInfo">用户信息</param>
        /// <returns>用户积分</returns>
        public static int GetUserCreditsByUserInfo(ShortUserInfo shortUserInfo)
        {
            string ArithmeticStr = Scoresets.GetScoreCalFormula();

            if (Utils.StrIsNullOrEmpty(ArithmeticStr))
            {
                return(0);
            }

            ArithmeticStr = ArithmeticStr.Replace("digestposts", shortUserInfo.Digestposts.ToString());
            ArithmeticStr = ArithmeticStr.Replace("posts", shortUserInfo.Posts.ToString());
            ArithmeticStr = ArithmeticStr.Replace("oltime", shortUserInfo.Oltime.ToString());
            ArithmeticStr = ArithmeticStr.Replace("pageviews", shortUserInfo.Pageviews.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits1", shortUserInfo.Extcredits1.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits2", shortUserInfo.Extcredits2.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits3", shortUserInfo.Extcredits3.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits4", shortUserInfo.Extcredits4.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits5", shortUserInfo.Extcredits5.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits6", shortUserInfo.Extcredits6.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits7", shortUserInfo.Extcredits7.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits8", shortUserInfo.Extcredits8.ToString());

            object expression = Arithmetic.ComputeExpression(ArithmeticStr);

            return(Utils.StrToInt(Math.Floor(Utils.StrToFloat(expression, 0)), 0));
        }
Example #3
0
        /// <summary>
        /// 获得系统设置的总积分计算公式
        /// </summary>
        /// <returns>计算公式</returns>
        private static string GetCreditsArithmetic(int uid)
        {
            string ArithmeticStr = Scoresets.GetScoreCalFormula();

            if (ArithmeticStr.Equals(""))
            {
                return("0");
            }
            string[] para =
            {
                "digestposts",
                "posts",
                "oltime",
                "pageviews",
                "extcredits1",
                "extcredits2",
                "extcredits3",
                "extcredits4",
                "extcredits5",
                "extcredits6",
                "extcredits7",
                "extcredits8"
            };


            IDataReader reader = Users.GetShortUserInfoToReader(uid);

            if (reader != null)
            {
                if (reader.Read())
                {
                    for (int i = 0; i < para.Length; i++)
                    {
                        ArithmeticStr = ArithmeticStr.Replace(para[i], Utils.StrToFloat(reader[para[i]], 0).ToString());
                    }
                }
                reader.Close();
            }
            return(ArithmeticStr);
        }