Source code of Windows XP (NT5)
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.

200 lines
4.7 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. Dim intIndex As Long
  34. Set g_cnn = New ADODB.Connection
  35. Set g_clsParameters = New Parameters
  36. g_strUserName = Space$(100)
  37. GetUserName g_strUserName, 100
  38. ' Get rid of the terminating NULL char.
  39. For intIndex = 1 To 100
  40. If (Asc(Mid$(g_strUserName, intIndex, 1)) = 0) Then
  41. g_strUserName = Left$(g_strUserName, intIndex - 1)
  42. Exit For
  43. End If
  44. Next
  45. SetLogFile
  46. End Sub
  47. Private Sub Class_Terminate()
  48. Set g_cnn = Nothing
  49. Set p_clsHHT = Nothing
  50. Set p_clsImporter = Nothing
  51. Set p_clsKeywords = Nothing
  52. Set g_clsParameters = Nothing
  53. Set p_clsStopSigns = Nothing
  54. Set p_clsStopWords = Nothing
  55. Set p_clsSynonymSets = Nothing
  56. Set p_clsTaxonomy = Nothing
  57. End Sub
  58. Public Sub SetDatabase( _
  59. ByVal i_strDatabaseName As String _
  60. )
  61. If (g_cnn.State = adStateOpen) Then
  62. g_cnn.Close
  63. End If
  64. g_cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  65. "Data Source=" & i_strDatabaseName & ";"
  66. If (g_cnn.State <> adStateOpen) Then
  67. Err.Raise E_FAIL
  68. End If
  69. CheckDatabaseVersion
  70. End Sub
  71. Public Function CopyAndCompactDatabase( _
  72. ByVal i_strDatabaseName As String, _
  73. ByVal i_strDatabaseCopy As String, _
  74. Optional ByVal lcid As Long = 1033 _
  75. ) As Boolean
  76. On Error GoTo LErrorHandler
  77. Dim je As New JRO.JetEngine
  78. CopyAndCompactDatabase = False
  79. ' Make sure that a file with the same name doesn't exist
  80. If Dir(i_strDatabaseCopy) <> "" Then Kill i_strDatabaseCopy
  81. ' Save the database first
  82. Name i_strDatabaseName As i_strDatabaseCopy
  83. ' Create the database by compacting the saved copy
  84. je.CompactDatabase _
  85. "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  86. "Data Source=" & i_strDatabaseCopy & ";", _
  87. "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  88. "Data Source=" & i_strDatabaseName & ";" & _
  89. "Locale Identifier=" & lcid & ";"
  90. ' "Jet OLEDB:Encrypt Database=True;" &
  91. ' "Jet OLEDB:Database Password=password"
  92. CopyAndCompactDatabase = True
  93. Exit Function
  94. LErrorHandler:
  95. End Function
  96. Public Property Get HHT() As HHT
  97. If (p_clsHHT Is Nothing) Then
  98. Set p_clsHHT = New HHT
  99. End If
  100. Set HHT = p_clsHHT
  101. End Property
  102. Public Property Get Importer() As Importer
  103. If (p_clsImporter Is Nothing) Then
  104. Set p_clsImporter = New Importer
  105. End If
  106. Set Importer = p_clsImporter
  107. End Property
  108. Public Property Get Keywords() As Keywords
  109. If (p_clsKeywords Is Nothing) Then
  110. Set p_clsKeywords = New Keywords
  111. End If
  112. Set Keywords = p_clsKeywords
  113. End Property
  114. Public Property Get Parameters() As Parameters
  115. Set Parameters = g_clsParameters
  116. End Property
  117. Public Property Get StopSigns() As StopSigns
  118. If (p_clsStopSigns Is Nothing) Then
  119. Set p_clsStopSigns = New StopSigns
  120. End If
  121. Set StopSigns = p_clsStopSigns
  122. End Property
  123. Public Property Get StopWords() As StopWords
  124. If (p_clsStopWords Is Nothing) Then
  125. Set p_clsStopWords = New StopWords
  126. End If
  127. Set StopWords = p_clsStopWords
  128. End Property
  129. Public Property Get SynonymSets() As SynonymSets
  130. If (p_clsSynonymSets Is Nothing) Then
  131. Set p_clsSynonymSets = New SynonymSets
  132. End If
  133. Set SynonymSets = p_clsSynonymSets
  134. End Property
  135. Public Property Get Taxonomy() As Taxonomy
  136. If (p_clsTaxonomy Is Nothing) Then
  137. Set p_clsTaxonomy = New Taxonomy
  138. End If
  139. Set Taxonomy = p_clsTaxonomy
  140. End Property