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.

139 lines
3.3 KiB

  1. // txnobj.cpp : Implementation of CASPObjectContext
  2. #include "stdafx.h"
  3. #include "txnscrpt.h"
  4. #include "txnobj.h"
  5. #include <hostinfo.h>
  6. #include <scrpteng.h>
  7. /////////////////////////////////////////////////////////////////////////////
  8. // CASPObjectContext
  9. HRESULT CASPObjectContext::Activate()
  10. {
  11. HRESULT hr = GetObjectContext(&m_spObjectContext);
  12. if (SUCCEEDED(hr))
  13. return S_OK;
  14. return hr;
  15. }
  16. BOOL CASPObjectContext::CanBePooled()
  17. {
  18. return FALSE;
  19. }
  20. void CASPObjectContext::Deactivate()
  21. {
  22. m_spObjectContext.Release();
  23. }
  24. STDMETHODIMP CASPObjectContext::Call
  25. (
  26. #ifdef _WIN64
  27. // Win64 fix -- use UINT64 instead of LONG_PTR since LONG_PTR is broken for Win64 1/21/2000
  28. UINT64 pvScriptEngine /*CScriptEngine*/,
  29. #else
  30. LONG_PTR pvScriptEngine /*CScriptEngine*/,
  31. #endif
  32. LPCOLESTR strEntryPoint,
  33. // BUGBUG - ASP uses this BOOLB type that resolves to a unsigned char. I changed things
  34. // to boolean for simplicity, but this requires some strange casts.
  35. boolean *pfAborted
  36. )
  37. {
  38. HRESULT hr = NOERROR;
  39. CScriptEngine *pScriptEngine = (CScriptEngine *)pvScriptEngine;
  40. m_fAborted = FALSE;
  41. hr = pScriptEngine->Call(strEntryPoint);
  42. // If the script timed out or there was an unhandled error, then autoabort
  43. if (SUCCEEDED(hr) && (pScriptEngine->FScriptTimedOut() || pScriptEngine->FScriptHadError()))
  44. {
  45. hr = SetAbort();
  46. m_fAborted = TRUE;
  47. }
  48. // If the script author did not do an explicit SetComplete or SetAbort
  49. // then do a SetComplete here so Viper will return the transaction
  50. // completion status to the caller
  51. if (SUCCEEDED(hr) && !m_fAborted)
  52. {
  53. hr = SetComplete();
  54. }
  55. *pfAborted = (boolean)m_fAborted;
  56. return hr;
  57. }
  58. STDMETHODIMP CASPObjectContext::ResetScript
  59. (
  60. #ifdef _WIN64
  61. // Win64 fix -- use UINT64 instead of LONG_PTR since LONG_PTR is broken for Win64 1/21/2000
  62. UINT64 pvScriptEngine /*CScriptEngine*/
  63. #else
  64. LONG_PTR pvScriptEngine /*CScriptEngine*/
  65. #endif
  66. )
  67. {
  68. HRESULT hr = NOERROR;
  69. CScriptEngine *pScriptEngine = (CScriptEngine *)pvScriptEngine;
  70. hr = pScriptEngine->ResetScript();
  71. return hr;
  72. }
  73. STDMETHODIMP CASPObjectContext::SetComplete()
  74. {
  75. HRESULT hr = E_NOTIMPL;
  76. IObjectContext * pContext = NULL;
  77. hr = GetObjectContext(&pContext);
  78. if( SUCCEEDED(hr) )
  79. {
  80. hr = pContext->SetComplete();
  81. pContext->Release();
  82. m_fAborted = FALSE; // If it was aborted, its not any more
  83. }
  84. return hr;
  85. }
  86. STDMETHODIMP CASPObjectContext::SetAbort()
  87. {
  88. IObjectContext * pContext = NULL;
  89. HRESULT hr = NOERROR;
  90. hr = GetObjectContext(&pContext);
  91. if( SUCCEEDED(hr) )
  92. {
  93. hr = pContext->SetAbort();
  94. pContext->Release();
  95. m_fAborted = TRUE; // transaction was esplicitly aborted
  96. }
  97. return hr;
  98. }
  99. STDMETHODIMP CASPObjectContext::InterfaceSupportsErrorInfo(REFIID riid)
  100. {
  101. static const IID* arr[] =
  102. {
  103. &IID_IASPObjectContextCustom
  104. , &IID_IASPObjectContext
  105. , &IID_IObjectControl
  106. , &IID_IDispatch
  107. };
  108. for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
  109. {
  110. if (InlineIsEqualGUID(*arr[i],riid))
  111. return S_OK;
  112. }
  113. return S_FALSE;
  114. }