Commit 1da133fb authored by liugd's avatar liugd

1

parent a006fa15
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ChuPiao.AutoPrint.Desktop</RootNamespace> <RootNamespace>ChuPiao.AutoPrint.Desktop</RootNamespace>
<AssemblyName>ChuPiao.AutoPrint.Desktop1</AssemblyName> <AssemblyName>ChuPiao.AutoPrint.Desktop</AssemblyName>
<ApplicationIcon>Computer.ico</ApplicationIcon> <ApplicationIcon>Computer.ico</ApplicationIcon>
<TargetZone>LocalIntranet</TargetZone> <TargetZone>LocalIntranet</TargetZone>
<GenerateManifests>false</GenerateManifests> <GenerateManifests>false</GenerateManifests>
......
...@@ -13,6 +13,7 @@ using ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode; ...@@ -13,6 +13,7 @@ using ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode;
using ChuPiao.Common.Communication.GtdJson.Packs; using ChuPiao.Common.Communication.GtdJson.Packs;
using ChuPiao.Common.Communication.GtdJson; using ChuPiao.Common.Communication.GtdJson;
using ChuPiao.Common.Communication.GtdJson.Items; using ChuPiao.Common.Communication.GtdJson.Items;
using ChuPiao.Common.HD;
namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1 namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
{ {
...@@ -501,6 +502,8 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1 ...@@ -501,6 +502,8 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
return list; return list;
} }
bool isTestFlag = false;
string testString;
/// <summary> /// <summary>
/// 执行数据接收任务 /// 执行数据接收任务
...@@ -519,10 +522,32 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1 ...@@ -519,10 +522,32 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
{ {
bytesToRead = PrinterPort.BytesToRead; bytesToRead = PrinterPort.BytesToRead;
} }
byte[] bytesTest = null;
if (GConfig.IsTest) {
if (!isTestFlag) {
isTestFlag = true;
testString = File.ReadAllText("d:\\1.txt");
HD.Test_LogPrint(testString);
bytesTest = HexString.StringToByte(testString);
bytesToRead = bytesTest.Length;
}
}
if (bytesToRead > 0) if (bytesToRead > 0)
{ {
byte[] readBytes = new byte[bytesToRead]; byte[] readBytes;
if (bytesTest == null)
{
readBytes = new byte[bytesToRead];
PrinterPort.Read(readBytes, 0, readBytes.Length); PrinterPort.Read(readBytes, 0, readBytes.Length);
}
else {
readBytes = bytesTest;
}
_receivedBuffer.AddRange(readBytes); _receivedBuffer.AddRange(readBytes);
//if (AlldataStream != null) //if (AlldataStream != null)
//{ //{
...@@ -553,13 +578,13 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1 ...@@ -553,13 +578,13 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
_receivedBuffer.Clear(); _receivedBuffer.Clear();
_receivedStringBuffer.Remove(0, _receivedStringBuffer.Length); _receivedStringBuffer.Remove(0, _receivedStringBuffer.Length);
} }
//
//if (strReceived.StartsWith("1D 4C 40 00 1D 57 00 03")) if (strReceived.StartsWith("1D 4C 40 00 1D 57 00 03"))
//{ {
// isreply = true; isreply = true;
// _receivedBuffer.RemoveRange(0, 8); _receivedBuffer.RemoveRange(0, 8);
// _receivedStringBuffer.Remove(0, 24); _receivedStringBuffer.Remove(0, 24);
//} }
//无回写功能,直接去掉 add 2022年10月10日10:42:50 liugd //无回写功能,直接去掉 add 2022年10月10日10:42:50 liugd
...@@ -587,6 +612,7 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1 ...@@ -587,6 +612,7 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
if (!_oneTicketReceived && isend) if (!_oneTicketReceived && isend)
{ {
HD.Test_LogPrint(string.Concat("从彩票机接收到一张完整票,字节数:", _receivedBuffer.Count, ",字符总长度:", strReceived.Length));
Log.Info(string.Concat("从彩票机接收到一张完整票,字节数:", _receivedBuffer.Count, ",字符总长度:", strReceived.Length)); Log.Info(string.Concat("从彩票机接收到一张完整票,字节数:", _receivedBuffer.Count, ",字符总长度:", strReceived.Length));
_oneTicketReceived = true; _oneTicketReceived = true;
...@@ -597,17 +623,17 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1 ...@@ -597,17 +623,17 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
SaveLastFile(oneTicketData); SaveLastFile(oneTicketData);
try //try
{ //{
if (MachineInfo.M_AllowPaperout) // if (MachineInfo.M_AllowPaperout)
{ // {
PrinterPort.Write(oneTicketData, 0, oneTicketData.Length); // PrinterPort.Write(oneTicketData, 0, oneTicketData.Length);
} // }
} //}
catch (Exception exception) //catch (Exception exception)
{ //{
Log.Info(string.Concat("打印错误:", exception.ToString())); // Log.Info(string.Concat("打印错误:", exception.ToString()));
} //}
//解析票 //解析票
CaptureDataInfo captureDataInfo = new CaptureDataInfo(oneTicketData); CaptureDataInfo captureDataInfo = new CaptureDataInfo(oneTicketData);
...@@ -747,6 +773,8 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1 ...@@ -747,6 +773,8 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
} }
else if (strPlayCodetype.Contains("缴款报表")) //缴款报表 else if (strPlayCodetype.Contains("缴款报表")) //缴款报表
{ {
HD.Test_LogPrint("缴款报表");
//缴款 //缴款
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();
...@@ -910,7 +938,7 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1 ...@@ -910,7 +938,7 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Warn(string.Concat("彩票机 ", this.MachineInfo.M_Number, " 打印机接收数据异常,请停止出票,重启软件,否则会白出!!!")); Log.Warn(string.Concat("彩票机 ", this.MachineInfo.M_Number, " 打印机接收数据异常,请停止出票,重启软件,否则会白出!!!")+ HD.Test_ExtractAllStackTrace(ex));
//Log.Warn(string.Concat("彩票机 ", this.MachineInfo.M_Number, " 接收数据异常:", ex.ToString())); //Log.Warn(string.Concat("彩票机 ", this.MachineInfo.M_Number, " 接收数据异常:", ex.ToString()));
//if (ex.Message.Contains("口被关闭")) //if (ex.Message.Contains("口被关闭"))
......
...@@ -11,7 +11,7 @@ namespace ChuPiao.Common.HD ...@@ -11,7 +11,7 @@ namespace ChuPiao.Common.HD
{ {
#if REALEASE_VERSION #if REALEASE_VERSION
public const string VersionName = "1.0.2"; public const string VersionName = "1.0.3";
public const string VersionText = "正式版本"; public const string VersionText = "正式版本";
......
...@@ -4,6 +4,8 @@ using System.Text; ...@@ -4,6 +4,8 @@ using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections;
using ChuPiao.Common.HD;
namespace ChuPiao.Common.HD namespace ChuPiao.Common.HD
{ {
...@@ -123,6 +125,36 @@ namespace ChuPiao.Common.HD ...@@ -123,6 +125,36 @@ namespace ChuPiao.Common.HD
} }
/// <summary>
/// 提取异常及其内部异常堆栈跟踪
/// </summary>
/// <param name="exception">提取的例外</param>
/// <param name="lastStackTrace">最后提取的堆栈跟踪(对于递归), String.Empty or null</param>
/// <param name="exCount">提取的堆栈数(对于递归)</param>
/// <returns>Syste.String</returns>
public static string Test_ExtractAllStackTrace(Exception exception, string lastStackTrace = null, int exCount = 1)
{
var ex = exception;
const string entryFormat = "#{0}: {1}\r\n{2}";
//修复最后一个堆栈跟踪参数
lastStackTrace = lastStackTrace ?? string.Empty;
//添加异常的堆栈跟踪
lastStackTrace += string.Format(entryFormat, exCount, ex.Message, ex.StackTrace);
if (exception.Data.Count > 0)
{
lastStackTrace += "\r\n Data: ";
foreach (var item in exception.Data)
{
var entry = (DictionaryEntry)item;
lastStackTrace += string.Format("\r\n\t{0}: {1}", entry.Key, exception.Data[entry.Key]);
}
}
//递归添加内部异常
//if ((ex = ex.InnerException) != null)
// return ex.Test_ExtractAllStackTrace(string.Format("{0}\r\n\r\n", lastStackTrace), ++exCount);
return lastStackTrace;
}
public static void Test_LogPrint(object obj) public static void Test_LogPrint(object obj)
{ {
......
...@@ -36,20 +36,22 @@ namespace ChuPiao.Common.Utils ...@@ -36,20 +36,22 @@ namespace ChuPiao.Common.Utils
public static byte[] StringToByte(string inputString) public static byte[] StringToByte(string inputString)
{ {
//inputString = inputString.Trim().Replace(" ",","); //inputString = inputString.Trim().Replace(" ",",");
string[] arrInput;
byte[] bytes; byte[] bytes;
if(string.IsNullOrEmpty(inputString))
if (string.IsNullOrEmpty(inputString))
{ {
bytes=new byte[]{}; bytes = new byte[] { };
} }
else else
{ {
arrInput = inputString.Split(" ".ToCharArray()); string[] strs = inputString.Trim().Split(' ');
bytes = new byte[strs.Length];
bytes = new byte[arrInput.Length]; int i = 0;
for (int i = 0; i < arrInput.Length; i++) foreach (var s in strs)
{ {
bytes[i] = Convert.ToByte(arrInput[i], 16); if (s.Length == 2) {
bytes[i++] = Convert.ToByte(s, 16);
}
} }
} }
return bytes; return bytes;
......
...@@ -36,17 +36,18 @@ namespace ChuPiao.Common.Utils ...@@ -36,17 +36,18 @@ namespace ChuPiao.Common.Utils
public static byte[] StringToByte(string inputString) public static byte[] StringToByte(string inputString)
{ {
byte[] bytes; byte[] bytes;
if (string.IsNullOrEmpty(inputString)) if (string.IsNullOrEmpty(inputString))
{ {
bytes = new byte[] { }; bytes = new byte[] { };
} }
else else
{ {
int length = inputString.Length / 2; string[] strs=inputString.Trim().Split(' ');
bytes = new byte[length]; bytes = new byte[strs.Length];
for (int i = 0; i < length; i++) int i = 0;
{ foreach (var s in strs) {
bytes[i] = Convert.ToByte(inputString.Substring(i * 2, 2), 16); bytes[i++] = Convert.ToByte(s, 16);
} }
} }
return bytes; return bytes;
......
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