Exemple #1
0
        /// <summary>
        /// 绑定feed模板中的变量值
        /// </summary>
        /// <param name="template"></param>
        /// <param name="dataJson"></param>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public static string MergeFeedTemplateData(string template, string dataJson, UserInfo userInfo)
        {
            Dictionary <string, string> dataList = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(dataJson))
            {
                dataList = JavaScriptConvert.DeserializeObject <Dictionary <string, string> >(dataJson);
            }

            string actorData = string.Format("<a href=\"{0}\">{1}</a>", Urls.UserInfoAspxRewrite(userInfo.Uid), userInfo.Username);

            dataList.Add("actor", actorData);

            foreach (string key in dataList.Keys)
            {
                template = template.Replace("{" + key + "}", dataList[key]);
            }

            return(template);
        }
Exemple #2
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());
        }
Exemple #3
0
 protected string UserInfoAspxRewrite(int userid)
 {
     return(Urls.UserInfoAspxRewrite(userid));
 }