Added internal parameter AgentStatus
[public/netxms.git] / src / console / win32 / InternalItemSelDlg.cpp
CommitLineData
b6af0366
VK
1// InternalItemSelDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "nxcon.h"
6#include "InternalItemSelDlg.h"
7#include "DataQueryDlg.h"
8
9#ifdef _DEBUG
10#define new DEBUG_NEW
11#undef THIS_FILE
12static char THIS_FILE[] = __FILE__;
13#endif
14
15
16//
17// Static data
18//
19
20static struct __item_info
21{
22 DWORD dwMatchFlags;
23 int iDataType;
24 TCHAR *pszName;
25 TCHAR *pszDescription;
26} m_itemList[] =
27{
04af194e 28 { NF_IS_NATIVE_AGENT, DCI_DT_INT, _T("AgentStatus"), _T("Status of NetXMS agent") },
282edbb5 29 { 0, DCI_DT_INT, _T("ChildStatus(*)"), _T("Status of child object {instance}") },
b6af0366
VK
30 { NF_IS_LOCAL_MGMT, DCI_DT_FLOAT, _T("Server.AverageConfigurationPollerQueueSize"), _T("Average length of configuration poller queue for last minute") },
31 { NF_IS_LOCAL_MGMT, DCI_DT_FLOAT, _T("Server.AverageDBWriterQueueSize"), _T("Average length of database writer's request queue for last minute") },
32 { NF_IS_LOCAL_MGMT, DCI_DT_UINT, _T("Server.AverageDCIQueuingTime"), _T("Average time to queue DCI for polling for last minute") },
33 { NF_IS_LOCAL_MGMT, DCI_DT_FLOAT, _T("Server.AverageDCPollerQueueSize"), _T("Average length of data collection poller's request queue for last minute") },
34 { NF_IS_LOCAL_MGMT, DCI_DT_FLOAT, _T("Server.AverageStatusPollerQueueSize"), _T("Average length of status poller queue for last minute") },
35 { 0, DCI_DT_INT, _T("Status"), _T("Status") },
36 { 0, 0, NULL, NULL }
37};
38
39
40/////////////////////////////////////////////////////////////////////////////
41// CInternalItemSelDlg dialog
42
43
44CInternalItemSelDlg::CInternalItemSelDlg(CWnd* pParent /*=NULL*/)
45 : CDialog(CInternalItemSelDlg::IDD, pParent)
46{
47 //{{AFX_DATA_INIT(CInternalItemSelDlg)
48 // NOTE: the ClassWizard will add member initialization here
49 //}}AFX_DATA_INIT
50}
51
52
53void CInternalItemSelDlg::DoDataExchange(CDataExchange* pDX)
54{
55 CDialog::DoDataExchange(pDX);
56 //{{AFX_DATA_MAP(CInternalItemSelDlg)
57 DDX_Control(pDX, IDC_LIST_PARAMETERS, m_wndListCtrl);
58 //}}AFX_DATA_MAP
59}
60
61
62BEGIN_MESSAGE_MAP(CInternalItemSelDlg, CDialog)
63 //{{AFX_MSG_MAP(CInternalItemSelDlg)
64 ON_BN_CLICKED(IDC_BUTTON_GET, OnButtonGet)
20a2d19c 65 ON_NOTIFY(NM_DBLCLK, IDC_LIST_PARAMETERS, OnDblclkListParameters)
b6af0366
VK
66 //}}AFX_MSG_MAP
67END_MESSAGE_MAP()
68
69/////////////////////////////////////////////////////////////////////////////
70// CInternalItemSelDlg message handlers
71
72BOOL CInternalItemSelDlg::OnInitDialog()
73{
74 DWORD i;
75 int iItem;
76 RECT rect;
77
78 CDialog::OnInitDialog();
79
80 m_wndListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_UNDERLINEHOT);
81 m_wndListCtrl.SetHoverTime(0x7FFFFFFF);
82 m_wndListCtrl.GetClientRect(&rect);
83 m_wndListCtrl.InsertColumn(0, _T("Parameter name"), LVCFMT_LEFT, 220);
84 m_wndListCtrl.InsertColumn(1, _T("Type"), LVCFMT_LEFT, 80);
85 m_wndListCtrl.InsertColumn(2, _T("Description"), LVCFMT_LEFT,
86 rect.right - 300 - GetSystemMetrics(SM_CXVSCROLL));
87
88 for(i = 0; m_itemList[i].pszName != NULL; i++)
89 if ((m_pNode->node.dwFlags & m_itemList[i].dwMatchFlags) ||
90 (m_itemList[i].dwMatchFlags == 0))
91 {
92 iItem = m_wndListCtrl.InsertItem(0x7FFFFFFF, m_itemList[i].pszName);
93 if (iItem != -1)
94 {
95 m_wndListCtrl.SetItemData(iItem, i);
96 m_wndListCtrl.SetItemText(iItem, 1, g_pszItemDataType[m_itemList[i].iDataType]);
97 m_wndListCtrl.SetItemText(iItem, 2, m_itemList[i].pszDescription);
98 }
99 }
100
101 return TRUE;
102}
103
104
105//
106// Handler for OK button
107//
108
109void CInternalItemSelDlg::OnOK()
110{
111 if (m_wndListCtrl.GetSelectedCount() == 0)
112 {
113 MessageBox(_T("You must select parameter from the list before pressing OK!"),
114 _T("Warning"), MB_OK | MB_ICONEXCLAMATION);
115 }
116 else
117 {
118 DWORD dwIndex;
119
120 dwIndex = m_wndListCtrl.GetItemData(m_wndListCtrl.GetSelectionMark());
121 _tcsncpy(m_szItemName, m_itemList[dwIndex].pszName, MAX_DB_STRING);
122 _tcsncpy(m_szItemDescription, m_itemList[dwIndex].pszDescription, MAX_DB_STRING);
123 m_iDataType = m_itemList[dwIndex].iDataType;
124 CDialog::OnOK();
125 }
126}
127
128
129//
130// Handler for "Get..." button
131//
132
133void CInternalItemSelDlg::OnButtonGet()
134{
135 if (m_wndListCtrl.GetSelectedCount() != 0)
136 {
137 CDataQueryDlg dlg;
138 DWORD dwIndex;
139
140 dwIndex = m_wndListCtrl.GetItemData(m_wndListCtrl.GetSelectionMark());
141 dlg.m_dwObjectId = m_pNode->dwId;
142 dlg.m_strNode = (LPCTSTR)m_pNode->szName;
143 dlg.m_strParameter = (LPCTSTR)m_itemList[dwIndex].pszName;
144 dlg.m_iOrigin = DS_INTERNAL;
145 dlg.DoModal();
146 }
e6ccf59b 147 m_wndListCtrl.SetFocus();
b6af0366 148}
20a2d19c
VK
149
150
151//
152// Handle double click in list view
153//
154
155void CInternalItemSelDlg::OnDblclkListParameters(NMHDR* pNMHDR, LRESULT* pResult)
156{
157 if (m_wndListCtrl.GetSelectedCount() > 0)
158 PostMessage(WM_COMMAND, IDOK, 0);
159
160 *pResult = 0;
161}