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.

260 lines
6.3 KiB

  1. Attribute VB_Name = "DuplicateCode"
  2. Option Explicit
  3. Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  4. Public Sub PopulateCboWithSKUs( _
  5. ByVal i_cbo As ComboBox, _
  6. Optional ByVal blnListCollectiveSKUs As Boolean = False _
  7. )
  8. Dim intIndex As Long
  9. Dim SKUs() As SKU_E
  10. If (blnListCollectiveSKUs) Then
  11. ReDim SKUs(11)
  12. Else
  13. ReDim SKUs(8)
  14. End If
  15. SKUs(0) = SKU_STANDARD_E
  16. SKUs(1) = SKU_PROFESSIONAL_E
  17. SKUs(2) = SKU_PROFESSIONAL_64_E
  18. SKUs(3) = SKU_SERVER_E
  19. SKUs(4) = SKU_ADVANCED_SERVER_E
  20. SKUs(5) = SKU_DATA_CENTER_SERVER_E
  21. SKUs(6) = SKU_ADVANCED_SERVER_64_E
  22. SKUs(7) = SKU_DATA_CENTER_SERVER_64_E
  23. SKUs(8) = SKU_WINDOWS_MILLENNIUM_E
  24. If (blnListCollectiveSKUs) Then
  25. SKUs(9) = SKU_DESKTOP_ALL_E
  26. SKUs(10) = SKU_SERVER_ALL_E
  27. SKUs(11) = SKU_ALL_E
  28. End If
  29. For intIndex = LBound(SKUs) To UBound(SKUs)
  30. i_cbo.AddItem DisplayNameForSKU(SKUs(intIndex)), intIndex
  31. i_cbo.ItemData(intIndex) = SKUs(intIndex)
  32. Next
  33. i_cbo.ListIndex = 0
  34. End Sub
  35. Public Function GetParameter( _
  36. ByVal i_cnn As ADODB.Connection, _
  37. ByVal i_strName As String _
  38. ) As Variant
  39. Dim rs As ADODB.Recordset
  40. Dim strQuery As String
  41. Dim str As String
  42. str = Trim$(i_strName)
  43. GetParameter = Null
  44. Set rs = New ADODB.Recordset
  45. strQuery = "" & _
  46. "SELECT * " & _
  47. "FROM DBParameters " & _
  48. "WHERE (Name = '" & str & "');"
  49. rs.Open strQuery, i_cnn, adOpenForwardOnly, adLockReadOnly
  50. If (Not rs.EOF) Then
  51. GetParameter = rs("Value")
  52. End If
  53. End Function
  54. Public Sub SetParameter( _
  55. ByVal i_cnn As ADODB.Connection, _
  56. ByVal i_strName As String, _
  57. ByRef i_vntValue As Variant _
  58. )
  59. Dim rs As ADODB.Recordset
  60. Dim strQuery As String
  61. Dim str As String
  62. str = Trim$(i_strName)
  63. Set rs = New ADODB.Recordset
  64. strQuery = "" & _
  65. "SELECT * " & _
  66. "FROM DBParameters " & _
  67. "WHERE (Name = '" & str & "');"
  68. rs.Open strQuery, i_cnn, adOpenForwardOnly, adLockPessimistic
  69. If (rs.EOF) Then
  70. rs.AddNew
  71. rs("Name") = i_strName
  72. End If
  73. rs("Value") = i_vntValue
  74. rs.Update
  75. End Sub
  76. Public Function GetUserName1() As String
  77. Dim str As String
  78. Dim intIndex As Long
  79. str = Space$(100)
  80. GetUserName str, 100
  81. ' Get rid of the terminating NULL char.
  82. For intIndex = 1 To 100
  83. If (Asc(Mid$(str, intIndex, 1)) = 0) Then
  84. str = Left$(str, intIndex - 1)
  85. Exit For
  86. End If
  87. Next
  88. GetUserName1 = str
  89. End Function
  90. Public Sub FixOrderingNumbers( _
  91. ByVal i_cnn As ADODB.Connection _
  92. )
  93. Dim rs As ADODB.Recordset
  94. Dim strQuery As String
  95. Dim intParentTID As Long
  96. Dim intLastParentTID As Long
  97. Dim intOrderUnderParent As Long
  98. Set rs = New ADODB.Recordset
  99. strQuery = "" & _
  100. "SELECT * " & _
  101. "FROM Taxonomy " & _
  102. "ORDER BY ParentTID, OrderUnderParent"
  103. rs.Open strQuery, i_cnn, adOpenForwardOnly, adLockPessimistic
  104. intLastParentTID = INVALID_ID_C
  105. Do While (Not rs.EOF)
  106. intParentTID = rs("ParentTID")
  107. If (intParentTID <> intLastParentTID) Then
  108. intLastParentTID = intParentTID
  109. intOrderUnderParent = 0
  110. End If
  111. If (rs("TID") <> ROOT_TID_C) Then
  112. intOrderUnderParent = intOrderUnderParent + PREFERRED_ORDER_DELTA_C
  113. rs("OrderUnderParent") = intOrderUnderParent
  114. rs.Update
  115. End If
  116. rs.MoveNext
  117. Loop
  118. End Sub
  119. Public Function GetKeywords( _
  120. ByRef i_cnn As ADODB.Connection, _
  121. ByRef i_DOMNode As MSXML2.IXMLDOMNode, _
  122. ByRef u_dictKeywords As Scripting.Dictionary _
  123. ) As String
  124. Dim DOMNode As MSXML2.IXMLDOMNode
  125. Dim strKeyword As String
  126. If (Not i_DOMNode.firstChild Is Nothing) Then
  127. For Each DOMNode In i_DOMNode.childNodes
  128. strKeyword = DOMNode.Text
  129. If ((strKeyword <> "") And (DOMNode.baseName = HHT_KEYWORD_C)) Then
  130. GetKeywords = GetKeywords & GetKID(i_cnn, strKeyword, u_dictKeywords) & " "
  131. End If
  132. Next
  133. GetKeywords = FormatKeywordsForTaxonomy(GetKeywords)
  134. End If
  135. End Function
  136. Public Function GetKID( _
  137. ByRef i_cnn As ADODB.Connection, _
  138. ByRef i_strKeyword As String, _
  139. ByRef u_dictKeywords As Scripting.Dictionary _
  140. ) As String
  141. Dim intKID As Long
  142. If (u_dictKeywords.Exists(i_strKeyword)) Then
  143. GetKID = u_dictKeywords(i_strKeyword)
  144. Else
  145. intKID = p_CreateKeyword(i_cnn, i_strKeyword)
  146. If (intKID <> INVALID_ID_C) Then
  147. u_dictKeywords.Add i_strKeyword, intKID
  148. GetKID = intKID
  149. End If
  150. End If
  151. End Function
  152. Private Function p_CreateKeyword( _
  153. ByRef i_cnn As ADODB.Connection, _
  154. ByVal i_strKeyword As String _
  155. ) As Long
  156. Dim rs As ADODB.Recordset
  157. Dim strQuery As String
  158. ' Does an active Keyword exist with this name?
  159. Set rs = New ADODB.Recordset
  160. p_GetKeyword i_cnn, i_strKeyword, rs
  161. If (Not rs.EOF) Then
  162. p_CreateKeyword = rs("KID")
  163. Exit Function
  164. End If
  165. rs.Close
  166. ' Create a new record in the database
  167. strQuery = "" & _
  168. "SELECT * " & _
  169. "FROM Keywords "
  170. rs.Open strQuery, i_cnn, adOpenStatic, adLockPessimistic
  171. If (rs.RecordCount > 0) Then
  172. rs.MoveLast
  173. End If
  174. rs.AddNew
  175. rs("Keyword") = i_strKeyword
  176. rs.Update
  177. p_CreateKeyword = rs("KID")
  178. End Function
  179. Private Sub p_GetKeyword( _
  180. ByRef i_cnn As ADODB.Connection, _
  181. ByVal i_strKeyword As String, _
  182. ByVal o_rs As ADODB.Recordset _
  183. )
  184. Dim strQuery As String
  185. strQuery = "" & _
  186. "SELECT * " & _
  187. "FROM Keywords " & _
  188. "WHERE (Keyword = """ & i_strKeyword & """ )"
  189. o_rs.Open strQuery, i_cnn, adOpenForwardOnly, adLockReadOnly
  190. End Sub