DLCardToolDlg.h
2.81 KB
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
// DLCardToolDlg.h : 头文件
//
#pragma once
#include "afxwin.h"
#include "afxcmn.h"
#include "password_machine.h"
#include "DLConfig.h"
enum LOG_TYPE
{
LOG_TRACE = 0,
LOG_ERROR
};
enum KEY_TYPE
{
KT_DCCK = 0,
KT_DEAK,
KT_DAMK,
KT_DACK,
};
enum CARD_STATE
{
CS_UNSTORAGE = 0,//未入库
CS_STORAGE, //已入库,未办卡
CS_USE //已办卡
};
enum ENCRYPT_TYPE
{
ET_PWM = 0, //加密机加密
ET_DES, //软加密
ET_NO, //未加密
ET_UNKNOWN //未知加密状态
};
typedef struct CARD_STATE_INFO
{
CARD_STATE csCardState;
CString sServiceData;
ENCRYPT_TYPE etEncryptType; //用来表示是否已经用加密机加密
CARD_STATE_INFO()
{
csCardState = CS_UNSTORAGE;
etEncryptType = ET_UNKNOWN;
}
CARD_STATE_INFO& operator= (const CARD_STATE_INFO stuSD)
{
this->csCardState = stuSD.csCardState;
this->sServiceData = stuSD.sServiceData;
this->etEncryptType = stuSD.etEncryptType;
return *this;
}
}CardStateInfo;
typedef struct CARD_BASIC_INFO
{
std::string sCardNum;
std::string sCardNewSn; //新sn号,以后秘钥等信息的生成依次为准
std::string sCardOldSn; //沈阳老卡写在05文件中的sn号
CARD_BASIC_INFO& operator= (const CARD_BASIC_INFO stuSD)
{
this->sCardNum = stuSD.sCardNum;
this->sCardNewSn = stuSD.sCardNewSn;
this->sCardOldSn = stuSD.sCardOldSn;
return *this;
}
}BasicInfo;
// CDLCardToolDlg 对话框
class CDLCardToolDlg : public CDialogEx
{
// 构造
public:
CDLCardToolDlg(CWnd* pParent = NULL); // 标准构造函数
// 对话框数据
enum { IDD = IDD_DLCARDTOOL_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
HICON m_hIcon;
// 生成的消息映射函数
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
private:
void SetMsgLog(CString sText, LOG_TYPE emLogType = LOG_TRACE, int iErrorCode = 0);
CardStateInfo CheckCardState(BasicInfo biCardInfo);
CardStateInfo ReadJson(CString sResponseBody);
void GetMainKey(ENCRYPT_TYPE etEncryptType, std::string sSN, std::string &sDCCK, std::string &sDACK);
BasicInfo ReadBasicInfo();
std::string CalculateKey(BasicInfo biCardBasicInfo, KEY_TYPE ktKeyType, int iEncryptType);
void InstallKey(std::string sDir, std::string sNewKey, std::string sMainKey, KEY_TYPE ktKeyType, int iKeyID);
void WriteData(std::string sDir, int iFileID, int iOffest, int iLen, std::string sKey, std::string sData);
void ShowBasicInfo(CString sCardNum, CARD_STATE csCardState);
public:
afx_msg void OnBnClickedButtonCardupdate();
private:
CStatic m_cExplain;
CRichEditCtrl m_cNotice;
CButton m_cUpdateButton;
//CButton m_cDecodeButton;
PWDMachine m_cPWDMachine;
CDLConfig m_cConfig;
public:
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
private:
CStatic m_cStaticCardNum;
CEdit m_cEditCardNum;
CStatic m_cStaticState;
CEdit m_cEditState;
CStatic m_cStaticBox;
};