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.

113 lines
3.0 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // SYNOPSIS
  6. //
  7. // Declares the class Database
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef DATABASE_H
  11. #define DATABASE_H
  12. #pragma once
  13. #include "lmcons.h"
  14. #include "account.h"
  15. #include "commandpool.h"
  16. #include "resource.h"
  17. class ATL_NO_VTABLE Database
  18. : public Accountant,
  19. public CComCoClass<Database, &__uuidof(DatabaseAccounting)>
  20. {
  21. public:
  22. IAS_DECLARE_REGISTRY(DatabaseAccounting, 1, IAS_REGISTRY_AUTO, IASTypeLibrary)
  23. IAS_DECLARE_OBJECT_ID(IAS_PROVIDER_MICROSOFT_DB_ACCT)
  24. Database() throw ();
  25. ~Database() throw ();
  26. HRESULT FinalConstruct() throw ();
  27. protected:
  28. // IIasComponent
  29. STDMETHOD(Initialize)();
  30. STDMETHOD(Shutdown)();
  31. STDMETHOD(PutProperty)(LONG Id, VARIANT* pValue);
  32. private:
  33. virtual void Process(IASTL::IASRequest& request);
  34. virtual void InsertRecord(
  35. void* context,
  36. IASTL::IASRequest& request,
  37. const SYSTEMTIME& localTime,
  38. PATTRIBUTEPOSITION first,
  39. PATTRIBUTEPOSITION last
  40. );
  41. virtual void Flush(
  42. void* context,
  43. IASTL::IASRequest& request,
  44. const SYSTEMTIME& localTime
  45. );
  46. // Execute a command. It need not be prepared.
  47. HRESULT ExecuteCommand(
  48. ReportEventCommand& command,
  49. const wchar_t* doc,
  50. bool retry
  51. ) throw ();
  52. // Prepare a command for execution.
  53. HRESULT PrepareCommand(ReportEventCommand& command) throw ();
  54. // Reset the connection to the database.
  55. void ResetConnection() throw ();
  56. // Events that trigger state changes.
  57. void OnConfigChange() throw ();
  58. void OnConnectError() throw ();
  59. void OnExecuteSuccess(ReportEventCommand& command) throw ();
  60. void OnExecuteError(ReportEventCommand& command) throw ();
  61. bool IsBlackedOut() throw ();
  62. void SetBlackOut() throw ();
  63. // States of the database connection.
  64. enum State
  65. {
  66. AVAILABLE,
  67. QUESTIONABLE,
  68. BLACKED_OUT
  69. };
  70. // Local computer name; included in each event we report.
  71. wchar_t computerName[MAX_COMPUTERNAME_LENGTH + 1];
  72. // Database initialization string. null if not configured.
  73. CComBSTR initString;
  74. // Connection to the database.
  75. CComPtr<IDBCreateSession> dataSource;
  76. // Pool of reusable commands.
  77. CommandPool pool;
  78. // Current state of the connection.
  79. State state;
  80. // Expiration time of the blackout state; ignored if state != BLACKED_OUT.
  81. ULONGLONG blackoutExpiry;
  82. // Blackout interval in units of DCE time.
  83. static const ULONGLONG blackoutInterval;
  84. // Not implemented.
  85. Database(const Database&);
  86. Database& operator=(const Database&);
  87. };
  88. #endif // DATABASE_H