Skip to content

Commit 82f1f89

Browse files
committed
modify:Serial number generation is only available after the server has generated it
1 parent 8e5ba5f commit 82f1f89

File tree

8 files changed

+170
-35
lines changed

8 files changed

+170
-35
lines changed

XEngine_Source/AuthorizeModule_Protocol/AuthorizeModule_Protocol.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ EXPORTS
2525
Protocol_Parse_HttpParseTry
2626
Protocol_Parse_HttpParseTable
2727
Protocol_Parse_HttpParseSerial
28+
Protocol_Parse_HttpParseSerial2
2829
Protocol_Parse_HttpParseOnline
2930
Protocol_Parse_HttpParseTime
3031
Protocol_Parse_HttpParseSwitch

XEngine_Source/AuthorizeModule_Protocol/Protocol_Define.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,50 @@ extern "C" bool Protocol_Parse_HttpParseTable(LPCXSTR lpszMsgBuffer, int nMsgLen
600600
*********************************************************************/
601601
extern "C" bool Protocol_Parse_HttpParseSerial(LPCXSTR lpszMsgBuffer, int nMsgLen, AUTHREG_SERIALTABLE*** pppSt_SerialTable, int* pInt_ListCount);
602602
/********************************************************************
603+
函数名称:Protocol_Parse_HttpParseSerial
604+
函数功能:解析HTTP序列号信息
605+
参数.一:lpszMsgBuffer
606+
In/Out:In
607+
类型:常量字符指针
608+
可空:N
609+
意思:输入要解析的缓冲区
610+
参数.二:nMsgLen
611+
In/Out:In
612+
类型:整数型
613+
可空:N
614+
意思:输入要解析的大小
615+
参数.三:ptszOUTTime
616+
In/Out:Out
617+
类型:字符指针
618+
可空:N
619+
意思:输出过期时间
620+
参数.四:ptszHASTime
621+
In/Out:Out
622+
类型:字符指针
623+
可空:N
624+
意思:输出拥有时间
625+
参数.五:pInt_SerialCount
626+
In/Out:Out
627+
类型:整数型指针
628+
可空:N
629+
意思:输出序列号个数
630+
参数.六:pInt_FieldCount
631+
In/Out:Out
632+
类型:整数型指针
633+
可空:N
634+
意思:输出字段个数
635+
参数.七:penSerialType
636+
In/Out:Out
637+
类型:枚举型指针
638+
可空:N
639+
意思:输出生成类型
640+
返回值
641+
类型:逻辑型
642+
意思:是否成功
643+
备注:
644+
*********************************************************************/
645+
extern "C" bool Protocol_Parse_HttpParseSerial2(LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR* ptszExpiredTime, XCHAR* ptszMaxTime, int* pInt_SerialCount, int* pInt_FieldCount, ENUM_VERIFICATION_MODULE_SERIAL_TYPE* penSerialType);
646+
/********************************************************************
603647
函数名称:Protocol_Parse_HttpParseOnline
604648
函数功能:解析在线列表
605649
参数.一:lpszMsgBuffer

XEngine_Source/AuthorizeModule_Protocol/Protocol_Parse/Protocol_Parse.cpp

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,94 @@ bool CProtocol_Parse::Protocol_Parse_HttpParseTable(LPCXSTR lpszMsgBuffer, int n
519519
}
520520
/********************************************************************
521521
函数名称:Protocol_Parse_HttpParseSerial
522+
函数功能:解析HTTP序列号信息
523+
参数.一:lpszMsgBuffer
524+
In/Out:In
525+
类型:常量字符指针
526+
可空:N
527+
意思:输入要解析的缓冲区
528+
参数.二:nMsgLen
529+
In/Out:In
530+
类型:整数型
531+
可空:N
532+
意思:输入要解析的大小
533+
参数.三:ptszOUTTime
534+
In/Out:Out
535+
类型:字符指针
536+
可空:N
537+
意思:输出过期时间
538+
参数.四:ptszHASTime
539+
In/Out:Out
540+
类型:字符指针
541+
可空:N
542+
意思:输出拥有时间
543+
参数.五:pInt_SerialCount
544+
In/Out:Out
545+
类型:整数型指针
546+
可空:N
547+
意思:输出序列号个数
548+
参数.六:pInt_FieldCount
549+
In/Out:Out
550+
类型:整数型指针
551+
可空:N
552+
意思:输出字段个数
553+
参数.七:penSerialType
554+
In/Out:Out
555+
类型:枚举型指针
556+
可空:N
557+
意思:输出生成类型
558+
返回值
559+
类型:逻辑型
560+
意思:是否成功
561+
备注:
562+
*********************************************************************/
563+
bool CProtocol_Parse::Protocol_Parse_HttpParseSerial2(LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR* ptszExpiredTime, XCHAR* ptszMaxTime, int* pInt_SerialCount, int* pInt_FieldCount, ENUM_VERIFICATION_MODULE_SERIAL_TYPE* penSerialType)
564+
{
565+
Protocol_IsErrorOccur = false;
566+
567+
if ((NULL == lpszMsgBuffer) || (NULL == ptszMaxTime))
568+
{
569+
Protocol_IsErrorOccur = true;
570+
Protocol_dwErrorCode = ERROR_AUTHORIZE_MODULE_PROTOCOL_PARAMENT;
571+
return false;
572+
}
573+
Json::Value st_JsonRoot;
574+
JSONCPP_STRING st_JsonError;
575+
Json::CharReaderBuilder st_ReaderBuilder;
576+
577+
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_ReaderBuilder.newCharReader());
578+
if (!pSt_JsonReader->parse(lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError))
579+
{
580+
Protocol_IsErrorOccur = true;
581+
Protocol_dwErrorCode = ERROR_AUTHORIZE_MODULE_PROTOCOL_PARSE;
582+
return false;
583+
}
584+
Json::Value st_JsonObject = st_JsonRoot["st_SerialInfo"];
585+
586+
if (!st_JsonObject["tszExpiredTime"].isNull())
587+
{
588+
_tcsxcpy(ptszExpiredTime, st_JsonObject["tszExpiredTime"].asCString());
589+
}
590+
if (!st_JsonObject["tszMaxTime"].isNull())
591+
{
592+
_tcsxcpy(ptszMaxTime, st_JsonObject["tszMaxTime"].asCString());
593+
}
594+
if (!st_JsonObject["nSerialCount"].isNull())
595+
{
596+
*pInt_SerialCount = st_JsonObject["nSerialCount"].asInt();
597+
}
598+
if (!st_JsonObject["nFieldCount"].isNull())
599+
{
600+
*pInt_FieldCount = st_JsonObject["nFieldCount"].asInt();
601+
}
602+
if (!st_JsonObject["enSerialType"].isNull())
603+
{
604+
*penSerialType = (ENUM_VERIFICATION_MODULE_SERIAL_TYPE)st_JsonObject["enSerialType"].asInt();
605+
}
606+
return true;
607+
}
608+
/********************************************************************
609+
函数名称:Protocol_Parse_HttpParseSerial
522610
函数功能:解析HTTP序列号信息
523611
参数.一:lpszMsgBuffer
524612
In/Out:In

XEngine_Source/AuthorizeModule_Protocol/Protocol_Parse/Protocol_Parse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class CProtocol_Parse
2626
bool Protocol_Parse_HttpParseTry(LPCXSTR lpszMsgBuffer, int nMsgLen, AUTHREG_TEMPVER* pSt_NETTry);
2727
bool Protocol_Parse_HttpParseTable(LPCXSTR lpszMsgBuffer, int nMsgLen, AUTHREG_USERTABLE* pSt_UserTable);
2828
bool Protocol_Parse_HttpParseSerial(LPCXSTR lpszMsgBuffer, int nMsgLen, AUTHREG_SERIALTABLE*** pppSt_SerialTable, int* pInt_ListCount);
29+
bool Protocol_Parse_HttpParseSerial2(LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR* ptszExpiredTime, XCHAR* ptszMaxTime, int* pInt_SerialCount, int* pInt_FieldCount, ENUM_VERIFICATION_MODULE_SERIAL_TYPE* penSerialType);
2930
bool Protocol_Parse_HttpParseOnline(LPCXSTR lpszMsgBuffer, int nMsgLen, bool* pbOnline);
3031
bool Protocol_Parse_HttpParseTime(LPCXSTR lpszMsgBuffer, int nMsgLen, AUTHREG_PROTOCOL_TIME* pSt_ProtocolTime);
3132
bool Protocol_Parse_HttpParseSwitch(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_FUNCTIONSWITCH* pSt_FunSwitch);

XEngine_Source/AuthorizeModule_Protocol/pch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ extern "C" bool Protocol_Parse_HttpParseSerial(LPCXSTR lpszMsgBuffer, int nMsgLe
118118
{
119119
return m_ProtocolParse.Protocol_Parse_HttpParseSerial(lpszMsgBuffer, nMsgLen, pppSt_SerialTable, pInt_ListCount);
120120
}
121+
extern "C" bool Protocol_Parse_HttpParseSerial2(LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR* ptszExpiredTime, XCHAR* ptszMaxTime, int* pInt_SerialCount, int* pInt_FieldCount, ENUM_VERIFICATION_MODULE_SERIAL_TYPE* penSerialType)
122+
{
123+
return m_ProtocolParse.Protocol_Parse_HttpParseSerial2(lpszMsgBuffer, nMsgLen, ptszExpiredTime, ptszMaxTime, pInt_SerialCount, pInt_FieldCount, penSerialType);
124+
}
121125
extern "C" bool Protocol_Parse_HttpParseOnline(LPCXSTR lpszMsgBuffer, int nMsgLen, bool * pbOnline)
122126
{
123127
return m_ProtocolParse.Protocol_Parse_HttpParseOnline(lpszMsgBuffer, nMsgLen, pbOnline);

XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ BOOL CDialog_Config::OnInitDialog()
8787
m_ListEncrypto.InsertString(0, _T("不启用"));
8888
m_ListEncrypto.InsertString(1, _T("AES128"));
8989
m_ListEncrypto.InsertString(2, _T("AES256"));
90-
m_ListEncrypto.SetCurSel(0);
90+
m_ListEncrypto.SetCurSel(1);
9191
m_ListEncrypto.EnableWindow(false);
9292

9393
m_EditPassword.SetWindowText(_T("123123aa"));

XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Serial.cpp

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -204,32 +204,18 @@ void CDialog_Serial::OnBnClickedButton2()
204204
AfxMessageBox(_T("必须配置卡拥有的时间和生成数量"));
205205
return;
206206
}
207-
208207
Json::Value st_JsonRoot;
209-
Json::Value st_JsonArray;
210208
Json::Value st_JsonObject;
211209

212-
213210
m_ComboNumber.GetLBText(m_ComboNumber.GetCurSel(), m_StrNumberCount);
214211
USES_CONVERSION;
215-
XCHAR tszTimeStr[XPATH_MIN] = {};
216-
BaseLib_Time_TimeToStr(tszTimeStr);
217-
for (int i = 0; i < _ttoi(m_StrSerialCount.GetBuffer()); i++)
218-
{
219-
Json::Value st_JsonObject;
220-
XCHAR tszSerialStr[XPATH_MIN] = {};
221-
Verification_XAuthKey_KeySerial(tszSerialStr, _ttoi(m_StrNumberCount.GetBuffer()), 0);
222-
223-
st_JsonObject["bIsUsed"] = false;
224-
st_JsonObject["enSerialType"] = m_ComboSerialType.GetCurSel();
225-
st_JsonObject["tszCreateTime"] = tszTimeStr;
226-
st_JsonObject["tszExpiredTime"] = W2A(m_StrExpiredTime.GetBuffer());
227-
st_JsonObject["tszMaxTime"] = W2A(m_StrHasTime.GetBuffer());
228-
st_JsonObject["tszSerialNumber"] = tszSerialStr;
229-
st_JsonObject["tszUserName"] = "NOT";
230-
st_JsonArray.append(st_JsonObject);
231-
}
232-
st_JsonRoot["Array"] = st_JsonArray;
212+
st_JsonObject["enSerialType"] = m_ComboSerialType.GetCurSel();
213+
st_JsonObject["tszExpiredTime"] = W2A(m_StrExpiredTime.GetBuffer());
214+
st_JsonObject["tszMaxTime"] = W2A(m_StrHasTime.GetBuffer());
215+
st_JsonObject["nSerialCount"] = _ttoi(m_StrSerialCount.GetBuffer());
216+
st_JsonObject["nFieldCount"] = _ttoi(m_StrNumberCount.GetBuffer());
217+
218+
st_JsonRoot["st_SerialInfo"] = st_JsonObject;
233219
st_JsonRoot["xhToken"] = _ttoll(m_StrToken.GetBuffer());
234220

235221
int nMsgLen = 0;

XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_Serial.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,39 @@ bool XEngine_AuthorizeHTTP_Serial(LPCXSTR lpszClientAddr, LPCXSTR lpszAPIName, L
7171
}
7272
else if (0 == _tcsxncmp(lpszAPIInsert, lpszAPIName, _tcsxlen(lpszAPIInsert)))
7373
{
74-
int nListCount = 0;
75-
AUTHREG_SERIALTABLE** ppSt_SerialTable;
74+
int nSerialCount = 0;
75+
int nFieldCount = 0;
76+
ENUM_VERIFICATION_MODULE_SERIAL_TYPE enSerialType;
77+
XCHAR tszExpiredTime[64] = {};
78+
XCHAR tszMaxTime[64] = {};
79+
XCHAR tszCreateTime[64] = {};
7680

77-
Protocol_Parse_HttpParseSerial(lpszMsgBuffer, nMsgLen, &ppSt_SerialTable, &nListCount);
78-
if (0 == st_AuthConfig.st_XSql.nDBType)
81+
Protocol_Parse_HttpParseSerial2(lpszMsgBuffer, nMsgLen, tszExpiredTime, tszMaxTime, &nSerialCount, &nFieldCount, &enSerialType);
82+
BaseLib_Time_TimeToStr(tszCreateTime);
83+
84+
for (int i = 0; i < nSerialCount; i++)
7985
{
80-
for (int i = 0; i < nListCount; i++)
86+
AUTHREG_SERIALTABLE st_SerialTable = {};
87+
st_SerialTable.bIsUsed = false;
88+
st_SerialTable.enSerialType = enSerialType;
89+
_xstprintf(st_SerialTable.tszUserName, _X("NOT"));
90+
_tcsxcpy(st_SerialTable.tszCreateTime, tszCreateTime);
91+
_tcsxcpy(st_SerialTable.tszExpiredTime, tszExpiredTime);
92+
_tcsxcpy(st_SerialTable.tszMaxTime, tszMaxTime);
93+
Verification_XAuthKey_KeySerial(st_SerialTable.tszSerialNumber, nFieldCount, 0);
94+
95+
if (0 == st_AuthConfig.st_XSql.nDBType)
8196
{
82-
DBModule_SQLite_SerialInsert(ppSt_SerialTable[i]);
97+
DBModule_SQLite_SerialInsert(&st_SerialTable);
8398
}
84-
}
85-
else
86-
{
87-
for (int i = 0; i < nListCount; i++)
99+
else
88100
{
89-
DBModule_SQLite_SerialInsert(ppSt_SerialTable[i]);
101+
DBModule_SQLite_SerialInsert(&st_SerialTable);
90102
}
91103
}
92-
BaseLib_Memory_Free((XPPPMEM)&ppSt_SerialTable, nListCount);
93104
Protocol_Packet_HttpComm(m_MemoryPool.get(), &nSDLen);
94105
XEngine_Client_TaskSend(lpszClientAddr, m_MemoryPool.get(), nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP);
95-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,请求插入自定义序列号成功,个数:%d"), lpszClientAddr, nListCount);
106+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,请求插入自定义序列号成功,个数:%d"), lpszClientAddr, nSerialCount);
96107
}
97108
return true;
98109
}

0 commit comments

Comments
 (0)