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.

411 lines
11 KiB

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmMain
  4. Caption = "HHTs To MDB"
  5. ClientHeight = 5685
  6. ClientLeft = 60
  7. ClientTop = 345
  8. ClientWidth = 7095
  9. LinkTopic = "Form1"
  10. ScaleHeight = 5685
  11. ScaleWidth = 7095
  12. StartUpPosition = 3 'Windows Default
  13. Begin VB.CheckBox chkNoTaxonomy
  14. Caption = "&Ignore Taxonomy"
  15. Height = 255
  16. Left = 120
  17. TabIndex = 11
  18. Top = 1320
  19. Width = 1575
  20. End
  21. Begin VB.ComboBox cboSKU
  22. Height = 315
  23. Left = 1080
  24. Style = 2 'Dropdown List
  25. TabIndex = 10
  26. Top = 840
  27. Width = 5535
  28. End
  29. Begin VB.TextBox txtOutput
  30. Height = 3765
  31. Left = 120
  32. Locked = -1 'True
  33. MultiLine = -1 'True
  34. ScrollBars = 3 'Both
  35. TabIndex = 8
  36. Top = 1800
  37. Width = 6855
  38. End
  39. Begin VB.CommandButton cmdClose
  40. Caption = "Close"
  41. Height = 375
  42. Left = 6120
  43. TabIndex = 7
  44. Top = 1320
  45. Width = 855
  46. End
  47. Begin VB.CommandButton cmdGo
  48. Caption = "Go"
  49. Height = 375
  50. Left = 5040
  51. TabIndex = 6
  52. Top = 1320
  53. Width = 975
  54. End
  55. Begin VB.CommandButton cmdMDB
  56. Caption = "..."
  57. Height = 255
  58. Left = 6720
  59. TabIndex = 5
  60. Top = 480
  61. Width = 255
  62. End
  63. Begin MSComDlg.CommonDialog dlgCommon
  64. Left = 4440
  65. Top = 1200
  66. _ExtentX = 847
  67. _ExtentY = 847
  68. _Version = 393216
  69. End
  70. Begin VB.TextBox txtMDB
  71. Height = 285
  72. Left = 1080
  73. TabIndex = 4
  74. Top = 480
  75. Width = 5535
  76. End
  77. Begin VB.CommandButton cmdFolder
  78. Caption = "..."
  79. Height = 255
  80. Left = 6720
  81. TabIndex = 2
  82. Top = 120
  83. Width = 255
  84. End
  85. Begin VB.TextBox txtFolder
  86. Height = 285
  87. Left = 1080
  88. TabIndex = 1
  89. Top = 120
  90. Width = 5535
  91. End
  92. Begin VB.Label lblSKU
  93. Caption = "&SKU"
  94. Height = 255
  95. Left = 120
  96. TabIndex = 9
  97. Top = 840
  98. Width = 855
  99. End
  100. Begin VB.Label lblMDB
  101. Caption = "&MDB file"
  102. Height = 255
  103. Left = 120
  104. TabIndex = 3
  105. Top = 480
  106. Width = 855
  107. End
  108. Begin VB.Label lblFolder
  109. Caption = "HH&Ts folder"
  110. Height = 255
  111. Left = 120
  112. TabIndex = 0
  113. Top = 120
  114. Width = 855
  115. End
  116. End
  117. Attribute VB_Name = "frmMain"
  118. Attribute VB_GlobalNameSpace = False
  119. Attribute VB_Creatable = False
  120. Attribute VB_PredeclaredId = True
  121. Attribute VB_Exposed = False
  122. Option Explicit
  123. ' Make sure that these letters correspond to the Alt key combinations.
  124. Private Const OPT_HHT_FOLDER_C As String = "t"
  125. Private Const OPT_MDB_FILE_C As String = "m"
  126. Private Const OPT_SKU_C As String = "s"
  127. Private Const OPT_IGNORE_TAXONOMY_C As String = "i"
  128. Private Const OPT_CLOSE_ON_WARNING_C As String = "qw"
  129. Private Const OPT_CLOSE_ALWAYS_C As String = "qa"
  130. Private Const OPT_HELP_C As String = "h,?,help"
  131. Private p_strSeparator As String
  132. Private p_blnWarning As Boolean
  133. Private p_blnError As Boolean
  134. Private p_clsSizer As Sizer
  135. Private WithEvents p_frmFolderChooser As frmFolderChooser
  136. Attribute p_frmFolderChooser.VB_VarHelpID = -1
  137. Private Sub p_DisplayHelp()
  138. Dim str As String
  139. str = "Usage: " & vbCrLf & vbCrLf & _
  140. App.EXEName & " /t <HHTs folder> /m <MDB file> /s <SKU> /i /qw /qa" & vbCrLf & vbCrLf & _
  141. "The /i, /qw, and /qa arguments are optional." & vbCrLf & _
  142. "/qw makes the window go away even if there are Warnings." & vbCrLf & _
  143. "/qa makes the window go away even if there are Errors and/or Warnings." & vbCrLf & _
  144. """" & App.EXEName & " /?"" displays this message."
  145. Output str, LOGGING_TYPE_NORMAL_E
  146. Output p_strSeparator, LOGGING_TYPE_NORMAL_E
  147. End Sub
  148. Private Sub Form_Load()
  149. cmdGo.Default = True
  150. cmdClose.Cancel = True
  151. PopulateCboWithSKUs cboSKU
  152. Set p_clsSizer = New Sizer
  153. Set p_frmFolderChooser = New frmFolderChooser
  154. SetLogFile
  155. Output "Version " & App.Major & "." & App.Minor & "." & App.Revision, LOGGING_TYPE_NORMAL_E
  156. Output "Currently, this tool has the following limitations: ", LOGGING_TYPE_NORMAL_E
  157. Output "1) It can only handle ADDs in the HHTs. It cannot handle DELs.", LOGGING_TYPE_NORMAL_E
  158. Output "2) It cannot handle the Attribute INSERTMODE.", LOGGING_TYPE_NORMAL_E
  159. Output "3) It assumes that there are no synonym sets currently in the database.", LOGGING_TYPE_NORMAL_E
  160. p_strSeparator = String(80, "-")
  161. Output p_strSeparator, LOGGING_TYPE_NORMAL_E
  162. p_ProcessCommandLine
  163. End Sub
  164. Private Sub p_ProcessCommandLine()
  165. Dim strCommand As String
  166. Dim strSKU As String
  167. Dim intIndex As Long
  168. Dim blnCloseOnWarning As Boolean
  169. Dim blnCloseAlways As Boolean
  170. Dim blnClose As Boolean
  171. strCommand = Trim$(Command$)
  172. If (strCommand = "") Then
  173. Exit Sub
  174. End If
  175. txtFolder = GetOption(strCommand, OPT_HHT_FOLDER_C, True)
  176. txtMDB = GetOption(strCommand, OPT_MDB_FILE_C, True)
  177. strSKU = GetOption(strCommand, OPT_SKU_C, True)
  178. cboSKU.ListIndex = -1
  179. If (IsNumeric(strSKU)) Then
  180. For intIndex = 0 To cboSKU.ListCount - 1
  181. If (cboSKU.ItemData(intIndex) = strSKU) Then
  182. cboSKU.ListIndex = intIndex
  183. Exit For
  184. End If
  185. Next
  186. End If
  187. If (OptionExists(strCommand, OPT_IGNORE_TAXONOMY_C, True)) Then
  188. chkNoTaxonomy.Value = vbChecked
  189. End If
  190. blnCloseOnWarning = OptionExists(strCommand, OPT_CLOSE_ON_WARNING_C, True)
  191. blnCloseAlways = OptionExists(strCommand, OPT_CLOSE_ALWAYS_C, True)
  192. If (OptionExists(strCommand, OPT_HELP_C, True)) Then
  193. p_DisplayHelp
  194. ElseIf (Len(strCommand) <> 0) Then
  195. cmdGo_Click
  196. If (p_blnError) Then
  197. ' If an error occurred, then close the window only if OPT_CLOSE_ALWAYS_C is specified.
  198. If (blnCloseAlways) Then
  199. blnClose = True
  200. End If
  201. ElseIf (p_blnWarning) Then
  202. ' If a warning occurred, but there was no error, then close the window only if
  203. ' OPT_CLOSE_ON_WARNING_C or OPT_CLOSE_ALWAYS_C is specified.
  204. If (blnCloseOnWarning Or blnCloseAlways) Then
  205. blnClose = True
  206. End If
  207. Else
  208. ' If there was no warning or error, then close the window.
  209. blnClose = True
  210. End If
  211. If (blnClose) Then
  212. cmdClose_Click
  213. End If
  214. End If
  215. End Sub
  216. Private Sub cmdGo_Click()
  217. On Error GoTo LError
  218. Dim strHHTsFolder As String
  219. Dim strMDBFile As String
  220. Dim blnIgnoreTaxonomy As Boolean
  221. Output "Start: " & Date & " " & Time, LOGGING_TYPE_NORMAL_E
  222. strHHTsFolder = Trim$(txtFolder.Text)
  223. strMDBFile = Trim$(txtMDB.Text)
  224. If (chkNoTaxonomy.Value = vbChecked) Then
  225. blnIgnoreTaxonomy = True
  226. End If
  227. If ((strHHTsFolder = "") Or (strMDBFile = "")) Then
  228. Output "Please specify the HHTs folder and MDB file", LOGGING_TYPE_ERROR_E
  229. GoTo LError
  230. End If
  231. If ((Not blnIgnoreTaxonomy) And (cboSKU.ListIndex = -1)) Then
  232. Output "Please specify the SKU", LOGGING_TYPE_ERROR_E
  233. GoTo LError
  234. End If
  235. Me.Enabled = False
  236. ImportHHTs2MDB strHHTsFolder, strMDBFile, cboSKU.ItemData(cboSKU.ListIndex), blnIgnoreTaxonomy
  237. LEnd:
  238. Output "End: " & Date & " " & Time, LOGGING_TYPE_NORMAL_E
  239. Output "The log file is: " & GetLogFileName, LOGGING_TYPE_NORMAL_E
  240. Output p_strSeparator, LOGGING_TYPE_NORMAL_E
  241. Me.Enabled = True
  242. Exit Sub
  243. LError:
  244. GoTo LEnd
  245. End Sub
  246. Private Sub cmdClose_Click()
  247. Unload Me
  248. End Sub
  249. Private Sub cmdFolder_Click()
  250. Load p_frmFolderChooser
  251. p_frmFolderChooser.SetFolder 0, txtFolder.Text
  252. p_frmFolderChooser.Show vbModal
  253. End Sub
  254. Private Sub cmdMDB_Click()
  255. On Error GoTo LError
  256. dlgCommon.CancelError = True
  257. dlgCommon.Flags = cdlOFNHideReadOnly
  258. dlgCommon.Filter = "Microsoft Access Files (*.mdb)|*.mdb"
  259. dlgCommon.ShowOpen
  260. txtMDB.Text = dlgCommon.FileName
  261. LEnd:
  262. Exit Sub
  263. LError:
  264. Select Case Err.Number
  265. Case cdlCancel
  266. ' Nothing. The user cancelled.
  267. End Select
  268. GoTo LEnd
  269. End Sub
  270. Private Sub p_frmFolderChooser_FolderChosen( _
  271. ByVal i_intIndex As Long, _
  272. ByVal strFolder As String _
  273. )
  274. txtFolder.Text = strFolder
  275. End Sub
  276. Private Sub Form_Activate()
  277. On Error GoTo LError
  278. p_SetSizingInfo
  279. DoEvents
  280. LError:
  281. End Sub
  282. Private Sub Form_Resize()
  283. On Error GoTo LError
  284. p_clsSizer.Resize
  285. LError:
  286. End Sub
  287. Private Sub p_SetSizingInfo()
  288. p_clsSizer.AddControl txtFolder
  289. Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
  290. p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
  291. p_clsSizer.AddControl cmdFolder
  292. Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
  293. p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
  294. p_clsSizer.AddControl txtMDB
  295. Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
  296. p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
  297. p_clsSizer.AddControl cmdMDB
  298. Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
  299. p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
  300. p_clsSizer.AddControl cboSKU
  301. Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
  302. p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
  303. p_clsSizer.AddControl cmdGo
  304. Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
  305. p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
  306. p_clsSizer.AddControl cmdClose
  307. Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
  308. p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
  309. p_clsSizer.AddControl txtOutput
  310. Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
  311. p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
  312. Set p_clsSizer.ReferenceControl(DIM_BOTTOM_E) = Me
  313. p_clsSizer.ReferenceDimension(DIM_BOTTOM_E) = DIM_HEIGHT_E
  314. End Sub
  315. Public Sub Output( _
  316. ByVal i_str As String, _
  317. ByVal i_enumLoggingType As LOGGING_TYPE_E _
  318. )
  319. OutputToTextBoxAndWriteLog txtOutput, i_str, i_enumLoggingType
  320. If (i_enumLoggingType = LOGGING_TYPE_ERROR_E) Then
  321. p_blnError = True
  322. ElseIf (i_enumLoggingType = LOGGING_TYPE_WARNING_E) Then
  323. p_blnWarning = True
  324. End If
  325. End Sub