Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.78 KB | None | 0 0
  1. ' ************************************
  2. ' *** Cherished Item Routing Start ***
  3. ' ************************************
  4.  
  5. Private Sub BeginCreateCherishedItemDocuments(ByVal pXRootFolder As CASCADELib.CscXFolder, ByVal CloseMode As CASCADELib.CscBatchCloseMode)
  6. On Error GoTo ErrorHandler
  7. OutputDebugString "Scansation.BeginCreateCherishedItemDocuments"
  8.  
  9. Dim i As Long
  10. Dim strBatchType As String
  11.  
  12. If CloseMode = CscBatchCloseFinal And Project.ScriptExecutionMode = CscScriptModeValidation Then
  13.  
  14. strBatchType = pXRootFolder.Fields.ItemByName("BatchType").Text
  15. For i = 0 To pXRootFolder.DocInfos.Count - 1
  16. If pXRootFolder.DocInfos(i).XDocument.ExtractionClass <> "Batch Header" Then
  17. CreateCherishedItemDocumentsFromXDocInfo pXRootFolder.DocInfos(i), strBatchType
  18. End If
  19. Next
  20.  
  21. End If
  22.  
  23. Exit Sub
  24. ErrorHandler:
  25. LogError(Err.Number, "BeginCreateCherishedItemDocuments", Err.Description)
  26. End Sub
  27.  
  28. Private Sub CreateCherishedItemDocumentsFromXDocInfo(ByVal oXDocInfo As CscXDocInfo, ByVal strBatchType As String)
  29. On Error GoTo ErrorHandler
  30. OutputDebugString "Scansation.CreateCherishedItemDocumentsFromXDocInfo"
  31.  
  32. Dim strAllIndexes As String
  33. Dim arrAllIndexes() As String
  34. Dim i As Long
  35. Dim j As Long
  36. Dim k As Long
  37. Dim lStartIndex As Long
  38. Dim lEndIndex As Long
  39. Dim oXdoc As CscXDocument
  40. Dim oNewXDocInfo As CscXDocInfo
  41. Dim strOriginalIndexes As String
  42. Dim strCertCopyIndexes As String
  43. Dim strPhotoCopyIndexes As String
  44. Dim bCopiedFirstPage As Boolean
  45. Dim strNewClassName As String
  46.  
  47. Set oXdoc = oXDocInfo.XDocument
  48.  
  49. strOriginalIndexes = oXdoc.Fields.ItemByName("DetectedPageIndexes_ORIGINAL").Text
  50. strCertCopyIndexes = oXdoc.Fields.ItemByName("DetectedPageIndexes_CERTCOPY").Text
  51. strPhotoCopyIndexes = oXdoc.Fields.ItemByName("DetectedPageIndexes_PHOTOCOPY").Text
  52.  
  53. strAllIndexes = strOriginalIndexes & IIf(strCertCopyIndexes <> "",",", "") & _
  54. strCertCopyIndexes & IIf(strPhotoCopyIndexes <> "",",", "") & _
  55. strPhotoCopyIndexes
  56. arrAllIndexes = Split(strAllIndexes, ",")
  57. QuickSort arrAllIndexes, 0, UBound(arrAllIndexes)
  58.  
  59. strOriginalIndexes = "," & strOriginalIndexes & ","
  60. strCertCopyIndexes = "," & strCertCopyIndexes & ","
  61.  
  62. For i = 0 To UBound(arrAllIndexes)
  63. lStartIndex = CLng(arrAllIndexes(i)) + 1
  64.  
  65. If i = UBound(arrAllIndexes) Then
  66. lEndIndex = oXDocInfo.PageCount - 1
  67.  
  68. If strBatchType <> "SFTP" Then
  69. lEndIndex = lEndIndex - 1
  70. End If
  71. Else
  72. lEndIndex = CLng(arrAllIndexes(i + 1)) - 1
  73. End If
  74.  
  75. Dim strFilePaths As String
  76. Dim arrFilePaths() As String
  77.  
  78. bCopiedFirstPage = False
  79. For j = lStartIndex To lEndIndex
  80. If Not bCopiedFirstPage Then
  81. Batch.CopyPageToNewDocumentTo oXDocInfo, j, oXdoc.ParentFolder, oXdoc.ParentFolder.DocInfos.Count
  82. Set oNewXDocInfo = oXdoc.ParentFolder.DocInfos.ItemByIndex(oXdoc.ParentFolder.DocInfos.Count - 1)
  83. bCopiedFirstPage = True
  84. Else
  85. Batch.CopyPageTo oXDocInfo, j, oNewXDocInfo, oNewXDocInfo.XDocument.Pages.Count
  86. End If
  87. Next
  88.  
  89. If InStr(1, strOriginalIndexes, "," & arrAllIndexes(i) & ",") > 0 Then
  90. strNewClassName = "ORIGINAL"
  91. ElseIf InStr(1, strCertCopyIndexes, "," & arrAllIndexes(i) & ",") > 0 Then
  92. strNewClassName = "CERTCOPY"
  93. Else
  94. strNewClassName = "PHOTOCOPY"
  95. End If
  96.  
  97. Batch.ChangeClass strNewClassName, oNewXDocInfo, True
  98. oNewXDocInfo.XDocument.Fields.ItemByName("HRN").Text = oXDocInfo.XDocument.Fields.ItemByName("HRN").Text
  99.  
  100. Next
  101. Exit Sub
  102. ErrorHandler:
  103. LogError(Err.Number, "CreateCherishedItemDocumentsFromXDocInfo", Err.Description)
  104. End Sub
  105.  
  106. Private Sub QuickSort(vArray As Variant, inLow As Long, inHi As Long)
  107. Dim pivot As Variant
  108. Dim tmpSwap As Variant
  109. Dim tmpLow As Long
  110. Dim tmpHi As Long
  111.  
  112. tmpLow = inLow
  113. tmpHi = inHi
  114.  
  115. pivot = vArray((inLow + inHi) \ 2)
  116.  
  117. While (tmpLow <= tmpHi)
  118. While (vArray(tmpLow) < pivot And tmpLow < inHi)
  119. tmpLow = tmpLow + 1
  120. Wend
  121.  
  122. While (pivot < vArray(tmpHi) And tmpHi > inLow)
  123. tmpHi = tmpHi - 1
  124. Wend
  125.  
  126. If (tmpLow <= tmpHi) Then
  127. tmpSwap = vArray(tmpLow)
  128. vArray(tmpLow) = vArray(tmpHi)
  129. vArray(tmpHi) = tmpSwap
  130. tmpLow = tmpLow + 1
  131. tmpHi = tmpHi - 1
  132. End If
  133. Wend
  134.  
  135. If (inLow < tmpHi) Then QuickSort vArray, inLow, tmpHi
  136. If (tmpLow < inHi) Then QuickSort vArray, tmpLow, inHi
  137. End Sub
  138.  
  139. Public Sub BnymDocumentRouting(ByVal pXRootFolder As CASCADELib.CscXFolder)
  140. On Error GoTo ErrorHandler
  141. OutputDebugString "Scansation.BnymDocumentRouting"
  142.  
  143. Dim i As Long
  144. Dim oXDocInfo As CASCADELib.CscXDocInfo
  145. Dim lPageIndex As Long
  146. Dim strNewBatchName As String
  147.  
  148. For i = 0 To pXRootFolder.GetTotalDocumentCount() - 1
  149. Set oXDocInfo = pXRootFolder.GetDocInfoByGlobalIndex(i)
  150.  
  151. Select Case oXDocInfo.XDocument.ExtractionClass
  152. Case "ORIGINAL", "CERTCOPY", "PHOTOCOPY"
  153. oXDocInfo.XValues.Set("KTM_DOCUMENTROUTING", "CherishedItem")
  154. End Select
  155.  
  156. If oXDocInfo.XDocument.Fields.Exists("HRN") Then
  157. oXDocInfo.XValues.Set("SS_BNYM_HRN", oXDocInfo.XDocument.Fields.ItemByName("HRN").Text)
  158. End If
  159. oXDocInfo.XValues.Set("SS_BNYM_ItemType", oXDocInfo.XDocument.ExtractionClass)
  160.  
  161. Next
  162.  
  163. pXRootFolder.XValues.Set("KTM_DOCUMENTROUTING_NEWBATCHCLASS_CherishedItem", "BNYM Cherished Items")
  164. strNewBatchName = pXRootFolder.XValues("AC_BATCH_NAME") & " - Cherished Items"
  165. pXRootFolder.XValues.Set("KTM_DOCUMENTROUTING_BATCHNAME_CherishedItem", strNewBatchName)
  166.  
  167.  
  168. Exit Sub
  169. ErrorHandler:
  170. LogError(Err.Number, "BnymDocumentRouting", Err.Description)
  171. End Sub
  172.  
  173.  
  174. ' ************************************
  175. ' *** Cherished Item Routing End *****
  176. ' ************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement