GYS_SyncServiceModel.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 GYS_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_supplierclass { get; set; }
  18. public string enablestate { get; set; }
  19. public string taxpayerid { 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. }
  26. }
  27. public class ImportXml
  28. {
  29. /// <summary>
  30. /// 模板头部份
  31. /// </summary>
  32. /// <returns></returns>
  33. public static XElement TemplateHeade()
  34. {
  35. return new XElement(new XElement("ufinterface", new object[]
  36. {
  37. new XAttribute("sender","dingding"),
  38. new XAttribute("roottag",""),
  39. new XAttribute("replace","Y"),
  40. new XAttribute("isexchange","Y"),
  41. new XAttribute("groupcode","0"),
  42. new XAttribute("filename",""),
  43. new XAttribute("billtype","supplier"),
  44. new XAttribute("proc","add"),
  45. new XAttribute("account","develop")
  46. }));
  47. }
  48. /// <summary>
  49. /// 组建表头xml
  50. /// </summary>
  51. /// <param name="item">表头参数</param>
  52. /// <returns></returns>
  53. public static XElement Header(DataModel item, string id)
  54. {
  55. var suplinkmanList = new List<XElement>();
  56. if (item.suplinkman != null && item.suplinkman.Count > 0)
  57. {
  58. foreach (var itemData in item.suplinkman)
  59. {
  60. suplinkmanList.Add(new XElement("item", new object[] {
  61. new XElement("linkmanvo",new object[]{
  62. new XElement("name",itemData.name),
  63. new XElement("cell",itemData.cell),
  64. }),
  65. new XElement("pk_linkman",""),
  66. new XElement("isdefault","N"),
  67. }));
  68. }
  69. }
  70. return new XElement("bill", new object[]
  71. {
  72. "",
  73. new XAttribute("id",id),
  74. new XElement("billhead", new object[]
  75. {
  76. new XElement("pk_group",item.pk_group),
  77. new XElement("pk_org",item.pk_org),
  78. new XElement("code",item.code),
  79. new XElement("name",item.name),
  80. new XElement("pk_supplierclass",item.pk_supplierclass),
  81. new XElement("enablestate",item.enablestate),
  82. new XElement("taxpayerid",item.taxpayerid),
  83. new XElement("suplinkman",suplinkmanList),
  84. new XElement("pk_country","CN"),
  85. new XElement("pk_timezone","P0800"),
  86. new XElement("pk_format","ZH-CN"),
  87. }),
  88. });
  89. }
  90. }
  91. }
  92. }