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.

147 lines
4.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: cisavtst.cxx
  7. //
  8. // History: 3-18-97 srikants Created
  9. //
  10. //----------------------------------------------------------------------------
  11. #include <pch.cxx>
  12. #pragma hdrstop
  13. #if CIDBG==1
  14. #include <cisavtst.hxx>
  15. #include <cicat.hxx>
  16. CCiSaveTest::CCiSaveTest( WCHAR const * pwszSaveDir,
  17. ICiPersistIncrFile * pICiPersistFile,
  18. CiCat & cicat )
  19. : _cicat(cicat),
  20. _pICiPersistFile(pICiPersistFile),
  21. #pragma warning( disable : 4355 ) // this used in base initialization
  22. _thrSave( SaveThread, this, TRUE ) // create suspended
  23. #pragma warning( default : 4355 )
  24. {
  25. unsigned cwc = wcslen( pwszSaveDir ) + 1;
  26. _xwszSaveDir.Init( cwc );
  27. RtlCopyMemory( _xwszSaveDir.GetPointer(), pwszSaveDir, cwc * sizeof WCHAR );
  28. _pICiPersistFile->AddRef();
  29. _fAbort = FALSE;
  30. _evt.Reset();
  31. _thrSave.Resume();
  32. END_CONSTRUCTION( CCiSaveTest );
  33. }
  34. DWORD WINAPI CCiSaveTest::SaveThread( void * self )
  35. {
  36. ciDebugOut(( DEB_ERROR, "Starting Save Thread\n" ));
  37. ((CCiSaveTest *) self)->DoIt();
  38. ciDebugOut(( DEB_ERROR, "Leaving Save Thread\n" ));
  39. return 0;
  40. }
  41. void CCiSaveTest::DoIt()
  42. {
  43. TRY
  44. {
  45. DWORD dwWaitTime = 1 * 60 * 1000; // 1 minute
  46. _evt.Wait( dwWaitTime ); // 1 minute
  47. _evt.Reset();
  48. dwWaitTime = 30 * 60 * 1000; // 30 minutes in milli seconds
  49. ULONG iCount = 1;
  50. while ( !_fAbort )
  51. {
  52. BOOL fFull = (iCount % 10) == 9;
  53. iCount++;
  54. ICiEnumWorkids * pICiEnumWorkids = 0;
  55. IEnumString * pIEnumString = 0;
  56. BOOL fCallerOwnsFiles;
  57. #if 1
  58. SCODE sc = _pICiPersistFile->Save(
  59. _xwszSaveDir.GetPointer(),
  60. fFull,
  61. 0, // No progress notify
  62. &_fAbort,
  63. &pICiEnumWorkids,
  64. &pIEnumString,
  65. &fFull,
  66. &fCallerOwnsFiles );
  67. #else
  68. SCODE sc = S_OK;
  69. #endif // 0
  70. XInterface<ICiEnumWorkids> xEnumWorkids;
  71. XInterface<IEnumString> xEnumString;
  72. if ( SUCCEEDED(sc) )
  73. {
  74. xEnumWorkids.Set( pICiEnumWorkids );
  75. xEnumString.Set( pIEnumString );
  76. _cicat.MakeBackupOfPropStore( _xwszSaveDir.GetPointer(),
  77. 0, // IProgressNotify
  78. _fAbort,
  79. fFull ? 0 : pICiEnumWorkids );
  80. ciDebugOut(( DEB_ERROR, "%s Backup of CiData succeeded\n",
  81. fFull ? "Full" : "Incremental" ));
  82. WCHAR * pwszFileName;
  83. ULONG cElements;
  84. xEnumString->Reset();
  85. while ( S_OK == xEnumString->Next( 1, &pwszFileName, &cElements ) )
  86. {
  87. ciDebugOut(( DEB_ERROR, "File: (%ws) \n", pwszFileName ));
  88. }
  89. }
  90. else
  91. {
  92. ciDebugOut(( DEB_ERROR, "%s Backup of CiData failed. Error 0x%X \n",
  93. fFull ? "Full" : "Incremental", sc ));
  94. }
  95. if ( !_fAbort )
  96. {
  97. _evt.Wait( dwWaitTime );
  98. _evt.Reset();
  99. }
  100. }
  101. }
  102. CATCH( CException , e )
  103. {
  104. ciDebugOut(( DEB_ERROR,
  105. "Error in Save Thread. 0x%X\n",
  106. e.GetErrorCode() ));
  107. }
  108. END_CATCH
  109. _pICiPersistFile->Release();
  110. ciDebugOut(( DEB_ERROR, "End of Save Thread\n" ));
  111. }
  112. #endif // CIDBG==1