亚洲3P视频,日韩BBW无码,亚洲制服麻豆网站,88re伊人,九草精品视频在线观看,国产精品久久夜,色青青狠狠色,无码熟女一区二区三区,日本一区二区成人网站

新聞建站cms系統(tǒng)、政府cms系統(tǒng)定制開發(fā)

廣州網(wǎng)站建設(shè)公司-閱速公司

asp.net新聞發(fā)布系統(tǒng)、報紙數(shù)字報系統(tǒng)方案
/
http://m.duxiu2008.cn/
廣州網(wǎng)站建設(shè)公司
您當前位置:首頁>ASP.NET MVC

ASP.NET MVC

asp.net mvc 服務(wù)器端返回JSON

發(fā)布時間:2013/6/10 10:13:34  作者:Admin  閱讀:526  

廣告:

using System;

using System.Text;

using System.Web;

using System.Web.Mvc;

using System.Data.SqlClient;

using System.Drawing;

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

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

廣告:

相關(guān)文章
asp.net mvc
JSON
cms新聞系統(tǒng)購買咨詢
掃描關(guān)注 廣州閱速軟件科技有限公司
掃描關(guān)注 廣州閱速科技
手游| 沧源| 家居| 修文县| 龙口市| 民勤县| 襄垣县| 大关县| 华蓥市| 东平县| 怀化市| 南宁市| 东兴市| 逊克县| 陇川县| 揭阳市| 菏泽市| 桑日县| 闻喜县| 湟中县| 伊金霍洛旗| 定南县| 文昌市| 张家川| 怀集县| 双柏县| 忻城县| 东乡县| 乳源| 泾川县| 罗平县| 连南| 宁安市| 隆德县| 冷水江市| 婺源县| 高平市| 丹寨县| 樟树市| 安新县| 奉化市|