0

我正在开发一个使用 ABBYY FC 12 捕获和存档文档的项目。需要构建一个到 OpenText DMS 的导出连接器。该连接器应该有自己的接口来连接到项目并将 ABBYY 中的字段映射到 OpenText DMS 上的对应字段,然后保存此配置。

我浏览了 ABBYY FC 开发人员指南,发现了一个使用 ABBYY FC Web API 的示例,它运行良好。但在这种情况下,工作流程将无人参与,所有阶段都将通过 API 执行。

任何人都可以帮助如何构建用于有人值守的导出连接器吗?

我希望我的问题很清楚!

提前致谢。

4

1 回答 1

1

您也可以使用 Abbyy FC Web API。您必须在简单工作流模式下设置项目。

使用 Web API生成sessionIdandbatchId并将文档上传到 Abbyy 后,您可以使用以下代码识别文档并获取nextstageand taskId

 public enum eProcessingStageTypes
        {
            Scanning = 100,
            Rescanning = 150,
            Recognition = 200,
            UnattendedProcessing = 250,
            DocumentAssemblyCheck = 300,
            DataVerificationPreprocessing = 390,
            DataVerification = 400,
            DataVerificationPostprocessing = 410,
            VerificationPreprocessing = 490,
            Verification = 500,
            VerificationPostprocessing = 510,
            BatchIntegrityCheck = 600,
            ExportConfirmation = 700,
            ExportPrerecognitionforexporttoPDFsearchable = 780,
            Export = 800,
            Training = 850,
            Userrequestsprocessing = 950,
            Processed = 900,
            Exceptions = 1000,
            VerificationVerificationPreprocessing = 2001,
            VerificationVerificationPostprocessing = 2002,
            UnknownStage = -1,
            Failed = -2,
            NextStage = -3
        };

int projId = 0;
int roleId = 0;
int sessionId = 0;
int batchId = 0;
int roleType = 0;
int stationType = 0;
string guid = String.Empty;

//guid = Guid of Project on Abbyy FC

//roleType - https://help.abbyy.com/en-us/flexicapture/12/developer/troletype

//stationType - https://help.abbyy.com/en-us/flexicapture/12/developer/stationtypeenum

sessionId = fcSvcObj.OpenSession(roleType, stationType);
projectId = fcSvcObj.OpenProject(sessionId, guid);
batchId = fcSvcObj.AddNewBatch(sessionId, projectId, batch, 0);

fcSvcObj.ProcessBatch(sessionId, batchId);

Stopwatch stopWatch = new Stopwatch();
currBatch = new Batch();
DateTime startTime = DateTime.Now;
var percentCompleted = 0;
double timeOut = 60;
double elapsedTime = 0.0;
stopWatch.Start();

while (percentCompleted < 100 && elapsedTime < timeOut && currBatch.StageExternalId < (int)eProcessingStageTypes.Recognition)
{
    percentCompleted = fcSvcObj.GetBatchPercentCompleted(batchId);
    currBatch = fcSvcObj.GetBatch(batchId);
    System.Threading.Thread.Sleep(500);
    elapsedTime = DateTime.Now.Subtract(startTime).TotalSeconds;
}

stopWatch.Stop();
stopWatch.Reset();


if (percentCompleted < 100 && elapsedTime > timeOut)
{
    throw new Exception("Timeout Error. Processing was not completed within maximum timeout provided.");
}


//Document has moved to Exceptions

if (currBatch.StageExternalId == (int)eProcessingStageTypes.Exceptions)
{
    throw new Exception("Document moved to exceptions");
}

//Document requires manual verification

if (currBatch.StageExternalId == (int)eProcessingStageTypes.Verification || currBatch.StageExternalId == (int)eProcessingStageTypes.DataVerification)
{
    TaskList tasks = fcSvcObj.GetAvailableTasks(sessionId, projId, 500, false);
    int taskId = tasks.Where(task => task.BatchId == batchId).FirstOrDefault().Id;

    // Generate Verification URL
    string verificationUrl = "http://servername/FlexiCapture12/Verification/Verify?projectId=<pid>&roleId=<rid>&taskId=<tid>&returnTo=DeadEnd&mode=mini";
    verificationUrl.Replace("<pid>",projectId).Replace("<rid>",roleId).Replace("<tid",taskId);

}

// Document is ready for export

if (currBatch.StageExternalId == (int)eProcessingStageTypes.Processed)
{
    //Code to Export Documents
}

发布后,您可以导航到 Abbyy 上的 Web 验证站以执行手动验证。验证URL可以在上面的代码中生成。

验证后,文件已准备好导出,您可以使用以下代码执行文件导出。

您需要保存sessionIdbatchId从处理的第一部分导出文档。您也可以使用新会话,但请确保在流程的第一部分关闭会话。

string outputFolderPath = "DestinationFolder";
bool isBatchOpen = fcSvcObj.OpenBatch(sessionId, batchId);

if (isBatchOpen)
{
    documents documents = fcSvcObj.GetDocuments(sessionId, batchId);

    if (documents == null) return;

    foreach (Document document in documents)
    {
        if (document.Id > 0)
        {
            fileNames fns = fcSvcObj.GetDocumentResultsList(sessionId, batchId, document.Id);

            if (fns != null)
            {
                foreach (string fn in fns)
                {

                    FCWebSvc.File file = fcSvcObj.LoadDocumentResult(sessionId, batchId, document.Id, fn);

                    System.IO.File.WriteAllBytes(outputFolderPath + Path.GetFileName(fn), file.Bytes);
                }
            }
        }
    }
}
于 2020-04-15T09:10:29.430 回答