Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

762 lines
22 KiB

  1. /*---------------------------------------------------------------------------
  2. File: AgentMonitorDlg.cpp
  3. Comments: This dialog shows a list of the computers the agent is being dispatched to
  4. along with their status.
  5. (c) Copyright 1999, Mission Critical Software, Inc., All Rights Reserved
  6. Proprietary and confidential to Mission Critical Software, Inc.
  7. REVISION LOG ENTRY
  8. Revision By: Christy Boles
  9. ---------------------------------------------------------------------------
  10. */// AgentMonitorDlg.cpp : implementation file
  11. //
  12. #include "stdafx.h"
  13. #include "resource.h"
  14. #include "MonDlg.h"
  15. #include "DetDlg.h"
  16. #include "scanlog.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. #include "Common.hpp"
  23. #include "UString.hpp"
  24. #include "TNode.hpp"
  25. #include "ServList.hpp"
  26. #include "Monitor.h"
  27. #include "Globals.h"
  28. #include "ResStr.h"
  29. #include <htmlhelp.h>
  30. #include "helpid.h"
  31. #define COLUMN_COMPUTER 0
  32. #define COLUMN_TIMESTAMP 1
  33. #define COLUMN_STATUS 2
  34. #define COLUMN_MESSAGE 3
  35. #define SORT_COLUMN_BITS 0x03
  36. #define SORT_REVERSE 0x80000000
  37. BOOL bWaiting = FALSE;
  38. TCHAR*
  39. GetSystemDirectoryHelper();
  40. // This is the sort function for the CListView
  41. int CALLBACK SortFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  42. {
  43. int result = 0;
  44. TServerNode * n1 = (TServerNode*)lParam1;
  45. TServerNode * n2 = (TServerNode*)lParam2;
  46. if ( n1 && n2 )
  47. {
  48. switch ( lParamSort & SORT_COLUMN_BITS )
  49. {
  50. case COLUMN_COMPUTER:
  51. // Sort by names
  52. result = UStrICmp(n1->GetServer(),n2->GetServer());
  53. break;
  54. case COLUMN_TIMESTAMP:
  55. result = UStrICmp(n1->GetTimeStamp(),n2->GetTimeStamp());
  56. break;
  57. case COLUMN_STATUS:
  58. if ( n1->GetStatus() == n2->GetStatus() )
  59. result = 0;
  60. else if ( n1->GetStatus() < n2->GetStatus() )
  61. result = -1;
  62. else
  63. result = 1;
  64. break;
  65. case COLUMN_MESSAGE:
  66. result = UStrICmp(n1->GetMessageText(),n2->GetMessageText());
  67. break;
  68. default:
  69. MCSVERIFY(FALSE);
  70. break;
  71. }
  72. }
  73. if ( lParamSort & SORT_REVERSE )
  74. {
  75. result *= -1;
  76. }
  77. return result;
  78. }
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CAgentMonitorDlg dialog
  81. CAgentMonitorDlg::CAgentMonitorDlg(CWnd* pParent /*=NULL*/)
  82. : CPropertyPage(CAgentMonitorDlg::IDD)
  83. {
  84. //{{AFX_DATA_INIT(CAgentMonitorDlg)
  85. //}}AFX_DATA_INIT
  86. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  87. m_SortColumn = 0;
  88. m_bReverseSort = FALSE;
  89. m_bSecTrans = TRUE;
  90. m_bReporting = FALSE;
  91. }
  92. void CAgentMonitorDlg::DoDataExchange(CDataExchange* pDX)
  93. {
  94. CPropertyPage::DoDataExchange(pDX);
  95. //{{AFX_DATA_MAP(CAgentMonitorDlg)
  96. DDX_Control(pDX, IDC_DETAILS, m_DetailsButton);
  97. DDX_Control(pDX, IDC_SERVERLIST, m_ServerList);
  98. //}}AFX_DATA_MAP
  99. }
  100. BEGIN_MESSAGE_MAP(CAgentMonitorDlg, CPropertyPage)
  101. //{{AFX_MSG_MAP(CAgentMonitorDlg)
  102. ON_WM_SYSCOMMAND()
  103. ON_WM_PAINT()
  104. ON_WM_QUERYDRAGICON()
  105. ON_NOTIFY(NM_DBLCLK, IDC_SERVERLIST, OnDblclkServerlist)
  106. ON_BN_CLICKED(IDC_VIEW_DISPATCH, OnViewDispatch)
  107. ON_BN_CLICKED(IDC_DETAILS, OnDetails)
  108. ON_NOTIFY(LVN_COLUMNCLICK, IDC_SERVERLIST, OnColumnclickServerlist)
  109. ON_NOTIFY(NM_CLICK, IDC_SERVERLIST, OnClickServerlist)
  110. ON_NOTIFY(LVN_GETDISPINFO, IDC_SERVERLIST, OnGetdispinfoServerlist)
  111. ON_NOTIFY(LVN_SETDISPINFO, IDC_SERVERLIST, OnSetdispinfoServerlist)
  112. ON_NOTIFY(HDN_ITEMCLICK, IDC_SERVERLIST, OnHeaderItemClickServerlist)
  113. ON_WM_HELPINFO()
  114. //}}AFX_MSG_MAP
  115. ON_MESSAGE(DCT_UPDATE_ENTRY, OnUpdateServerEntry)
  116. ON_MESSAGE(DCT_ERROR_ENTRY, OnServerError)
  117. END_MESSAGE_MAP()
  118. /////////////////////////////////////////////////////////////////////////////
  119. // CAgentMonitorDlg message handlers
  120. BOOL CAgentMonitorDlg::OnInitDialog()
  121. {
  122. CPropertyPage::OnInitDialog();
  123. // Setup the columns for the server list
  124. CString heading;
  125. heading.LoadString(IDS_ComputerColumnHeading);
  126. m_ServerList.InsertColumn(COLUMN_COMPUTER,heading,LVCFMT_LEFT,120);
  127. heading.LoadString(IDS_TimestampColumnHeading);
  128. m_ServerList.InsertColumn(COLUMN_TIMESTAMP,heading,LVCFMT_LEFT,120);
  129. heading.LoadString(IDS_StatusColumnHeading);
  130. m_ServerList.InsertColumn(COLUMN_STATUS,heading,LVCFMT_LEFT,120);
  131. heading.LoadString(IDS_MessageColumnHeading);
  132. m_ServerList.InsertColumn(COLUMN_MESSAGE,heading,LVCFMT_LEFT,200);
  133. // Read the server list to get any information we may have missed so far
  134. TNodeListEnum e;
  135. TServerList * pServerList = gData.GetUnsafeServerList();
  136. TServerNode * pServer;
  137. gData.Lock();
  138. for ( pServer = (TServerNode *)e.OpenFirst(pServerList) ; pServer ; pServer = (TServerNode *)e.Next() )
  139. {
  140. if ( pServer->Include() )
  141. {
  142. // OnUpdateServerEntry(0,(long)pServer);
  143. OnUpdateServerEntry(0,(LPARAM)pServer);
  144. }
  145. }
  146. e.Close();
  147. gData.Unlock();
  148. gData.SetListWindow(m_hWnd);
  149. m_DetailsButton.EnableWindow(m_ServerList.GetSelectedCount());
  150. CString str;
  151. str.LoadString(IDS_WaitingMessage);
  152. m_ServerList.InsertItem(0,str);
  153. bWaiting = TRUE;
  154. return TRUE; // return TRUE unless you set the focus to a control
  155. }
  156. void CAgentMonitorDlg::OnSysCommand(UINT nID, LPARAM lParam)
  157. {
  158. CPropertyPage::OnSysCommand(nID, lParam);
  159. }
  160. // If you add a minimize button to your dialog, you will need the code below
  161. // to draw the icon. For MFC applications using the document/view model,
  162. // this is automatically done for you by the framework.
  163. void CAgentMonitorDlg::OnPaint()
  164. {
  165. if (IsIconic())
  166. {
  167. CPaintDC dc(this); // device context for painting
  168. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  169. // Center icon in client rectangle
  170. int cxIcon = GetSystemMetrics(SM_CXICON);
  171. int cyIcon = GetSystemMetrics(SM_CYICON);
  172. CRect rect;
  173. GetClientRect(&rect);
  174. int x = (rect.Width() - cxIcon + 1) / 2;
  175. int y = (rect.Height() - cyIcon + 1) / 2;
  176. // Draw the icon
  177. dc.DrawIcon(x, y, m_hIcon);
  178. }
  179. else
  180. {
  181. CPropertyPage::OnPaint();
  182. }
  183. }
  184. // The system calls this to obtain the cursor to display while the user drags
  185. // the minimized window.
  186. HCURSOR CAgentMonitorDlg::OnQueryDragIcon()
  187. {
  188. return (HCURSOR) m_hIcon;
  189. }
  190. //LRESULT CAgentMonitorDlg::OnUpdateServerEntry(UINT nID, long x)
  191. LRESULT CAgentMonitorDlg::OnUpdateServerEntry(UINT nID, LPARAM x)
  192. {
  193. TServerNode * pNode = (TServerNode *)x;
  194. LVFINDINFO findInfo;
  195. CString timestamp;
  196. CWaitCursor w;
  197. memset(&findInfo,0,(sizeof findInfo));
  198. // This turns off the initial hourglass in the dispatch monitor
  199. if ( bWaiting )
  200. {
  201. if ( pNode )
  202. {
  203. AfxGetApp()->DoWaitCursor(-1);
  204. if ( m_ServerList.GetItemCount() == 1 )
  205. {
  206. m_ServerList.DeleteItem(0);
  207. }
  208. }
  209. else
  210. {
  211. BOOL bLDone;
  212. gData.GetLogDone(&bLDone);
  213. if ( bLDone )
  214. {
  215. AfxGetApp()->DoWaitCursor(-1);
  216. if ( m_ServerList.GetItemCount() == 1 )
  217. {
  218. m_ServerList.DeleteItem(0);
  219. CString str;
  220. str.LoadString(IDS_NoServersMessage);
  221. m_ServerList.InsertItem(0,str);
  222. }
  223. }
  224. }
  225. }
  226. bWaiting = FALSE;
  227. if ( pNode )
  228. {
  229. findInfo.flags = LVFI_STRING;
  230. findInfo.psz = pNode->GetServer();
  231. int ndx = m_ServerList.FindItem(&findInfo);
  232. if ( ndx == -1 )
  233. {
  234. // add the server to the list
  235. ndx = m_ServerList.GetItemCount();
  236. // m_ServerList.InsertItem(LVIF_TEXT | LVIF_PARAM,ndx,pNode->GetServer(),0,0,0,(long)pNode);
  237. m_ServerList.InsertItem(LVIF_TEXT | LVIF_PARAM,ndx,pNode->GetServer(),0,0,0,(LPARAM)pNode);
  238. if ( m_bReverseSort )
  239. {
  240. m_ServerList.SortItems(&SortFunction,m_SortColumn | SORT_REVERSE);
  241. }
  242. else
  243. {
  244. m_ServerList.SortItems(&SortFunction,m_SortColumn);
  245. }
  246. }
  247. m_ServerList.RedrawItems(ndx,ndx);
  248. }
  249. return 0;
  250. }
  251. //LRESULT CAgentMonitorDlg::OnServerError(UINT nID, long x)
  252. LRESULT CAgentMonitorDlg::OnServerError(UINT nID, LPARAM x)
  253. {
  254. TServerNode * pNode = (TServerNode *)x;
  255. LVFINDINFO findInfo;
  256. CString timestamp;
  257. CWaitCursor w;
  258. memset(&findInfo,0,(sizeof findInfo));
  259. // This turns off the initial hourglass in the dispatch monitor
  260. if ( bWaiting )
  261. {
  262. if ( pNode )
  263. {
  264. AfxGetApp()->DoWaitCursor(-1);
  265. if ( m_ServerList.GetItemCount() == 1 )
  266. {
  267. m_ServerList.DeleteItem(0);
  268. }
  269. }
  270. else
  271. {
  272. BOOL bLDone;
  273. gData.GetLogDone(&bLDone);
  274. if ( bLDone )
  275. {
  276. AfxGetApp()->DoWaitCursor(-1);
  277. if ( m_ServerList.GetItemCount() == 1 )
  278. {
  279. m_ServerList.DeleteItem(0);
  280. CString str;
  281. str.LoadString(IDS_NoServersMessage);
  282. m_ServerList.InsertItem(0,str);
  283. }
  284. }
  285. }
  286. }
  287. bWaiting = FALSE;
  288. findInfo.flags = LVFI_STRING;
  289. findInfo.psz = pNode->GetServer();
  290. int ndx = m_ServerList.FindItem(&findInfo);
  291. if ( ndx == -1 )
  292. {
  293. // add the server to the list
  294. ndx = m_ServerList.GetItemCount();
  295. // m_ServerList.InsertItem(LVIF_TEXT | LVIF_PARAM,ndx,pNode->GetServer(),0,0,0,(long)pNode);
  296. m_ServerList.InsertItem(LVIF_TEXT | LVIF_PARAM,ndx,pNode->GetServer(),0,0,0,(LPARAM)pNode);
  297. if ( m_bReverseSort )
  298. {
  299. m_ServerList.SortItems(&SortFunction,m_SortColumn | SORT_REVERSE);
  300. }
  301. else
  302. {
  303. m_ServerList.SortItems(&SortFunction,m_SortColumn);
  304. }
  305. }
  306. // the subitems will be callbacks
  307. m_ServerList.RedrawItems(ndx,ndx);
  308. return 0;
  309. }
  310. void CAgentMonitorDlg::OnDblclkServerlist(NMHDR* pNMHDR, LRESULT* pResult)
  311. {
  312. OnDetails();
  313. *pResult = 0;
  314. }
  315. void CAgentMonitorDlg::OnViewDispatch()
  316. {
  317. WCHAR filename[MAX_PATH];
  318. CString cmd;
  319. STARTUPINFO startupInfo;
  320. PROCESS_INFORMATION processInfo;
  321. TCHAR* pszSystemDirectoryName = NULL;
  322. CString message;
  323. CString title;
  324. memset(&startupInfo,0,(sizeof startupInfo));
  325. startupInfo.cb = (sizeof startupInfo);
  326. gData.GetReadableLogFile(filename);
  327. pszSystemDirectoryName = GetSystemDirectoryHelper();
  328. if(!pszSystemDirectoryName)
  329. {
  330. // we could not get the system directory name, we should bail out, otherwise we might launch
  331. // malicious process
  332. title.LoadString(IDS_MessageTitle);
  333. message.LoadString(IDS_LaunchNotePadFailed);
  334. MessageBox(message,title, MB_ICONERROR | MB_OK);
  335. return;
  336. }
  337. cmd.FormatMessage(IDS_NotepadCommandLine, pszSystemDirectoryName, filename);
  338. delete [] pszSystemDirectoryName;
  339. CreateProcess(NULL,cmd.GetBuffer(0),NULL,NULL,TRUE,0,NULL,NULL,&startupInfo,&processInfo);
  340. }
  341. void CAgentMonitorDlg::OnDetails()
  342. {
  343. const int NOT_FOUND = -1; //indicates no match in search - PRT
  344. const int WHOLE_LIST = -1; //index to start search of whole list - PRT
  345. UpdateData(TRUE);
  346. // POSITION p = m_ServerList.GetFirstSelectedItemPosition();
  347. // if ( p )
  348. // {
  349. // int ndx = m_ServerList.GetNextSelectedItem(p);
  350. //search whole list control for first (and only) selected item
  351. int ndx = m_ServerList.GetNextItem(WHOLE_LIST, LVNI_SELECTED); //PRT
  352. //if found selected item, disply it's details
  353. if (ndx != NOT_FOUND) //PRT
  354. { //PRT
  355. CString serverName;
  356. serverName = m_ServerList.GetItemText(ndx,0);
  357. if ( serverName.GetLength() )
  358. {
  359. // Launch the details dialog
  360. CAgentDetailDlg det;
  361. gData.Lock();
  362. TServerNode * s = gData.GetUnsafeServerList()->FindServer((LPCTSTR)serverName);
  363. gData.Unlock();
  364. if ( s )
  365. {
  366. det.SetNode(s);
  367. if ( ! m_bSecTrans )
  368. {
  369. det.SetFormat(-1);
  370. }
  371. if ( m_bReporting )
  372. {
  373. det.SetGatheringInfo(TRUE);
  374. }
  375. if ( s->IsFinished() && *s->GetJobFile() )
  376. {
  377. DetailStats detailStats;
  378. WCHAR directory[MAX_PATH];
  379. WCHAR filename[MAX_PATH];
  380. CString plugInText;
  381. gData.GetResultDir(directory);
  382. memset(&detailStats,0,(sizeof detailStats));
  383. swprintf(filename,GET_STRING(IDS_AgentResultFileFmt),s->GetJobFile());
  384. if ( SUCCEEDED(CoInitialize(NULL)) )
  385. {
  386. if ( ReadResults(s,directory,filename,&detailStats,plugInText,FALSE) )
  387. {
  388. det.SetStats(&detailStats);
  389. det.SetPlugInText(plugInText);
  390. det.SetLogFile(s->GetLogPath());
  391. det.SetLogFileValid(s->GetLogPathValid());
  392. }
  393. CoUninitialize();
  394. }
  395. }
  396. det.DoModal();
  397. }
  398. }
  399. }
  400. UpdateData(FALSE);
  401. }
  402. void CAgentMonitorDlg::OnColumnclickServerlist(NMHDR* pNMHDR, LRESULT* pResult)
  403. {
  404. CWaitCursor w;
  405. NM_LISTVIEW * pNMListView = (NM_LISTVIEW*)pNMHDR;
  406. // sort by pNMListView->iSubItem
  407. if ( m_SortColumn == pNMListView->iSubItem )
  408. {
  409. m_bReverseSort = ! m_bReverseSort;
  410. }
  411. else
  412. {
  413. m_bReverseSort = FALSE;
  414. }
  415. m_SortColumn = pNMListView->iSubItem;
  416. if ( m_bReverseSort )
  417. {
  418. m_ServerList.SortItems(&SortFunction,m_SortColumn | SORT_REVERSE);
  419. }
  420. else
  421. {
  422. m_ServerList.SortItems(&SortFunction,m_SortColumn);
  423. }
  424. *pResult = 0;
  425. }
  426. void CAgentMonitorDlg::OnClickServerlist(NMHDR* pNMHDR, LRESULT* pResult)
  427. {
  428. const int NOT_FOUND = -1; //indicates no match in search - PRT
  429. const int WHOLE_LIST = -1; //index to start search of whole list - PRT
  430. UpdateData(TRUE);
  431. if ( m_ServerList.GetSelectedCount() )
  432. {
  433. // POSITION p = m_ServerList.GetFirstSelectedItemPosition();
  434. // if ( p )
  435. // {
  436. //search whole list control for first (and only) selected item
  437. int ndx = m_ServerList.GetNextItem(WHOLE_LIST, LVNI_SELECTED); //PRT
  438. //if found selected item, disply it's details
  439. if (ndx != NOT_FOUND) //PRT
  440. { //PRT
  441. CString msg1;
  442. CString msg2;
  443. // int ndx = m_ServerList.GetNextSelectedItem(p);
  444. CString serverName;
  445. serverName = m_ServerList.GetItemText(ndx,0);
  446. msg1.LoadString(IDS_WaitingMessage);
  447. msg2.LoadString(IDS_NoServersMessage);
  448. if ( serverName.Compare(msg1) && serverName.Compare(msg2) )
  449. {
  450. m_DetailsButton.EnableWindow(TRUE);
  451. }
  452. else
  453. {
  454. m_DetailsButton.EnableWindow(FALSE);
  455. }
  456. }
  457. }
  458. else
  459. {
  460. m_DetailsButton.EnableWindow(FALSE);
  461. }
  462. UpdateData(FALSE);
  463. *pResult = 0;
  464. }
  465. WCHAR gMessage[1000];
  466. void CAgentMonitorDlg::OnGetdispinfoServerlist(NMHDR* pNMHDR, LRESULT* pResult)
  467. {
  468. LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
  469. // find iItem in the serverList, and set the pszText for the iSubItem appropriately
  470. CString status;
  471. TServerNode * pNode = NULL;
  472. CString timestamp;
  473. WCHAR * text = gMessage;
  474. CString serverName;
  475. WCHAR convertedTimestamp[MAX_PATH];
  476. WCHAR* originalTimestamp;
  477. status.LoadString(IDS_Status_Unknown);
  478. serverName = m_ServerList.GetItemText(pDispInfo->item.iItem,0);
  479. if ( serverName.GetLength() )
  480. {
  481. gData.Lock();
  482. pNode = gData.GetUnsafeServerList()->FindServer(serverName.GetBuffer(0));
  483. gData.Unlock();
  484. if ( pNode )
  485. {
  486. switch ( pDispInfo->item.iSubItem )
  487. {
  488. case COLUMN_TIMESTAMP:
  489. originalTimestamp = pNode->GetTimeStamp();
  490. timestamp = (ConvertToLocalUserDefault(originalTimestamp, convertedTimestamp, sizeof(convertedTimestamp)/sizeof(convertedTimestamp[0])))
  491. ? convertedTimestamp : originalTimestamp;
  492. if ( timestamp.Right(1) == "\n" )
  493. {
  494. timestamp = timestamp.Left(timestamp.GetLength() - 1);
  495. }
  496. //text = new char[timestamp.GetLength() + 1];
  497. UStrCpy(text,timestamp.GetBuffer(0));
  498. pDispInfo->item.pszText = text;
  499. break;
  500. case COLUMN_STATUS:
  501. if ( pNode->HasFailed() )
  502. {
  503. status.LoadString(IDS_Status_InstallFailed);
  504. }
  505. if ( pNode->IsInstalled() )
  506. {
  507. if ( ! pNode->HasFailed() )
  508. status.LoadString(IDS_Status_Installed);
  509. else
  510. status.LoadString(IDS_Status_DidNotStart);
  511. }
  512. if ( pNode->GetStatus() & Agent_Status_Started )
  513. {
  514. if ( ! pNode->HasFailed() )
  515. status.LoadString(IDS_Status_Running);
  516. else
  517. status.LoadString(IDS_Status_Failed);
  518. }
  519. if ( pNode->IsFinished() )
  520. {
  521. if (pNode->QueryFailed())
  522. {
  523. // we show "Status Unknown" in the status field
  524. status.LoadString(IDS_Status_Unknown);
  525. }
  526. else if (!pNode->IsResultPullingTried() || (pNode->HasResult() && !pNode->IsResultProcessed()))
  527. {
  528. // if still pulling results or results not yet processed
  529. // we want to show the status of still running
  530. status.LoadString(IDS_Status_Running);
  531. }
  532. else
  533. {
  534. if (!pNode->HasResult())
  535. {
  536. // if there is no result, we consider it an error
  537. status.LoadString(IDS_Status_Completed_With_Errors);
  538. }
  539. else if ( ! pNode->GetSeverity() )
  540. {
  541. // if we have the result and no error happened during agent operation
  542. // we show the status of complete
  543. status.LoadString(IDS_Status_Completed);
  544. }
  545. else
  546. {
  547. // if we have the result, we set the status
  548. // based on the error/warning level
  549. switch ( pNode->GetSeverity() )
  550. {
  551. case 1:
  552. status.LoadString(IDS_Status_Completed_With_Warnings);
  553. break;
  554. case 2:
  555. status.LoadString(IDS_Status_Completed_With_Errors);
  556. break;
  557. case 3:
  558. default:
  559. status.LoadString(IDS_Status_Completed_With_SErrors);
  560. break;
  561. }
  562. }
  563. }
  564. }
  565. UStrCpy(text,status);
  566. pDispInfo->item.pszText = text;
  567. break;
  568. case COLUMN_MESSAGE:
  569. {
  570. BOOL bUpdate = TRUE;
  571. if (pNode->IsFinished() && pNode->QueryFailed())
  572. {
  573. // in this case, we show the error during the query
  574. status = pNode->GetMessageText();
  575. }
  576. else if (pNode->IsFinished()
  577. && (!pNode->IsResultPullingTried()
  578. || (pNode->HasResult() && !pNode->IsResultProcessed())))
  579. {
  580. // if agent has finished but result not yet pulled or processed,
  581. // we show the status of "still processing results"
  582. status.LoadString(IDS_Status_Processing_Results);
  583. }
  584. else if (pNode->IsFinished() && pNode->IsResultPullingTried() && !pNode->HasResult())
  585. {
  586. // if agent finished but we cannot retrieve results
  587. // we show the status of "cannot retrieve results"
  588. status.LoadString(IDS_Status_Cannot_Retrieve_Results);
  589. }
  590. else if ( pNode->HasFailed() || pNode->QueryFailed() || pNode->GetSeverity() || pNode->IsFinished())
  591. {
  592. // for these cases, we get the message stored on the node
  593. status = pNode->GetMessageText();
  594. }
  595. else
  596. {
  597. bUpdate = FALSE;
  598. }
  599. if (bUpdate)
  600. {
  601. UStrCpy(text, (LPCTSTR)status);
  602. pDispInfo->item.pszText = text;
  603. }
  604. }
  605. break;
  606. }
  607. }
  608. }
  609. *pResult = 0;
  610. }
  611. BOOL CAgentMonitorDlg::OnSetActive()
  612. {
  613. BOOL rc = CPropertyPage::OnSetActive();
  614. CancelToClose();
  615. return rc;
  616. }
  617. void CAgentMonitorDlg::OnSetdispinfoServerlist(NMHDR* pNMHDR, LRESULT* pResult)
  618. {
  619. LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
  620. // TODO: Add your control notification handler code here
  621. *pResult = 0;
  622. }
  623. void CAgentMonitorDlg::OnHeaderItemClickServerlist(NMHDR* pNMHDR, LRESULT* pResult)
  624. {
  625. HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
  626. // TODO: Add your control notification handler code here
  627. *pResult = 0;
  628. }
  629. void CAgentMonitorDlg::OnOK()
  630. {
  631. CPropertyPage::OnOK();
  632. }
  633. BOOL CAgentMonitorDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  634. {
  635. LPNMHDR lpnm = (LPNMHDR) lParam;
  636. switch (lpnm->code)
  637. {
  638. case PSN_HELP :
  639. helpWrapper(m_hWnd, IDH_WINDOW_AGENT_SERVER_LIST );
  640. break;
  641. }
  642. return CPropertyPage::OnNotify(wParam, lParam, pResult);
  643. }
  644. BOOL CAgentMonitorDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  645. {
  646. helpWrapper(m_hWnd, IDH_WINDOW_AGENT_SERVER_LIST );
  647. return CPropertyPage::OnHelpInfo(pHelpInfo);
  648. }