| | |
| | | /// <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) |
| | |
| | | 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节点的Name属性值 |
| | | 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/Events/Event/Relation/Batch";// + de.Key.ToString(); |
| | | string subNode = "Document/Events/Event/DataField";// + de.Key.ToString(); |
| | | |
| | | XmlNode node = xml.SelectSingleNode(subNode, nsmgr); |
| | | if (de != null) |
| | |
| | | attr = xml.CreateAttribute("ActDate"); //操作时间 |
| | | attr.Value = de.Split(",")[3]; |
| | | createNode.Attributes.Append(attr); |
| | | attr = xml.CreateAttribute("DisCorpID"); //运输企业 |
| | | attr.Value = ""; |
| | | createNode.Attributes.Append(attr); |
| | | attr = xml.CreateAttribute("AssCorpID"); //委托企业 |
| | | attr.Value = ""; |
| | | attr = xml.CreateAttribute("WrongCode"); //是否错误码 |
| | | attr.Value = "False"; |
| | | createNode.Attributes.Append(attr); |
| | | attr = xml.CreateAttribute("ToCorpID"); // 下游收货企业编号 |
| | | attr.Value = ""; |
| | | createNode.Attributes.Append(attr); |
| | | attr = xml.CreateAttribute("FromPerson");//发货人 |
| | | attr.Value = ""; //de.Split(",")[2] |
| | | createNode.Attributes.Append(attr); |
| | | node.AppendChild(createNode); |
| | | } |