示例#1
0
        public void Do()
        {
            string filePath = AssemblyPathHelper.GetAssemblyPath() + "Resource/210311990023-20180712.txt";

            if (!File.Exists(filePath))
            {
                return;
            }

            try
            {
                int offSet = 0;

                byte[] billsByte = File.ReadAllBytes(filePath);

                string bills = Encoding.GetEncoding("UTF-8").GetString(billsByte);
                int    lines = bills.Count(item => item == '\n');

                Console.WriteLine(bills);

                BillCheckingSummary       summary = TextAnalysor.AnalyseToBillCheckingSummary(billsByte, ref offSet);
                List <BillCheckingDetail> details = TextAnalysor.AnalyseToBillCheckingDetails(billsByte, summary.CheckCount, offSet);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }
示例#2
0
        private void AnalyseSwiftpassPayResponse()
        {
            string filePath = AssemblyPathHelper.GetAssemblyPath() + "Resource/SwiftPayResponse.xml";

            if (!File.Exists(filePath))
            {
                Console.WriteLine("File not exist");
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(filePath);

            XmlNode nodes = doc.FirstChild;

            string status          = nodes.SelectSingleNode("status").InnerText;
            string resultCode      = nodes.SelectSingleNode("result_code").InnerText;
            string payInfoNodeJson = nodes.SelectSingleNode("pay_info").InnerText;

            JObject payInfoObj = (JObject)JsonConvert.DeserializeObject(payInfoNodeJson);
        }
示例#3
0
        private void AnalyseXMLFromFile()
        {
            string filePath = AssemblyPathHelper.GetAssemblyPath() + "Resource/PaymentNotification.xml";

            if (!File.Exists(filePath))
            {
                Console.WriteLine("File not exist");
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(filePath);

            XmlNode firstChild = doc.FirstChild;

            if (firstChild.HasChildNodes)
            {
                foreach (XmlNode node in firstChild.ChildNodes)
                {
                    Console.WriteLine("[node name]:{0}, [node xml]:{1}, [node text]:{2}", node.Name, node.InnerXml, node.InnerText);
                }
            }
        }