SysSoft.EDI.ShipRecord.Message message = new SysSoft.EDI.ShipRecord.Message();
this.Message = message;
Type MessageType = message.GetType();
PropertyInfo[] MessgeInfo = MessageType.GetProperties();
string ProName;
for (int j = 0; j < MessgeInfo.Length; j++) {
ProName = MessgeInfo[j].Name;
object SubObject = MessageType.InvokeMember(ProName, BindingFlags.GetProperty, null, message, null);
Type SubType = SubObject.GetType();
PropertyInfo[] SubProInfo = SubType.GetProperties();
PropertyInfo SubInfo;
for (int i = 0; i < SubProInfo.Length; i++)
{
SubInfo = SubProInfo[i];
if (SubInfo.PropertyType.Namespace.ToLower().Trim() != "system") GetSubNodeData(SubInfo.Name, SubObject);
if (EDICommondList[SubInfo.Name] == null) continue;
SubInfo.SetValue(SubObject, Convert.ChangeType(EDICommondList[SubInfo.Name], SubInfo.PropertyType), null);
}
PropertyInfo InfoHead = MessageType.GetProperty(ProName);
InfoHead.SetValue(message, SubObject, null);
}
private void GetSubNodeData(string SubNodeName, object Node)
{
Type NodeType=Node.GetType();
string NodeName = NodeType.Name;
object SubNodeObject = NodeType.InvokeMember(SubNodeName, BindingFlags.GetProperty, null,Node, null);
Type SubNodeType = SubNodeObject.GetType();
PropertyInfo[] SubNodePros = SubNodeType.GetProperties();
string ProName;
CShipStandardMapping Mapping = new CShipStandardMapping();
CShipStandardEntities StandardEntity = new CShipStandardEntities();
Type StandardEntityType = StandardEntity.GetType();
StandardEntity.GetEntityData(this.ShipKey);
PropertyInfo EntryProperty;
object EntryProValue;
for (int i = 0; i < SubNodePros.Length; i++)
{
ProName = SubNodePros[i].Name;
if (SubNodePros[i].PropertyType.Namespace.ToLower() != "system")
{
GetSubNodeData(ProName, SubNodeObject);
}
else
{
if (NodeName.ToLower() == "messagemessagebodydeclaration")
{
object MaoCol = Mapping.ColsMapping[ProName];
if (MaoCol==null) continue;
EntryProperty = StandardEntityType.GetProperty(MaoCol.ToString());
EntryProValue = EntryProperty.GetValue(StandardEntity, null);
if (EntryProValue == null) continue;
SubNodePros[i].SetValue(SubNodeObject, EntryProValue, null);
}
else
{
SubNodePros[i].SetValue(SubNodeObject, Convert.ChangeType(EDICommondList[ProName], SubNodePros[i].PropertyType), null);
}
}
}
PropertyInfo InfoSubNode = NodeType.GetProperty(SubNodeName);
InfoSubNode.SetValue(Node, SubNodeObject, null);
}