1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
using System.Collections.Generic;
using System.Text.RegularExpressions;
using ChuPiao.AutoPrint.Machine.Models;
using ChuPiao.Common.Models;
using ChuPiao.Common.Core.Utils;
using System;
namespace ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode
{
/// <summary>
/// 彩种玩法投注模式(键码发送、电子票解析)
/// </summary>
public class MacLotPlayModePsFsService : TjJingCaiV1.MacLotPlayMode.MacLotPlayModeService
{
//public string RegexCode = @"([\d|.]){10}";
public string RegexCode = @"第[①|②|③]{1}位:([^\d]+)([\d|.]){10}";//复式([\d|.]){10}
public string RegexMoney = @"\d{1,5}元";
public MacLotPlayModePsFsService()
{
base.SplitStr = "|";
}
#region 键码发送
/// <summary>
/// 获得投注需要发送的键码列表
/// </summary>
/// <param name="ticketEntity"></param>
/// <param name="machineEntity"></param>
/// <returns></returns>
public override List<KeycodeInfo> GetSendKeycodeList(L_LotTicketEntity ticketEntity, M_MachineEntity machineEntity)
{
List<KeycodeInfo> keycodeList = new List<KeycodeInfo>();
M_MachineModeConfigEntity machineModeConfig = machineEntity.MachineModeConfigs[ticketEntity.MacModeId];
//初始化
if(machineModeConfig.C_IsEveryInit)
{
if (!string.IsNullOrEmpty(machineModeConfig.C_MacModeKeys))
{
foreach (string key in machineModeConfig.C_MacModeKeys.Split(','))
{
keycodeList.Add(new KeycodeInfo(key, machineModeConfig.C_MacModeKeysInterval));
}
}
}
//投注号码
List<string> codeList = SplitString(ticketEntity.L_Code.Replace(",",""), SplitStr);
foreach (string oneCode in codeList)
{
string strTemp = oneCode;
for (int i = 0; i < strTemp.Length; i++)
{
keycodeList.Add(new KeycodeInfo(strTemp.Substring(i, 1), machineModeConfig.C_SendKeyInterval));
}
//下个场次
keycodeList.Add(new KeycodeInfo(machineModeConfig.C_NextKey, machineModeConfig.C_NextKeyInterval));
}
//删除最后一个NextKey
int delIndex = keycodeList.Count - 1;
keycodeList.RemoveAt(delIndex);
//倍投);
if(ticketEntity.L_Mutiple>1)
{
keycodeList.Add(new KeycodeInfo(machineModeConfig.C_MultipleKey, machineModeConfig.C_MultipleKeyInterval));
string strTemp = ticketEntity.L_Mutiple.ToString();
for (int i = 0; i < strTemp.Length; i++)
{
keycodeList.Add(new KeycodeInfo( strTemp.Substring(i, 1), machineModeConfig.C_SendKeyInterval));
}
if(!string.IsNullOrEmpty(machineModeConfig.C_MultipleConfirmKey))
{
keycodeList.Add(new KeycodeInfo( machineModeConfig.C_MultipleConfirmKey, machineModeConfig.C_MultipleConfirmKeyInterval));
}
}
//打印确认
keycodeList.Add(new KeycodeInfo( machineModeConfig.C_PrintConfirmKey, machineModeConfig.C_PrintConfirmKeyInterval));
//是否输入密码
//TODO 配置
//if (ticketEntity.L_Money >= 500)
//{
// string password = machineEntity.M_ZxPassword;
// for (int i = 0; i < password.Length; i++)
// {
// keycodeList.Add(new KeycodeInfo(password.Substring(i, 1), machineModeConfig.C_SendKeyInterval));
// }
// if (!string.IsNullOrEmpty(machineModeConfig.C_PasswordConfirmKey)) //确认输入密码
// {
// keycodeList.Add(new KeycodeInfo(machineModeConfig.C_PasswordConfirmKey, machineModeConfig.C_PasswordConfirmKeyInterval));
// }
//}
//是否输入密码
keycodeList.AddRange(GetPasswordKeycodeList(ticketEntity, machineEntity, machineModeConfig));
return keycodeList;
}
#endregion
#region 电子票解析
/// <summary>
/// 解析电子票
/// </summary>
/// <param name="machineEntity"></param>
/// <param name="decodePrintData"></param>
/// <param name="ticketEntity"></param>
public override void DecodeData(L_LotTicketEntity ticketEntity, M_MachineEntity machineEntity, DecodePrintData decodePrintData)
{
M_MachineModeConfigEntity machineModeConfig = machineEntity.MachineModeConfigs[ticketEntity.MacModeId];
//抓取的返回
decodePrintData.L_PrintTicketEntity.P_PrnText = TicketTextUtil.CompressAndEncrypt(decodePrintData.InputData.CaptureDataBytes);
decodePrintData.L_PrintTicketEntity.P_SucTime = DateTime.Now;
string input = decodePrintData.InputData.CaptureDataString;
//input = input.Replace("大乐透12035期开奖01+04+30+32+35 08+12", "");
string strTemp;
//票号、密码、期号解析
bool suc = DecodeHead(ticketEntity,decodePrintData);
if(!suc)
{
decodePrintData.ErrorMessage = string.Format("头部解析错误:{0}", decodePrintData.ErrorMessage);
decodePrintData.DecodeSuccess = false;
return;
}
int position;
Regex regex;
//金额
//int position = input.IndexOf(decodePrintData.L_PrintTicketEntity.P_TicketCode) + 70;
//Regex regex=new Regex(RegexMoney);
//strTemp = input.Substring(position, 20);
//Match match = regex.Match(strTemp);
//if(!match.Success)
//{
// decodePrintData.ErrorMessage += "没有找到金额";
// decodePrintData.DecodeSuccess = false;
// return;
//}
//string money = Regex.Replace(match.Value, @"\D", "");
//decodePrintData.L_PrintTicketEntity.P_Money = decimal.Parse(money);
//if (decimal.Parse(money) != ticketEntity.L_Money)
//{
// decodePrintData.ErrorMessage += string.Format("金额不匹配,软件金额:{0} 电子票金额:{1}", ticketEntity.L_Money,
// money);
// decodePrintData.DecodeSuccess = false;
// return;
//}
//投注号码
//position = input.IndexOf("直 选 复 式 票"); //新机器
//if (position < 0) {
// position = input.IndexOf("直选复式票");//老机器
//}
//strTemp = Regex.Replace(input.Substring(position, 150), @"\n", "");
position = input.IndexOf("合计");
strTemp = Regex.Replace(input.Substring(position), @"\n", "");
regex=new Regex(RegexCode);
MatchCollection matchCollection = regex.Matches(strTemp);
decodePrintData.L_PrintTicketEntity.P_Code = ticketEntity.L_Code;
//if (machineModeConfig.C_IsCheckCode)
//{
// //进行号码检测
// string code = string.Empty;
// foreach (Match oneMatch in matchCollection)
// {
// code += oneMatch.Value+SplitStr;
// }
// string s1 = Regex.Replace(ticketEntity.L_Code, @"\D", "");
// string s2 = Regex.Replace(code, @"\D", "");
// if (s1 != s2)
// {
// decodePrintData.ErrorMessage += string.Format("投注号码不匹配,软件号码:{0} 电子票号码:{1}", s1,
// s2);
// //把跟投注号码不匹配的电子票号设成"01,02,03,04,05"这种格式,以便入库
// decodePrintData.L_PrintTicketEntity.P_Code = code;
// decodePrintData.DecodeSuccess = false;
// return;
// }
//}
decodePrintData.L_PrintTicketEntity.P_SingleZhuShu = ticketEntity.L_SingleZhuShu;
decodePrintData.DecodeSuccess = true;
}
#endregion
}
}