2024年5月10日发(作者:)

(detail1);

var detail2 = new Detail { N707_01 = "n707-01 2", N707_02 = "n707-02 2" };

(detail2);

(bodyItem);

Line(ToXml(details, false));

ine(ng());

}

public static string ToXml(Entity entity, bool isValue)

{

var xml = new StringBuilder();

var type = e();

var atts = tomAttributes(false);

var nodeName = "";

foreach (var att in atts)

{

if (att is XmlNameAttribute)

{

var attr = att as XmlNameAttribute;

nodeName = e;

}

}

var pros = new List();

($"<{nodeName}");

foreach (var pro in perties())

{

var proAtts = tomAttributes(false);

var isXmlProperty = false;

foreach (var att in proAtts)

{

//xml节点属性的属性

if (att is IsXmlPropertyAttribute)

{

isXmlProperty = true;

var attr = att as IsXmlPropertyAttribute;

if (roperty == true)

{

var IsXmlNameMark = false;

foreach (var nameAtt in proAtts)

{

if (nameAtt is XmlNameAttribute)

{

var nameAttr = nameAtt as XmlNameAttribute;

($" {e}="{ue(entity, null).ToString()}"");

IsXmlNameMark = true;

}

}

if (!IsXmlNameMark)

{

($" {}="{ue(entity, null).ToString()}"");

}

}

}

}

//节点属性

if (!isXmlProperty)

{

(pro);

}

}

Line($">");

if (isValue)

{

Line($"{perty("SelfValue", lic | ce).GetValue(entity, null)}");

}

else

{

foreach (var pro in pros)

{

var proAtts = tomAttributes(false);

if (lassOf(typeof(Entity)))

{

var childEntity = ue(entity, null) as Entity;

var isXmlValueMark = false;

foreach (var att in proAtts)

{

if (att is IsXmlValueAttribute)

{

isXmlValueMark = true;

Line(ToXml(childEntity, true));

break;

}

}

if (!isXmlValueMark)

{

Line(ToXml(childEntity, false));

}

}

else

{

if (ricType)

{

var list = ue(entity, null) as IList;

foreach (var item in list)

{

Line(ToXml(item as Entity, false));

}

}

else

{

var IsXmlNameMark = false;

foreach (var att in proAtts)

{

IsXmlNameMark = true;

if (att is XmlNameAttribute)

{

var attr = att as XmlNameAttribute;

Line($"<{e}>{ue(entity, null)}");

}

}

if (!IsXmlNameMark)

{

if ( == "DateTime")

{

if (ue(entity, null) == null)

{

Line($"<{}>");

}

else

{

Line($"<{}>{Time(ue(entity, null)).ToString("yyyy-MM-dd HH:mm:ss")}");

}

}

else

{

Line($"<{}>{ue(entity, null)}");

}

}

}

}

}

}

($"");

return ng();

}

}

public abstract class Entity

{ }

///

/// 上传明细类

///

[XmlName("NDEML")]

public class UploadDetail : Entity

{

[IsXmlProperty(true)]

[XmlName("templateVersion")]

public string TemplateVersion { get; set; } = "1.0";

public Head Head

{ get; set; }

public Body Body

{ get; set; }

}

[XmlName("head")]

public class Head : Entity

{

///

/// 导出时间

///

public DateTime exportDate { get; set; } = ;

///

/// 导出数据的业务类型,填写 N707