Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

111 řádky
4.1KB

  1. Option Explicit
  2. Dim dev:dev = True
  3. Dim WshShell:Set WshShell = WScript.CreateObject("Wscript.Shell")
  4. Dim fso:Set fso = WScript.CreateObject("Scripting.Filesystemobject")
  5. Dim outFile
  6. Dim DataDirectory
  7. Dim ConnectionString
  8. Dim oConn:Set oConn = WScript.CreateObject("ADODB.Connection")
  9. Dim glob:set glob = CreateObject("Chilkat_9_5_0.Global")
  10. Dim success:success = glob.UnlockBundle("KENTCM.CB1022025_RGzBPM5J655e")
  11. If (success <> 1) Then
  12. WriteLine(glob.LastErrorText)
  13. WScript.Quit
  14. End If
  15. Dim objCSV:Set objCsv = CreateObject("Chilkat_9_5_0.Csv")
  16. Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.ScriptName,"")
  17. If dev Then
  18. 'set outFile = fso.CreateTextFile("F:\Development\Tracking_Kits\ImportService\temp.csv",True)
  19. set outFile = fso.CreateTextFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\temp.csv",True)
  20. DataDirectory = WorkingDirectory & "test"
  21. ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=F:\Development\Tracking_Kits\Data\webdata - Copy.mdb;"
  22. Else
  23. DataDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataImport\"
  24. set outFile = fso.CreateTextFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\temp.csv",True)
  25. ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;"
  26. End If
  27. oConn.ConnectionString = ConnectionString
  28. oConn.Open
  29. Dim KitID:KitID = CheckForJobsToCass()
  30. If KitID > 0 Then
  31. ExportMMCsv(KitID)
  32. RunMailManager
  33. ImportCass
  34. End If
  35. Sub ImportCass
  36. Dim currentRow
  37. objCsv.LoadFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\FROM_MM.CSV")
  38. For currentRow = 0 To objCsv.NumRows -1
  39. oConn.Execute("UPDATE InkJetRecords SET CassADDRESS1 = '" & objCsv.GetCell(currentRow,1) & "', " &_
  40. "CassADDRESS2 = '" & objCSV.GetCell(currentRow,3) & "', " &_
  41. "CassADDRESS3 = '" & objCSV.GetCell(currentRow,4) & "', " &_
  42. "CassADDRESS4 = '" & objCSV.GetCell(currentRow,5) & "', " &_
  43. "CassADDRESS5 = '" & objCsv.GetCell(currentRow,6) & ", " & objCsv.GetCell(currentRow,7) & " " & objCsv.GetCell(currentRow,8) & "'" &_
  44. " WHERE ID = " & objCSV.GetCell(currentRow,0) & ";")
  45. Next
  46. oConn.Execute("UPDATE Kit SET Status ='Ready To Create Labels' WHERE ID =" & KitID & ";")
  47. End Sub
  48. Sub RunMailManager
  49. WshShell.Run "\\MM2012\APPS\BCC\MM2010\mailman.exe -p -j MMJOB.mjb -u DAN",1,True
  50. End Sub
  51. Sub ExportMMCsv(KitId)
  52. Dim success
  53. objCsv.HasColumnNames = 1
  54. objCSV.EnableQuotes = 1
  55. success = objCsv.SetColumnName(0,"ID")
  56. success = objCsv.SetColumnName(1,"NAME")
  57. success = objCsv.SetColumnName(2,"ADDRESS1")
  58. success = objCsv.SetColumnName(3,"ADDRESS2")
  59. success = objCsv.SetColumnName(4,"ADDRESS3")
  60. success = objCsv.SetColumnName(5,"ADDRESS4")
  61. success = objCsv.SetColumnName(6,"ADDRESS5")
  62. Dim rs : Set rs = oConn.Execute("Select ID," & _
  63. "IIF(FIRSTNAME IS NULL,'',FIRSTNAME & ' ') & " & _
  64. "IIF(MIDDLENAME IS NULL,'',MIDDLENAME & ' ') & " & _
  65. "IIF(LASTNAME IS NULL,'',LASTNAME & ' ') & " & _
  66. "IIF(SUFFIX IS NULL,'',SUFFIX & ' ') " & _
  67. "AS NAME, ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4,ADDRESS5 FROM InkjetRecords WHERE KitID =" & KitID & " ORDER By ID;")
  68. Dim CurrentRow:CurrentRow = 0
  69. While Not rs.EOF
  70. objCSV.SetCell CurrentRow,0,rs("ID").value
  71. objCSV.SetCell CurrentRow,1,rs("NAME").value
  72. objCSV.SetCell CurrentRow,2,rs("ADDRESS1").value
  73. objCSV.SetCell CurrentRow,3,rs("ADDRESS2").value
  74. objCSV.SetCell CurrentRow,4,rs("ADDRESS3").value
  75. objCSV.SetCell CurrentRow,5,rs("ADDRESS4").value
  76. objCSV.SetCell CurrentRow,6,rs("ADDRESS5").value
  77. rs.MoveNext
  78. CurrentRow = CurrentRow +1
  79. Wend
  80. Dim CsvString:CsvString = objCSV.SaveToString()
  81. outFile.WriteLine CsvString
  82. outFile.Close
  83. End Sub
  84. Function CheckForJobsToCass()
  85. Dim rs : set rs = oConn.Execute("Select TOP 1 ID from Kit Where Status ='Ready to Cass' ORDER BY ID DESC;")
  86. If Not rs.EOF Then
  87. Dim kitId : kitId = rs("ID").value
  88. rs.Close
  89. CheckForJobsToCass = KitID
  90. oConn.Execute("UPDATE Kit SET Status ='Cassing' WHERE ID =" & KitID & ";")
  91. Else
  92. CheckForJobsToCass = 0
  93. End If
  94. End Function

Powered by TurnKey Linux.