国产老熟女高潮毛片A片仙踪林,欧美喂奶吃大乳,狠狠爱无码一区二区三区,女神的私人医生动漫免费阅读

新聞建站cms系統、政府cms系統定制開發

廣州網站建設公司-閱速公司

asp.net新聞發布系統、報紙數字報系統方案
/
http://www.tjsimaide.com/
廣州網站建設公司
您當前位置:首頁>ASP.NET MVC

ASP.NET MVC

asp.net mvc 服務器端返回JSON

發布時間:2013/6/10 10:13:34  作者:Admin  閱讀:470  

廣告:

using System;

using System.Text;

using System.Web;

using System.Web.Mvc;

using System.Data.SqlClient;

using System.Drawing;

#region 生成文件JSON(也可直接輸出JSON,生成文件便于減少服務器壓力)

public void Provincefile()

{

int classid = 1; //報紙 6為雜志

if (Request.QueryString["bi"] != null && Request.QueryString["bi"].ToString() != "")

classid = int.Parse(Request.QueryString["bi"].ToString());

string wherestr = " parentid=0 ";

string sql = "select areaid,cnname,parentid,childclass from area where " + wherestr;

SqlDataReader dr = DB.DataReader(sql, null);

string areaid = "";

string cnname = "";

int total = 0;

int i = 0;

int j = 0;

string childclass = "";

StringBuilder hb = new StringBuilder();

hb.Append("{\"bk_province\": [ ");//返回bk_province表

while (dr.Read())

{

i++;

areaid = dr[0].ToString();

cnname = dr[1].ToString();

total = Mvc_areabll.Totalbk(Fun.Toint(areaid),classid);

childclass=dr[3].ToString();

if (i >1)

hb.Append(",");

hb.Append("{ \"areaid\": \"");

hb.Append(areaid);

hb.Append("\", \"cnname\": \"");

hb.Append(cnname);

hb.Append("\", \"total\": \"");

hb.Append(total);

hb.Append("\", \"childclass\": \"");

hb.Append(childclass);

hb.Append("\"");

//下面二級城市 bk_city:{....}

wherestr = " parentid=" +areaid;

sql = "select areaid,cnname,parentid,childclass from area where " + wherestr;

SqlDataReader dr2 = DB.DataReader(sql, null);

j = 0;

if (dr2.Read())

{

hb.Append(",\"bk_city\": [ ");//二級bk_city表記錄

do

{

areaid = dr2[0].ToString();

cnname = dr2[1].ToString();

total = Mvc_areabll.Totalbk(Fun.Toint(areaid), classid);

childclass = dr2[3].ToString();

if (total > 0)

{

j++;

if (j>1)

hb.Append(",");

hb.Append("{ \"cityid\": \"");

hb.Append(areaid);

hb.Append("\", \"cityname\": \"");

hb.Append(cnname);

hb.Append("\", \"citytotal\": \"");

hb.Append(total);

hb.Append("\", \"citychildclass\": \"");

hb.Append(childclass);

hb.Append("\" }");

}

 

}

while (dr2.Read());

hb.Append(" ]"); //二級bk_city表記錄

}

dr2.Close();

dr2.Dispose();

//二級城市 bk_city finish

hb.Append(" }");

 

}

dr.Close();

dr.Dispose();

hb.Append(" ] }"); //返回表名

string filestr = hb.ToString();

//生成json文件

string filename = "";

if (classid == 1)

filename = "bk_province.json";

else

filename = "mag_province.json";

string filename1 = Server.MapPath(Fun.Webdirectory + Fun.Savedata() + "/json/" + filename);

// Response.Write(filestr);

Mvccom.Funs.SaveFile(filestr, filename1);

Response.Write("ok");

hb = null;

return;

}

#endregion

 

using System;

using System.Globalization;

using System.Text;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.IO;

#region 保存為文件方法

public static void SaveFile(string filecon, string fileName)

{

FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);

byte[] byteData = Encoding.UTF8.GetBytes(filecon);

fs.Write(byteData, 0, byteData.Length);

fs.Close();

fs.Dispose();

}

#endregion

廣告:

相關文章
asp.net mvc
JSON
cms新聞系統購買咨詢
掃描關注 廣州閱速軟件科技有限公司
掃描關注 廣州閱速科技
主站蜘蛛池模板: 南丹县| 玛纳斯县| 金堂县| 德惠市| 麻江县| 长海县| 延吉市| 温州市| 扶绥县| 堆龙德庆县| 贵阳市| 黔江区| 定陶县| 汾西县| 嵩明县| 九江市| 张家川| 师宗县| 昌江| 东平县| 博湖县| 正宁县| 当雄县| 集安市| 桂林市| 冀州市| 开封县| 新宁县| 红河县| 泽普县| 镶黄旗| 福州市| 西峡县| 南宁市| 贡嘎县| 唐山市| 河南省| 南汇区| 融水| 云梦县| 芷江|