using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace HH.YiDaSyncNC.Models { class GYS_SyncServiceModel { public class DataModel { public string pk_group { get; set; } public string pk_org { get; set; } public string code { get; set; } public string name { get; set; } public string pk_supplierclass { get; set; } public string enablestate { get; set; } public string taxpayerid { get; set; } public List suplinkman { get; set; } public class SuplinkmanItem { public string name { get; set; } public string cell { get; set; } } } public class ImportXml { /// /// 模板头部份 /// /// public static XElement TemplateHeade() { return new XElement(new XElement("ufinterface", new object[] { new XAttribute("sender","dingding"), new XAttribute("roottag",""), new XAttribute("replace","Y"), new XAttribute("isexchange","Y"), new XAttribute("groupcode","0"), new XAttribute("filename",""), new XAttribute("billtype","supplier"), new XAttribute("proc","add"), new XAttribute("account","develop") })); } /// /// 组建表头xml /// /// 表头参数 /// public static XElement Header(DataModel item, string id) { var suplinkmanList = new List(); if (item.suplinkman != null && item.suplinkman.Count > 0) { foreach (var itemData in item.suplinkman) { suplinkmanList.Add(new XElement("item", new object[] { new XElement("linkmanvo",new object[]{ new XElement("name",itemData.name), new XElement("cell",itemData.cell), }), new XElement("pk_linkman",""), new XElement("isdefault","N"), })); } } return new XElement("bill", new object[] { "", new XAttribute("id",id), new XElement("billhead", new object[] { new XElement("pk_group",item.pk_group), new XElement("pk_org",item.pk_org), new XElement("code",item.code), new XElement("name",item.name), new XElement("pk_supplierclass",item.pk_supplierclass), new XElement("enablestate",item.enablestate), new XElement("taxpayerid",item.taxpayerid), new XElement("suplinkman",suplinkmanList), new XElement("pk_country","CN"), new XElement("pk_timezone","P0800"), new XElement("pk_format","ZH-CN"), }), }); } } } }