DLCardToolDlg.h 3.02 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 ENCRYPT_TYPE
{
	ET_PWM = 0,      //加密机加密
	ET_DES,			 //软加密
	ET_NO,			 //未加密
	ET_UNKNOWN		 //未知加密状态
};

typedef struct CARD_STATE_INFO
{
	bool bAlreadyUpdate;

	CARD_STATE_INFO()
	{
		bAlreadyUpdate = false;
	}

	CARD_STATE_INFO& operator= (const CARD_STATE_INFO stuSD)
	{
		this->bAlreadyUpdate = stuSD.bAlreadyUpdate;
		return *this;
	}
}CardStateInfo;

typedef struct CARD_BASIC_INFO
{
	std::string sCardNum;
	std::string sCardOldSn; //沈阳老卡写在05文件中的sn号

	CARD_BASIC_INFO& operator= (const CARD_BASIC_INFO stuSD)
	{
		this->sCardNum = stuSD.sCardNum;
		this->sCardOldSn = stuSD.sCardOldSn;
		return *this;
	}

}BasicInfo;

// CDLCardToolDlg 对话框
class CDLCardToolDlg : public CDialogEx
{

	class UpdataBtn : public CButton
	{
	private:
		virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
		void DrawFilledRect(CDC* dc, CRect rc, COLORREF color);
		void DrawButtonText(CDC* dc, CRect rc, CString caption, COLORREF textcolor);
	};

// 构造
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(bool bUsePWM, std::string sSN, std::string &sDCCK);
	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 ResizeCtrl();
	void SetCtrlText();
	void SetCtrlFont();
	void SetCtrlImg();

	void SetResultTest(CString sTitle, CString sText);

public:
	afx_msg void OnBnClickedButtonCardupdate();
	
private:
	CStatic m_cExplain;
	CStatic m_cExplain1;
	CStatic m_cExplain2;
	CStatic m_cExplain3;
	CStatic m_cExplain4;
	CStatic m_cExplain5;
	CStatic m_cExplain6;
	CStatic m_cExplain7;
	CStatic m_cExplain8;
	CStatic m_cExplain9;
	CStatic m_cExplain10;
	CStatic m_cExplain11;
	UpdataBtn m_cUpdateButton;

	CStatic m_cResult;
	CStatic m_cResultText;
	CStatic m_cResultText2;

	CStatic m_cStaticImg;

	PWDMachine m_cPWDMachine;
	CDLConfig m_cConfig;
private:
	CStatic m_cStaticCardNum;
	CStatic m_cStaticCardNumText;
	
	CFont m_cFontBig;
	CFont m_cFontSmall;

	CImage m_cImg;

	CPen m_cPen;
public:
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);

private:
	bool m_bSetRed;
};