In certain situations when designing your workflow, you
might find it necessary to filter out documents based on scan queue. As of V15,
there is no way to configure this type of filter. You can filter by doc type
and limiting your scan queue doc types, but what if you wanted to quality check
all documents being scanned in except scans of any doc type coming from certain
scan queues? In this case, the following Unity script could be helpful.
namespace ScanQueueFilter
{
using System;
using System.Text;
using
Hyland.Unity;
using
Hyland.Unity.Workflow;
using System.IO;
using
System.Collections.Generic;
using
System.Collections;
using
System.Data.Odbc;
///
<summary>
/// scan queue filter to route incoming
documents to their appropriate sub process
///
///
</summary>
public class ScanQueueFilter:
Hyland.Unity.IWorkflowScript
{
private Hyland.Unity.Document _doc;
private
string ODBCOnBaseConnectionString = string.Empty;
#region
IWorkflowScript
///
<summary>
///
Implementation of <see
cref="IWorkflowScript.OnWorkflowScriptExecute" />.
/// <seealso
cref="IWorkflowScript" />
///
</summary>
/// <param
name="app"></param>
/// <param
name="args"></param>
public void
OnWorkflowScriptExecute(Hyland.Unity.Application app,
Hyland.Unity.WorkflowEventArgs args)
{
_doc = args.Document;
string
keyvalue = null;
bool
IsInScanQueueScope = false;
//check
for doc inclusion in scan queue scope
string
dochandle = _doc.ID.ToString();
//get
ODBC connection
app.Configuration.TryGetValue("ODBCOnBaseConnectionString",
out ODBCOnBaseConnectionString);
using
(OdbcConnection conn = openODBCConnection()){
OdbcDataReader
dr = null;
OdbcCommand
cmd = null;
cmd
= new OdbcCommand("select a.itemnum, a.itemname " +
"from
itemdata a, archivedqueue b " +
"where
a.batchnum = b.batchnum " +
"and
a.itemnum = '"+dochandle+"' " +
"and
b.queuenum in ('221')", conn);
//221
is the scan queue configuration number
dr =
cmd.ExecuteReader();
while
(dr.Read())
{
IsInScanQueueScope
= true;
break;
}
dr.Close();
}
if(IsInScanQueueScope){
args.ScriptResult=true;
}else{
args.ScriptResult=false;
}
}
No comments:
Post a Comment