NCImportFunc.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using HH.YiDaSyncNC.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml.Linq;
  8. namespace HH.YiDaSyncNC.Helper
  9. {
  10. class NCImportFunc
  11. {
  12. public static string NCImport(XElement tempHeader, XElement xElement, string url)
  13. {
  14. try
  15. {
  16. tempHeader.Add(xElement);
  17. //xElement.Element("voucher").Element("voucher_head").Element("details").Add(Bodydebit(body));//表体没有记录
  18. string xmlString = DBHelper.ToXmlElementMethod(tempHeader).OuterXml;//变成xml字符串
  19. xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + xmlString;
  20. DBHelper.WriteLog("传入参数:" + xmlString);
  21. string resultMsg = DBHelper.SendNsg(xmlString, url);//接收返回的数据
  22. DBHelper.WriteLog("返回参数:" + resultMsg);
  23. XElement xE = XElement.Parse(resultMsg);
  24. string resultcode = xE.Element("sendresult").Element("resultcode").Value;
  25. return resultMsg;//返回错误信息
  26. }
  27. catch (Exception ex)
  28. {
  29. throw ex;
  30. }
  31. }
  32. public static string NCImport2(XElement xElement, string url)
  33. {
  34. try
  35. {
  36. string xmlString = DBHelper.ToXmlElementMethod(xElement).OuterXml;//变成xml字符串
  37. xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + xmlString;
  38. DBHelper.WriteLog("传入参数:" + xmlString);
  39. string resultMsg = DBHelper.SendNsg(xmlString, url);//接收返回的数据
  40. DBHelper.WriteLog("返回参数:" + resultMsg);
  41. XElement xE = XElement.Parse(resultMsg);
  42. string resultcode = xE.Element("sendresult").Element("resultcode").Value;
  43. return resultMsg;//返回错误信息
  44. }
  45. catch (Exception ex)
  46. {
  47. throw ex;
  48. }
  49. }
  50. }
  51. }