ConfigDialog.cpp
3.49 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
// SetAppDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "ConfigDialog.h"
#include "afxdialogex.h"
#include "etradeclient/utility/application_config.h"
#include "etradeclient/utility/url_config.h"
#include "etradeclient/utility/string_converter.h"
IMPLEMENT_DYNAMIC(CConfigDialog, CDialog)
BEGIN_MESSAGE_MAP(CConfigDialog, CDialog)
ON_CBN_SELCHANGE(IDC_COMBO_PROTOCOL, &CConfigDialog::OnCbnSelchangeComboProtocol)
END_MESSAGE_MAP()
CConfigDialog::CConfigDialog(CWnd* pParent /*=NULL*/)
: CDialog(CConfigDialog::IDD, pParent)
, m_id_reader_type(0)
{}
static const int HTTP = 0, HTTPS = 1;
void CConfigDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
const int kMinPortValue = 0, kMaxPortValue = 65535;
const int kMinMsgCountQueryInterval = 60, kMaxMsgCountQueryInterval = 3600;
const int kMinTimeoutMs = 100, kMaxTimeoutMs = 10000;
const int kMinTimeoutSeconds = 1, kMaxTimeoutSeconds = 15;
const int kMinPwdLen = 6, kMaxPwdLen = 32;
DDX_Text(pDX, IDC_EDIT_MSG_COUNT_QUERY_INTERVAL, m_msg_count_query_interval);
DDV_MinMaxInt(pDX, m_msg_count_query_interval, kMinMsgCountQueryInterval, kMaxMsgCountQueryInterval);
DDX_CBIndex(pDX, IDC_COMBO_PROTOCOL, m_protocol_index);
DDX_Text(pDX, IDC_EDIT_SERVER_PORT, m_server_port);
DDV_MinMaxInt(pDX, m_server_port, kMinPortValue, kMaxPortValue);
DDX_Text(pDX, IDC_IP_ADDR_PWD_MACHINE, m_pwd_machine_ip);
DDX_Text(pDX, IDC_EDIT_PWD_MACHINE_PORT, m_pwd_machine_port);
DDV_MinMaxInt(pDX, m_pwd_machine_port, kMinPortValue, kMaxPortValue);
DDX_Text(pDX, IDC_EDIT_PWD_MACHINE_TIMEOUT, m_pwd_machine_timeout);
DDV_MinMaxInt(pDX, m_pwd_machine_timeout, kMinTimeoutMs, kMaxTimeoutMs);
DDX_Text(pDX, IDC_EDIT_PIN_PAD_LEN, m_pin_pad_pwd_len);
DDV_MinMaxInt(pDX, m_pin_pad_pwd_len, kMinPwdLen, kMaxPwdLen);
DDX_Text(pDX, IDC_EDIT_PIN_PAD_TIMEOUT, m_pin_pad_timeout);
DDV_MinMaxInt(pDX, m_pin_pad_timeout, kMinTimeoutSeconds, kMaxTimeoutSeconds);
DDX_Radio(pDX, IDC_RADIO_HUASHIDIANZI, m_id_reader_type);
}
void CConfigDialog::OnCbnSelchangeComboProtocol()
{
if (!UpdateData(TRUE))// 检查输入数据合法性,并存入关联变量
return;
const int kDefaultHttpsPort = 443, kDefaultHttpPort = 80;
m_server_port = (HTTPS == m_protocol_index) ? kDefaultHttpsPort : kDefaultHttpPort;
UpdateData(FALSE);
}
BOOL CConfigDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// 取出配置,并更新到界面
const ApplicationConfig& app_config = ApplicationConfig::Instance();
m_msg_count_query_interval = app_config.MsgCountQueryInterval();
m_pwd_machine_ip = str_2_wstr(app_config.PWDMachineIP()).c_str();
m_pwd_machine_port = app_config.PWDMachinePort();
m_pwd_machine_timeout = app_config.PWDMachineTimeout();
m_pin_pad_pwd_len = app_config.PINPadPWDLen();
m_pin_pad_timeout = app_config.PINPadTimeout();
m_id_reader_type = app_config.IDReaderType();
const URLConfig& url_config = URLConfig::Instance();
m_protocol_index = url_config.IsHttps() ? HTTPS : HTTP;
m_server_port = url_config.Port();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CConfigDialog::OnOK()
{
if (!UpdateData(TRUE))// 检查输入数据合法性,并存入关联变量
return;
// 保存配置的值
/*ApplicationConfig::Instance().ModifyCfg(
m_msg_count_query_interval,
wstr_2_str(m_pwd_machine_ip.GetBuffer(m_pwd_machine_ip.GetLength())),
m_pwd_machine_port,
m_pwd_machine_timeout,
m_pin_pad_pwd_len,
m_pin_pad_timeout,
m_id_reader_type);*/
//URLConfig::Instance().ModifyCfg((HTTPS == m_protocol_index), m_server_port);
return CDialog::OnOK();
}