http://tech.it168.com/a2009/0604/583/000000583382_5.shtml
//webmethod序列化数据
privatevoid btnSerial_Click(object sender, EventArgs e)
{
try
{
this.dtGrid.DataSource =null;
DataSet ds =new DataSet();
DateTime dtBegin = DateTime.Now;
byte[] datas = ws.GetDataSetBytes();
DateTime dtDown = DateTime.Now;
ds = (DataSet)ComZipClass.zip.objXmlDeserialize(datas, typeof(DataSet));
DateTime dtSerial = DateTime.Now;
this.dtGrid.DataSource = ds.Tables[0];
MessageBox.Show(string.Format("下载耗时:{0},解压序列化数据耗时:{1},绑定数据耗时:{2},数据量:{3}",
dtDown - dtBegin,dtSerial-dtDown, DateTime.Now - dtDown, datas.Length));
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
//序列化并压缩BZIP后数据
privatevoid btnBZip_Click(object sender, EventArgs e)
{
try
{
this.dtGrid.DataSource =null;
DataSet ds =new DataSet();
DateTime dtBegin = DateTime.Now;
byte[] datas = ws.GetBZiipCompress();
DateTime dtDown = DateTime.Now;
byte[] uzip = ComZipClass.zip.BZipDeCompress(datas);
DateTime dtUnzip = DateTime.Now;
ds = (DataSet)ComZipClass.zip.objXmlDeserialize(uzip, typeof(DataSet));
DateTime dtSerial = DateTime.Now;
this.dtGrid.DataSource = ds.Tables[0];
MessageBox.Show(string.Format("下载耗时:{0},解压BZIP耗时:{1},解压序列化耗时:{2},绑定数据耗时:{3},数据量:{4}",
dtDown - dtBegin, dtUnzip - dtDown, dtSerial - dtUnzip, DateTime.Now - dtSerial, datas.Length));
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
//序列化并压缩Deflate后数据
privatevoid btnDeflater_Click(object sender, EventArgs e)
{
try
{
this.dtGrid.DataSource =null;
DataSet ds =new DataSet();
DateTime dtBegin = DateTime.Now;
byte[] datas = ws.GetDeflaterCompress();
DateTime dtDown = DateTime.Now;
byte[] uzip = ComZipClass.zip.DeflaterDeCompress(datas);
DateTime dtUnzip = DateTime.Now;
ds = (DataSet)ComZipClass.zip.objXmlDeserialize(uzip, typeof(DataSet));
DateTime dtSerial = DateTime.Now;
this.dtGrid.DataSource = ds.Tables[0];
MessageBox.Show(string.Format("下载耗时:{0},解压Deflater耗时:{1},解压序列化耗时:{2},绑定数据耗时:{3},数据量:{4}",
dtDown - dtBegin, dtUnzip - dtDown, dtSerial - dtUnzip, DateTime.Now - dtSerial, datas.Length));
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
//序列化并压缩GZIP后数据
privatevoid btnGZip_Click(object sender, EventArgs e)
{
try
{
this.dtGrid.DataSource =null;
DataSet ds =new DataSet();
DateTime dtBegin = DateTime.Now;
byte[] datas = ws.GetGZipCompress();
DateTime dtDown = DateTime.Now;
byte[] uzip = ComZipClass.zip.GZipDeCompress(datas);
DateTime dtUnzip = DateTime.Now;
ds = (DataSet)ComZipClass.zip.objXmlDeserialize(uzip, typeof(DataSet));
DateTime dtSerial = DateTime.Now;
this.dtGrid.DataSource = ds.Tables[0];
MessageBox.Show(string.Format("下载耗时:{0},解压GZIP耗时:{1},解压序列化耗时:{2},绑定数据耗时:{3},数据量:{4}",
dtDown - dtBegin, dtUnzip - dtDown, dtSerial - dtUnzip, DateTime.Now - dtSerial, datas.Length));
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
//序列化并压缩ZIP后数据
privatevoid btnZip_Click(object sender, EventArgs e)
{
try
{
this.dtGrid.DataSource =null;
DataSet ds =new DataSet();
DateTime dtBegin = DateTime.Now;
byte[] datas = ws.GetZipCompress();
DateTime dtDown = DateTime.Now;
byte[] uzip = ComZipClass.zip.ZipDeCompress(datas);
DateTime dtUnzip = DateTime.Now;
ds = (DataSet)ComZipClass.zip.objXmlDeserialize(uzip, typeof(DataSet));
DateTime dtSerial = DateTime.Now;
this.dtGrid.DataSource = ds.Tables[0];
MessageBox.Show(string.Format("下载耗时:{0},解压ZIP耗时:{1},解压序列化耗时:{2},绑定数据耗时:{3},数据量:{4}",
dtDown - dtBegin, dtUnzip - dtDown, dtSerial - dtUnzip, DateTime.Now - dtSerial, datas.Length));
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}