Capture 10.1 Workflow Agent Development

Capture 10.1 Workflow Agent Development

Postby » Thu Dec 12, 2013 11:00 am

Here is a sample Workflow Agent that uses the new Capture .NET libraries. This WFA processes after the Recognition Module and simply writes out the Index Field values of all the Documents in the Batch to a text file.

First add references to the following Kofax Capture API dll's:

Kofax.Capture.ACWFLib.dll
Kofax.Capture.SDK.Workflow.dll
Kofax.Capture.SDK.Data.dll

Following is the complete source code for the Workflow Agent.

A couple of notes regarding this project:

1. Neither the DbLite or DbLiteOpt libraries are required when using the new libraries for Workflow Agents.

2. The ACDataElement is replaced with the IACDataElement.

3. The WorkflowData object is replaced with the IACWorkflowData object.

4. Some COM related aspects still exist and are required such as, in the project properties, Assembly Info, COM Visible must be set to True. Register for COM Interop does NOT need to be set. The same class attributes, (i.e. Guid, ClassInterface, ProgId), are still required.

Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Kofax.Capture.ACWFLib;
using Kofax.Capture.SDK.Workflow;
using Kofax.Capture.SDK.Data;

namespace WFAExportValues
{
   [Guid("7F819B7B-7F21-4F5E-8699-51F09C93A088")]
   [ClassInterface(ClassInterfaceType.None)]
   [ProgId("WFAExportValues.ExportValues")]
   public class ExportValues : IACWorkflowAgent
   {
      public void ProcessWorkflow(ref IACWorkflowData oWorkflowData)
      {
         if (oWorkflowData.CurrentModule.ID.ToLower() == "fp.exe")
         {
            try
            {
               IACDataElement oRoot = oWorkflowData.ExtractRuntimeACDataElement(0);
               IACDataElement oBatch = oRoot.FindChildElementByName("Batch");
               IACDataElement oDocument = oBatch.FindChildElementByName("Documents");
               IACDataElementCollection oDocColl = oDocument.FindChildElementsByName("Document");

               using (StreamWriter sw = new StreamWriter(@"C:\ProgramData\Kofax\CaptureSV\Logs\WFAIndexData.txt", true))
               {
                  foreach (IACDataElement oDoc in oDocColl)
                  {
                     IACDataElement oIndex = oDoc.FindChildElementByName("IndexFields");
                     IACDataElementCollection oIndexColl = oIndex.FindChildElementsByName("IndexField");
                     sw.WriteLine("Document: {0}", oDoc["UniqueID"].ToString());
                     foreach (IACDataElement oField in oIndexColl)
                     {
                        sw.WriteLine("Name: {0}, Value: {1}", oField["Name"].ToString(), oField["Value"].ToString());
                     }
                     sw.WriteLine("----------------------------------------------------");
                  }
               }
            }
            catch (Exception ex)
            {
               using (StreamWriter sw = new StreamWriter(@"C:\ProgramData\Kofax\CaptureSV\Logs\WFAIndexData.txt", true))
               {
                  sw.WriteLine("************************************");
                  sw.WriteLine("Error: {0}", ex.Message);
                  sw.WriteLine("************************************");
               }
            }
         }
      }
   }
}
If they are going to hate you anyway for what you do, then you might as well put forth your best effort.
User avatar
Participant
 
Posts: 62
Joined: Tue Apr 10, 2007 8:11 am

Re: Capture 10.1 Workflow Agent Development

Postby » Thu Mar 20, 2014 3:06 am

Thanks for giving the sample code. Its help me to write custom workflow agent.

But can you please let me know how can i create the ".aex" file....?

I belive Its required for the register/add workflow agent in Kofax Capture
Participant
 
Posts: 40
Joined: Sun Jun 16, 2013 8:46 pm

Re: Capture 10.1 Workflow Agent Development

Postby » Wed Apr 16, 2014 3:48 am

The original poster didn't reply so here is a sample I have used. A word of caution though. When you create the aex file make sure you save it using something like plain Notepad so that it saves in ansi/windows format. I spent hours trying to fix an error because the AEX file created within the SharpDevelop environment would raise errors when registering but the errors would disappear if I just opened the file, made an edit and saved in Notepad or Textpad. Note that if you recompile the DLL and increment the version it has to be updated in the AEX file too.

Code: Select all
[Workflow Agents]
WFAExportValues

[WFAExportValues]
WorkflowAgentID=WFAExportValues.ExportValues
WorkflowAgentProgID=Tnt.Avt.A9Workflow.ConsignmentWfa
WorkflowAgentFile=WFAExportValues.dll
Description=Some description
Version=1.0
SupportsNonImageFiles=True
Participant
 
Posts: 14
Joined: Wed Nov 17, 2010 5:35 am

Re: Capture 10.1 Workflow Agent Development

Postby » Wed Apr 30, 2014 5:09 pm

I created a .dll using the sample code, and an .aex file using the sample file, and was able to get things registered on the server and added to the workflow agents for a batch type. However, when I scan a batch using it, I get a "[Kofax.Capture.ACWFLIB] 12000 Unable to load Workflow Agent "WFAExportValues." (429 Cannot create ActiveX component.)" error.

This happens immediately after scan, not after recognition. This makes sense, as my understanding is the ProcessWorkflow function runs as a batch leaves each queue. But I am unable to determine if the code is even being run, or if it's failing before that point.

I've been hitting my head on this for the past 3 hours.

A google search returned a few threads here on the Kofax forums and a few (unrelated) ones from elsewhere, but none of the issues seemed to apply.

Have any of you encountered this?

Thanks,
Chris
Chris
TeamPraxis
Participant
 
Posts: 33
Joined: Tue Mar 25, 2014 12:53 pm

Re: Capture 10.1 Workflow Agent Development

Postby » Fri May 02, 2014 3:14 am

Do You have latest patches installed?
for example from FP1:
119889 - Workflow agent written fo Kofax Capture 9 does not run on Kofax Capture 10.1.

Hando
Participant
 
Posts: 362
Joined: Thu Jul 17, 2008 9:42 pm

Re: Capture 10.1 Workflow Agent Development

Postby » Fri May 02, 2014 11:59 am

Hando,

No I do not. I will install that shortly.

One question though - this workflow was written for 10.1, according to the title - how did you know it was written for 9?

Thanks!
I will report back once I've updated and tested.

- Chris
Chris
TeamPraxis
Participant
 
Posts: 33
Joined: Tue Mar 25, 2014 12:53 pm

Re: Capture 10.1 Workflow Agent Development

Postby » Fri May 02, 2014 3:33 pm

In the AEX file do you have
Code: Select all
WorkflowAgentProgID=WorkflowAgentProgID=Tnt.Avt.A9Workflow.ConsignmentWfa

or
Code: Select all
WorkflowAgentProgID=WFAExportValues.ExportValues

Also what is the name of the DLL you ceated? What does the compete AEX file look like? What do you have as ProgID in the source code?
All these parameters must match up, otherwise WFA will not work. I do not think you need to apply any patch to solve this. The patch referred by Hando should only be needed if you can't recompile the source code for KC 10.1 (that is you use a DLL already compiled for KC 9). But it has no relevance since you compile a new DLL.
Best Regards,

Daniel Kekesi
DocSoft Hungary
Image
Participant
 
Posts: 2569
Joined: Thu Dec 08, 2005 12:56 am
Location: Budapest, Hungary

Re: Capture 10.1 Workflow Agent Development

Postby » Mon May 05, 2014 10:49 pm

Hi!

The patch fixes some errors that prevent WF agents running correctly on 10.1. So it is quite mandatory...
And of course - all the parameters in AEX file must be specified :)
Participant
 
Posts: 362
Joined: Thu Jul 17, 2008 9:42 pm

Re: Capture 10.1 Workflow Agent Development

Postby » Wed May 07, 2014 7:24 am

Not all. The WorkflowAgentSkipIfCantLoad doesn't need to be specified. But, the default value for this is "False".
If they are going to hate you anyway for what you do, then you might as well put forth your best effort.
User avatar
Participant
 
Posts: 62
Joined: Tue Apr 10, 2007 8:11 am


Return to Custom Modules General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest