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); } }
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); }
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); } } }