Guest User

Untitled

a guest
Jun 24th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. Sub main
  2. Dim batchNum
  3. Dim docType
  4. Dim OrderNum
  5. Dim strCurrentFile
  6. Dim Truck
  7. Dim Trailer
  8. Dim Driver
  9. Dim Invoice
  10. Dim Billto
  11. Dim BOL
  12. Dim scandate
  13. dim k
  14. dim curdate
  15. dim objTif
  16. dim intPages
  17. dim D
  18. dim fs
  19.  
  20. Set objTif = CreateObject("BITIFF.BITiffCtrl.1")
  21. batchNum = NextSeqValue("ShipsAway")
  22.  
  23.  
  24. for i = 1 to Job.Documents.count
  25. Set fs = CreateObject("Scripting.FileSystemObject")
  26. strOriginalFile = Job.Documents.item(i).Directory & Job.Documents.item(i).Filename
  27.  
  28. intPages = objTif.GetNumberOfImagesInTiffFile(strOriginalFile)
  29.  
  30. If intPages = 1 Then
  31. docType = job.documents.item(i).parameters.item(1).value
  32. OrderNum = job.documents.item(i).parameters.item(2).value
  33. Truck = job.documents.item(i).parameters.item(3).value
  34. Trailer = job.documents.item(i).parameters.item(4).value
  35. BOL = job.documents.item(i).parameters.item(5).value
  36. Billto = job.documents.item(i).parameters.item(6).value
  37. Driver = job.documents.item(i).parameters.item(7).value
  38. Invoice = job.documents.item(i).parameters.item(8).value
  39. CurDate = formatdatetime(now(), 2)
  40. D = Trim(curdate)
  41. ScanDate = D
  42. 'msgbox(scandate)
  43. strNewFilename = strDateNow & NextSeqValue("ShipsAway") & ".tif"
  44. strNewFile = Job.Documents.item(i).Directory & strNewFilename
  45. ' Call objTif.CopyTiffImageInFile(strOriginalFile, k, strNewFile, 3)
  46. fs.CopyFile strOriginalFile, strNewFile
  47. Call createIDX(batchNum, strNewFileName, docType, OrderNum, Truck, Trailer, BOL, Billto, Driver, Invoice)
  48.  
  49. Else
  50. For k = 0 To intPages - 1
  51. docType = job.documents.item(i).parameters.item(1).value
  52. OrderNum = job.documents.item(i).parameters.item(2).value
  53. Truck = job.documents.item(i).parameters.item(3).value
  54. Trailer = job.documents.item(i).parameters.item(4).value
  55. BOL = job.documents.item(i).parameters.item(5).value
  56. Billto = job.documents.item(i).parameters.item(6).value
  57. Driver = job.documents.item(i).parameters.item(7).value
  58. Invoice = job.documents.item(i).parameters.item(8).value
  59. CurDate = formatdatetime(now(), 2)
  60. D = Trim(curdate)
  61. ScanDate = D
  62. 'msgbox(scandate)
  63.  
  64. strNewFilename = strDateNow & NextSeqValue("ShipsAway") & ".tif"
  65. strNewFile = Job.Documents.item(i).Directory & strNewFilename
  66.  
  67. Call objTif.CopyTiffImageInFile(strOriginalFile, k, strNewFile, 3)
  68. 'fs.CopyFile strOriginalFile, strNewFile
  69. Call createIDX(batchNum, strNewFileName, docType, OrderNum, Truck, Trailer, BOL, Billto, Driver, Invoice)
  70. ' fs.DeleteFile (strOriginalFile)
  71.  
  72. Next
  73.  
  74. End if
  75. fs.DeleteFile (strOriginalFile)
  76. 'strCurrentFile = Job.Documents.item(i).Filename
  77. set strCurrentFile = nothing
  78. set fs = nothing
  79. Next
  80.  
  81. Call createINF(batchNum, scanDate)
  82. Call createBatch(batchNum)
  83.  
  84. filesystem.Attachments.Add CStr(Job.Documents.item(1).Directory & batchNum & "_" & job.jobid & ".zip")
  85.  
  86. End Sub
  87.  
  88. Public Sub createBatch(batchNum)
  89. Dim imageDir
  90. Dim importDir
  91. Dim PZ
  92.  
  93. imageDir = Job.Documents.item(1).Directory
  94.  
  95.  
  96. Set PZ = CreateObject("PolarZipLight.ZipLight")
  97. PZ.SourceDirectory = imageDir
  98. PZ.ZipFileName = imageDir & batchNum & ".zip "
  99. PZ.Add
  100.  
  101.  
  102. End Sub
  103.  
  104. Private Function NextSeqValue(strSeqName)
  105.  
  106. Dim objSeq
  107. Dim strValue
  108. Dim bRet
  109. dim strReturnMessage
  110.  
  111. set objSeq = CreateObject("SeqValueLib.SequenceValue")
  112.  
  113. bRet = objSeq.GetNextValue(strSeqName, strValue, strReturnMessage)
  114.  
  115. If bRet = True then
  116. NextSeqValue = strValue
  117. Else
  118. NextSeqValue = ""
  119. FileSystem.ScriptMessage = cstr(strReturnMessage)
  120. End If
  121.  
  122. set objSeq = nothing
  123. end Function
  124.  
  125.  
  126. Public Sub createINF(batchNum, scanDate)
  127. Dim output
  128. Dim myFSO
  129. Dim outputFile
  130. Dim writeINF
  131.  
  132. output = "ScanComputer: Titan IDE" & vbCrLf & _
  133. "User: admin" & vbCrLf & _
  134. "ScanDate: " & scanDate
  135.  
  136. Set myFSO = CreateObject("Scripting.FileSystemObject")
  137. outputFile = Job.Documents.item(1).Directory & batchNum & ".inf"
  138. Set writeINF = myFSO.OpenTextFile(outputFile, 8, True)
  139. writeINF.WriteLine (output)
  140. writeINF.Close
  141.  
  142. End Sub
  143.  
  144. Public Sub createIDX(batchNum, fileName, docType, OrderNum, Truck, Trailer, BOL, Billto, Driver, Invoice)
  145.  
  146. Dim output
  147. Dim myFSO
  148. Dim outputFile
  149. Dim writeINF
  150.  
  151.  
  152. output = fileName & "|" & docType & "|*|" & orderNum & "|" & Truck & "|" & Trailer & "|" & BOL & "|" & Billto & "|" & Driver & "|" & Invoice
  153.  
  154. Set myFSO = CreateObject("Scripting.FileSystemObject")
  155. outputFile = Job.Documents.item(1).Directory & batchNum & ".idx"
  156. Set writeINF = myFSO.OpenTextFile(outputFile, 8, True)
  157. writeINF.WriteLine (output)
  158. writeINF.Close
  159.  
  160.  
  161.  
  162. End Sub
Add Comment
Please, Sign In to add comment