/// <summary> /// 产生数据 /// </summary> /// <param name="dataSet">数据集</param> /// <param name="serialXmlObject">xml序列化对象</param> /// <returns></returns> private _Data GenerateXmlData(DataSet dataSet, MessageSerialXml serialXmlObject) { _Data xmlData = new _Data(); _Table[] xmlTableStructSet = serialXmlObject.Head.DataDefine.TableSet; xmlData.DataTableSet = new _DataTable[serialXmlObject.Head.DataDefine.TableSet.Length]; for (int i = 0; i < xmlTableStructSet.Length; i++) { _Table xmlTableStruct = xmlTableStructSet[i]; _DataTable xmlDataTable = new _DataTable(); DataTable dt = null; if (xmlTableStructSet.Length <= 1) { dt = dataSet.Tables[0]; dt.TableName = xmlTableStruct.TableName; } else { dt = dataSet.Tables[xmlTableStruct.TableName]; } if (dt.Rows.Count <= 0) { continue; } xmlData.DataTableSet[i] = GenerateXmlDataTable(dt, xmlTableStruct, xmlDataTable); } return(xmlData); }
/// <summary> /// 导入数据集 /// </summary> /// <param name="xmlDataSet">xml数据集</param> /// <param name="dataSetStruct">数据集结构</param> /// <returns></returns> private DataSet ImportDataSet(_Data xmlDataSet, DataSet dataSetStruct) { if (xmlDataSet == null || xmlDataSet.DataTableSet == null) { return(dataSetStruct); } foreach (_DataTable xmlDataTable in xmlDataSet.DataTableSet) { ImportDataTable(xmlDataTable, dataSetStruct); } return(dataSetStruct); }