我正在做一个项目,用ABBYYFC12捕获和归档文档。有一个要求,以建立一个导出连接器,以OpenText的数字管理系统。此连接器应该有自己的接口来连接到项目,并将ABBYY中的字段映射到OpenText DMS上的对应字段,然后保存此配置。
我浏览了ABBYY FC开发人员指南,发现了一个使用ABBYY FC web API的示例,它工作得很好。但在这种情况下,工作流将是无人参与的,所有阶段都将通过API执行。
有没有人可以帮我构建一个导出连接器,以供有人参与使用?
我希望我的问题清楚了!
提前谢谢。
发布于 2020-04-15 17:10:29
您可以使用Abbyy FC Web API来实现同样的功能。您必须在Simple工作流模式下设置项目。
生成sessionId
和batchId
并使用Web API将文档上传到Abbyy后,您可以使用以下代码识别文档并获取nextstage
和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可以在上面的代码中生成。
验证完成后,文档已准备好导出,您可以使用以下代码执行文档导出。
您需要保存处理的第一部分中的sessionId
和batchId
,才能导出文档。您也可以使用新会话,但请确保在该过程的第一部分关闭该会话。
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);
}
}
}
}
}
https://stackoverflow.com/questions/58543025
复制相似问题