Ejemplo n.º 1
0
        /// <summary>
        /// 获得用户排行的html
        /// </summary>
        /// <param name="users"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetUserRankHtml(ShortUserInfo[] users, string type, int maxrows)
        {
            StringBuilder builder   = new StringBuilder();
            string        unit      = "";
            int           blankrows = maxrows;

            foreach (ShortUserInfo u in users)
            {
                string count = string.Empty;
                switch (type)
                {
                case "credits":
                    count = u.Credits.ToString();
                    break;

                case "extcredits1":
                    count = u.Extcredits1.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[1];
                    break;

                case "extcredits2":
                    count = u.Extcredits2.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[2];
                    break;

                case "extcredits3":
                    count = u.Extcredits3.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[3];
                    break;

                case "extcredits4":
                    count = u.Extcredits4.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[4];
                    break;

                case "extcredits5":
                    count = u.Extcredits5.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[5];
                    break;

                case "extcredits6":
                    count = u.Extcredits6.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[6];
                    break;

                case "extcredits7":
                    count = u.Extcredits7.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[7];
                    break;

                case "extcredits8":
                    count = u.Extcredits8.ToString();
                    unit  = Scoresets.GetValidScoreUnit()[8];
                    break;

                case "digestposts":
                    count = u.Digestposts.ToString();
                    break;

                case "onlinetime":
                    count = Math.Round(((double)u.Oltime) / 60, 2).ToString();
                    unit  = "小时";
                    break;

                default:
                    count = u.Posts.ToString();
                    break;
                }

                builder.AppendFormat("<li><em>{0}</em><a href=\"{1}\" target=\"_blank\">{2}</a></li>", count + (unit == string.Empty ? string.Empty : " " + unit), Urls.UserInfoAspxRewrite(u.Uid), u.Username);
                blankrows--;
            }
            for (int i = 0; i < blankrows; i++)
            {
                builder.Append("<li>&nbsp;</li>");
            }
            return(builder.ToString());
        }