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.

211 lines
5.0 KiB

  1. VERSION 1.0 CLASS
  2. BEGIN
  3. MultiUse = -1 'True
  4. Persistable = 0 'NotPersistable
  5. DataBindingBehavior = 0 'vbNone
  6. DataSourceBehavior = 0 'vbNone
  7. MTSTransactionMode = 0 'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "Main"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = True
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
  15. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  16. Attribute VB_Ext_KEY = "Member0" ,"CHHT"
  17. Attribute VB_Ext_KEY = "Member1" ,"CKeywords"
  18. Attribute VB_Ext_KEY = "Member2" ,"CMilestones"
  19. Attribute VB_Ext_KEY = "Member3" ,"CStopSigns"
  20. Attribute VB_Ext_KEY = "Member4" ,"CStopWords"
  21. Attribute VB_Ext_KEY = "Member5" ,"CSynonymSets"
  22. Attribute VB_Ext_KEY = "Member6" ,"CTaxonomy"
  23. Option Explicit
  24. Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  25. Private p_clsHHT As HHT
  26. Private p_clsImporter As Importer
  27. Private p_clsKeywords As Keywords
  28. Private p_clsStopSigns As StopSigns
  29. Private p_clsStopWords As StopWords
  30. Private p_clsSynonymSets As SynonymSets
  31. Private p_clsTaxonomy As Taxonomy
  32. Private Sub Class_Initialize()
  33. Set g_cnn = New ADODB.Connection
  34. Set g_clsParameters = New Parameters
  35. g_strUserName = p_GetUserName
  36. SetLogFile
  37. End Sub
  38. Private Function p_GetUserName() As String
  39. Dim str As String
  40. Dim intIndex As Long
  41. str = Space$(100)
  42. GetUserName str, 100
  43. ' Get rid of the terminating NULL char.
  44. For intIndex = 1 To 100
  45. If (Asc(Mid$(str, intIndex, 1)) = 0) Then
  46. str = Left$(str, intIndex - 1)
  47. Exit For
  48. End If
  49. Next
  50. p_GetUserName = str
  51. End Function
  52. Private Sub Class_Terminate()
  53. Set g_cnn = Nothing
  54. Set p_clsHHT = Nothing
  55. Set p_clsImporter = Nothing
  56. Set p_clsKeywords = Nothing
  57. Set g_clsParameters = Nothing
  58. Set p_clsStopSigns = Nothing
  59. Set p_clsStopWords = Nothing
  60. Set p_clsSynonymSets = Nothing
  61. Set p_clsTaxonomy = Nothing
  62. End Sub
  63. Public Sub SetDatabase( _
  64. ByVal i_strDatabaseName As String _
  65. )
  66. If (g_cnn.State = adStateOpen) Then
  67. g_cnn.Close
  68. End If
  69. g_cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  70. "Data Source=" & i_strDatabaseName & ";"
  71. If (g_cnn.State <> adStateOpen) Then
  72. Err.Raise E_FAIL
  73. End If
  74. CheckDatabaseVersion
  75. g_clsParameters.ReadVerbalOperators
  76. End Sub
  77. Public Function CopyAndCompactDatabase( _
  78. ByVal i_strDatabaseName As String, _
  79. ByVal i_strDatabaseCopy As String, _
  80. Optional ByVal lcid As Long = 1033 _
  81. ) As Boolean
  82. On Error GoTo LErrorHandler
  83. Dim je As New JRO.JetEngine
  84. CopyAndCompactDatabase = False
  85. ' Make sure that a file with the same name doesn't exist
  86. If Dir(i_strDatabaseCopy) <> "" Then Kill i_strDatabaseCopy
  87. ' Save the database first
  88. Name i_strDatabaseName As i_strDatabaseCopy
  89. ' Create the database by compacting the saved copy
  90. je.CompactDatabase _
  91. "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  92. "Data Source=" & i_strDatabaseCopy & ";", _
  93. "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  94. "Data Source=" & i_strDatabaseName & ";" & _
  95. "Locale Identifier=" & lcid & ";"
  96. ' "Jet OLEDB:Encrypt Database=True;" &
  97. ' "Jet OLEDB:Database Password=password"
  98. CopyAndCompactDatabase = True
  99. Exit Function
  100. LErrorHandler:
  101. End Function
  102. Public Property Get HHT() As HHT
  103. If (p_clsHHT Is Nothing) Then
  104. Set p_clsHHT = New HHT
  105. End If
  106. Set HHT = p_clsHHT
  107. End Property
  108. Public Property Get Importer() As Importer
  109. If (p_clsImporter Is Nothing) Then
  110. Set p_clsImporter = New Importer
  111. End If
  112. Set Importer = p_clsImporter
  113. End Property
  114. Public Property Get Keywords() As Keywords
  115. If (p_clsKeywords Is Nothing) Then
  116. Set p_clsKeywords = New Keywords
  117. End If
  118. Set Keywords = p_clsKeywords
  119. End Property
  120. Public Property Get Parameters() As Parameters
  121. Set Parameters = g_clsParameters
  122. End Property
  123. Public Property Get StopSigns() As StopSigns
  124. If (p_clsStopSigns Is Nothing) Then
  125. Set p_clsStopSigns = New StopSigns
  126. End If
  127. Set StopSigns = p_clsStopSigns
  128. End Property
  129. Public Property Get StopWords() As StopWords
  130. If (p_clsStopWords Is Nothing) Then
  131. Set p_clsStopWords = New StopWords
  132. End If
  133. Set StopWords = p_clsStopWords
  134. End Property
  135. Public Property Get SynonymSets() As SynonymSets
  136. If (p_clsSynonymSets Is Nothing) Then
  137. Set p_clsSynonymSets = New SynonymSets
  138. End If
  139. Set SynonymSets = p_clsSynonymSets
  140. End Property
  141. Public Property Get Taxonomy() As Taxonomy
  142. If (p_clsTaxonomy Is Nothing) Then
  143. Set p_clsTaxonomy = New Taxonomy
  144. End If
  145. Set Taxonomy = p_clsTaxonomy
  146. End Property