Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
ticket_half_auto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李佳
ticket_half_auto
Commits
1da133fb
Commit
1da133fb
authored
Nov 14, 2022
by
liugd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a006fa15
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
39 deletions
+102
-39
ChuPiao.AutoPrint.Desktop.csproj
ChuPiao.AutoPrint.Desktop/ChuPiao.AutoPrint.Desktop.csproj
+1
-1
VirtualPrinter.cs
ChuPiao.AutoPrint.Machine/TjJingCaiV1/VirtualPrinter.cs
+52
-24
GConfig.cs
ChuPiao.Common/HD/GConfig.cs
+1
-1
HD.cs
ChuPiao.Common/HD/HD.cs
+32
-0
HexString.cs
ChuPiao.Common/Utils/HexString.cs
+10
-8
HexStringUtil.cs
ChuPiao.Common/Utils/HexStringUtil.cs
+6
-5
No files found.
ChuPiao.AutoPrint.Desktop/ChuPiao.AutoPrint.Desktop.csproj
View file @
1da133fb
...
...
@@ -9,7 +9,7 @@
<OutputType>
WinExe
</OutputType>
<AppDesignerFolder>
Properties
</AppDesignerFolder>
<RootNamespace>
ChuPiao.AutoPrint.Desktop
</RootNamespace>
<AssemblyName>
ChuPiao.AutoPrint.Desktop
1
</AssemblyName>
<AssemblyName>
ChuPiao.AutoPrint.Desktop
</AssemblyName>
<ApplicationIcon>
Computer.ico
</ApplicationIcon>
<TargetZone>
LocalIntranet
</TargetZone>
<GenerateManifests>
false
</GenerateManifests>
...
...
ChuPiao.AutoPrint.Machine/TjJingCaiV1/VirtualPrinter.cs
View file @
1da133fb
...
...
@@ -13,6 +13,7 @@ using ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode;
using
ChuPiao.Common.Communication.GtdJson.Packs
;
using
ChuPiao.Common.Communication.GtdJson
;
using
ChuPiao.Common.Communication.GtdJson.Items
;
using
ChuPiao.Common.HD
;
namespace
ChuPiao.AutoPrint.Machine.TjJingCaiV1
{
...
...
@@ -501,6 +502,8 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
return
list
;
}
bool
isTestFlag
=
false
;
string
testString
;
/// <summary>
/// 执行数据接收任务
...
...
@@ -519,10 +522,32 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
{
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
)
{
byte
[]
readBytes
=
new
byte
[
bytesToRead
];
PrinterPort
.
Read
(
readBytes
,
0
,
readBytes
.
Length
);
byte
[]
readBytes
;
if
(
bytesTest
==
null
)
{
readBytes
=
new
byte
[
bytesToRead
];
PrinterPort
.
Read
(
readBytes
,
0
,
readBytes
.
Length
);
}
else
{
readBytes
=
bytesTest
;
}
_receivedBuffer
.
AddRange
(
readBytes
);
//if (AlldataStream != null)
//{
...
...
@@ -553,14 +578,14 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
_receivedBuffer
.
Clear
();
_receivedStringBuffer
.
Remove
(
0
,
_receivedStringBuffer
.
Length
);
}
//
//
if (strReceived.StartsWith("1D 4C 40 00 1D 57 00 03"))
//
{
//
isreply = true;
//
_receivedBuffer.RemoveRange(0, 8);
//
_receivedStringBuffer.Remove(0, 24);
//
}
if
(
strReceived
.
StartsWith
(
"1D 4C 40 00 1D 57 00 03"
))
{
isreply
=
true
;
_receivedBuffer
.
RemoveRange
(
0
,
8
);
_receivedStringBuffer
.
Remove
(
0
,
24
);
}
//无回写功能,直接去掉 add 2022年10月10日10:42:50 liugd
//if (isreply)
...
...
@@ -587,6 +612,7 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
if
(!
_oneTicketReceived
&&
isend
)
{
HD
.
Test_LogPrint
(
string
.
Concat
(
"从彩票机接收到一张完整票,字节数:"
,
_receivedBuffer
.
Count
,
",字符总长度:"
,
strReceived
.
Length
));
Log
.
Info
(
string
.
Concat
(
"从彩票机接收到一张完整票,字节数:"
,
_receivedBuffer
.
Count
,
",字符总长度:"
,
strReceived
.
Length
));
_oneTicketReceived
=
true
;
...
...
@@ -597,17 +623,17 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
SaveLastFile
(
oneTicketData
);
try
{
if
(
MachineInfo
.
M_AllowPaperout
)
{
PrinterPort
.
Write
(
oneTicketData
,
0
,
oneTicketData
.
Length
);
}
}
catch
(
Exception
exception
)
{
Log
.
Info
(
string
.
Concat
(
"打印错误:"
,
exception
.
ToString
()));
}
//
try
//
{
//
if (MachineInfo.M_AllowPaperout)
//
{
//
PrinterPort.Write(oneTicketData, 0, oneTicketData.Length);
//
}
//
}
//
catch (Exception exception)
//
{
//
Log.Info(string.Concat("打印错误:", exception.ToString()));
//
}
//解析票
CaptureDataInfo
captureDataInfo
=
new
CaptureDataInfo
(
oneTicketData
);
...
...
@@ -747,8 +773,10 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
}
else
if
(
strPlayCodetype
.
Contains
(
"缴款报表"
))
//缴款报表
{
//缴款
ChuPiao
.
AutoPrint
.
Machine
.
TjJingCaiV1
.
MacReport
.
MacReportService
service
=
new
ChuPiao
.
AutoPrint
.
Machine
.
TjJingCaiV1
.
MacReport
.
MacReportService
();
HD
.
Test_LogPrint
(
"缴款报表"
);
//缴款
ChuPiao
.
AutoPrint
.
Machine
.
TjJingCaiV1
.
MacReport
.
MacReportService
service
=
new
ChuPiao
.
AutoPrint
.
Machine
.
TjJingCaiV1
.
MacReport
.
MacReportService
();
DecodeMachinePayMoneyReport
decodePrintData
=
new
DecodeMachinePayMoneyReport
();
decodePrintData
.
InputData
=
captureDataInfo
;
service
.
DecodeMachinePayMoneyReport
(
null
,
decodePrintData
);
...
...
@@ -910,7 +938,7 @@ namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1
}
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()));
//if (ex.Message.Contains("口被关闭"))
...
...
ChuPiao.Common/HD/GConfig.cs
View file @
1da133fb
...
...
@@ -11,7 +11,7 @@ namespace ChuPiao.Common.HD
{
#if REALEASE_VERSION
public
const
string
VersionName
=
"1.0.
2
"
;
public
const
string
VersionName
=
"1.0.
3
"
;
public
const
string
VersionText
=
"正式版本"
;
...
...
ChuPiao.Common/HD/HD.cs
View file @
1da133fb
...
...
@@ -4,6 +4,8 @@ using System.Text;
using
System.Runtime.InteropServices
;
using
System.Windows.Forms
;
using
Newtonsoft.Json
;
using
System.Collections
;
using
ChuPiao.Common.HD
;
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
)
{
...
...
ChuPiao.Common/Utils/HexString.cs
View file @
1da133fb
...
...
@@ -36,20 +36,22 @@ namespace ChuPiao.Common.Utils
public
static
byte
[]
StringToByte
(
string
inputString
)
{
//inputString = inputString.Trim().Replace(" ",",");
string
[]
arrInput
;
byte
[]
bytes
;
if
(
string
.
IsNullOrEmpty
(
inputString
))
if
(
string
.
IsNullOrEmpty
(
inputString
))
{
bytes
=
new
byte
[]{
};
bytes
=
new
byte
[]
{
};
}
else
{
arrInput
=
inputString
.
Split
(
" "
.
ToCharArray
()
);
bytes
=
new
byte
[
arrInput
.
Length
]
;
for
(
int
i
=
0
;
i
<
arrInput
.
Length
;
i
++
)
string
[]
strs
=
inputString
.
Trim
().
Split
(
' '
);
bytes
=
new
byte
[
strs
.
Length
];
int
i
=
0
;
for
each
(
var
s
in
strs
)
{
bytes
[
i
]
=
Convert
.
ToByte
(
arrInput
[
i
],
16
);
if
(
s
.
Length
==
2
)
{
bytes
[
i
++]
=
Convert
.
ToByte
(
s
,
16
);
}
}
}
return
bytes
;
...
...
ChuPiao.Common/Utils/HexStringUtil.cs
View file @
1da133fb
...
...
@@ -36,17 +36,18 @@ namespace ChuPiao.Common.Utils
public
static
byte
[]
StringToByte
(
string
inputString
)
{
byte
[]
bytes
;
if
(
string
.
IsNullOrEmpty
(
inputString
))
{
bytes
=
new
byte
[]
{
};
}
else
{
int
length
=
inputString
.
Length
/
2
;
bytes
=
new
byte
[
l
ength
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
bytes
[
i
]
=
Convert
.
ToByte
(
inputString
.
Substring
(
i
*
2
,
2
)
,
16
);
string
[]
strs
=
inputString
.
Trim
().
Split
(
' '
)
;
bytes
=
new
byte
[
strs
.
L
ength
];
int
i
=
0
;
foreach
(
var
s
in
strs
)
{
bytes
[
i
++]
=
Convert
.
ToByte
(
s
,
16
);
}
}
return
bytes
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment