Commit 6c95d5a5 authored by 李佳's avatar 李佳

打印数据去掉干扰字符再解析

parent dcbe0719
...@@ -251,6 +251,10 @@ namespace ChuPiao.AutoPrint.Desktop.AutoPrint ...@@ -251,6 +251,10 @@ namespace ChuPiao.AutoPrint.Desktop.AutoPrint
arr = File.ReadAllBytes(content); arr = File.ReadAllBytes(content);
} }
string tmpStr = HexString.ByteToString(arr);
tmpStr = Regex.Replace(tmpStr, @"EE DD [\s\S]{2} [\s\S]{2} ", ""); //去掉干扰字符 EEDD开头的4位16进制
arr = HexString.StringToByte(tmpStr);
using (MemoryStream ms = new MemoryStream()) using (MemoryStream ms = new MemoryStream())
{ {
ms.Write(arr, 0, arr.Length); ms.Write(arr, 0, arr.Length);
......
...@@ -12,6 +12,7 @@ using ChuPiao.AutoPrint.Services.AutoPrint; ...@@ -12,6 +12,7 @@ using ChuPiao.AutoPrint.Services.AutoPrint;
using ChuPiao.Common.Core.Utils; using ChuPiao.Common.Core.Utils;
using ChuPiao.Common.Utils; using ChuPiao.Common.Utils;
using ChuPiao.AutoPrint.Desktop.ZxEncashTicket; using ChuPiao.AutoPrint.Desktop.ZxEncashTicket;
using System.Text.RegularExpressions;
namespace ChuPiao.AutoPrint.Desktop.AutoPrint namespace ChuPiao.AutoPrint.Desktop.AutoPrint
{ {
...@@ -116,6 +117,11 @@ namespace ChuPiao.AutoPrint.Desktop.AutoPrint ...@@ -116,6 +117,11 @@ namespace ChuPiao.AutoPrint.Desktop.AutoPrint
//this.txtTicketPath.Text = fileInfo.FullName; //this.txtTicketPath.Text = fileInfo.FullName;
string content = File.ReadAllText(fileInfo.FullName); string content = File.ReadAllText(fileInfo.FullName);
byte[] arr = TicketTextUtil.DecryptAndDecompress(content); byte[] arr = TicketTextUtil.DecryptAndDecompress(content);
string tmpStr = HexString.ByteToString(arr);
tmpStr = Regex.Replace(tmpStr, @"EE DD [\s\S]{2} [\s\S]{2} ", ""); //去掉干扰字符 EEDD开头的4位16进制
arr = HexString.StringToByte(tmpStr);
using (MemoryStream ms = new MemoryStream()) using (MemoryStream ms = new MemoryStream())
{ {
ms.Write(arr, 0, arr.Length); ms.Write(arr, 0, arr.Length);
......
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using ChuPiao.Common.Utils;
namespace ChuPiao.AutoPrint.Machine.Models namespace ChuPiao.AutoPrint.Machine.Models
{ {
...@@ -11,17 +12,20 @@ namespace ChuPiao.AutoPrint.Machine.Models ...@@ -11,17 +12,20 @@ namespace ChuPiao.AutoPrint.Machine.Models
public CaptureDataInfo(byte[] captureDataBytes) public CaptureDataInfo(byte[] captureDataBytes)
{ {
_captureDataBytes = captureDataBytes; _captureDataBytes = captureDataBytes;
//_captureDataString = Encoding.GetEncoding("gb2312").GetString(_captureDataBytes); string tmpStr = HexString.ByteToString(_captureDataBytes);
_captureDataString = Encoding.GetEncoding("GB18030").GetString(_captureDataBytes); tmpStr = Regex.Replace(tmpStr, @"EE DD [\s\S]{2} [\s\S]{2} ", ""); //去掉干扰字符 EEDD开头的4位16进制
_captureDataString = Encoding.GetEncoding("gb2312").GetString(HexString.StringToByte(tmpStr));
//去掉无效字符 //去掉无效字符
_captureDataString = Regex.Replace(_captureDataString, @"U\?\0[\s\S]{1}", ""); //天津盒子 //_captureDataString = Regex.Replace(_captureDataString, @"U\?\0[\s\S]{1}", ""); //天津盒子
_captureDataString = Regex.Replace(_captureDataString, @"钶[\s\S]{2}", ""); //湖北盒子 //_captureDataString = Regex.Replace(_captureDataString, @"钶[\s\S]{2}", ""); //湖北盒子
//湖北元字有乱码 ////湖北元字有乱码
_captureDataString = _captureDataString.Replace(@"灶\?@\?", "元").Replace("灶?@?", "元"); //_captureDataString = _captureDataString.Replace(@"灶\?@\?", "元").Replace("灶?@?", "元");
//放到比分玩法里面去替换了 //放到比分玩法里面去替换了
////广西“其它”有乱码 (3:3)@60.00元+(平祁?@渌?@175.0元+(2:4)@60 (负祁?渌?)@50.00元 (平祁?@渌?)@ ////广西“其它”有乱码 (3:3)@60.00元+(平祁?@渌?@175.0元+(2:4)@60 (负祁?渌?)@50.00元 (平祁?@渌?)@
......
...@@ -246,19 +246,19 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode ...@@ -246,19 +246,19 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode
/// <returns></returns> /// <returns></returns>
private string DealRateCode(string Istr) private string DealRateCode(string Istr)
{ {
//(平祁?@渌?@175.0元 ////(平祁?@渌?@175.0元
//(负祁?渌?)@50.00元 ////(负祁?渌?)@50.00元
//(平祁?@渌?)@50.00元 ////(平祁?@渌?)@50.00元
//(平其祟?@?)@150.0元 ////(平其祟?@?)@150.0元
Regex re = new Regex(@"[胜平负](\D{1,})@\d{1,}.\d{1,}元"); //Regex re = new Regex(@"[胜平负](\D{1,})@\d{1,}.\d{1,}元");
MatchCollection mc = re.Matches(Istr); //MatchCollection mc = re.Matches(Istr);
foreach (Match ma in mc) //foreach (Match ma in mc)
{ //{
if (ma.Groups[1].Value != "其它)") // if (ma.Groups[1].Value != "其它)")
{ // {
Istr = Istr.Replace(ma.Groups[1].Value, "其它)"); // Istr = Istr.Replace(ma.Groups[1].Value, "其它)");
} // }
} //}
Istr = Regex.Replace(Istr, @"[^():胜平负其它元@.+\d]{1}", ""); Istr = Regex.Replace(Istr, @"[^():胜平负其它元@.+\d]{1}", "");
......
...@@ -51,7 +51,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -51,7 +51,7 @@ namespace ChuPiao.AutoPrint.Test
machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>(); machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
machine.MachineModeConfigs.Add(7040102, config); machine.MachineModeConfigs.Add(7040102, config);
DecodePrintData data = new DecodePrintData(); DecodePrintData data = new DecodePrintData();
data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/20210402121337.prn", Encoding.GetEncoding("gb2312")))); data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/20210402121337.prn")));
service.DecodeData(ticket, machine, data); service.DecodeData(ticket, machine, data);
...@@ -67,7 +67,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -67,7 +67,7 @@ namespace ChuPiao.AutoPrint.Test
//machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>(); //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
//machine.MachineModeConfigs.Add(7020101, config); //machine.MachineModeConfigs.Add(7020101, config);
//DecodePrintData data = new DecodePrintData(); //DecodePrintData data = new DecodePrintData();
//data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/ps.prn", Encoding.GetEncoding("gb2312")))); //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/ps.prn")));
//service.DecodeData(ticket, machine, data); //service.DecodeData(ticket, machine, data);
...@@ -83,7 +83,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -83,7 +83,7 @@ namespace ChuPiao.AutoPrint.Test
//machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>(); //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
//machine.MachineModeConfigs.Add(9110111, config); //machine.MachineModeConfigs.Add(9110111, config);
//DecodePrintData data = new DecodePrintData(); //DecodePrintData data = new DecodePrintData();
//data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/jz2.prn", Encoding.GetEncoding("gb2312")))); //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/jz2.prn")));
//service.DecodeData(ticket, machine, data); //service.DecodeData(ticket, machine, data);
//ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeJlHhggService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeJlHhggService(); //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeJlHhggService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeJlHhggService();
...@@ -98,7 +98,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -98,7 +98,7 @@ namespace ChuPiao.AutoPrint.Test
//machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>(); //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
//machine.MachineModeConfigs.Add(9110112, config); //machine.MachineModeConfigs.Add(9110112, config);
//DecodePrintData data = new DecodePrintData(); //DecodePrintData data = new DecodePrintData();
//data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("E:/4.prn", Encoding.GetEncoding("gb2312")))); //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("E:/4.prn")));
//service.DecodeData(ticket, machine, data); //service.DecodeData(ticket, machine, data);
//ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeDlX3DsService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeDlX3DsService(); //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeDlX3DsService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeDlX3DsService();
...@@ -114,7 +114,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -114,7 +114,7 @@ namespace ChuPiao.AutoPrint.Test
//machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>(); //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
//machine.MachineModeConfigs.Add(5030301, config); //machine.MachineModeConfigs.Add(5030301, config);
//DecodePrintData data = new DecodePrintData(); //DecodePrintData data = new DecodePrintData();
//data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("C:/333.prn", Encoding.GetEncoding("gb2312")))); //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("C:/333.prn")));
//service.DecodeData(ticket, machine, data); //service.DecodeData(ticket, machine, data);
//ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeLtZjDsService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeLtZjDsService(); //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeLtZjDsService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeLtZjDsService();
...@@ -130,7 +130,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -130,7 +130,7 @@ namespace ChuPiao.AutoPrint.Test
//machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>(); //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
//machine.MachineModeConfigs.Add(7010201, config); //machine.MachineModeConfigs.Add(7010201, config);
//DecodePrintData data = new DecodePrintData(); //DecodePrintData data = new DecodePrintData();
//data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("C:/444.prn", Encoding.GetEncoding("gb2312")))); //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("C:/444.prn")));
//service.DecodeData(ticket, machine, data); //service.DecodeData(ticket, machine, data);
} }
...@@ -215,7 +215,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -215,7 +215,7 @@ namespace ChuPiao.AutoPrint.Test
//缴款 //缴款
ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService(); ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService();
DecodeMachinePayMoneyReport decodePrintData = new DecodeMachinePayMoneyReport(); DecodeMachinePayMoneyReport decodePrintData = new DecodeMachinePayMoneyReport();
decodePrintData.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/jkbb_yidongzhifu.prn", Encoding.GetEncoding("gb2312")))); decodePrintData.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/jkbb_yidongzhifu.prn")));
service.DecodeMachinePayMoneyReport(null, decodePrintData); service.DecodeMachinePayMoneyReport(null, decodePrintData);
if (decodePrintData.DecodeSuccess) if (decodePrintData.DecodeSuccess)
...@@ -264,7 +264,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -264,7 +264,7 @@ namespace ChuPiao.AutoPrint.Test
////竞彩时段报表 ////竞彩时段报表
//ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService(); //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService();
//DecodeMachineReport decodeMachineReport = new DecodeMachineReport(); //DecodeMachineReport decodeMachineReport = new DecodeMachineReport();
//decodeMachineReport.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/sdbb_2.prn", Encoding.GetEncoding("gb2312")))); //decodeMachineReport.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/sdbb_2.prn")));
//service.DecodeMachineReportReport(null, decodeMachineReport); //service.DecodeMachineReportReport(null, decodeMachineReport);
//if (decodeMachineReport.DecodeSuccess) //if (decodeMachineReport.DecodeSuccess)
...@@ -298,7 +298,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -298,7 +298,7 @@ namespace ChuPiao.AutoPrint.Test
private void button5_Click(object sender, EventArgs e) private void button5_Click(object sender, EventArgs e)
{ {
CaptureDataInfo info = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("d:/dlt.prn", Encoding.GetEncoding("gb2312")))); CaptureDataInfo info = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("d:/dlt.prn")));
string passwd; string passwd;
Regex regex = new Regex(@"[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6} (\d{6}) "); //110430-289460-026185-900502 503504 xxygvQ 常规彩 Regex regex = new Regex(@"[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6} (\d{6}) "); //110430-289460-026185-900502 503504 xxygvQ 常规彩
...@@ -420,7 +420,7 @@ namespace ChuPiao.AutoPrint.Test ...@@ -420,7 +420,7 @@ namespace ChuPiao.AutoPrint.Test
//解析票 //解析票
CaptureDataInfo captureDataInfo = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText(file, Encoding.GetEncoding("gb2312")))); CaptureDataInfo captureDataInfo = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText(file)));
string input = captureDataInfo.CaptureDataString; string input = captureDataInfo.CaptureDataString;
int tmpEnd = input.IndexOf("-------------------"); int tmpEnd = input.IndexOf("-------------------");
string strPlayCodetype = input.Substring(0, tmpEnd); string strPlayCodetype = input.Substring(0, tmpEnd);
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment