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.

443 lines
13 KiB

  1. VERSION 5.00
  2. Begin VB.Form frmLiveImageTracker
  3. Caption = "Live Image Tracking Utility"
  4. ClientHeight = 5115
  5. ClientLeft = 3375
  6. ClientTop = 2910
  7. ClientWidth = 6930
  8. LinkTopic = "Form1"
  9. ScaleHeight = 5115
  10. ScaleWidth = 6930
  11. Begin VB.TextBox txtReport
  12. Height = 2655
  13. Left = 0
  14. MultiLine = -1 'True
  15. TabIndex = 9
  16. Top = 1920
  17. Width = 6855
  18. End
  19. Begin VB.ComboBox cmbSku
  20. Height = 315
  21. Left = 1920
  22. TabIndex = 8
  23. Top = 480
  24. Width = 4935
  25. End
  26. Begin VB.TextBox txtDbLocation
  27. Height = 375
  28. Left = 1920
  29. TabIndex = 6
  30. Top = 840
  31. Width = 4935
  32. End
  33. Begin VB.CommandButton cmdCLose
  34. Caption = "&Close"
  35. Height = 375
  36. Left = 6120
  37. TabIndex = 2
  38. Top = 4680
  39. Width = 735
  40. End
  41. Begin VB.CommandButton cmdGo
  42. Caption = "&Go"
  43. Height = 375
  44. Left = 5280
  45. TabIndex = 1
  46. Top = 4680
  47. Width = 735
  48. End
  49. Begin VB.TextBox txtLiveImageDir
  50. Height = 375
  51. Left = 1920
  52. TabIndex = 0
  53. Top = 120
  54. Width = 4935
  55. End
  56. Begin VB.Label lblDbLocation
  57. Caption = "Database Location"
  58. Height = 375
  59. Left = 120
  60. TabIndex = 7
  61. Top = 840
  62. Width = 1815
  63. End
  64. Begin VB.Label lblStatus
  65. Height = 375
  66. Left = 120
  67. TabIndex = 5
  68. Top = 1320
  69. Width = 6735
  70. End
  71. Begin VB.Label lblSku
  72. Caption = "Sku Specifier"
  73. Height = 375
  74. Left = 120
  75. TabIndex = 4
  76. Top = 480
  77. Width = 1815
  78. End
  79. Begin VB.Label lblLiveImageDir
  80. Caption = "Live Image Directory"
  81. Height = 255
  82. Left = 120
  83. TabIndex = 3
  84. Top = 120
  85. Width = 1815
  86. End
  87. End
  88. Attribute VB_Name = "frmLiveImageTracker"
  89. Attribute VB_GlobalNameSpace = False
  90. Attribute VB_Creatable = False
  91. Attribute VB_PredeclaredId = True
  92. Attribute VB_Exposed = False
  93. '===========================================================================================
  94. ' Compiland : frmLiveImageTracker.frm
  95. ' Author : Pierre Jacomet
  96. ' Version : 1.0
  97. '
  98. ' Description : Implements Interactive UI and Command Line Wrappers for COM Object
  99. ' that tracks Live Help File Image for HSC Production Tools.
  100. '
  101. ' Called by : Command Line with Arguments or Interactively from Explorer.
  102. '
  103. ' Environment data:
  104. ' Files that it uses (Specify if they are inherited in open state): NONE
  105. ' Parameters (Command Line) and usage mode {I,I/O,O}:
  106. ' Look in Function ParseOpts() for the latest incarnation of these.
  107. '
  108. ' Parameters (inherited from environment) : NONE
  109. ' Public Variables created: NONE
  110. ' Environment Variables (Public or Module Level) modified: NONE
  111. ' Environment Variables used in coupling with other routines: NONE
  112. ' Local variables : N/A
  113. ' Problems detected :
  114. ' DCR Suggestions:
  115. ' - Make File Copies Incremental, even in those cases where things should be
  116. ' completely destroyed.
  117. '
  118. ' History:
  119. ' 2000-07-16 Initial Creation
  120. '===========================================================================================
  121. Option Explicit
  122. ' We declare the Live Help File Image Com Object with Events in order to be abel to get Status
  123. ' information from it and eventually cancel the run.
  124. Private m_db As AuthDatabase.Main
  125. Private WithEvents m_oLvi As AuthDatabase.LiveImageTracker
  126. Attribute m_oLvi.VB_VarHelpID = -1
  127. ' ================== SKU Relatewd Stuff ================================
  128. '' NOTE: This is the SKU ENUM as defined elsewhere in the System, however we do not NEED it here
  129. ' as long as this SKU IDs are respected, we do extrapolate the ID from the Index of either
  130. ' the array used or the ComboBox.
  131. ' Enum SKU_E
  132. ' SKU_STANDARD_E = &H1
  133. ' SKU_PROFESSIONAL_E = &H2
  134. ' SKU_SERVER_E = &H4
  135. ' SKU_ADVANCED_SERVER_E = &H8
  136. ' SKU_DATA_CENTER_SERVER_E = &H10
  137. ' SKU_PROFESSIONAL_64_E = &H20
  138. ' SKU_ADVANCED_SERVER_64_E = &H40
  139. ' SKU_DATA_CENTER_SERVER_64_E = &H80
  140. ' End Enum
  141. Private m_idSku As Long
  142. Private m_SkuMap(8) As String
  143. Private Sub cmbSku_Click()
  144. Debug.Print cmbSku.ListIndex
  145. m_idSku = 2 ^ cmbSku.ListIndex
  146. End Sub
  147. Private Sub cmdCLose_Click()
  148. Unload Me
  149. End Sub
  150. Private Sub cmdGo_Click()
  151. Dim strErrMsg As String: strErrMsg = "": If (g_bOnErrorHandling) Then On Error GoTo Error_Handler
  152. m_db.SetDatabase Me.txtDbLocation
  153. ' While we work, we disable all Data Entry except for the Cancel Button.
  154. cmdGo.Enabled = False
  155. cmdCLose.Caption = "&Cancel"
  156. With Me
  157. .txtLiveImageDir.Enabled = False
  158. .cmbSku.Enabled = False
  159. .txtDbLocation.Enabled = False
  160. End With
  161. m_oLvi.UpdateTrackingInfo m_idSku, Me.txtLiveImageDir, Emitreport:=True
  162. p_CreateReport
  163. ' We are done, so let's get out.
  164. cmdGo.Caption = "Done"
  165. cmdCLose.Caption = "&Close"
  166. Common_Exit:
  167. Exit Sub
  168. Error_Handler:
  169. g_XErr.SetInfo "frmLiveImageTracker::cmdGo_Click", strErrMsg
  170. g_XErr.Dump
  171. End Sub
  172. Private Sub Form_Load()
  173. If (Not GlobalInit) Then
  174. MsgBox "Could Not Initialize"
  175. Unload Me
  176. GoTo Common_Exit
  177. End If
  178. Dim strErrMsg As String: strErrMsg = "": If (g_bOnErrorHandling) Then On Error GoTo Error_Handler
  179. Set m_db = New AuthDatabase.Main
  180. Set m_oLvi = m_db.LiveImageTracker
  181. Me.cmbSku.AddItem "Whistler Standard (STD)"
  182. Me.cmbSku.AddItem "Whistler Pro (PRO)"
  183. Me.cmbSku.AddItem "Whistler Server (SRV)"
  184. Me.cmbSku.AddItem "Whistler Advanced Server (ADV)"
  185. Me.cmbSku.AddItem "Whistler Datacenter (DAT)"
  186. Me.cmbSku.AddItem "Whistler Pro 64 (PRO64)"
  187. Me.cmbSku.AddItem "Whistler Advanced Server 64 (ADV64)"
  188. Me.cmbSku.AddItem "Whistler Datacenter 64 (DAT64)"
  189. Me.cmbSku.AddItem "Windows Me (WINME)"
  190. Me.cmbSku.ListIndex = 0
  191. If (Len(Command$) = 0) Then
  192. ' Temporary default FileNames. They should not be taken as indicative of
  193. ' anything.
  194. ' txtLiveImageDir = "\\taos\public\builds\win98\Latest"
  195. txtLiveImageDir = "c:\temp\test"
  196. Me.txtDbLocation = "c:\temp\winme.mdb"
  197. Else
  198. doWork Command$
  199. Unload Me
  200. End If
  201. Common_Exit:
  202. Exit Sub
  203. Error_Handler:
  204. ' We will hit an Err.Number of vbObject + 9999 by Normal Exit Conditions,
  205. ' so we are not interested in dumping this information.
  206. If (Err.Number = (vbObject + 9999)) Then
  207. Unload Me
  208. Else
  209. g_XErr.Dump
  210. End If
  211. GoTo Common_Exit
  212. End Sub
  213. Private Sub m_oLvi_GoStatus(strWhere As String, bCancel As Boolean)
  214. lblStatus.Caption = strWhere
  215. End Sub
  216. ' ============= Command Line Interface ====================
  217. ' Function: Parseopts
  218. ' Objective : Supplies a Command Line arguments interface for creating the Live Help File Image.
  219. '
  220. ' LviTracker /LVIDIR \\pietrino\d$\public\HlpImages\Server\winnt\help
  221. ' /SKU SkuString
  222. ' /DBLOCATION MDB-File
  223. Function ParseOpts(ByVal strCmd As String) As Boolean
  224. Dim strErrMsg As String: strErrMsg = "": If (g_bOnErrorHandling) Then On Error GoTo Error_Handler
  225. Dim lProgOpt As Long
  226. Dim iError As Long
  227. Const OPT_LVIDIR As Long = 2 ^ 2
  228. Const OPT_SKU As Long = 2 ^ 3
  229. Const OPT_DBLOCATION As Long = 2 ^ 4
  230. m_SkuMap(0) = "std": m_SkuMap(1) = "pro": m_SkuMap(2) = "srv":
  231. m_SkuMap(3) = "adv": m_SkuMap(4) = "dat": m_SkuMap(5) = "pro64"
  232. m_SkuMap(6) = "adv64": m_SkuMap(7) = "dat64": m_SkuMap(8) = "winme"
  233. Dim strArg As String
  234. Do While (Len(strCmd) > 0 And iError = 0)
  235. strCmd = Trim$(strCmd)
  236. If Left$(strCmd, 1) = Chr(34) Then
  237. strCmd = Right$(strCmd, Len(strCmd) - 1)
  238. strArg = vntGetTok(strCmd, sTokSepIN:=Chr(34))
  239. Else
  240. strArg = vntGetTok(strCmd, sTokSepIN:=" ")
  241. End If
  242. If (Left$(strArg, 1) = "/" Or Left$(strArg, 1) = "-") Then
  243. strArg = Mid$(strArg, 2)
  244. Select Case UCase$(strArg)
  245. ' All the Cases are in alphabetical order to make your life
  246. ' easier to go through them. There are a couple of exceptions.
  247. ' The first one is that every NOXXX option goes after the
  248. ' pairing OPTION.
  249. Case "DBLOCATION"
  250. strArg = LCase$(vntGetTok(strCmd, sTokSepIN:=" "))
  251. If ("\\" = Left$(strArg, 2)) Then
  252. lProgOpt = (lProgOpt Or OPT_DBLOCATION)
  253. Me.txtDbLocation = strArg
  254. Else
  255. MsgBox ("Database location must be specified using UNC '\\' style notation")
  256. iError = 1
  257. End If
  258. Case "LVIDIR"
  259. strArg = LCase$(vntGetTok(strCmd, sTokSepIN:=" "))
  260. If ("\\" = Left$(strArg, 2)) Then
  261. lProgOpt = (lProgOpt Or OPT_LVIDIR)
  262. Me.txtLiveImageDir = strArg
  263. Else
  264. MsgBox ("Live Image Directory must be specified using UNC '\\' style notation")
  265. iError = 1
  266. End If
  267. Case "SKU"
  268. strArg = LCase$(vntGetTok(strCmd, sTokSepIN:=" "))
  269. m_idSku = Arg2SkuID(strArg)
  270. If (m_idSku > 0) Then
  271. lProgOpt = (lProgOpt Or OPT_SKU)
  272. Else
  273. iError = 1
  274. End If
  275. Case Else
  276. MsgBox "Program Option: " & "/" & strArg & " is not supported", vbOKOnly, "Program Arguments Error"
  277. lProgOpt = 0
  278. iError = 1
  279. End Select
  280. End If
  281. Loop
  282. ' Now we check for a complete and <coherent> list of options. As all options are
  283. ' mandatory then we check for ALL options being set.
  284. If ((lProgOpt And (OPT_DBLOCATION Or OPT_LVIDIR Or OPT_SKU)) <> _
  285. (OPT_DBLOCATION Or OPT_LVIDIR Or OPT_SKU)) Then
  286. UseageMsg
  287. iError = 1
  288. End If
  289. ParseOpts = (0 = iError)
  290. Exit Function
  291. Error_Handler:
  292. g_XErr.SetInfo "frmLiveImageTracker::ParseOpts", strErrMsg
  293. Err.Raise Err.Number
  294. End Function
  295. Sub doWork(ByVal strCmd As String)
  296. Dim strErrMsg As String: strErrMsg = "": If (g_bOnErrorHandling) Then On Error GoTo Error_Handler
  297. If Not ParseOpts(strCmd) Then
  298. GoTo Common_Exit
  299. End If
  300. Me.Show vbModeless
  301. cmdGo_Click
  302. Common_Exit:
  303. Exit Sub
  304. Error_Handler:
  305. g_XErr.SetInfo "frmLiveImageTracker::doWork", strErrMsg
  306. Err.Raise Err.Number
  307. End Sub
  308. Private Function Arg2SkuID(ByVal strSku As String) As Long
  309. Arg2SkuID = 0
  310. strSku = Trim$(strSku)
  311. If (Len(strSku) = 0) Then GoTo Common_Exit
  312. Dim i As Integer
  313. For i = 0 To UBound(m_SkuMap)
  314. If (strSku = m_SkuMap(i)) Then
  315. Arg2SkuID = 2 ^ i
  316. Exit For
  317. End If
  318. Next i
  319. Common_Exit:
  320. Exit Function
  321. End Function
  322. Sub UseageMsg()
  323. MsgBox "LviTracker [/LVIDIR \\pietrino\d$\public\HlpImages\Server\winnt\help]" + vbCrLf + _
  324. " /SKU {STD|PRO|SRV|ADV|DAT|PRO64|ADV64|DAT64|WINME}" + vbCrLf + _
  325. " /DBLOCATION \\pietrino\HSCDB\HSC.MDB" + vbCrLf + vbCrLf + _
  326. "Where each option means:" + vbCrLf + vbCrLf + _
  327. "/LVIDIR Destination Live Help File Image Directory" + vbCr + _
  328. "/SKU String Identifier for SKU to be processed" + vbCr + _
  329. "/DBLOCATION Database location where tracking information is to be written"
  330. End Sub
  331. Private Function p_ID2SkuName(ByVal IDSku As Long) As Long
  332. p_ID2SkuName = Log(IDSku) / Log(2#)
  333. End Function
  334. Private Sub p_CreateReport()
  335. Dim rs As ADODB.Recordset
  336. Set rs = m_oLvi.DetailedReport
  337. txtReport.Font = "Courier New"
  338. txtReport.FontSize = 8
  339. txtReport = txtReport & "Summary Data for Run of " & App.EXEName & _
  340. " Version: " & App.Major & "." & App.Minor & "." & App.Revision & vbCrLf
  341. txtReport = txtReport & "Date: " & Now & vbCrLf
  342. txtReport = txtReport + "Live Image Directory: " + Me.txtLiveImageDir + vbCrLf
  343. txtReport = txtReport + "Database Location: " + Me.txtDbLocation + vbCrLf
  344. txtReport = txtReport + "SKU: " + Me.cmbSku.List(p_ID2SkuName(m_idSku)) + vbCrLf + vbCrLf
  345. Do While (Not rs.EOF)
  346. txtReport = txtReport & rs("Action") & " - " & rs("PathName") & " - " & rs("DateFileModified") & vbCrLf
  347. rs.MoveNext
  348. Loop
  349. txtReport = txtReport + vbCrLf
  350. txtReport = txtReport & "Summary of File Operations: Added (" & m_oLvi.AddedFiles & _
  351. ") Changed (" & m_oLvi.ChangedFiles & ") Deleted (" & m_oLvi.DeletedFiles & ")"
  352. Dim iFh As Integer
  353. iFh = FreeFile
  354. Open App.EXEName + ".log" For Output As #iFh
  355. Print #iFh, txtReport.Text
  356. Close #iFh
  357. Common_Exit:
  358. Exit Sub
  359. End Sub