Exemplo n.º 1
0
        /// <summary>
        /// 给指定帖子评分
        /// </summary>
        /// <param name="postidlist">帖子列表</param>
        /// <param name="score">要加/减的分值列表</param>
        /// <param name="extcredits">对应的扩展积分列表</param>
        /// <returns>更新数量</returns>
        public static int RatePosts(int tid, string postidlist, string score, string extcredits, int userid, string username, string reason)
        {
            if (!Utils.IsNumericList(postidlist))
            {
                return(0);
            }

            float[]  extcreditslist    = new float[] { 0, 0, 0, 0, 0, 0, 0, 0 };
            string[] tmpScorelist      = Utils.SplitString(score, ",");
            string[] tmpExtcreditslist = Utils.SplitString(extcredits, ",");
            int      tempExtc          = 0;
            string   posttableid       = Data.PostTables.GetPostTableId(tid);

            for (int i = 0; i < tmpExtcreditslist.Length; i++)
            {
                tempExtc = TypeConverter.StrToInt(tmpExtcreditslist[i], -1);
                if (tempExtc > 0 && tempExtc < extcreditslist.Length)
                {
                    extcreditslist[tempExtc - 1] = TypeConverter.StrToInt(tmpScorelist[i]);

                    //更新相应帖子的积分数
                    foreach (string pid in Utils.SplitString(postidlist, ","))
                    {
                        if (pid.Trim() != string.Empty)
                        {
                            SetPostRate(posttableid,
                                        TypeConverter.StrToInt(pid),
                                        TypeConverter.StrToInt(tmpExtcreditslist[i]),
                                        TypeConverter.StrToFloat(tmpScorelist[i]),
                                        true);
                        }
                    }
                    AdminRateLogs.InsertLog(postidlist,
                                            userid,
                                            username,
                                            tempExtc,
                                            TypeConverter.StrToFloat(tmpScorelist[i]),
                                            reason);
                }
            }
            return(CreditsFacade.UpdateUserExtCredits(GetUserListWithPostlist(tid, postidlist), extcreditslist));
        }