DLCardToolDlg.h 2.81 KB

// 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;
};