json1246574([{"site_Id":"E001","group_Id":"11","id":"4","parentId":"1","sm_Career":"4","sm_CountryID":"3","sm_Level":"120","sm_PlayerName":"TJ春哥","sm_UID":"11259595285420516","sm_UpState":"4","sm_UpdateTime":"1264236590","sm_officeRankBase":"91"}],
[{"site_Id":"E001","id":"3","sm_Career":"1","sm_PlayerName":"TJ卡耐基","sm_UID":"11001897265572627","sm_UpState":"5","sm_UpdateTime":"1264236028","sm_officeRankBase":"95"}],"id":"2","sm_Career":"3","sm_CountryID":"2","sm_PlayerName":"天边飞羽","sm_UID":"11001897304015173","sm_UpState":"3","sm_UpdateTime":"1264179528","sm_officeRankBase":"36"}])
===================================================================
//Json获取数据的函数,其中rankName、rankType通过url赋值
public static string GetRankInfoForWeb(int count,string siteId,string groupId,string rankName,string rankType)@H_404_11@ {@H_404_11@ StringBuilder builder = null;
try@H_404_11@ {@H_404_11@ DataTable dt =@H_404_11@ AllService.GetDataFromRankNameByTopNRank(count,siteId,groupId,rankName,rankType).Tables[0];
if (dt != null)@H_404_11@ {@H_404_11@ builder = new StringBuilder();@H_404_11@ // builder.Append("({");@H_404_11@ builder.Append("(");@H_404_11@ if (rankName == "Army_ArmyPower") //军团——强度@H_404_11@ {@H_404_11@ for (int i = 0; i < dt.Rows.Count; i++)@H_404_11@ {@H_404_11@ builder.Append("[{");@H_404_11@ builder.AppendFormat(@H_404_11@ "/"site_Id/":/"{0}/",/"group_Id/":/"{1}/",/"id/":/"{2}/",/"parentId/":/"{3}/",/"sm_ArmyLeaderLevel/":/"{4}/","@H_404_11@ +@H_404_11@ "/"sm_ArmyLevel/":/"{5}/",/"sm_ArmyName/":/"{6}/",/"sm_ArmyPeople/":/"{7}/",/"sm_ArmyPower/":/"{8}/","@H_404_11@ + "/"sm_CountryID/":/"{9}/",/"sm_UpState/":/"{10}/",/"sm_ArmyID/":/"{11}/"",@H_404_11@ dt.Rows[i]["site_id"],dt.Rows[i]["group_id"],dt.Rows[i]["id"],dt.Rows[i]["parentID"],@H_404_11@ dt.Rows[i]["sm_ArmyLeaderLevel"],dt.Rows[i]["sm_ArmyLevel"],dt.Rows[i]["sm_ArmyName"],@H_404_11@ dt.Rows[i]["sm_ArmyPeople"],dt.Rows[i]["sm_ArmyPower"],dt.Rows[i]["sm_CountryID"],@H_404_11@ dt.Rows[i]["sm_UpState"],dt.Rows[i]["sm_ArmyID"]); //dt.Rows[0]["rowtime"],@H_404_11@ builder.Append("}]");@H_404_11@ builder.Append(",");@H_404_11@ }@H_404_11@ }@H_404_11@ if (rankName == "Level_LevelAll") //等级——个人@H_404_11@ {@H_404_11@ for (int i = 0; i < dt.Rows.Count;i++ )@H_404_11@ {@H_404_11@ builder.Append("[{");@H_404_11@ builder.AppendFormat(@H_404_11@ "/"site_Id/":/"{0}/",/"sm_Career/":/"{4}/","@H_404_11@ +@H_404_11@ "/"sm_CountryID/":/"{5}/",/"sm_Level/":/"{6}/",/"sm_PlayerName/":/"{7}/",/"sm_UID/":/"{8}/","@H_404_11@ + "/"sm_UpState/":/"{9}/",/"sm_UpdateTime/":/"{10}/",/"sm_officeRankBase/":/"{11}/"",@H_404_11@ dt.Rows[i]["sm_Career"],dt.Rows[i]["sm_Level"],@H_404_11@ dt.Rows[i]["sm_PlayerName"],dt.Rows[i]["sm_UID"],dt.Rows[i]["sm_UpState"],@H_404_11@ dt.Rows[i]["sm_UpdateTime"],dt.Rows[i]["sm_officeRankBase"]);@H_404_11@ builder.Append("}]");@H_404_11@ builder.Append(",");@H_404_11@ }@H_404_11@ }@H_404_11@ builder.Append("}");@H_404_11@ //builder.Append(",");@H_404_11@ builder.Remove(builder.Length - 1,1);@H_404_11@ builder.Append(")");@H_404_11@ builder.Remove(builder.Length - 2,1);//去掉倒数第二个符号,@H_404_11@ }@H_404_11@ }@H_404_11@ catch (Exception ex)@H_404_11@ {@H_404_11@ LogHelper.Error("获取排行榜中信息异常,方法名[GetRankInfoForWeb()]",ex);@H_404_11@ }@H_404_11@ string nullStr = "信息为空";@H_404_11@ string sbStr = string.Empty;@H_404_11@ if (builder != null)@H_404_11@ {@H_404_11@ sbStr = Equals(builder,nullStr) ? nullStr : builder.ToString();@H_404_11@ return sbStr;@H_404_11@ }@H_404_11@ return sbStr;@H_404_11@ }
if(!IsPostBack)@H_404_11@ {@H_404_11@ try@H_404_11@ {@H_404_11@ string callback = Request.QueryString["callback"].ToString();@H_404_11@ // int count = int.Parse(ConfigurationManager.AppSettings["TopNforweb"].ToString());@H_404_11@ int count = 3;@H_404_11@ string rankName = ""; //排行榜的名称@H_404_11@ string rankType = ""; //排行的类型@H_404_11@ string str = "";@H_404_11@ rankName = Request.QueryString["rankName"].ToString();@H_404_11@ rankType = Request.QueryString["rankType"].ToString();@H_404_11@ if (!string.IsNullOrEmpty(rankType))@H_404_11@ {@H_404_11@ str = OutPutService.GetRankInfoForWeb(count,"",rankType); //军团—强度;等级——个人@H_404_11@ }@H_404_11@ else@H_404_11@ {@H_404_11@ Response.Write("请输入正确的参数!");@H_404_11@ }
Response.Write(callback + str);@H_404_11@ }@H_404_11@ catch (Exception ex)@H_404_11@ {@H_404_11@ Response.Write("提示:请输入正确的参数。");@H_404_11@ }@H_404_11@ }
其他备注:
<form id="form1" runat="server" method="post" action="OutPutDataWrite.aspx?rankName=?&&rankType=?&&callback=?">
OutPutDataForWeb.aspx?rankName=Level_LevelAll&&rankType=sm_Level&&callback=json1246574
原文链接:https://www.f2er.com/json/290825.html