using System.IO;
using System.IO.Compression;
using System.Data;
using System.Data.SqlClient;
using System.Runtime.Serialization.Formatters.Binary;
//DataSet
#region
private void BindDataSet(DataSet ds)
{
//this.GridView1.DataSource = null;
//this.GridView1.DataSource = ds.Tables[0];
//this.GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
localhost. Service1 ws = new localhost.Service1();
DateTime dtBegin = DateTime .Now;
DataSet ds = ws.GetDataSet();
this.Label1.Text = string .Format("耗时 : {0}",DateTime.Now-dtBegin);
BindDataSet(ds);
}
protected void Button2_Click(object sender, EventArgs e)
{
localhost. Service1 ws = new localhost.Service1();
DateTime dtBegin = DateTime .Now;
byte[] buffer = ws.GetDataSetBytes();
BinaryFormatter ser = new BinaryFormatter();
DataSet ds = ser.Deserialize(new MemoryStream(buffer)) as DataSet;
this.Label2.Text = string .Format("耗时 : {0}; 大小:{1}" , DateTime.Now - dtBegin,buffer.Length.ToString());
BindDataSet(ds);
}
protected void Button3_Click(object sender, EventArgs e)
{
localhost. Service1 ws = new localhost.Service1();
DateTime dtBegin = DateTime .Now;
byte[] buffer = ws.GetDataSetSurrogateBytes();
BinaryFormatter ser = new BinaryFormatter();
dss. DataSetSurrogate dss = ser.Deserialize(new MemoryStream(buffer)) as dss.DataSetSurrogate;
DataSet ds = dss.ConvertToDataSet();
this.Label3.Text = string .Format("耗时 : {0}; 大小:{1}" , DateTime.Now - dtBegin,buffer.Length.ToString());
BindDataSet(ds);
}
protected void Button4_Click(object sender, EventArgs e)
{
localhost. Service1 ws = new localhost.Service1();
DateTime dtBegin = DateTime .Now;
byte[] zipBuffer = ws.GetDataSetSurrogateZipBytes();
byte[] buffer = UnZipClass .Decompress(zipBuffer);
BinaryFormatter ser = new BinaryFormatter();
dss. DataSetSurrogate dss = ser.Deserialize(new MemoryStream(buffer)) as dss.DataSetSurrogate;
DataSet ds = dss.ConvertToDataSet();
this.Label4.Text = string .Format("耗时 : {0}; 大小:{1}" , DateTime.Now - dtBegin,zipBuffer.Length.ToString());
BindDataSet(ds);
}
#endregion
Webservice之Dataset传输[客户端]
最新推荐文章于 2020-10-28 16:53:43 发布