Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据用户Id获取用户积分
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <returns>用户积分</returns>
        public static int GetUserCreditsByUid(int uid)
        {
            ///根据公式计算用户的总积分,并更新
            string ExpressionStr = GetCreditsArithmetic(uid);

            return(Utils.StrToInt(Math.Floor(Utils.StrToFloat(Arithmetic.ComputeExpression(ExpressionStr), 0)), 0));
        }
Exemplo n.º 3
0
        public static int GetUserCreditsByUserInfo(IUser shortUserInfo)
        {
            string text = Scoresets.GetScoreCalFormula();

            if (text.IsNullOrEmpty())
            {
                return(0);
            }
            text = text.Replace("digestposts", shortUserInfo.DigestPosts.ToString());
            text = text.Replace("posts", shortUserInfo.Posts.ToString());
            text = text.Replace("oltime", shortUserInfo.OLTime.ToString());
            text = text.Replace("pageviews", shortUserInfo.PageViews.ToString());
            text = text.Replace("extcredits1", shortUserInfo.ExtCredits1.ToString());
            text = text.Replace("extcredits2", shortUserInfo.ExtCredits2.ToString());
            text = text.Replace("extcredits3", shortUserInfo.ExtCredits3.ToString());
            text = text.Replace("extcredits4", shortUserInfo.ExtCredits4.ToString());
            text = text.Replace("extcredits5", shortUserInfo.ExtCredits5.ToString());
            text = text.Replace("extcredits6", shortUserInfo.ExtCredits6.ToString());
            text = text.Replace("extcredits7", shortUserInfo.ExtCredits7.ToString());
            text = text.Replace("extcredits8", shortUserInfo.ExtCredits8.ToString());
            object strValue = Arithmetic.ComputeExpression(text);

            return((Int32)Math.Floor(strValue.ToDouble()));
        }