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.

1149 lines
34 KiB

  1. '//+----------------------------------------------------------------------------
  2. '//
  3. '// File: newver.frm
  4. '//
  5. '// Module: pbadmin.exe
  6. '//
  7. '// Synopsis: The dialog for publishing phonebooks in PBA
  8. '//
  9. '// Copyright (c) 1997-1999 Microsoft Corporation
  10. '//
  11. '// Author: quintinb Created Header 09/02/99
  12. '//
  13. '//+----------------------------------------------------------------------------
  14. VERSION 5.00
  15. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
  16. Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
  17. Begin VB.Form frmNewVersion
  18. BorderStyle = 3 'Fixed Dialog
  19. Caption = "build Phone Book"
  20. ClientHeight = 4440
  21. ClientLeft = 405
  22. ClientTop = 1500
  23. ClientWidth = 6795
  24. Icon = "newver.frx":0000
  25. KeyPreview = -1 'True
  26. LinkTopic = "Form1"
  27. MaxButton = 0 'False
  28. MinButton = 0 'False
  29. PaletteMode = 1 'UseZOrder
  30. ScaleHeight = 4440
  31. ScaleWidth = 6795
  32. ShowInTaskbar = 0 'False
  33. WhatsThisButton = -1 'True
  34. WhatsThisHelp = -1 'True
  35. Begin InetCtlsObjects.Inet inetOCX
  36. Left = 1860
  37. Top = 3030
  38. _ExtentX = 1005
  39. _ExtentY = 1005
  40. _Version = 393216
  41. Protocol = 2
  42. RemotePort = 21
  43. URL = "ftp://"
  44. End
  45. Begin VB.CommandButton cmbOptions
  46. Caption = "&options..."
  47. Height = 375
  48. Left = 5160
  49. TabIndex = 2
  50. Top = 780
  51. WhatsThisHelpID = 14010
  52. Width = 1410
  53. End
  54. Begin VB.Frame Frame2
  55. Height = 30
  56. Left = 225
  57. TabIndex = 15
  58. Top = 3750
  59. Width = 6405
  60. End
  61. Begin VB.Frame Frame1
  62. Height = 30
  63. Left = 210
  64. TabIndex = 14
  65. Top = 2325
  66. Width = 6405
  67. End
  68. Begin VB.CommandButton BrowseButton
  69. Caption = "brwse"
  70. Height = 375
  71. Left = 5175
  72. TabIndex = 5
  73. Top = 1890
  74. WhatsThisHelpID = 14030
  75. Width = 1425
  76. End
  77. Begin VB.TextBox DirText
  78. Alignment = 1 'Right Justify
  79. Height = 330
  80. Left = 3000
  81. MaxLength = 255
  82. TabIndex = 4
  83. Top = 1905
  84. WhatsThisHelpID = 14020
  85. Width = 1980
  86. End
  87. Begin VB.CommandButton Command3
  88. Caption = "post"
  89. Height = 375
  90. Left = 270
  91. TabIndex = 1
  92. Top = 3255
  93. WhatsThisHelpID = 14070
  94. Width = 1185
  95. End
  96. Begin VB.CommandButton cmbCancel
  97. Cancel = -1 'True
  98. Caption = "clos"
  99. Height = 375
  100. Left = 5445
  101. TabIndex = 6
  102. Top = 3930
  103. WhatsThisHelpID = 10020
  104. Width = 1170
  105. End
  106. Begin VB.CommandButton Command1
  107. Caption = "&create"
  108. Height = 375
  109. Left = 210
  110. TabIndex = 0
  111. Top = 1860
  112. WhatsThisHelpID = 14060
  113. Width = 1200
  114. End
  115. Begin ComctlLib.ProgressBar ProgressBar1
  116. Height = 270
  117. Left = 225
  118. TabIndex = 16
  119. Top = 4035
  120. Visible = 0 'False
  121. Width = 2985
  122. _ExtentX = 5265
  123. _ExtentY = 476
  124. _Version = 327682
  125. Appearance = 1
  126. End
  127. Begin VB.Label ServerNameText
  128. BackStyle = 0 'Transparent
  129. BorderStyle = 1 'Fixed Single
  130. Height = 315
  131. Left = 3420
  132. TabIndex = 13
  133. Top = 3270
  134. WhatsThisHelpID = 14040
  135. Width = 3180
  136. End
  137. Begin VB.Label ServerLabel
  138. BackStyle = 0 'Transparent
  139. Caption = "server"
  140. Height = 240
  141. Left = 3435
  142. TabIndex = 12
  143. Top = 3030
  144. WhatsThisHelpID = 14040
  145. Width = 3075
  146. End
  147. Begin VB.Label CreateLabel
  148. BackStyle = 0 'Transparent
  149. Caption = "create a new phone book release."
  150. Height = 1575
  151. Left = 180
  152. TabIndex = 11
  153. Top = 90
  154. Width = 2655
  155. End
  156. Begin VB.Label txtver
  157. Alignment = 1 'Right Justify
  158. BackStyle = 0 'Transparent
  159. BorderStyle = 1 'Fixed Single
  160. BeginProperty Font
  161. Name = "MS Sans Serif"
  162. Size = 12
  163. Charset = 0
  164. Weight = 400
  165. Underline = 0 'False
  166. Italic = 0 'False
  167. Strikethrough = 0 'False
  168. EndProperty
  169. Height = 315
  170. Left = 3000
  171. TabIndex = 10
  172. Top = 810
  173. WhatsThisHelpID = 14000
  174. Width = 990
  175. End
  176. Begin VB.Label DirLabel
  177. Caption = "release directory:"
  178. Height = 255
  179. Left = 3030
  180. TabIndex = 3
  181. Top = 1680
  182. WhatsThisHelpID = 14020
  183. Width = 2385
  184. End
  185. Begin VB.Label PostLabel
  186. BackStyle = 0 'Transparent
  187. Caption = "post the new release to the Phone Book Server."
  188. Height = 720
  189. Left = 210
  190. TabIndex = 7
  191. Top = 2490
  192. Width = 2325
  193. End
  194. Begin VB.Label lbldate
  195. BorderStyle = 1 'Fixed Single
  196. ForeColor = &H00000000&
  197. Height = 285
  198. Left = 2490
  199. TabIndex = 9
  200. Top = 1950
  201. Visible = 0 'False
  202. Width = 390
  203. End
  204. Begin VB.Label ReleaseLabel
  205. BackStyle = 0 'Transparent
  206. Caption = "new release:"
  207. Height = 225
  208. Left = 3000
  209. TabIndex = 8
  210. Top = 480
  211. WhatsThisHelpID = 14000
  212. Width = 2595
  213. End
  214. End
  215. Attribute VB_Name = "frmNewVersion"
  216. Attribute VB_GlobalNameSpace = False
  217. Attribute VB_Creatable = False
  218. Attribute VB_PredeclaredId = True
  219. Attribute VB_Exposed = False
  220. Option Explicit
  221. Dim bAuthFinished As Boolean
  222. Function ChangeProgressBar(AddValue As Integer) As Integer
  223. On Error GoTo ProgressErr
  224. If (ProgressBar1.Value + AddValue) <= 100 And (ProgressBar1.Value + AddValue) >= 0 Then
  225. ProgressBar1.Value = ProgressBar1.Value + AddValue
  226. Else
  227. If (ProgressBar1.Value + AddValue) < 0 Then
  228. ProgressBar1.Value = 0
  229. Else
  230. ProgressBar1.Value = 100
  231. End If
  232. End If
  233. Exit Function
  234. ProgressErr:
  235. ChangeProgressBar = 1
  236. Exit Function
  237. End Function
  238. Function LoadBuildRes()
  239. Dim cRef As Integer
  240. On Error GoTo LoadErr
  241. cRef = 5000
  242. Me.Caption = LoadResString(cRef + 191) & " " & gsCurrentPB
  243. Command1.Caption = LoadResString(cRef + 192)
  244. Command3.Caption = LoadResString(cRef + 193)
  245. cmbOptions.Caption = LoadResString(cRef + 194)
  246. BrowseButton.Caption = LoadResString(1009)
  247. CreateLabel.Caption = LoadResString(cRef + 195)
  248. PostLabel.Caption = LoadResString(cRef + 196)
  249. ReleaseLabel.Caption = LoadResString(cRef + 197)
  250. DirLabel.Caption = LoadResString(cRef + 198)
  251. ServerLabel.Caption = LoadResString(cRef + 199)
  252. 'statuslabel.Caption = LoadResString(cRef + 200)
  253. cmbCancel.Caption = LoadResString(1005)
  254. ' set fonts
  255. SetFonts Me
  256. On Error GoTo 0
  257. Exit Function
  258. LoadErr:
  259. Exit Function
  260. End Function
  261. Public Function outdtaddf(ByVal path As String, ByVal dtafile As String, ByVal PBKFile As String, ByVal version As String)
  262. Dim intFile As Integer
  263. Dim strRegFile As String
  264. Dim strPBKFile As String
  265. Dim strVerFile As String
  266. On Error GoTo DTAErr
  267. strRegFile = gQuote & path & gsCurrentPB & ".pbr" & gQuote
  268. strPBKFile = gQuote & PBKFile & gQuote
  269. version = Trim(version)
  270. strVerFile = gQuote & path & version & ".ver" & gQuote
  271. intFile = FreeFile
  272. Open path & dtafile For Output As #intFile
  273. Print #intFile, strRegFile; " "; gsCurrentPB & ".pbr"
  274. Print #intFile, strPBKFile; " "; "pbupdate.pbd"
  275. Print #intFile, strVerFile; " "; "pbupdate.ver"
  276. Close #intFile
  277. On Error GoTo 0
  278. Exit Function
  279. DTAErr:
  280. Exit Function
  281. End Function
  282. Public Function outfullddf(ByVal path As String, ByVal fullfile As String, ByVal version As String)
  283. Dim strPBKFile As String
  284. Dim strRegFile As String
  285. Dim strVerFile As String
  286. Dim intFile As Integer
  287. On Error GoTo fullddfErr
  288. strPBKFile = gQuote & path & fullfile & gQuote
  289. strRegFile = gQuote & path & gsCurrentPB & ".pbr" & gQuote
  290. version = Trim(version)
  291. strVerFile = gQuote & path & version & ".ver" & gQuote
  292. 'If CheckPath(strINFfile) <> 0 Then
  293. ' MakeFullINF gsCurrentPB
  294. 'End If
  295. intFile = FreeFile
  296. Open path & version & "Full.ddf" For Output As #intFile
  297. Print #intFile, strRegFile; " "; gsCurrentPB & ".pbr"
  298. Print #intFile, strPBKFile; " "; gsCurrentPB & ".pbk"
  299. Print #intFile, strVerFile; " "; "pbupdate.ver"
  300. Close #intFile
  301. On Error GoTo 0
  302. Exit Function
  303. fullddfErr:
  304. Exit Function
  305. End Function
  306. Public Function PostFiles(ByVal Host As String, ByVal UID As String, ByVal PWD As String, ByVal version As Integer, ByVal PostDir As String, ByVal VirPath As String) As Integer
  307. ' =================================================================================
  308. ' this function handles the
  309. ' POST to the PB Server
  310. '
  311. ' Arguments: host, uid, pwd, version, postdir, virpath
  312. ' Returns: 0 = success
  313. ' 1 = fail
  314. '
  315. ' history: Created April '97 Paul Kreemer
  316. '
  317. ' =================================================================================
  318. Const VROOT As String = "PBSDATA"
  319. Const DIR_DB As String = "DATABASE"
  320. Const LOCALFILE As String = "pbserver.mdb"
  321. Const REMOTEFILE As String = "newpb.mdb"
  322. Dim intAuthCount As Byte
  323. Dim intX As Integer
  324. Dim strBaseFile As String
  325. ' setup the OCX and check for connection
  326. With inetOCX
  327. .URL = "ftp://" & Host
  328. .UserName = UID
  329. .Password = PWD
  330. .Protocol = icFTP
  331. .AccessType = icUseDefault
  332. .RequestTimeout = 60
  333. End With
  334. On Error GoTo DirError
  335. inetOCX.Execute , "CD /" & VROOT & "/" & VirPath
  336. PostWait
  337. ' If the directory doesn't exist then create it
  338. If inetOCX.ResponseCode = 12003 Then
  339. inetOCX.Execute , "CD /" & VROOT
  340. PostWait
  341. If inetOCX.ResponseCode = 12003 Then
  342. MsgBox LoadResString(6060) & " " & Host & vbCrLf & inetOCX.ResponseInfo, 0
  343. PostFiles = 1
  344. Exit Function
  345. End If
  346. inetOCX.Execute , "MKDIR " & VirPath
  347. PostWait
  348. If inetOCX.ResponseCode = 12003 Then
  349. MsgBox LoadResString(6060) & " " & Host & vbCrLf & inetOCX.ResponseInfo, 0
  350. PostFiles = 1
  351. Exit Function
  352. End If
  353. inetOCX.Execute , "CD /" & VROOT & "/" & VirPath
  354. PostWait
  355. If inetOCX.ResponseCode = 12003 Then
  356. MsgBox LoadResString(6060) & " " & Host & vbCrLf & inetOCX.ResponseInfo, 0
  357. PostFiles = 1
  358. Exit Function
  359. End If
  360. End If
  361. ' full CAB
  362. inetOCX.Execute , "PUT " & gQuote & PostDir & "\" & version & "full.cab" & gQuote & " " & _
  363. version & "full.cab"
  364. ChangeProgressBar 10
  365. PostWait
  366. If inetOCX.ResponseCode = 0 Then
  367. ' Delta CABs
  368. strBaseFile = version & "delta"
  369. For intX = version - GetDeltaCount(version) To version - 1
  370. inetOCX.Execute , "PUT " & gQuote & PostDir & "\" & strBaseFile & intX & ".cab" & gQuote & " " & _
  371. strBaseFile & intX & ".cab"
  372. ChangeProgressBar 10
  373. PostWait
  374. If inetOCX.ResponseCode <> 0 Then GoTo ineterr
  375. Next
  376. ' go to db dir
  377. inetOCX.Execute , "CD /" & VROOT & "/" & DIR_DB
  378. PostWait
  379. If inetOCX.ResponseCode <> 0 Then GoTo ineterr
  380. 'PBSERVER.mdb (NewPB.mdb)
  381. inetOCX.Execute , "PUT " & gQuote & PostDir & "\" & LOCALFILE & gQuote & " " & REMOTEFILE
  382. PostWait
  383. If inetOCX.ResponseCode <> 0 Then GoTo ineterr
  384. ChangeProgressBar 10
  385. ' NewPB.txt
  386. inetOCX.Execute , "PUT " & gQuote & DirText.Text & "\" & version & ".ver" & gQuote & " newpb.txt"
  387. PostWait
  388. ChangeProgressBar 5
  389. Else
  390. GoTo ineterr
  391. End If
  392. inetOCX.Execute , "QUIT"
  393. PostFiles = 0
  394. Exit Function
  395. ineterr:
  396. MsgBox LoadResString(6101) & " " & inetOCX.ResponseInfo, 0
  397. inetOCX.Execute , "QUIT"
  398. PostFiles = 1
  399. Exit Function
  400. DirError:
  401. inetOCX.Execute , "QUIT"
  402. Select Case Err.Number
  403. Case 35750 To 35755, 35761 'Unable to contact
  404. MsgBox LoadResString(6042), vbExclamation + vbOKOnly
  405. PostFiles = 1
  406. Case 35756 To 35760 'Connection Timed Out
  407. MsgBox LoadResString(6043), vbExclamation + vbOKOnly
  408. PostFiles = 1
  409. Case Else
  410. MsgBox LoadResString(6043), vbExclamation + vbOKOnly
  411. PostFiles = 1
  412. End Select
  413. End Function
  414. Public Function UpdateHkeeper(ByVal DBPath As String, ByVal PhoneBook As String, ByVal version As Integer, ByVal VirPath As String) As Integer
  415. '==========================================================================
  416. ' handle all updates of HKEEPER.MDB relating to posting a phone book.
  417. '
  418. ' Arguments:
  419. ' Returns: 0 = success
  420. ' 1 = failure
  421. '
  422. ' History: Created Apr 24 '97 Paul Kreemer
  423. '==========================================================================
  424. Dim rsOS, rsTemp As Recordset
  425. Dim intISPid As Integer
  426. Dim intPrevious As Integer
  427. Dim intX As Integer
  428. Dim strPath As String
  429. On Error GoTo UpdateErr
  430. Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(DBPath)
  431. Set rsOS = gsyspb.OpenRecordset("OSTypes")
  432. Set rsTemp = Gsyspbpost.OpenRecordset("select * from ISPs where Description like '" & PhoneBook & "'", dbOpenDynaset)
  433. If rsTemp.EOF And rsTemp.BOF Then
  434. 'insert row w/ new id
  435. Set rsTemp = Gsyspbpost.OpenRecordset("select max(ISPid) as maxID from ISPs", dbOpenSnapshot)
  436. If IsNull(rsTemp!maxID) Then
  437. intISPid = 1
  438. Else
  439. intISPid = rsTemp!maxID + 1
  440. End If
  441. Set rsTemp = Gsyspbpost.OpenRecordset("select * from ISPs", dbOpenDynaset)
  442. rsTemp.AddNew
  443. rsTemp!Description = PhoneBook
  444. rsTemp!ISPid = intISPid
  445. rsTemp.Update
  446. Else
  447. ' use existing ID
  448. rsTemp.MoveFirst
  449. intISPid = rsTemp!ISPid
  450. End If
  451. rsTemp.Close
  452. Gsyspbpost.Execute "DELETE from Phonebooks WHERE ISPid = " & Str(intISPid), dbFailOnError
  453. ChangeProgressBar 10
  454. rsOS.MoveFirst
  455. While Not rsOS.EOF
  456. intPrevious = version - GetDeltaCount(version)
  457. For intX = 1 To GetDeltaCount(version)
  458. strPath = "/PBSDATA/" & VirPath & "/" & version & "DELTA" & intPrevious & ".cab"
  459. Gsyspbpost.Execute "INSERT INTO Phonebooks " & _
  460. "(ISPid, Version, LCID, OS, Arch, VirtualPath) " & _
  461. "VALUES ( " & Str$(intISPid) & "," & _
  462. intPrevious & "," & _
  463. "0," & _
  464. Str$(rsOS!OSType) & ", " & _
  465. "0, " & _
  466. "'" & strPath & "')", dbFailOnError
  467. intPrevious = intPrevious + 1
  468. Next intX
  469. strPath = "/PBSDATA/" & VirPath & "/" & version & "full.cab"
  470. Gsyspbpost.Execute "INSERT INTO Phonebooks " & _
  471. "(ISPid, Version, LCID, OS, Arch, VirtualPath) " & _
  472. "VALUES ( " & Str$(intISPid) & "," & _
  473. version & "," & _
  474. "0," & _
  475. Str$(rsOS!OSType) & ", " & _
  476. "0, " & _
  477. "'" & strPath & "')", dbFailOnError
  478. rsOS.MoveNext
  479. Wend
  480. DBEngine.Idle
  481. rsOS.Close
  482. Gsyspbpost.Close
  483. Exit Function
  484. UpdateErr:
  485. UpdateHkeeper = 1
  486. End Function
  487. Public Function VersionOutFile(file As String, vernum As Integer)
  488. Dim intFile As Integer
  489. intFile = FreeFile
  490. Open file For Output As #intFile
  491. Print #intFile, Trim(vernum)
  492. Close #intFile
  493. End Function
  494. Public Function PostWait()
  495. Do Until Not inetOCX.StillExecuting
  496. DoEvents
  497. Loop
  498. End Function
  499. Public Function WriteRegionFile(file As String) As Integer
  500. Dim ds As Recordset
  501. Dim intFile As Integer
  502. On Error GoTo WriteErr
  503. intFile = FreeFile
  504. Set ds = gsyspb.OpenRecordset("SELECT RegionDesc FROM Region order by RegionId", dbOpenSnapshot)
  505. Open file For Output As #intFile
  506. If ds.EOF And ds.BOF Then
  507. Print #intFile, "0"
  508. Else
  509. ds.MoveLast
  510. ds.MoveFirst
  511. Print #intFile, ds.RecordCount
  512. While Not ds.EOF
  513. Print #intFile, Trim(ds!RegionDesc)
  514. ds.MoveNext
  515. Wend
  516. End If
  517. Close #intFile
  518. ds.Close
  519. Exit Function
  520. WriteErr:
  521. Exit Function
  522. End Function
  523. Private Sub BrowseButton_Click()
  524. On Error GoTo ErrTrap
  525. Load frmGetDir
  526. frmGetDir.SelDir = DirText.Text
  527. frmGetDir.Show vbModal
  528. If frmGetDir.SelDir <> "" Then
  529. If Len(frmGetDir.SelDir) > 110 Then
  530. MsgBox LoadResString(6059), 0
  531. Else
  532. DirText.Text = frmGetDir.SelDir
  533. End If
  534. End If
  535. Unload frmGetDir
  536. On Error GoTo 0
  537. Exit Sub
  538. ErrTrap:
  539. Exit Sub
  540. End Sub
  541. Private Sub cmbCancel_Click()
  542. On Error GoTo CancelErr
  543. Unload Me
  544. Exit Sub
  545. CancelErr:
  546. Resume Next
  547. End Sub
  548. Private Sub cmbOptions_Click()
  549. On Error GoTo ErrTrap
  550. frmcab.Show vbModal
  551. Dim rsConfig As Recordset
  552. Set rsConfig = gsyspb.OpenRecordset("select * from Configuration where Index = 1", dbOpenSnapshot)
  553. If Not IsNull(rsConfig!URL) Then
  554. ServerNameText.Caption = " " & rsConfig!URL
  555. ' HTTPocx.GetDoc "http://" & rsConfig!URL & "/pbserver/pbserver.asp"
  556. ' ServerStatusText.Caption = " <unknown>"
  557. Else
  558. ServerNameText.Caption = ""
  559. 'ServerStatusText.Caption = ""
  560. End If
  561. rsConfig.Close
  562. Exit Sub
  563. ErrTrap:
  564. Exit Sub
  565. 'Dim rsConfig As recordset
  566. 'Set rsConfig = GsysPb.OpenRecordset("select * from Configuration where Index = 1", dbOpenSnapshot)
  567. 'If Not IsNull(rsConfig!URL) Then
  568. ' ServerNameText.Caption = " " & rsConfig!URL
  569. ' HTTPocx.GetDoc "http://" & rsConfig!URL & "/pbserver/pbserver.asp"
  570. ' ServerStatusText.Caption = " <unknown>"
  571. 'Else
  572. ' ServerNameText.Caption = ""
  573. ' ServerStatusText.Caption = ""
  574. 'End If
  575. 'rsConfig.Close
  576. End Sub
  577. Private Sub Command1_Click()
  578. ' here's the 'create release' code
  579. Dim config As Recordset
  580. Dim deltnum, vercheck As Integer
  581. Dim sql1, sql2 As String
  582. Dim vernumsql, mastersql, deltasql As String
  583. Dim deltanum As Integer, vernum As Integer, previousver As Integer
  584. Dim filesaveas As String, i As Integer, verfile As String
  585. Dim fullddffile As String, dtaddffile As String
  586. Dim sShort, sLong As String
  587. Dim strTemp As String
  588. Dim strRelPath As String
  589. Dim strSPCfile As String
  590. Dim strPVKfile As String
  591. Dim filelen As Long
  592. Dim bNewVersion As Boolean
  593. Dim dblFreeSpace As Double
  594. Dim result As Integer
  595. Dim strucFname As OFSTRUCT
  596. Dim strSearchFile As String
  597. Dim strRelativePath As String
  598. On Error GoTo ErrTrap
  599. If Len(DirText.Text) > 110 Then
  600. MsgBox LoadResString(6059), 0
  601. DirText.SetFocus
  602. Exit Sub
  603. End If
  604. If Trim(DirText.Text) = "" Or CheckPath(DirText.Text) <> 0 Then
  605. MsgBox LoadResString(6037), vbExclamation
  606. DirText.SetFocus
  607. Exit Sub
  608. Else
  609. DirText.Text = Trim(DirText.Text)
  610. If Right(DirText.Text, 1) = "\" Then
  611. DirText.Text = Left(DirText.Text, Len(DirText.Text) - 1)
  612. End If
  613. 'strRelPath = GetMyShortPath(DirText.Text & "\")
  614. strRelPath = DirText.Text & "\"
  615. End If
  616. dblFreeSpace = GetDriveSpace(DirText.Text, 350000)
  617. If dblFreeSpace = -2 Then
  618. Exit Sub
  619. End If
  620. Set config = gsyspb.OpenRecordset("select * from Configuration where Index = 1", dbOpenDynaset)
  621. config.MoveLast
  622. If GsysDelta.RecordCount = 0 Then
  623. deltnum = 1
  624. Else
  625. GsysDelta.MoveLast
  626. deltnum = GsysDelta!deltanum
  627. vercheck = GsysDelta!NewVersion
  628. bNewVersion = False
  629. If Not IsNull(config!NewVersion) Then
  630. If config!NewVersion = 1 Then
  631. bNewVersion = True
  632. End If
  633. End If
  634. If vercheck = 1 And Not bNewVersion Then
  635. config.Close
  636. MsgBox LoadResString(6038), vbInformation
  637. Exit Sub
  638. End If
  639. End If
  640. ' handle UI
  641. Screen.MousePointer = 11
  642. Command1.Enabled = False
  643. cmbOptions.Enabled = False
  644. DirText.Enabled = False
  645. BrowseButton.Enabled = False
  646. cmbCancel.Enabled = False
  647. With ProgressBar1
  648. .Visible = True
  649. .Value = 0
  650. End With
  651. ChangeProgressBar 10
  652. config.Edit
  653. config!PBbuildDir = DirText.Text
  654. config.Update
  655. vernum = txtver.Caption
  656. mastersql = "SELECT * from DialUpPort where Status = '1' order by AccessNumberId"
  657. Set GsysNDial = gsyspb.OpenRecordset(mastersql, dbOpenSnapshot)
  658. If GsysNDial.RecordCount = 0 Then 'master phone file
  659. Set GsysNDial = Nothing
  660. Command1.Enabled = True
  661. cmbOptions.Enabled = True
  662. DirText.Enabled = True
  663. BrowseButton.Enabled = True
  664. cmbCancel.Enabled = True
  665. ProgressBar1.Visible = False
  666. ProgressBar1.Value = 0
  667. Screen.MousePointer = 0
  668. MsgBox LoadResString(6039), vbExclamation
  669. Exit Sub
  670. Else
  671. sLong = strRelPath
  672. filesaveas = sLong & vernum & "Full.pbk"
  673. verfile = sLong & vernum & ".VER"
  674. 'fullddffile = sLong & vernum & "Full.ddf"
  675. masterOutfile filesaveas, GsysNDial
  676. FileCopy filesaveas, sLong & gsCurrentPB & ".pbk"
  677. VersionOutFile verfile, vernum
  678. 'outfullddf fullddffile, filesaveas, verfile, config
  679. outfullddf sLong, vernum & "Full.pbk", Str(vernum)
  680. WriteRegionFile sLong & gsCurrentPB & ".pbr"
  681. If Left(Trim(locPath), 2) <> "\\" Then
  682. ChDrive locPath
  683. End If
  684. ChDir locPath
  685. WaitForApp "full.bat" & " " & _
  686. gQuote & sLong & vernum & "Full.cab" & gQuote & " " & _
  687. gQuote & sLong & vernum & "Full.ddf" & gQuote
  688. ChangeProgressBar 20 + 10 / vernum
  689. ChangeProgressBar 20 / vernum
  690. End If
  691. 'Check for existence of full.cab
  692. strSearchFile = sLong & vernum & "Full.cab"
  693. result = OpenFile(strSearchFile, strucFname, OF_EXIST)
  694. If result = -1 Then
  695. MsgBox LoadResString(6075), 0
  696. Screen.MousePointer = 0
  697. Command1.Enabled = True
  698. cmbOptions.Enabled = True
  699. DirText.Enabled = True
  700. BrowseButton.Enabled = True
  701. cmbCancel.Enabled = True
  702. With ProgressBar1
  703. .Visible = False
  704. .Value = 0
  705. End With
  706. Exit Sub
  707. End If
  708. If vernum > 1 Then
  709. deltasql = "Select * from delta order by DeltaNum"
  710. Set GsysNDelta = gsyspb.OpenRecordset(deltasql, dbOpenSnapshot)
  711. If GsysNDelta.RecordCount <> 0 Then
  712. GsysNDelta.MoveLast
  713. deltanum = GsysNDelta!deltanum
  714. End If
  715. previousver = vernum - deltanum + 1
  716. For i = 2 To deltanum
  717. deltasql = "Select * from delta where NewVersion <> 1 and DeltaNum = " & i & " order by AccessNumberId"
  718. Set GsysNDelta = gsyspb.OpenRecordset(deltasql, dbOpenSnapshot)
  719. filesaveas = sLong & vernum & "DTA" & previousver & ".pbk"
  720. dtaddffile = vernum & "DELTA" & previousver & ".ddf"
  721. deltaoutfile filesaveas, GsysNDelta
  722. outdtaddf sLong, dtaddffile, filesaveas, Str(vernum)
  723. WaitForApp "dta.bat" & " " & _
  724. gQuote & sLong & vernum & "DELTA" & previousver & ".cab" & gQuote & " " & _
  725. gQuote & sLong & vernum & "DELTA" & previousver & ".ddf" & gQuote
  726. previousver = previousver + 1
  727. ChangeProgressBar 70 / (deltanum - 1)
  728. Next i%
  729. End If
  730. Set GsysNDial = Nothing
  731. Set GsysNDelta = Nothing
  732. If Trim(ServerNameText.Caption) <> "" Then
  733. Command3.Enabled = True
  734. End If
  735. cmbCancel.Enabled = True
  736. ProgressBar1.Visible = False
  737. ProgressBar1.Value = 0
  738. Screen.MousePointer = 0
  739. Exit Sub
  740. ErrTrap:
  741. Set GsysNDial = Nothing
  742. Set GsysNDelta = Nothing
  743. Command1.Enabled = True
  744. cmbOptions.Enabled = True
  745. cmbCancel.Enabled = True
  746. DirText.Enabled = True
  747. BrowseButton.Enabled = True
  748. ProgressBar1.Visible = False
  749. ProgressBar1.Value = 0
  750. Screen.MousePointer = 0
  751. If Err.Number = 3022 Then
  752. MsgBox LoadResString(6040), vbCritical
  753. ElseIf Err.Number = 75 Then
  754. MsgBox LoadResString(6041), vbCritical
  755. Else
  756. MsgBox LoadResString(6041), vbCritical
  757. End If
  758. Exit Sub
  759. End Sub
  760. Private Sub Command3_Click()
  761. Dim sql1 As String, sql2 As String
  762. Dim configure As Recordset
  763. 'Dim rsTemp As Recordset
  764. Dim i, intX As Integer, deltanum As Integer, previous As Integer
  765. Dim vertualpath As String
  766. Dim strSource As String, strDestination As String
  767. Dim webpostdir As String
  768. Dim webpostdir1 As String
  769. Dim strBaseFile As String
  770. Dim strPBVirPath As String
  771. Dim strPBName As String
  772. Dim sLong As String
  773. Dim postpath As Variant
  774. Dim filelen As Long
  775. Dim myValue As Long
  776. Dim intAuthCount As Integer
  777. Dim bErr As Boolean
  778. Dim bTriedRepair As Boolean
  779. Dim dblFreeSpace As Double
  780. Dim intVersion As Integer
  781. Dim intRC As Integer
  782. On Error GoTo ErrTrap
  783. dblFreeSpace = GetDriveSpace(DirText.Text, 400000)
  784. If dblFreeSpace = -2 Then
  785. Exit Sub
  786. End If
  787. ' handle UI
  788. Screen.MousePointer = 11
  789. Command1.Enabled = False
  790. Command3.Enabled = False
  791. cmbCancel.Enabled = False
  792. ProgressBar1.Visible = True
  793. DoEvents
  794. On Error GoTo dbErr
  795. bTriedRepair = False
  796. intVersion = Val(txtver.Caption)
  797. deltanum = GetDeltaCount(intVersion)
  798. postpath = locPath + "pbserver.mdb"
  799. strPBName = gsCurrentPB
  800. strPBVirPath = ReplaceChars(strPBName, " ", "_")
  801. Set configure = gsyspb.OpenRecordset("select * from Configuration where Index = 1", dbOpenDynaset)
  802. intRC = UpdateHkeeper(postpath, gsCurrentPB, intVersion, strPBVirPath)
  803. ' intRC = PostFiles(configure!URL, configure!ServerUID, configure!ServerUID, intVersion, webpostdir, strPBVirPath)
  804. On Error GoTo ErrTrap
  805. ChangeProgressBar 15
  806. ' here's the webpost stuff
  807. webpostdir = DirText.Text & "\" & intVersion & "post"
  808. If CheckPath(webpostdir) = 0 Then
  809. ' dir name in use - rename old
  810. myValue = Hour(Now) * 10000 + Minute(Now) * 100 + Second(Now)
  811. Name webpostdir As webpostdir & "_old_" & myValue
  812. End If
  813. MkDir webpostdir
  814. FileCopy locPath & "pbserver.mdb", webpostdir & "\pbserver.mdb"
  815. ' copy the CABs
  816. FileCopy DirText.Text & "\" & intVersion & "full.cab", webpostdir & "\" & intVersion & "full.cab"
  817. previous = intVersion - deltanum
  818. For intX = 1 To deltanum
  819. strSource = DirText.Text & "\" & intVersion & "delta" & previous & ".cab"
  820. strDestination = webpostdir & "\" & intVersion & "delta" & previous & ".cab"
  821. FileCopy strSource, strDestination
  822. previous = previous + 1
  823. Next intX
  824. 'sLong = GetMyShortPath(webpostdir)
  825. 'paths = sLong
  826. ChangeProgressBar 20
  827. intRC = PostFiles(configure!URL, configure!ServerUID, configure!ServerPWD, intVersion, webpostdir, strPBVirPath)
  828. If intRC = 1 Then bErr = True
  829. If Not bErr Then
  830. GsysVer.AddNew
  831. GsysVer!version = intVersion
  832. GsysVer!CreationDate = lbldate.Caption
  833. GsysVer.Update
  834. Set GsysDelta = gsyspb.OpenRecordset("SELECT * FROM delta ORDER BY DeltaNum", dbOpenDynaset)
  835. GsysDelta.MoveLast
  836. deltanum = GsysDelta!deltanum
  837. If deltanum < 6 Then
  838. GsysDelta.AddNew
  839. GsysDelta!deltanum = deltanum + 1
  840. GsysDelta!NewVersion = 1
  841. GsysDelta.Update
  842. Else
  843. sql1 = "DELETE FROM delta WHERE DeltaNum = 1"
  844. gsyspb.Execute sql1, dbFailOnError
  845. sql2 = "UPDATE delta SET DeltaNum = DeltaNum - 1"
  846. gsyspb.Execute sql2, dbFailOnError
  847. Set GsysDelta = gsyspb.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
  848. GsysDelta.AddNew
  849. GsysDelta!deltanum = 6
  850. GsysDelta!NewVersion = 1
  851. GsysDelta.Update
  852. End If
  853. Set GsysDelta = Nothing
  854. End If
  855. 'handle UI
  856. cmbCancel.Enabled = True
  857. ProgressBar1.Visible = False
  858. ProgressBar1.Value = 0
  859. If bErr Then
  860. Command3.Enabled = True
  861. 'MsgBox LoadResString(6043), vbExclamation
  862. Else
  863. configure.Edit
  864. configure!NewVersion = 0
  865. configure.Update
  866. Command3.Enabled = False
  867. LogPublish intVersion
  868. End If
  869. configure.Close
  870. Screen.MousePointer = 0
  871. Exit Sub
  872. dbErr:
  873. postpath = locPath + "pbserver.mdb"
  874. If bTriedRepair Then
  875. MsgBox LoadResString(6055), vbCritical
  876. cmbCancel.Enabled = True
  877. Screen.MousePointer = 0
  878. Else
  879. If CheckPath(postpath) <> 0 Then
  880. MsgBox LoadResString(6032) & Chr(13) & postpath, vbCritical
  881. cmbCancel.Enabled = True
  882. Screen.MousePointer = 0
  883. Exit Sub
  884. Else
  885. bTriedRepair = True
  886. DBEngine.RepairDatabase postpath
  887. Resume Next
  888. End If
  889. End If
  890. Exit Sub
  891. ErrTrap:
  892. Set GsysDelta = Nothing
  893. 'Set GsysNDelta = Nothing
  894. If Err.Number = 76 Then
  895. postpath = locPath + "pbserver.mdb"
  896. Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(postpath)
  897. ' handle UI
  898. cmbCancel.Enabled = True
  899. DoEvents
  900. Command3_Click
  901. Exit Sub
  902. Else
  903. ' handle UI
  904. Screen.MousePointer = 0
  905. Command3.Enabled = True
  906. cmbCancel.Enabled = True
  907. ProgressBar1.Visible = False
  908. ProgressBar1.Value = 0
  909. MsgBox LoadResString(6043), vbExclamation
  910. Exit Sub
  911. End If
  912. End Sub
  913. Private Sub DirText_GotFocus()
  914. SelectText DirText
  915. End Sub
  916. Private Sub Form_KeyPress(KeyAscii As Integer)
  917. CheckChar KeyAscii
  918. End Sub
  919. Private Sub Form_Load()
  920. Dim Pbversion As Integer
  921. Dim testnum As Integer, testcheck As Integer
  922. Dim rsConfig As Recordset
  923. Set GsysVer = gsyspb.OpenRecordset("Select * from PhoneBookVersions order by version", dbOpenDynaset)
  924. Set GsysDelta = gsyspb.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
  925. Set rsConfig = gsyspb.OpenRecordset("select * from Configuration where Index = 1", dbOpenSnapshot)
  926. If GsysVer.RecordCount = 0 Then
  927. Pbversion = 1
  928. Else
  929. GsysVer.MoveLast
  930. Pbversion = GsysVer!version + 1
  931. End If
  932. LoadBuildRes
  933. txtver.Caption = Pbversion
  934. Command1.Enabled = True
  935. Command3.Enabled = False
  936. DirText.Text = locPath & gsCurrentPB
  937. 'If Not IsNull(rsConfig!PBbuildDir) Then
  938. ' If CheckPath(rsConfig!PBbuildDir) = 0 Then
  939. ' DirText.Text = rsConfig!PBbuildDir
  940. ' End If
  941. 'End If
  942. If Not IsNull(rsConfig!URL) Then ' show info on PB server
  943. ServerNameText.Caption = " " & rsConfig!URL
  944. 'With HTTPocx
  945. ' .EnableTimer(prcConnectTimeout) = True
  946. ' .Timeout(prcConnectTimeout) = 30
  947. ' .EnableTimer(prcReceiveTimeout) = True
  948. ' .Timeout(prcReceiveTimeout) = 30
  949. '.EnableTimer(prcUserTimeout) = True
  950. '.Timeout(prcUserTimeout) = 30
  951. 'End With
  952. 'ServerStatusText.Caption = " " & LoadResString(5201)
  953. 'HTTPocx.GetDoc "//" & rsConfig!URL & "/pbserver/pbserver.dll" & _
  954. "?ServiceName=11223399&pbVer=1&"
  955. End If
  956. rsConfig.Close
  957. CenterForm Me, Screen
  958. Screen.MousePointer = 0
  959. End Sub
  960. Private Sub Form_Unload(Cancel As Integer)
  961. On Error Resume Next
  962. Screen.MousePointer = 0
  963. GsysVer.Close
  964. GsysDelta.Close
  965. End Sub
  966. Private Sub txtver_Change()
  967. If txtver.Caption <> "" Then
  968. lbldate.Caption = Date
  969. Else
  970. lbldate.Caption = ""
  971. End If
  972. End Sub