| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Xml;
 
- using Newtonsoft.Json;
 
- using Newtonsoft.Json.Linq;
 
- namespace PTMedicalInsurance
 
- {
 
-     class AnalysisXML
 
-     {
 
-         /// <summary>
 
-         /// XML转换JSON对象
 
-         /// </summary>
 
-         /// <param name="sXML"></param>
 
-         /// <param name="outParam"></param>
 
-         /// <returns></returns>
 
-         public JObject ConvertXMLToObject(string sXML)
 
-         {
 
-             XmlDocument xmlDoc = new XmlDocument();
 
-             xmlDoc.LoadXml(sXML);
 
-             string jsonStr = JsonConvert.SerializeXmlNode(xmlDoc);
 
-             jsonStr = jsonStr.Replace("@", "").ToString();
 
-             //MessageBox.Show(jsonStr);
 
-             return JObject.Parse(jsonStr);
 
-         }
 
-         /// <summary>
 
-         /// 判断XML是否存在元素
 
-         /// </summary>
 
-         /// <param name="xmldoc"></param>
 
-         /// <param name="xmlnode"></param>
 
-         /// <param name="element"></param>
 
-         /// <param name="Type">0字符串 1金额</param>
 
-         /// <returns></returns>
 
-         public string FormatXMLElement(XmlDocument xmldoc, XmlNode xmlnode, string element, int Type)        
 
-         {
 
-             if ((Type != 0) && (Type != 1))
 
-             {
 
-                 Type = 0;
 
-             }
 
-             string key = "";
 
-             key = "//" + element;
 
-             if (xmldoc.SelectSingleNode(key) != null)
 
-             {
 
-                 return xmlnode.SelectNodes(element)[0].InnerText;
 
-             }
 
-             else
 
-             {
 
-                 if (Type == 0)
 
-                     return "";
 
-                 else
 
-                     return "0.00";
 
-             }
 
-         }
 
-         public XmlDocument GetXmlDoc(string sXML)
 
-         {
 
-             XmlDocument xmlDoc = new XmlDocument();
 
-             xmlDoc.LoadXml(sXML);
 
-             return xmlDoc;
 
-         }
 
-         public XmlNode GetNodeFromPath(XmlNode oParentNode, string sPath)
 
-         {
 
-             XmlNode tmpNode = oParentNode.SelectNodes(sPath)[0];
 
-             return tmpNode;
 
-         }
 
-         public bool CheckState(XmlDocument xmlDoc,out string OutMsg)
 
-         {
 
-             OutMsg = "";
 
-             string sState = GetNodeFromPath(xmlDoc.DocumentElement, "state").Attributes["success"].InnerText;
 
-             bool bRet = false;
 
-             if (sState.Equals("true"))
 
-             {
 
-                 bRet = true;
 
-                 //AddLog("调用返回状态:成功");
 
-             }
 
-             else
 
-             {
 
-                 bRet = false;
 
-                 //AddLog("调用返回状态:失败");
 
-                 //读取错误信息
 
-                 XmlNodeList errNodes = GetNodeFromPath(xmlDoc.DocumentElement, "state").SelectNodes("error");
 
-                 string sErrNO = "", sErrMsg = "";
 
-                 for (int i = 0; i < errNodes.Count; i++)
 
-                 {
 
-                     if (errNodes[i].Attributes.Count > 0)
 
-                     {
 
-                         sErrNO = errNodes[i].Attributes["no"].InnerText;
 
-                         sErrMsg = errNodes[i].Attributes["info"].InnerText;
 
-                         //AddLog("调用返回错误:编号 [" + sErrNO + "] -- 描述 [" + sErrMsg + "]");
 
-                     }
 
-                 }
 
-                 //读取警告信息
 
-                 string sWarNO = "", sWarMsg = "";
 
-                 XmlNodeList warNodes = GetNodeFromPath(xmlDoc.DocumentElement, "state").SelectNodes("warning");
 
-                 for (int i = 0; i < warNodes.Count; i++)
 
-                 {
 
-                     if (warNodes[i].Attributes.Count > 0)
 
-                     {
 
-                         sWarNO = warNodes[i].Attributes["no"].InnerText;
 
-                         sWarMsg = warNodes[i].Attributes["info"].InnerText;
 
-                         //AddLog("调用返回警告:编号 [" + sWarNO + "] -- 描述 [" + sWarMsg + "]");
 
-                     }
 
-                 }
 
-                 if ((sWarNO != "") || (sWarMsg != "")|| (sErrNO != "") || (sErrMsg != ""))
 
-                 {
 
-                     OutMsg = "错误编号:" + sErrNO + "\n" +
 
-                              "错误信息:" + sErrMsg + "\n" +
 
-                              "警告编号:" + sWarNO + "\n" +
 
-                              "警告信息:" + sWarMsg + "\n";
 
-                 }
 
-             }
 
-             //读取信息
 
-             //XmlNodeList infNodes = GetNodeFromPath(xmlDoc.DocumentElement, "state").SelectNodes("information");
 
-             //for (int i = 0; i < infNodes.Count; i++)
 
-             //{
 
-             //    if (infNodes[i].Attributes.Count > 0)
 
-             //    {
 
-             //        string sInfNO = infNodes[i].Attributes["no"].InnerText;
 
-             //        string sInfMsg = infNodes[i].Attributes["info"].InnerText;
 
-             //        //AddLog("调用返回信息:编号 [" + sInfNO + "] -- 描述 [" + sInfMsg + "]");
 
-             //    }
 
-             //}
 
-             return bRet;
 
-         }
 
-         //public string bSucess(XmlDocument xmlDoc, string ItemName)
 
-         //{
 
-         //    if (Node(ItemName) <> null)
 
-         //}
 
-         //public string GetXMLValue(string aXmlText, string FieldName)
 
-         //{ 
 
-         //}
 
-         public bool CheckOutputState(XmlDocument xmlDoc)
 
-         {
 
-             string sState = GetNodeFromPath(xmlDoc.DocumentElement, "state").Attributes["success"].InnerText;
 
-             bool bRet = false;
 
-             if (sState.Equals("true"))
 
-             {
 
-                 bRet = true;
 
-                 //AddLog("调用返回状态:成功");
 
-             }
 
-             else
 
-             {
 
-                 bRet = false;
 
-                 //AddLog("调用返回状态:失败");
 
-             }
 
-             //读取错误信息
 
-             XmlNodeList errNodes = GetNodeFromPath(xmlDoc.DocumentElement, "state").SelectNodes("error");
 
-             for (int i = 0; i < errNodes.Count; i++)
 
-             {
 
-                 if (errNodes[i].Attributes.Count > 0)
 
-                 {
 
-                     string sErrNO = errNodes[i].Attributes["no"].InnerText;
 
-                     string sErrMsg = errNodes[i].Attributes["info"].InnerText;
 
-                     //AddLog("调用返回错误:编号 [" + sErrNO + "] -- 描述 [" + sErrMsg + "]");
 
-                 }
 
-             }
 
-             //读取警告信息
 
-             XmlNodeList warNodes = GetNodeFromPath(xmlDoc.DocumentElement, "state").SelectNodes("warning");
 
-             for (int i = 0; i < warNodes.Count; i++)
 
-             {
 
-                 if (warNodes[i].Attributes.Count > 0)
 
-                 {
 
-                     string sWarNO = warNodes[i].Attributes["no"].InnerText;
 
-                     string sWarMsg = warNodes[i].Attributes["info"].InnerText;
 
-                     //AddLog("调用返回警告:编号 [" + sWarNO + "] -- 描述 [" + sWarMsg + "]");
 
-                 }
 
-             }
 
-             //读取信息
 
-             XmlNodeList infNodes = GetNodeFromPath(xmlDoc.DocumentElement, "state").SelectNodes("information");
 
-             for (int i = 0; i < infNodes.Count; i++)
 
-             {
 
-                 if (infNodes[i].Attributes.Count > 0)
 
-                 {
 
-                     string sInfNO = infNodes[i].Attributes["no"].InnerText;
 
-                     string sInfMsg = infNodes[i].Attributes["info"].InnerText;
 
-                     //AddLog("调用返回信息:编号 [" + sInfNO + "] -- 描述 [" + sInfMsg + "]");
 
-                 }
 
-             }
 
-             return bRet;
 
-         }
 
-     }
 
- }
 
 
  |