Пример #1
0
        /// <summary>
        /// 验证xml返回结果是否正确
        /// </summary>
        /// <param name="rowsName"></param>
        /// <returns></returns>
        public static ValidXmlDto ValidXml(string rowsName)
        {
            var result = new ValidXmlDto();

            string      pathXml = System.AppDomain.CurrentDomain.BaseDirectory + "RequestParams.xml";
            XmlDocument doc     = new XmlDocument();

            doc.Load(pathXml);
            XmlNode po_fhzNode = doc.SelectSingleNode("/ROW/PO_FHZ");

            result.PO_FHZ = po_fhzNode.InnerText;
            XmlNode po_msgNode = doc.SelectSingleNode("/ROW/PO_MSG");

            result.PO_MSG = po_msgNode.InnerText;
            if (result.PO_FHZ == "1")
            {
                var pO_RDXXNode = doc.SelectNodes("/ROW/" + rowsName + "/ROW");
                result.IsRows = pO_RDXXNode.Count > 1 ? true : false;
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        ///  回参
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="isAbnormal"></param>
        /// <returns></returns>
        public static T DeSerializerModel <T>(T t, bool isAbnormal)
        {
            var    result      = t;
            string pathXml     = null;
            string copyPathXml = null;
            var    valid       = new ValidXmlDto();
            var    is64Bit     = Environment.Is64BitOperatingSystem;

            if (is64Bit)
            {
                pathXml     = @"C:\Program Files (x86)\Microsoft\本鼎医保插件\" + "ResponseParams.xml";
                copyPathXml = @"C:\Program Files (x86)\Microsoft\本鼎医保插件\";
            }
            else
            {
                pathXml     = @"C:\Program Files\Microsoft\本鼎医保插件\" + "ResponseParams.xml";
                copyPathXml = @"C:\Program Files\Microsoft\本鼎医保插件\";
            }

            string copyPathXmlNew = copyPathXml + "xmlData\\" +
                                    DateTime.Now.Date.ToString("yyyy-MM-dd").Substring(0, 10) + "\\" +
                                    DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xml";

            File.Copy(pathXml, copyPathXmlNew);

            // pathXml = System.AppDomain.CurrentDomain.BaseDirectory + "ResponseParams.xml";

            if (!System.IO.File.Exists(pathXml))
            {
                throw new SystemException("ResponseParams文件不存在!!!");
            }
            XmlDocument doc = new XmlDocument();

            doc.Load(pathXml);
            var fhz = doc.SelectSingleNode("/ROW/PO_FHZ");

            if (fhz != null)
            {
                valid.PO_FHZ = fhz.InnerText;
            }
            else
            {
                var fhzNew = doc.SelectSingleNode("/row/po_fhz");
                valid.PO_FHZ = fhzNew.InnerText;
            }
            var msg = doc.SelectSingleNode("/ROW/PO_MSG");

            if (msg != null)
            {
                valid.PO_MSG = msg.InnerText;
            }
            else
            {
                var msgNew = doc.SelectSingleNode("/row/po_msg");
                valid.PO_MSG = msgNew.InnerText;
            }

            if (isAbnormal == true)
            {
                if (valid.PO_FHZ != "1")
                {
                    throw new SystemException(valid.PO_MSG);
                }
            }
            string jsonText = JsonConvert.SerializeXmlNode(doc);

            var resultData = JsonConvert.DeserializeObject <ResultData>(jsonText);

            if (resultData?.Row != null && resultData.Row.ToString() != "")
            {
                var jsonStr = JsonConvert.SerializeObject(resultData.Row);
                result = JsonConvert.DeserializeObject <T>(jsonStr);
            }

            doc = null;
            return(result);
        }
Пример #3
0
        public static string DeSerializerModelStr(string rowsName)
        {
            string resultData  = null;
            var    valid       = new ValidXmlDto();
            string pathXml     = null;
            string copyPathXml = null;
            var    is64Bit     = Environment.Is64BitOperatingSystem;

            if (is64Bit)
            {
                pathXml     = @"C:\Program Files (x86)\Microsoft\本鼎医保插件\" + "ResponseParams.xml";
                copyPathXml = @"C:\Program Files (x86)\Microsoft\本鼎医保插件\";
            }
            else
            {
                pathXml     = @"C:\Program Files\Microsoft\本鼎医保插件\" + "ResponseParams.xml";
                copyPathXml = @"C:\Program Files\Microsoft\本鼎医保插件\";
            }

            string copyPathXmlNew = copyPathXml + "xmlData\\" +
                                    DateTime.Now.Date.ToString("yyyy-MM-dd").Substring(0, 10) + "\\" +
                                    DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xml";

            File.Copy(pathXml, copyPathXmlNew);
            XmlDocument doc = new XmlDocument();

            doc.Load(pathXml);
            if (!System.IO.File.Exists(pathXml))
            {
                throw new SystemException("ResponseParams文件不存在!!!");
            }
            var fhz = doc.SelectSingleNode("/ROW/PO_FHZ");

            if (fhz != null)
            {
                valid.PO_FHZ = fhz.InnerText;
            }
            else
            {
                var fhzNew = doc.SelectSingleNode("/row/po_fhz");
                valid.PO_FHZ = fhzNew.InnerText;
            }
            var msg = doc.SelectSingleNode("/ROW/PO_MSG");

            if (msg != null)
            {
                valid.PO_MSG = msg.InnerText;
            }
            else
            {
                var msgNew = doc.SelectSingleNode("/row/po_msg");
                valid.PO_MSG = msgNew.InnerText;
            }
            if (valid.PO_FHZ == "1")
            {
                var    rowNode = doc.SelectSingleNode("/ROW/" + rowsName) ?? doc.SelectSingleNode("/row/" + rowsName);
                string strIni  = "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'";
                resultData = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" + "<" + rowsName + " " + strIni + ">" + rowNode.InnerXml + "</" + rowsName + ">";
            }
            else
            {
                throw new SystemException(valid.PO_MSG);
            }

            doc = null;
            return(resultData);
        }