From 4c49b591b3833a2752634355cb37b0a74923e916 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期五, 07 十一月 2025 09:41:17 +0800
Subject: [PATCH] 开发成品出库导出上传码上放心平台xm文件
---
Wms/Utility/Tools/HttpHelper.cs | 48 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/Wms/Utility/Tools/HttpHelper.cs b/Wms/Utility/Tools/HttpHelper.cs
index 28bef60..16c9d2d 100644
--- a/Wms/Utility/Tools/HttpHelper.cs
+++ b/Wms/Utility/Tools/HttpHelper.cs
@@ -4,7 +4,9 @@
using System.IO;
using System.Linq;
using System.Net;
+using System.Net.Security;
using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Xml;
using Newtonsoft.Json;
@@ -13,6 +15,11 @@
{
public class HttpHelper
{
+ private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
+ {
+ return true; //濡傛灉涓嶅笇鏈涢獙璇佽瘉涔︽湁鏁堟�э紝鐩存帴杩斿洖 true
+ }
+
private static HttpWebRequest GetHttpWebRequest(string url, Dictionary<string, string> headerDic, string method)
{
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
@@ -105,6 +112,10 @@
}
try
{
+ if (url.Contains("https"))
+ {
+ ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
+ }
var requestData = GetResponseString(request);
LogFile.SaveLogToFile($"{logStr}鍙嶉锛�( {requestData} ),", logStr2);
return requestData;
@@ -184,12 +195,12 @@
/// <param name="method"></param>
/// <param name="xmlName"></param>
/// <returns></returns>
- public static XmlDocument EncodeParsToFuMa(List<string> Pars, string method, string xmlName)
+ public static XmlDocument EncodeParsToFuMa(List<string> Pars, string method, string xmlName,string fileName)
{
try
{
XmlDocument xml = null;
- var str = $"Utility.XML.{xmlName}.xml";
+ var str = $"Utility.XML.{fileName}.xml";
//浠庤祫婧愭枃浠跺緱鍒版枃浠舵祦
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(str);
if (stream == null)
@@ -201,19 +212,42 @@
xml.Load(stream);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable);
- nsmgr.AddNamespace("xsi", @"http://www.w3.org/2001/XMLSchema-instance");
+ nsmgr.AddNamespace("xsi", @"http://www.w3.org/2001/XMLSchema-instance");
+
+ // 淇敼Event鑺傜偣鐨凬ame灞炴�у��
+ string eventNodePath = "Document/Events/Event";
+ XmlNode eventNode = xml.SelectSingleNode(eventNodePath, nsmgr);
+ if (eventNode != null && eventNode.Attributes["Name"] != null)
+ {
+ eventNode.Attributes["Name"].Value = xmlName; // 淇敼涓轰紶鍏ョ殑xmlName鍙傛暟
+ }
//淇敼鍙傛暟鐨勫��
foreach (var de in Pars)
{
- string subNode = "DataList/Product/Batch";// + de.Key.ToString();
+ string subNode = "Document/Events/Event/DataField";// + de.Key.ToString();
XmlNode node = xml.SelectSingleNode(subNode, nsmgr);
if (de != null)
{
XmlNode createNode = xml.CreateNode(XmlNodeType.Element, "Data", "");
- XmlAttribute attr = xml.CreateAttribute("code");
- attr.Value = de;
+ XmlAttribute attr = xml.CreateAttribute("Code"); //绠辩爜
+ attr.Value = de.Split(",")[0];
+ createNode.Attributes.Append(attr);
+ attr = xml.CreateAttribute("CorpOrderID"); //鍗曟嵁鍙�
+ attr.Value = de.Split(",")[1];
+ createNode.Attributes.Append(attr);
+ attr = xml.CreateAttribute("Actor"); //鎿嶄綔浜�
+ attr.Value = de.Split(",")[2];
+ createNode.Attributes.Append(attr);
+ attr = xml.CreateAttribute("ActDate"); //鎿嶄綔鏃堕棿
+ attr.Value = de.Split(",")[3];
+ createNode.Attributes.Append(attr);
+ attr = xml.CreateAttribute("WrongCode"); //鏄惁閿欒鐮�
+ attr.Value = "False";
+ createNode.Attributes.Append(attr);
+ attr = xml.CreateAttribute("ToCorpID"); // 涓嬫父鏀惰揣浼佷笟缂栧彿
+ attr.Value = "";
createNode.Attributes.Append(attr);
node.AppendChild(createNode);
}
@@ -463,4 +497,6 @@
}
+
+
}
--
Gitblit v1.8.0