//public AbbyyRSWrapper addRecords(List<Record> recordsToProceed) //{ // List<InputFile> list = new List<InputFile>(); // foreach (Record record in recordsToProceed) // { // FileContainer fileContainer = new FileContainer(); // fileContainer.FileContents = record.content; // InputFile inputFile = new InputFile(); // inputFile.FileData = fileContainer; // list.Add(inputFile); // } // this.inputFiles = list.ToArray(); // return this; //} //public AbbyyRSWrapper addRecord(Record record) //{ // this.inputFiles = new InputFile[1]; // FileContainer fileContainer = new FileContainer(); // fileContainer.FileContents = record.content; // InputFile inputFile = new InputFile(); // inputFile.FileData = fileContainer; // inputFiles[0] = inputFile; // return this; //} //public void proceedRecordsRecognition() //{ // this.clientObject.Timeout = 60000; // XmlTicket ticket = clientObject.CreateTicket(this.location, this.workFlowName); // ticket.ExportParams.Formats = formats.ToArray(); // ticket.InputFiles = this.inputFiles; // XmlResult xmlResult = clientObject.ProcessTicket(this.location, this.workFlowName, ticket); // if (xmlResult.IsFailed) // { // Console.WriteLine("Recognition failed"); // } // else // { // Console.WriteLine("Recognition passed"); // } //} //public byte[] proceedRecordRecognition() //{ // this.clientObject.Timeout = 60000; // XmlTicket ticket = clientObject.CreateTicket(this.location, this.workFlowName); // ticket.ExportParams.Formats = formats.ToArray(); // ticket.InputFiles = this.inputFiles; // XmlResult xmlResult = clientObject.ProcessTicket(this.location, this.workFlowName, ticket); // if (xmlResult.IsFailed) // { // Console.WriteLine("Recognition failed"); // return null; // } // else // { // Console.WriteLine("Recognition passed"); // byte[] fileContent = xmlResult.JobDocuments[0].OutputDocuments[0].Files[0].FileContents; //СДЕЛАТЬ НОРМАЛЬНО // return fileContent; // } //} public XmlTicket createTicket(ExportSettings es) { try { XmlTicket ticket = clientObject.CreateTicket(this.location, es.workFlowName); List <OutputFormatSettings> formats = new List <OutputFormatSettings>(); formats.Add(es.getFormat()); ticket.ExportParams.Formats = formats.ToArray(); return(ticket); } catch (Exception e) { log.Error(e, "Exception in method 'createTicket' while trying to create ticket with location: '{0}' and workflow name: '{1}'.", new object[] { this.location, es.workFlowName }); return(null); } }
//public bool proceedRecord(AbbyyRSWrapper abbyyRs) //{ // abbyyRs.setTimeout(60000); // InputFile[] inputFiles = getInputFilesFromRecord(this.record.content); // JobDocument[] jd = null; // List<ExportSettings> exportSettingsList = getExportSettings(this.record.workTypeId); // foreach (ExportSettings es in exportSettingsList) // { // XmlTicket ticket = getManager().getAbbyService().createTicket(es); // byte[] recognizedContent = null; // ticket.InputFiles = inputFiles; // jd = abbyyRs.processTicket(ticket, this.record, es.workFlowName); // if (jd == null) return false; // recognizedContent = jd[0].OutputDocuments[0].Files[0].FileContents; // inputFiles = getInputFilesFromRecord(recognizedContent); // if (recognizedContent == null) return false; // this.record.content = recognizedContent; // return true; // } //} public bool proceedRecord(AbbyyRSWrapper abbyyRs) { abbyyRs.setTimeout(60000); List <InputFile[]> inputFiles = getInputFilesFromRecord(this.record.content); JobDocument[] jds = null; List <ExportSettings> exportSettingsList = getExportSettings(this.record.workTypeId); int i = 0; foreach (ExportSettings es in exportSettingsList) { i++; foreach (InputFile[] infile in inputFiles) { XmlTicket ticket = getManager().getAbbyService().createTicket(es); if (ticket == null) { return(false); } ticket.InputFiles = infile; jds = abbyyRs.processTicket(ticket, this.record, es.workFlowName); if (jds == null) { getManager().getOTUtils().incrementIterationsCounter(record, "ABBYY RS Failed to proceed recognition of record content."); return(false); } if (i < exportSettingsList.Count()) { inputFiles = getInputFilesFromJobDocuments(jds); } else { addResultToRecognizedContentList(jds); } } } return(true); }
public JobDocument[] processTicket(XmlTicket t, Record r, string workFlowName) { try { XmlResult xmlResult = clientObject.ProcessTicket(this.location, workFlowName, t); if (xmlResult.IsFailed) { log.Error("Recognition failed for object: '{0}', version: '{1}', work type id: '{1}'.", new object[] { r.objectId, r.versionNum, r.workTypeId }); return(null); } else { log.Info("Recognition succeed for object: '{0}', version: '{1}', work type id: '{1}'.", new object[] { r.objectId, r.versionNum, r.workTypeId }); return(xmlResult.JobDocuments); } } catch (Exception e) { log.Error(e, "Exception in method 'processTicket' while trying to recognize object: '{0}', version: '{1}', using work type with id: '{1}'.", new object[] { r.objectId, r.versionNum, r.workTypeId }); return(null); } }