Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

93 řádky
2.7KB

  1. <?xml version="1.0"?>
  2. <?component error="true" debug="false"?>
  3. <component>
  4. <registration
  5. description="WscMvc RequestContext"
  6. progid="WscMvc.RequestContext"
  7. version="1.00"
  8. classid="{1C36FA55-34DF-4974-94B9-D657389362B2}">
  9. </registration>
  10. <public>
  11. <method name="Initialize">
  12. <parameter name="path"/>
  13. <parameter name="httpMethod"/>
  14. <parameter name="logDir"/>
  15. </method>
  16. <method name="ElapsedMs"/>
  17. <method name="Path"/>
  18. <method name="HttpMethod"/>
  19. <method name="CorrelationId"/>
  20. <method name="LogDir"/>
  21. </public>
  22. <script language="VBScript">
  23. <![CDATA[
  24. Option Explicit
  25. ' Per-request, primitive-only data holder. Never references ASP intrinsics
  26. ' (Request/Response/Server/Session) - Default.asp resolves logDir via
  27. ' Server.MapPath before calling Initialize, and passes it in as a plain string.
  28. '
  29. ' NOTE: `Property Get/Let/Set` requires a `Class...End Class` block in
  30. ' VBScript - it cannot be used at the top level of a WSC <script> block
  31. ' (verified experimentally: registration fails with "Must be defined inside
  32. ' a Class", error 1048). Plain Function-style getters exposed as <method>
  33. ' are used instead, matching Application.wsc/HomeController.wsc.
  34. Dim m_path, m_httpMethod, m_logDir, m_correlationId, m_startTimer, m_initialized
  35. m_initialized = False
  36. Sub Initialize(path, httpMethod, logDir)
  37. m_path = path
  38. m_httpMethod = httpMethod
  39. m_logDir = logDir
  40. m_correlationId = NewCorrelationId()
  41. m_startTimer = Timer
  42. m_initialized = True
  43. End Sub
  44. Function NewCorrelationId()
  45. ' Timer/Randomize/Rnd() was tried first and FAILED experimentally: two
  46. ' Initialize calls within the same system-clock tick call `Randomize` with
  47. ' the same implicit time-based seed, so Rnd() returns the identical first
  48. ' value both times - two contexts created back-to-back got the exact same
  49. ' correlation id. FileSystemObject.GetTempName() is used instead: verified
  50. ' experimentally to return a distinct value on every call even in a tight
  51. ' loop (it does not depend on Randomize/Rnd state at all).
  52. Dim secs, fso, tempPart
  53. secs = Fix(Timer)
  54. Set fso = CreateObject("Scripting.FileSystemObject")
  55. tempPart = Replace(fso.GetTempName(), ".tmp", "")
  56. Set fso = Nothing
  57. NewCorrelationId = CStr(secs) & "-" & tempPart
  58. End Function
  59. Function ElapsedMs()
  60. If m_initialized Then
  61. ElapsedMs = CLng((Timer - m_startTimer) * 1000)
  62. Else
  63. ElapsedMs = -1
  64. End If
  65. End Function
  66. Function Path()
  67. Path = m_path
  68. End Function
  69. Function HttpMethod()
  70. HttpMethod = m_httpMethod
  71. End Function
  72. Function CorrelationId()
  73. CorrelationId = m_correlationId
  74. End Function
  75. Function LogDir()
  76. LogDir = m_logDir
  77. End Function
  78. ]]>
  79. </script>
  80. </component>

Powered by TurnKey Linux.