KH_SyncServiceModel.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Xml.Linq;
  7. namespace HH.YiDaSyncNC.Models
  8. {
  9. class KH_SyncServiceModel
  10. {
  11. public class DataModel
  12. {
  13. public string pk_group { get; set; }
  14. public string pk_org { get; set; }
  15. public string code { get; set; }
  16. public string name { get; set; }
  17. public string pk_custclass { get; set; }
  18. public string taxpayerid { get; set; }
  19. public string custprop { get; set; }
  20. public List<SuplinkmanItem> suplinkman { get; set; }
  21. public class SuplinkmanItem
  22. {
  23. public string name { get; set; }
  24. public string cell { get; set; }
  25. public string vjob { get; set; }
  26. }
  27. }
  28. public class ImportXml
  29. {
  30. /// <summary>
  31. /// 模板头部份
  32. /// </summary>
  33. /// <returns></returns>
  34. public static XElement TemplateHeade()
  35. {
  36. return new XElement(new XElement("ufinterface", new object[]
  37. {
  38. new XAttribute("sender","dingding"),
  39. new XAttribute("roottag",""),
  40. new XAttribute("replace","Y"),
  41. new XAttribute("isexchange","Y"),
  42. new XAttribute("groupcode","0"),
  43. new XAttribute("filename",""),
  44. new XAttribute("billtype","customer"),
  45. new XAttribute("proc","add"),
  46. new XAttribute("account","develop")
  47. }));
  48. }
  49. /// <summary>
  50. /// 组建表头xml
  51. /// </summary>
  52. /// <param name="item">表头参数</param>
  53. /// <returns></returns>
  54. public static XElement Header(DataModel item, string id)
  55. {
  56. var suplinkmanList = new List<XElement>();
  57. if (item.suplinkman != null && item.suplinkman.Count > 0)
  58. {
  59. foreach (var itemData in item.suplinkman)
  60. {
  61. suplinkmanList.Add(new XElement("item", new object[] {
  62. new XElement("linkmanvo",new object[]{
  63. new XElement("name",itemData.name),
  64. new XElement("cell",itemData.cell),
  65. new XElement("vjob",itemData.vjob),
  66. }),
  67. new XElement("pk_linkman",""),
  68. new XElement("isdefault","N"),
  69. }));
  70. }
  71. }
  72. return new XElement("bill", new object[]
  73. {
  74. "",
  75. new XAttribute("id",id),
  76. new XElement("billhead", new object[]
  77. {
  78. new XElement("pk_group",item.pk_group),
  79. new XElement("pk_org",item.pk_org),
  80. new XElement("code",item.code),
  81. new XElement("name",item.name),
  82. new XElement("pk_custclass",item.pk_custclass),
  83. new XElement("taxpayerid",item.taxpayerid),
  84. new XElement("custprop",item.custprop),
  85. new XElement("custcontacts",suplinkmanList),
  86. new XElement("pk_country","CN"),
  87. new XElement("pk_timezone","P0800"),
  88. new XElement("pk_format","ZH-CN"),
  89. }),
  90. });
  91. }
  92. }
  93. }
  94. }