コード例 #1
0
        /// <summary>
        /// 把压缩后的字节数组 解压并反序列化成DataSet
        /// </summary>
        /// <param name="byteArray"></param>
        /// <returns>DataSet</returns>
        public static DataSet GetDataSetByZipBytes(byte[] byteArray)
        {
            DataSetSurrogate sds = null;

            MemoryStream    _MemoryStream    = new MemoryStream(Decompress(byteArray));
            BinaryFormatter _BinaryFormatter = new BinaryFormatter();
            object          o = _BinaryFormatter.Deserialize(_MemoryStream);

            sds = (DataSetSurrogate)o;
            return(sds.ConvertToDataSet());
        }
コード例 #2
0
ファイル: ReleaseData.cs プロジェクト: fengyubox/SFIS
        public static DataTable arrByteToDataTable(byte[] zipBuffer)
        {
            if (zipBuffer == null || zipBuffer.Length < 1)
            {
                return(null);
            }
            byte[]           buffer  = UnZipClass.Decompress(zipBuffer);
            BinaryFormatter  ser     = new BinaryFormatter();
            DataSetSurrogate dss     = ser.Deserialize(new MemoryStream(buffer)) as DataSetSurrogate;
            DataSet          dataSet = dss.ConvertToDataSet();

            return(dataSet.Tables[0]);
        }
コード例 #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            WebServices.SOAPTEST.SOAPTEST ds = new WebServices.SOAPTEST.SOAPTEST();
            DateTime dtBegin = DateTime.Now;

            byte[]           buffer  = ds.GetDataSetSurrogateBytes();
            BinaryFormatter  ser     = new BinaryFormatter();
            DataSetSurrogate dss     = ser.Deserialize(new MemoryStream(buffer)) as DataSetSurrogate;
            DataSet          dataSet = dss.ConvertToDataSet();

            this.label3.Text = string.Format("耗时:{0}", DateTime.Now - dtBegin) + "  " + buffer.Length;
            binddata(dataSet);
        }
コード例 #4
0
        /// <summary>
        /// 序列化转化为二进制数组的DataSet
        /// </summary>
        /// <param name="DS"></param>
        /// <returns></returns>
        public static byte[] GetDataSetSurrogateZipBYtes(DataSet DS)
        {
            DataSetSurrogate dss = new DataSetSurrogate(DS);
            ///二进制方式方式序列化
            BinaryFormatter ser = new BinaryFormatter();
            MemoryStream    ms  = new MemoryStream();

            ser.Serialize(ms, dss);
            byte[] buffer = ms.ToArray();
            ///调用压缩方法
            byte[] Zipbuffer = Compress(buffer);
            return(Zipbuffer);
        }
コード例 #5
0
        /// <summary>
        /// 返回压缩后的字节数组
        /// </summary>
        /// <param name="_DataSet">DataSet</param>
        /// <returns>byte[]</returns>
        public static byte[] GetZipBytesByDataSet(DataSet _DataSet)
        {
            DataSetSurrogate _DataSetSurrogate = new DataSetSurrogate(_DataSet);
            BinaryFormatter  _BinaryFormatter  = new BinaryFormatter();
            MemoryStream     _MemoryStream     = new MemoryStream();

            _BinaryFormatter.Serialize(_MemoryStream, _DataSetSurrogate);
            byte[] _buffer    = _MemoryStream.ToArray();
            byte[] _Zipbuffer = Compress(_buffer);
            //
            _MemoryStream.Close();
            _MemoryStream.Dispose();
            //
            return(_Zipbuffer);
        }
コード例 #6
0
ファイル: MapListConverter.cs プロジェクト: fengyubox/SFIS
        public byte[] GetDataSetSurrogateZipBytes(DataSet dataSet)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                DataSetSurrogate dss = new DataSetSurrogate(dataSet);
                BinaryFormatter  ser = new BinaryFormatter();
                ser.Serialize(ms, dss);
                byte[] buffer    = ms.ToArray();
                byte[] zipBuffer = Compress(buffer);

                ms.Close();
                ms.Dispose();
                return(zipBuffer);
            }
        }
コード例 #7
0
        public static byte[] SerializeBinary(object[] obj)
        {
            if (obj == null || obj.Length == 0)
                return new byte[] { };

            for (int i = 0; i < obj.Length; i++)
            {
                if (obj[i] != null)
                {
                    if (obj[i] is DataSet)
                        obj[i] = new DataSetSurrogate((DataSet)obj[i]);
                    else if (obj[i] is DataTable)
                        obj[i] = new DataTableSurrogate((DataTable)obj[i]);
                }
            }
            BinaryFormatter se = new BinaryFormatter();
            MemoryStream memStream = new MemoryStream();
            se.Serialize(memStream, obj);
            byte[] bobj = memStream.ToArray();
            memStream.Close();
            return bobj;
        }
コード例 #8
0
ファイル: DataSetZip.cs プロジェクト: wgang10/ZYWeb
 /// <summary>  
 /// 取得将DataSet转化为DataSetSurrogate对象用Binary进行序列化,并压缩后的二进制数组  
 /// </summary>  
 /// <param name="dsData">需压缩的DataSet数据</param>  
 /// <returns>压缩后二进制数组</returns>  
 public static byte[] GetDataSetZipBytes(DataSet dsData)
 {
     try
     {
         DataSetSurrogate dss = new DataSetSurrogate(dsData);
         BinaryFormatter ser = new BinaryFormatter();
         MemoryStream ms = new MemoryStream();
         ser.Serialize(ms, dss);
         byte[] buffer = ms.ToArray();
         byte[] Zipbuffer = Compress(buffer);
         return Zipbuffer;
     }
     catch (Exception ex)
     {
         //throw new DataSetConverterException(MSG_ERR_INTERNAL, new string[] { "DataSetZip", "GetDataSetZipBytes" }, ex, null);
         throw ex;
     }
 }