예제 #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 + "bin\\ResponseParams.xml";

            if (!System.IO.File.Exists(pathXml))
            {
                throw new SystemException("ResponseParams文件不存在!!!");
            }
            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>
        /// <returns></returns>
        public static string XmlBackParam()
        {
            var    result  = "";
            string pathXml = null;
            var    valid   = new ValidXmlDto();

            pathXml = System.AppDomain.CurrentDomain.BaseDirectory + "bin\\ResponseParams.xml";
            XmlDocument doc = new XmlDocument();

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

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

            valid.PO_MSG = po_msgNode.InnerText;
            if (valid.PO_FHZ == "1")
            {
                string jsonText   = JsonConvert.SerializeXmlNode(doc);
                var    resultData = JsonConvert.DeserializeObject <ResultData>(jsonText);
                if (resultData?.Row != null && resultData.Row.ToString() != "")
                {
                    result = doc.InnerXml;
                }
            }
            else
            {
                throw new SystemException(valid.PO_MSG);
            }
            doc = null;
            return(result);
        }
예제 #3
0
        /// <summary>
        /// 实体转换为model
        /// </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;
            var    valid   = new ValidXmlDto();

            pathXml = System.AppDomain.CurrentDomain.BaseDirectory + "bin\\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);
        }
예제 #4
0
        /// <summary>
        /// 入参
        /// </summary>
        /// <returns></returns>
        public static string XmlParticipationParam()
        {
            var    result  = "";
            string pathXml = null;
            var    valid   = new ValidXmlDto();

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

            doc.Load(pathXml);
            result = doc.InnerXml;
            doc    = null;
            return(result);
        }
예제 #5
0
        public static string DeSerializerModelStr(string rowsName)
        {
            string resultData = null;
            var    valid      = new ValidXmlDto();
            string pathXml    = null;

            pathXml = System.AppDomain.CurrentDomain.BaseDirectory + "bin\\ResponseParams.xml";
            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);
        }
예제 #6
0
        /// <summary>
        /// 错误检查
        /// </summary>
        public static string DeSerializerXmlInfo(string operatorId)
        {
            string jsonStr = null;
            string pathXml = null;
            var    valid   = new ValidXmlDto();
            var    is64Bit = Environment.Is64BitOperatingSystem;

            if (is64Bit)
            {
                pathXml = @"C:\Program Files (x86)\Microsoft\BenDingActiveSetup\" + "ResponseParams.xml";
            }
            else
            {
                pathXml = @"C:\Program Files\Microsoft\BenDingActiveSetup\" + "ResponseParams.xml";
            }

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

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

            doc.Load(pathXml);
            //获取xml字符串

            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")
            {
                Logs.LogWrite(new LogParam()
                {
                    Msg          = valid.PO_MSG,
                    OperatorCode = operatorId,
                    ResultData   = JsonConvert.SerializeXmlNode(doc)
                });
                throw new SystemException(valid.PO_MSG);
            }
            string jsonText = JsonConvert.SerializeXmlNode(doc);

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

            if (resultData?.Row != null && resultData.Row.ToString() != "")
            {
                jsonStr = JsonConvert.SerializeObject(resultData.Row);
            }
            doc = null;
            return(jsonStr);
        }
예제 #7
0
        /// <summary>
        ///  返回装换为json
        /// </summary>
        /// <returns></returns>
        public static string SerializerModelJson()
        {
            string jsonStr     = null;
            string pathXml     = null;
            string copyPathXml = null;
            var    valid       = new ValidXmlDto();
            var    is64Bit     = Environment.Is64BitOperatingSystem;

            if (is64Bit)
            {
                pathXml     = @"C:\Program Files (x86)\Microsoft\BenDingActiveSetup\" + "ResponseParams.xml";
                copyPathXml = @"C:\Program Files (x86)\Microsoft\BenDingActiveSetup\";
            }
            else
            {
                pathXml     = @"C:\Program Files\Microsoft\BenDingActiveSetup\" + "ResponseParams.xml";
                copyPathXml = @"C:\Program Files\Microsoft\BenDingActiveSetup\";
            }
            File.Copy(pathXml, copyPathXml + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xml");

            // 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 (valid.PO_FHZ != "1")
            {
                throw new SystemException(valid.PO_MSG);
            }
            string jsonText = JsonConvert.SerializeXmlNode(doc);

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

            if (resultData?.Row != null && resultData.Row.ToString() != "")
            {
                jsonStr = JsonConvert.SerializeObject(resultData.Row);
            }

            doc = null;
            return(jsonStr);
        }
예제 #8
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\BenDingActiveSetup\" + "ResponseParams.xml";
                copyPathXml = @"C:\Program Files (x86)\Microsoft\BenDingActiveSetup\";
            }
            else
            {
                pathXml     = @"C:\Program Files\Microsoft\BenDingActiveSetup\" + "ResponseParams.xml";
                copyPathXml = @"C:\Program Files\Microsoft\BenDingActiveSetup\";
            }
            File.Copy(pathXml, copyPathXml + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xml");
            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);
        }