//初始化c:PrimaryKey的节点 private void InitPrimary(XmlNode xnKeys, TableInfo pTable) { foreach (XmlNode xnKey in xnKeys) { PdmKey key = GetPrimary(xnKey); foreach (PdmKey pk in pTable.Keys) { if (pk.KeyId.Equals(key.KeyId)) { foreach (ColumnInfo ci in pk.Columns) { pTable.AddPrimary(ci.ColumnId); } } } } }
//初始化"c:Columns"的节点 private void InitColumns(XmlNode xnColumns, TableInfo pTable) { foreach (XmlNode xnColumn in xnColumns) { pTable.AddColumn(GetColumn(xnColumn)); } }
//初始化c:Keys"的节点 private void InitKeys(XmlNode xnKeys, TableInfo pTable) { foreach (XmlNode xnKey in xnKeys) { pTable.AddKey(GetKey(xnKey)); } }
//初始化"o:Table"的节点 private TableInfo GetTable(XmlNode xnTable) { TableInfo mTable = new TableInfo(); XmlElement xe = (XmlElement)xnTable; mTable.TableId = xe.GetAttribute("Id"); XmlNodeList xnTProperty = xe.ChildNodes; foreach (XmlNode xnP in xnTProperty) { switch (xnP.Name) { case "a:ObjectID": mTable.ObjectID = xnP.InnerText; break; case "a:Name": mTable.Name = xnP.InnerText; break; case "a:Code": mTable.Code = xnP.InnerText; break; case "a:CreationDate": mTable.CreationDate = Convert.ToInt32(xnP.InnerText); break; case "a:Creator": mTable.Creator = xnP.InnerText; break; case "a:ModificationDate": mTable.ModificationDate = Convert.ToInt32(xnP.InnerText); break; case "a:Modifier": mTable.Modifier = xnP.InnerText; break; case "a:Comment": mTable.Comment = xnP.InnerText; break; case "a:PhysicalOptions": mTable.PhysicalOptions = xnP.InnerText; break; case "c:Columns": InitColumns(xnP, mTable); break; case "c:Keys": InitKeys(xnP, mTable); break; case "c:PrimaryKey": InitPrimary(xnP, mTable); break; } } return mTable; }