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.

169 lines
4.8 KiB

  1. Attribute VB_Name = "Main"
  2. Option Explicit
  3. Private Const DB_VERSION_C As String = "DBVersion"
  4. Private Const OPERATORS_AND_C As String = "OperatorsAnd"
  5. Private Const OPERATORS_OR_C As String = "OperatorsOr"
  6. Private Const OPERATORS_NOT_C As String = "OperatorsNot"
  7. Private Const AUTHORING_GROUP_C As String = "AuthoringGroup"
  8. Private Const LOCK_KEYWORDS_C As String = "LockKeywords"
  9. Private Const LOCK_STOP_SIGNS_C As String = "LockStopSigns"
  10. Private Const LOCK_STOP_WORDS_C As String = "LockStopWords"
  11. Private Const LOCK_SYNONYMS_C As String = "LockSynonyms"
  12. Private Const LOCK_SYNONYM_SETS_C As String = "LockSynonymSets"
  13. Private Const LOCK_TAXONOMY_C As String = "LockTaxonomy"
  14. Private Const LOCK_TYPES_C As String = "LockTypes"
  15. Private Const MINIMUM_KEYWORD_VALIDATION_C As String = "MinimumKeywordValidation"
  16. Private Const AUTHORING_GROUP_VALUE_C As Long = 10001
  17. Private p_cnn As ADODB.Connection
  18. Public Sub MainFunction( _
  19. ByVal i_strDatabaseIn As String, _
  20. ByVal i_strDatabaseOut As String _
  21. )
  22. On Error GoTo LError
  23. Dim FSO As Scripting.FileSystemObject
  24. Dim rs As ADODB.Recordset
  25. Dim strQuery As String
  26. Dim strVersion As String
  27. Dim strAnd As String
  28. Dim strOr As String
  29. Dim strNot As String
  30. Set FSO = New Scripting.FileSystemObject
  31. If (Not FSO.FileExists(i_strDatabaseIn)) Then
  32. Err.Raise E_FAIL, , "File " & i_strDatabaseIn & " does not exist"
  33. End If
  34. FSO.CopyFile i_strDatabaseIn, i_strDatabaseOut
  35. Set p_cnn = New ADODB.Connection
  36. p_cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & i_strDatabaseOut & ";"
  37. Set rs = New ADODB.Recordset
  38. strQuery = "UPDATE Taxonomy SET Username = ""Microsoft"", Comments = """""
  39. rs.Open strQuery, p_cnn, adOpenStatic, adLockPessimistic
  40. strVersion = p_GetParameter(DB_VERSION_C)
  41. strAnd = p_GetParameter(OPERATORS_AND_C)
  42. strOr = p_GetParameter(OPERATORS_OR_C)
  43. strNot = p_GetParameter(OPERATORS_NOT_C)
  44. strQuery = "DELETE * FROM DBParameters"
  45. rs.Open strQuery, p_cnn, adOpenStatic, adLockPessimistic
  46. p_SetParameter AUTHORING_GROUP_C, AUTHORING_GROUP_VALUE_C
  47. p_SetParameter DB_VERSION_C, strVersion
  48. p_SetParameter OPERATORS_AND_C, strAnd
  49. p_SetParameter OPERATORS_OR_C, strOr
  50. p_SetParameter OPERATORS_NOT_C, strNot
  51. p_SetParameter LOCK_KEYWORDS_C, "False"
  52. p_SetParameter LOCK_STOP_SIGNS_C, "False"
  53. p_SetParameter LOCK_STOP_WORDS_C, "False"
  54. p_SetParameter LOCK_SYNONYMS_C, "False"
  55. p_SetParameter LOCK_SYNONYM_SETS_C, "False"
  56. p_SetParameter LOCK_TAXONOMY_C, "False"
  57. p_SetParameter LOCK_TYPES_C, "False"
  58. p_SetParameter MINIMUM_KEYWORD_VALIDATION_C, "False"
  59. p_cnn.Close
  60. p_CompactDatabase i_strDatabaseOut
  61. LEnd:
  62. Exit Sub
  63. LError:
  64. frmMain.Output Err.Description, LOGGING_TYPE_ERROR_E
  65. Err.Raise Err.Number
  66. End Sub
  67. Public Function p_GetParameter( _
  68. ByVal i_strName As String _
  69. ) As Variant
  70. Dim rs As ADODB.Recordset
  71. Dim strQuery As String
  72. Dim str As String
  73. str = Trim$(i_strName)
  74. p_GetParameter = Null
  75. Set rs = New ADODB.Recordset
  76. strQuery = "" & _
  77. "SELECT * " & _
  78. "FROM DBParameters " & _
  79. "WHERE (Name = '" & str & "');"
  80. rs.Open strQuery, p_cnn, adOpenForwardOnly, adLockReadOnly
  81. If (Not rs.EOF) Then
  82. p_GetParameter = rs("Value")
  83. End If
  84. End Function
  85. Private Sub p_SetParameter( _
  86. ByVal i_strName As String, _
  87. ByRef i_vntValue As Variant _
  88. )
  89. Dim rs As ADODB.Recordset
  90. Dim strQuery As String
  91. Dim str As String
  92. str = Trim$(i_strName)
  93. Set rs = New ADODB.Recordset
  94. strQuery = "" & _
  95. "SELECT * " & _
  96. "FROM DBParameters " & _
  97. "WHERE (Name = '" & str & "');"
  98. rs.Open strQuery, p_cnn, adOpenForwardOnly, adLockPessimistic
  99. If (rs.EOF) Then
  100. rs.AddNew
  101. rs("Name") = i_strName
  102. End If
  103. rs("Value") = i_vntValue
  104. rs.Update
  105. End Sub
  106. Public Sub p_CompactDatabase( _
  107. ByVal i_strDatabase As String, _
  108. Optional ByVal lcid As Long = 1033 _
  109. )
  110. Dim je As New JRO.JetEngine
  111. Dim FSO As Scripting.FileSystemObject
  112. Dim strTempFile As String
  113. Set FSO = New Scripting.FileSystemObject
  114. strTempFile = Environ$("TEMP") & "\" & FSO.GetTempName
  115. je.CompactDatabase _
  116. "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  117. "Data Source=" & i_strDatabase & ";", _
  118. "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  119. "Data Source=" & strTempFile & ";" & _
  120. "Locale Identifier=" & lcid & ";"
  121. FSO.DeleteFile i_strDatabase
  122. FSO.MoveFile strTempFile, i_strDatabase
  123. End Sub