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.

238 lines
5.2 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 = "StopWords"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = False
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = True
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
  15. Attribute VB_Ext_KEY = "Top_Level" ,"No"
  16. Option Explicit
  17. Public Sub GetAllStopWordsRs( _
  18. ByVal o_rs As ADODB.Recordset _
  19. )
  20. Dim strQuery As String
  21. CheckDatabaseVersion
  22. CloseRecordSet o_rs
  23. strQuery = "" & _
  24. "SELECT * " & _
  25. "FROM StopWords " & _
  26. "ORDER BY StopWord"
  27. o_rs.Open strQuery, g_cnn, adOpenStatic, adLockReadOnly
  28. End Sub
  29. Public Sub GetAllStopWordsDict( _
  30. ByVal o_dictStopWords As Scripting.Dictionary _
  31. )
  32. Dim rs As ADODB.Recordset
  33. Dim strQuery As String
  34. CheckDatabaseVersion
  35. Set rs = New ADODB.Recordset
  36. strQuery = "" & _
  37. "SELECT * " & _
  38. "FROM StopWords"
  39. rs.Open strQuery, g_cnn, adOpenForwardOnly, adLockReadOnly
  40. Do While (Not rs.EOF)
  41. o_dictStopWords.Add rs("SWID").Value, rs("StopWord").Value
  42. DoEvents
  43. rs.MoveNext
  44. Loop
  45. End Sub
  46. Public Function ContainsStopWord( _
  47. ByVal i_str As String _
  48. ) As Boolean
  49. Dim rs As ADODB.Recordset
  50. Dim arrStr() As String
  51. Dim strStopWord As String
  52. Dim strWord As String
  53. Dim intIndex As Long
  54. CheckDatabaseVersion
  55. ContainsStopWord = False
  56. Set rs = New ADODB.Recordset
  57. GetAllStopWordsRs rs
  58. If (rs.EOF) Then
  59. Exit Function
  60. End If
  61. arrStr = Split(i_str)
  62. Do While (Not rs.EOF)
  63. strStopWord = rs("StopWord")
  64. For intIndex = LBound(arrStr) To UBound(arrStr)
  65. strWord = LCase$(arrStr(intIndex))
  66. If (strWord = strStopWord) Then
  67. ContainsStopWord = True
  68. Exit Function
  69. End If
  70. Next
  71. rs.MoveNext
  72. Loop
  73. End Function
  74. Public Sub Create( _
  75. ByVal i_strStopWord As String _
  76. )
  77. Dim rsLock As ADODB.Recordset
  78. Dim rs As ADODB.Recordset
  79. Dim strQuery As String
  80. CheckDatabaseVersion
  81. LockTable LOCK_TABLE_STOP_WORDS, rsLock
  82. CheckAuthoringGroupAccess
  83. ' Do some validation to see if the StopWord is acceptable.
  84. p_ValidateStopWord i_strStopWord
  85. ' Does an active StopWord exist with this name?
  86. Set rs = New ADODB.Recordset
  87. p_GetStopWord i_strStopWord, rs
  88. If (Not rs.EOF) Then
  89. Err.Raise errAlreadyExists
  90. Exit Sub
  91. End If
  92. rs.Close
  93. ' Create a new record in the database
  94. strQuery = "" & _
  95. "SELECT * " & _
  96. "FROM StopWords "
  97. rs.Open strQuery, g_cnn, adOpenStatic, adLockPessimistic
  98. If (Not rs.EOF) Then
  99. rs.MoveLast
  100. End If
  101. rs.AddNew
  102. rs("StopWord") = i_strStopWord
  103. rs.Update
  104. End Sub
  105. Public Sub Delete( _
  106. ByVal i_intSWID As Long, _
  107. ByVal i_intUID As Long, _
  108. ByVal i_strComments As String _
  109. )
  110. Dim rsLock As ADODB.Recordset
  111. Dim rs As ADODB.Recordset
  112. Dim strQuery As String
  113. Dim strStopWord As String
  114. CheckDatabaseVersion
  115. LockTable LOCK_TABLE_STOP_WORDS, rsLock
  116. CheckAuthoringGroupAccess
  117. Set rs = New ADODB.Recordset
  118. strQuery = "" & _
  119. "DELETE * " & _
  120. "FROM StopWords " & _
  121. "WHERE (SWID = " & i_intSWID & ")"
  122. rs.Open strQuery, g_cnn, adOpenStatic, adLockPessimistic
  123. End Sub
  124. Private Sub p_GetStopWord( _
  125. ByVal i_strStopWord As String, _
  126. ByVal o_rs As ADODB.Recordset _
  127. )
  128. Dim strQuery As String
  129. CloseRecordSet o_rs
  130. strQuery = "" & _
  131. "SELECT * " & _
  132. "FROM StopWords " & _
  133. "WHERE (StopWord = """ & i_strStopWord & """)"
  134. o_rs.Open strQuery, g_cnn, adOpenForwardOnly, adLockReadOnly
  135. End Sub
  136. Private Function p_ContainsStopSign( _
  137. ByVal i_strStopWord As String _
  138. ) As Boolean
  139. Dim clsStopSigns As StopSigns
  140. Set clsStopSigns = New StopSigns
  141. p_ContainsStopSign = clsStopSigns.ContainsStopSign(i_strStopWord)
  142. End Function
  143. Private Function p_MultiWord( _
  144. ByVal i_strStopWord As String _
  145. ) As Boolean
  146. Dim arr() As String
  147. arr = Split(i_strStopWord)
  148. p_MultiWord = UBound(arr) > 0
  149. End Function
  150. Private Sub p_ValidateStopWord( _
  151. ByVal i_strStopWord As String _
  152. )
  153. If (ContainsGarbage(i_strStopWord)) Then
  154. Err.Raise errContainsGarbageChar
  155. ElseIf (p_MultiWord(i_strStopWord)) Then
  156. Err.Raise errMultiWord
  157. ElseIf (p_ContainsStopSign(i_strStopWord)) Then
  158. Err.Raise errContainsStopSign
  159. ElseIf (ContainsOperatorShortcut(i_strStopWord)) Then
  160. Err.Raise errContainsOperatorShortcut
  161. ElseIf (ContainsVerbalOperator(i_strStopWord)) Then
  162. Err.Raise errContainsVerbalOperator
  163. End If
  164. End Sub