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.

135 lines
3.6 KiB

  1. Attribute VB_Name = "Globals"
  2. Option Explicit
  3. Public g_cnn As ADODB.Connection
  4. Public g_clsParameters As Parameters
  5. Public g_strUserName As String
  6. Public Enum LOCK_TABLE_E
  7. LOCK_TABLE_KEYWORDS = 1
  8. LOCK_TABLE_STOP_SIGNS = 2
  9. LOCK_TABLE_STOP_WORDS = 3
  10. LOCK_TABLE_SYNONYMS = 4
  11. LOCK_TABLE_SYNONYM_SETS = 5
  12. LOCK_TABLE_TAXONOMY = 6
  13. LOCK_TABLE_TYPES = 7
  14. End Enum
  15. Public Sub CheckDatabaseVersion( _
  16. )
  17. Dim strVersion1 As String
  18. Dim strVersion2 As String
  19. strVersion1 = g_clsParameters.Value(DB_VERSION_C) & ""
  20. strVersion2 = App.Major & "." & App.Minor
  21. If (strVersion1 <> strVersion2) Then
  22. Err.Raise errDatabaseVersionIncompatible
  23. End If
  24. End Sub
  25. Public Sub CheckAuthoringGroupAccess( _
  26. )
  27. Dim intAG As Long
  28. intAG = g_clsParameters.AuthoringGroup
  29. If (intAG > AG_CORE_MAX_C) Then
  30. Err.Raise errNotPermittedForAuthoringGroup
  31. End If
  32. End Sub
  33. Public Sub CheckForSameAuthoringGroup( _
  34. ByVal i_intAG As Long, _
  35. Optional ByVal i_intAuthoringGroup As Long = INVALID_ID_C _
  36. )
  37. Dim intAG As Long
  38. If (i_intAuthoringGroup = INVALID_ID_C) Then
  39. intAG = g_clsParameters.AuthoringGroup
  40. Else
  41. intAG = i_intAuthoringGroup
  42. End If
  43. If (intAG <> i_intAG) Then
  44. Err.Raise errAuthoringGroupDiffers
  45. End If
  46. End Sub
  47. Private Function p_NewerDatabase( _
  48. ByVal i_strVersion As String _
  49. ) As Boolean
  50. Dim arrVersion() As String
  51. arrVersion = Split(i_strVersion, ".")
  52. If (arrVersion(0) < App.Major) Then
  53. p_NewerDatabase = False
  54. ElseIf (arrVersion(0) > App.Major) Then
  55. p_NewerDatabase = True
  56. ElseIf (arrVersion(1) < App.Minor) Then
  57. p_NewerDatabase = False
  58. ElseIf (arrVersion(1) > App.Minor) Then
  59. p_NewerDatabase = True
  60. Else
  61. p_NewerDatabase = False
  62. End If
  63. End Function
  64. ' If you wish to modify the Taxonomy table, call LockTable(LOCK_TABLE_TAXONOMY, rs)
  65. ' at the beginning of the function. If this convention is always followed, then
  66. ' functions that just read the Taxonomy table will succeed. But those that modify
  67. ' the Taxonomy table (and hence call LockTable) will throw an exception (E_FAIL).
  68. ' When rs goes out of scope in the calling function, the lock is released. If the
  69. ' process is killed, then also the lock is released.
  70. ' It may be sufficient to call this function in only the Public functions of a
  71. ' module. However, then we have to worry about whether the Public function or any
  72. ' of its descendents will ever modify the database.
  73. ' Be very careful with functions like Keywords.Delete, which modify 2 tables:
  74. ' Keywords and Synonyms.
  75. ' Do a findstr LockTable * in the Authdatabase directory to make sure that you don't
  76. ' call LockTable(A) and LockTable(B), when both should have locked table A.
  77. Public Sub LockTable( _
  78. ByVal i_enumTable As LOCK_TABLE_E, _
  79. ByRef o_rs As ADODB.Recordset _
  80. )
  81. Dim strQuery As String
  82. Dim strTable As String
  83. Set o_rs = New ADODB.Recordset
  84. Select Case i_enumTable
  85. Case LOCK_TABLE_KEYWORDS
  86. strTable = LOCK_KEYWORDS_C
  87. Case LOCK_TABLE_STOP_SIGNS
  88. strTable = LOCK_STOP_SIGNS_C
  89. Case LOCK_TABLE_STOP_WORDS
  90. strTable = LOCK_STOP_WORDS_C
  91. Case LOCK_TABLE_SYNONYMS
  92. strTable = LOCK_SYNONYMS_C
  93. Case LOCK_TABLE_SYNONYM_SETS
  94. strTable = LOCK_SYNONYM_SETS_C
  95. Case LOCK_TABLE_TAXONOMY
  96. strTable = LOCK_TAXONOMY_C
  97. Case LOCK_TYPES_C
  98. strTable = LOCK_TYPES_C
  99. End Select
  100. strQuery = "SELECT * FROM DBParameters WHERE (Name = """ & strTable & """)"
  101. o_rs.Open strQuery, g_cnn, adOpenStatic, adLockPessimistic
  102. o_rs("Value") = True
  103. End Sub