Kofax TotalAgility to Move Folder
using System;
using Agility.Server.Scripting.ScriptAssembly;
using TotalAgility.Sdk;
using Agility.Sdk.Model.Capture;
using System.Text.RegularExpressions;
namespace MyNamespace
{
public class Class1
{
public Class1()
{
}
[StartMethodAttribute()]
public void Method1(ScriptParameters sp)
{
//
// TODO: Add start method code here
//
CaptureDocumentService cds = new CaptureDocumentService();
// get all documents in folder
string temp ="";
string text = "";
string doctype = "";
int i = 0;
string sessionId = sp.InputVariables["
SPP_SYSTEM_SESSION_ID
Server variable
"].ToString();
string folderId = sp.InputVariables["
Folder.InstanceID
Process variable
"].ToString();
Folder folder = cds.GetFolder(sessionId, null, folderId);
foreach (Document document in folder.Documents)
{
//Console.WriteLine(string.Format("{0} ({2}): {1}", document.Id, document.FileName, document.MimeType));
temp = temp + "| " + i.ToString() + " - " + document.Id + " , DocType: " + document.DocumentType.Identity.Name;
string tempDocType = document.DocumentType.Identity.Name.ToUpper();
Regex pattern = new Regex(@"(?<DocuType>.*?)\-.*", RegexOptions.IgnoreCase);
Match match = pattern.Match(tempDocType );
if(match.Groups["DocuType"].Value.Length>0){
doctype = match.Groups["DocuType"].Value;
}else{
doctype = tempDocType ;
}
////
if(doctype == "INT_DOC" || doctype == "CLM_DOC"){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtINT_DOC_fid
Process variable
"] ,-1);
}else if(doctype == "ABL_LOADLS_CNTNR" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtABL_LOADLS_CNTNR_fid
Process variable
"] ,-1);
}else if(doctype == "ADV_BCONF" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtABL_LOADLS_CNTNR_fid
Process variable
"] ,-1);
}else if(doctype == "ADV_DELIVERY" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtADV_DELIVERY_fid
Process variable
"] ,-1);
}else if(doctype == "BL_HOUSE_HBL" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtBL_HOUSE_HBL_fid
Process variable
"] ,-1);
}else if(doctype == "PCKLST" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtPCKLST_fid
Process variable
"] ,-1);
}else if(doctype == "POS_PICKLIST" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtPOS_PICKLIST_fid
Process variable
"] ,-1);
}else if(doctype == "WHS_INV" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtWHS_INV_fid
Process variable
"] ,-1);
}else if(doctype == "WHS_LoadList" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtWHS_LoadList_fid
Process variable
"] ,-1);
}else if(doctype == "WHS_LOADLIST" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtWHS_LoadList_fid
Process variable
"] ,-1);
}else if(doctype == "WHS_ShipInstr" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtWHS_ShipInstr_fid
Process variable
"] ,-1);
}else if( doctype == "WHS_SHIPINSTR"){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtWHS_ShipInstr_fid
Process variable
"] ,-1);
}else if(doctype == "WHS_VALRP" ){
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtWHS_VALRP_fid
Process variable
"] ,-1);
}else{
//Console.WriteLine("UNK") as OTHERS;
cds.MoveDocument(sessionId, null, document.Id, sp.InputVariables["
dtINT_DOC_fid
Process variable
"] ,-1);
}
//
}
sp.OutputVariables["
tempMSG
Process variable
"] = sessionId + " _ " + folderId + "_" + temp;
}
}
}