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.

165 lines
3.6 KiB

  1. #include "headers.hxx"
  2. #include "AnalysisPage.hpp"
  3. #include "resource.h"
  4. #include "common.hpp"
  5. #include "AnalysisResults.hpp"
  6. #include "CSVDSReader.hpp"
  7. #include "Analysis.hpp"
  8. #include "global.hpp"
  9. #include "constants.hpp"
  10. AnalysisPage::AnalysisPage
  11. (
  12. const CSVDSReader& csvReader409_,
  13. const CSVDSReader& csvReaderIntl_,
  14. const String& ldapPrefix_,
  15. const String& rootContainerDn_,
  16. AnalysisResults& res,
  17. const String& reportName_
  18. )
  19. :
  20. csvReader409(csvReader409_),
  21. csvReaderIntl(csvReaderIntl_),
  22. ldapPrefix(ldapPrefix_),
  23. rootContainerDn(rootContainerDn_),
  24. results(res),
  25. reportName(reportName_),
  26. WizardPage
  27. (
  28. IDD_ANALYSIS,
  29. IDS_ANALYSIS_PAGE_TITLE,
  30. IDS_ANALYSIS_PAGE_SUBTITLE,
  31. true
  32. )
  33. {
  34. LOG_CTOR(AnalysisPage);
  35. }
  36. AnalysisPage::~AnalysisPage()
  37. {
  38. LOG_DTOR(AnalysisPage);
  39. }
  40. long WINAPI startAnalysis(long arg)
  41. {
  42. LOG_FUNCTION(startAnalysis);
  43. AnalysisPage *page=(AnalysisPage *)arg;
  44. Analysis analysis(
  45. page->csvReader409,
  46. page->csvReaderIntl,
  47. page->ldapPrefix,
  48. page->rootContainerDn,
  49. page->results,
  50. &page->reportName,
  51. page
  52. );
  53. // CoInitialize must be called per thread
  54. HRESULT hr = ::CoInitialize(0);
  55. ASSERT(SUCCEEDED(hr));
  56. hrError=analysis.run();
  57. CoUninitialize();
  58. page->FinishProgress();
  59. return 0;
  60. }
  61. // WizardPage overrides
  62. bool
  63. AnalysisPage::OnSetActive()
  64. {
  65. LOG_FUNCTION(AnalysisPage::OnSetActive);
  66. Win::PropSheet_SetWizButtons(Win::GetParent(hwnd), 0);
  67. pos=0;
  68. HANDLE hA=CreateThread(
  69. NULL,0,
  70. (LPTHREAD_START_ROUTINE) startAnalysis,
  71. this,
  72. 0, 0
  73. );
  74. CloseHandle(hA);
  75. return true;
  76. }
  77. void
  78. AnalysisPage::OnInit()
  79. {
  80. LOG_FUNCTION(AnalysisPage::OnInit);
  81. HWND prog=GetDlgItem(hwnd,IDC_PROGRESS_ANALYSIS);
  82. // calculate the # of locales
  83. for(long t=0;LOCALEIDS[t]!=0;t++)
  84. {
  85. //empty
  86. }
  87. SendMessage(prog,PBM_SETRANGE,0,MAKELPARAM(0,t));
  88. };
  89. bool
  90. AnalysisPage::OnWizBack()
  91. {
  92. LOG_FUNCTION(AnalysisPage::OnWizBack);
  93. GetWizard().SetNextPageID(hwnd,IDD_WELCOME);
  94. return true;
  95. }
  96. bool
  97. AnalysisPage::OnWizNext()
  98. {
  99. LOG_FUNCTION(AnalysisPage::OnWizNext);
  100. if (FAILED(hrError))
  101. {
  102. GetWizard().SetNextPageID(hwnd,IDD_FINISH);
  103. }
  104. else
  105. {
  106. GetWizard().SetNextPageID(hwnd,IDD_UPDATES_REQUIRED);
  107. }
  108. return true;
  109. }
  110. void AnalysisPage::StepProgress()
  111. {
  112. LOG_FUNCTION(AnalysisPage::StepProgress);
  113. HWND prog=GetDlgItem(hwnd,IDC_PROGRESS_ANALYSIS);
  114. SendMessage(prog,PBM_SETPOS,pos++,0);
  115. }
  116. void AnalysisPage::FinishProgress()
  117. {
  118. LOG_FUNCTION(AnalysisPage::FinishProgress);
  119. Win::PropSheet_SetWizButtons(Win::GetParent(hwnd),PSWIZB_NEXT);
  120. String result;
  121. if (FAILED(hrError))
  122. {
  123. result=String::format(IDS_IDC_ANALYSIS_RESULT_INCOMPLETE);
  124. error=String::format(IDS_ANALYSIS_ERROR,error.c_str());
  125. }
  126. else
  127. {
  128. result=String::format(IDS_IDC_ANALYSIS_RESULT_COMPLETE);
  129. }
  130. Win::SetDlgItemText(hwnd,IDC_ANALYSIS_RESULT,result);
  131. HWND text=GetDlgItem(hwnd,IDC_ANALYSIS_RESULT);
  132. Win::ShowWindow(text,SW_SHOW);
  133. }