Document and Folder Separation Scripts

Use the methods in these classes to trigger profiles and to control separation:

  • DocumentSeparationProcessingScript – methods for determining document separation
  • DocumentSeparationProfileTriggerScript – methods to trigger the correct document separation profile
  • FolderSeparationProcessingScript – methods for determining folder separation
  • FolderSeparationProfileTriggerScript – methods to trigger the correct folder separation profile

Each separation profile you create in your document type has its own unique set of classes. In the example below there are two document separation profiles, and each profile has a unique set of the DocumentSeparationProcessingScript and the DocumentSeparationProfileTriggerScript classes. There is also a folder separation profile; it too has its own copies of the FolderSeparationProcessingScript and the FolderSeparationProfileTriggerScript classes.

 

 

DocumentSeparationProcessingScript Class

CheckForDocumentSeparation Method

CheckForDocumentSeparation returns Boolean (true or false). This method is called by the Capture / Import module after barcode and patch code recognition on each page. Return false (the default) if the page is not a separator sheet, or return true to trigger separation.

 

Parameters:

 

Direction Parameter Type Description
IN folder IFolder

The current folder

barcodes list of IBarcode The list of any barcodes detected on the page
patchcodes list of IPatchCode The list of any patch codes detected on the page
importFIlePath string The full path of the imported document
importFileElements array of string The pieces of the importFilePath, including the file name; for example, “c:\docs\doc1.tif” would have three entries – “c:”, “docs” and “doc1.tif”
devicePage IDevicePage Various information about the current page; see IDevicePage for detailsAvailable only in v5.3.1 and higher.
IN/OUT separatorValue string A separator value that you can return to the batch; defaults to an empty string

 

Return:

True or false

Example – Examine the list of barcodes on each page. If the page contains both a Data Matrix and a Code39 barcode, the page is a separator:
public virtual bool CheckForDocumentSeparation
(IFolder folder, IEnumerable<IBarcode> barcodes, IEnumerable<IPatchCode> patchcodes, string importFilePath, string[] importFileElements, IDevicePage devicePage, ref string separatorValue)
  {
    try
    {
      // Detection flags
      bool containsDataMatrix = false;
      bool containsCode39 = false;
      // Examine each barcode in the page's list of barcodes
      foreach(IBarcode barcode in barcodes)
      {
        if(barcode.Type == BarcodeTypes.DataMatrix)
          containsDataMatrix = true;
        else if(barcode.Type == BarcodeTypes.Code39)
          containsCode39 = true;
        // Once both types are found we have a separator, so return true
        if(containsDataMatrix && containsCode39)
          return true;
      }
      // Both types were not present, so this page is not a separator
      return false;
    }
    catch (Exception exception)
    {
      base.ProcessException(exception);
      return false;
    }
  }
}

 

CheckForSeparationTrigger Method

CheckForSeparationTrigger returns either true or false. This method is called after barcode and patch code recognition on each page. Return true to select the current profile, or false to bypass the profile.

 

Parameters:

 

Direction Parameter Type Description
IN barcodes list of IBarcode The list of any barcodes detected on the page
patchcodes list of IPatchCode The list of any patch codes detected on the page
importFilePath string The full path of the imported document
importFileElements array of string The pieces of the importFilePath, including the file name; for example, “c:\docs\doc1.tif” would have three entries – “c:”, “docs” and “doc1.tif”
devicePage IDevicePage Various information about the current page; see IDevicePage for detailsAvailable only in v5.3.1 and higher.

 

Return:

True of false

 

Example – In this example, the document separation profile associated with this CheckForSeparationTrigger method is selected if the current page contains a DataMatrix barcode whose value begins with the characters “PO”:
public virtual bool CheckForSeparationTrigger(IEnumerable<IBarcode> barcodes, 
IEnumerable<IPatchCode> patchcodes, string importFilePath, string[] importFileElements, IDevicePage devicePage)
{
  try
  {
    foreach(IBarcode barcode in barcodes)
    {
      if(barcode.Type == BarcodeTypes.DataMatrix && barcode.Value.StartsWith("PO"))
        return true;
    }
    return false;
  }
  catch (Exception exception)
  {
    base.ProcessException(exception);
    return false;
  }
}

 

FolderSeparationProcessingScript Class

CheckForFolderSeparation Method

CheckForFolderSeparation returns either true or false. This method is called by the Capture / Import module after barcode and patch code recognition on each page. Return false (the default) if the page is not a folder separator sheet, or return true to trigger separation.

 

Parameters:

 

Direction Parameter Type Description
IN batch IBatch The current batch
barcodes list of IBarcode The list of any barcodes detected on the page
patchcodes list of IPatchCode The list of any patch codes detected on the page
importFilePath string The full path of the imported document
importFileElements array of strings The pieces of the importFilePath, including the file name; for example, “c:\docs\doc1.tif” would have three entries – “c:”, “docs” and “doc1.tif”
devicePage IDevicePage Various information about the current page; see IDevicePage for detailsAvailable only in v5.3.1 and higher.
IN/OUT separatorValue string A separator value that you can return to the batch; defaults to an empty string
folderName string The name of the folder

 

Return:

True or false

Example – Examine the list of barcodes on each page. If the page contains both a Data Matrix and a Code39 barcode, the page is a folder separator and the folder name should be set to the value detected in the DataMatrix barcode:
public virtual bool CheckForFolderSeparation
(IBatch batch, IEnumerable<IBarcode> barcodes, IEnumerable<IPatchCode> patchcodes, string importFilePath, string[] importFileElements, IDevicePage devicePage, ref string separatorValue, ref string folderName)
  {
    try
    {
      // Detection flags
      bool containsDataMatrix = false;
      bool containsCode39 = false;
      string newFolderName = string.Empty;
      // Examine each barcode in the page's list of barcodes
      foreach(IBarcode barcode in barcodes)
      {
        if(barcode.Type == BarcodeTypes.DataMatrix)
        {
          containsDataMatrix = true;
          newFolderName = barcode.Value;
        }
        else if(barcode.Type == BarcodeTypes.Code39)
          containsCode39 = true;
        // Once both types are found we have a separator, so return true
        if(containsDataMatrix && containsCode39)
        {
          folderName = newFolderName;
          return true;
        }
      }
      // Both types were not present, so this page is not a separator
      return false;
    }
    catch (Exception exception)
    {
      base.ProcessException(exception);
      return false;
    }
  }
}

 

CheckForSeparationTrigger Method

CheckForSeparationTrigger returns either true or false. This method is called by the Capture / Import module after barcode and patch code recognition on each page. Return true to select the current profile, or false to bypass the profile.

 

Parameters:

 

Direction Parameter Type Description
IN barcodes list of IBarcode The list of any barcodes detected on the page
patchcodes list of IPatchCode The list of any patch codes detected on the page
importFilePath string The full path of the imported document
importFileElements array of string The pieces of the importFilePath, including the file name; for example, “c:\docs\doc1.tif” would have three entries – “c:”, “docs” and “doc1.tif”
devicePage IDevicePage Various information about the current page; see IDevicePage for detailsAvailable only in v5.3.1 and higher.

 

Return:

True or false

 

Example – In this example, the folder separation profile associated with this CheckForSeparationTrigger method is selected if the current page contains a DataMatrix barcode whose value begins with the characters “PO”:
public virtual bool CheckForSeparationTrigger(IEnumerable<IBarcode> barcodes, 
IEnumerable<IPatchCode> patchcodes, string importFilePath, string[] importFileElements, IDevicePage devicePage)
{
  try
  {
    foreach(IBarcode barcode in barcodes)
    {
      if(barcode.Type == BarcodeTypes.DataMatrix && barcode.Value.StartsWith("PO"))
        return true;
    }
    return false;
  }
  catch (Exception exception)
  {
    base.ProcessException(exception);
    return false;
  }
}
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.