public async Task Collect_Images_With_Confidence_Greater_Than_950_240dpi_tif() { // Arrange const int jobId = 5830013; batches = new List<OcrBatch>(); batchesExtra = new List<OcrBatch>(); var VouchersPath = Path.Combine(VouchersBasePath, dpi_240_tif); var batch1 = new OcrBatch { JobIdentifier = jobId.ToString(), Vouchers = new List<OcrVoucher>() }; GetAllTestVouchers(batch1, Path.Combine(VouchersPath, Checks), 0, 200); batches.Add(batch1); configuration.MaxProcessorCount = 2; configuration.FileType = "TIF"; configuration.StickyChannelTimeout = 200; var a2IaService = new A2iAStickyConnectionService(engine1, configuration); try { a2IaService.Initialise(); a2IaService.BatchComplete += BatchCompleteHandler950; // Act foreach (var batch in batches) { a2IaService.ProcessBatch(batch); } Thread.Sleep(configuration.StickyChannelTimeout + 5000); } finally { a2IaService.Shutdown(); } // Assert var resultFile = Path.Combine(ResultPath, ResultFilename); var batchCount = 1; foreach (var batch in batches) { batchCount += batch.Vouchers.Count(); } var results = new string[batchCount]; var index = 0; results[index++] = "Voucher Id, Amount, Score"; foreach (var batch in batches) { foreach (var voucher in batch.Vouchers) { results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score); } } File.WriteAllLines(resultFile, results); a2IaService.Shutdown(); a2IaService.BatchComplete -= BatchCompleteHandler950; }
public async Task Execute_Two_Instances_Of_Wrapper() { // Arrange var jobId = 5830013; batches = new List<OcrBatch>(); const string VouchersPath = VouchersBasePath; var voucherCount = 0; const int voucherIncrement = 100; for (int i = 0; i < 2; i++) { var batch = new OcrBatch { JobIdentifier = jobId++.ToString(), Vouchers = new List<OcrVoucher>() }; GetAllTestVouchers(batch, Path.Combine(VouchersPath, Checks), voucherCount, voucherCount + voucherIncrement); voucherCount += voucherIncrement; batches.Add(batch); } configuration.MaxProcessorCount = 2; configuration.FileType = "TIF"; configuration.StickyChannelTimeout = 200; var a2IaService1 = new A2iAStickyConnectionService(engine1, configuration); //var a2IaService2 = new A2iAStickyConnectionService(engine1, configuration); try { a2IaService1.Initialise(); //a2IaService2.Initialise(); a2IaService1.BatchComplete += BatchCompleteHandler; //a2IaService2.BatchComplete += BatchCompleteHandler; // Act object lockObject = new object(); lock (lockObject) { Parallel.Invoke(() => a2IaService1.ProcessBatch(batches[0]), () => a2IaService1.ProcessBatch(batches[1])); } //await a2IaService1.ProcessBatchTask(batches[0], false); //await a2IaService2.ProcessBatchTask(batches[1], false); Thread.Sleep(configuration.StickyChannelTimeout + 5000); } finally { a2IaService1.Shutdown(); //a2IaService2.Shutdown(); } // Assert foreach (var batch in batches) { WriteResults(batch.Vouchers); } }
public void Execute_Wrapper_With_Two_Documents_In_Table() { // Arrange var jobId = 5830013; batches = new List<OcrBatch>(); const string VouchersPath = VouchersBasePath; var voucherCount = 0; const int voucherIncrement = 100; for (int i = 0; i < 2; i++) { var batch = new OcrBatch { JobIdentifier = jobId++.ToString(), Vouchers = new List<OcrVoucher>() }; GetAllTestVouchers(batch, Path.Combine(VouchersPath, Checks), voucherCount, voucherCount + voucherIncrement); voucherCount += voucherIncrement; batches.Add(batch); } configuration.MaxProcessorCount = 2; configuration.FileType = "TIF"; configuration.StickyChannelTimeout = 200; var a2IaService1 = new A2iAStickyConnectionService(engine1, configuration); a2IaService1.Initialise(); a2IaService1.BatchComplete += BatchCompleteHandler; // Act a2IaService1.ProcessBatch(batches[0]); a2IaService1.ProcessBatch(batches[1]); Thread.Sleep(configuration.StickyChannelTimeout + 5000); a2IaService1.Shutdown(); // Assert // Results in BatchCompleteHandler }
public async Task A2iABatchPoolService_Test_Async_240dpi_tif_With_Open_Connection() { // Arrange const int jobId = 5830013; batches = new List<OcrBatch>(); batchesExtra = new List<OcrBatch>(); var VouchersPath = Path.Combine(VouchersBasePath, dpi_240_tif); //var directory = Path.Combine(VouchersPath, Checks, "ImageProcessed"); //var files = Directory.EnumerateFiles(directory); //foreach (var file in files) //{ // File.Delete(file); //} var batch1 = new OcrBatch { JobIdentifier = jobId.ToString(), Vouchers = new List<OcrVoucher>() }; //GetAllTestVouchers(batch1, Path.Combine(VouchersPath, Checks)); //VouchersPath = @"C:\Sandbox"; //const string Output = @"Output\"; GetAllTestVouchers(batch1, Path.Combine(VouchersPath, Checks), 0, 42); batches.Add(batch1); configuration.MaxProcessorCount = 2; configuration.FileType = "TIF"; configuration.StickyChannelTimeout = 2000; var a2IaService = new A2iAStickyConnectionService(engine1, configuration); try { a2IaService.Initialise(); a2IaService.BatchComplete += BatchCompleteHandler; // Act Debug.WriteLine("Act"); foreach (var batch in batches) { a2IaService.ProcessBatch(batch); } Debug.WriteLine(string.Format("timer {0}", DateTime.Now.ToString("hh:mm:ss.fff"))); //a2IaService.CloseOcrChannel(); //foreach (var batch in batchesExtra) //{ // a2IaService.ProcessBatch(batch); //} Thread.Sleep(configuration.StickyChannelTimeout + 5000); } finally { a2IaService.Shutdown(); } // Assert var resultFile = Path.Combine(ResultPath, ResultFilename); var batchCount = 1; foreach (var batch in batches) { batchCount += batch.Vouchers.Count(); } var results = new string[batchCount]; var index = 0; results[index++] = "Voucher Id, Amount, Score"; foreach (var batch in batches) { foreach (var voucher in batch.Vouchers) { results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score); } } File.WriteAllLines(resultFile, results); a2IaService.Shutdown(); a2IaService.BatchComplete -= BatchCompleteHandler; }
public async Task A2iABatchPoolService_Test_Async_Multi_100_Batch_4_Images_With_Open_Connection() { // Arrange var jobId = 5830013; batches = new List<OcrBatch>(); const string VouchersPath = VouchersBasePath; var voucherCount = 0; const int voucherIncrement = 4; for (int i = 0; i < 100; i++) { var batch = new OcrBatch { JobIdentifier = jobId++.ToString(), Vouchers = new List<OcrVoucher>() }; GetAllTestVouchers(batch, Path.Combine(VouchersPath, Checks), voucherCount, voucherCount + voucherIncrement); voucherCount += voucherIncrement; batches.Add(batch); } batchesExtra = new List<OcrBatch>(); for (int i = 0; i < 100; i++) { var batch = new OcrBatch { JobIdentifier = jobId++.ToString(), Vouchers = new List<OcrVoucher>() }; GetAllTestVouchers(batch, Path.Combine(VouchersPath, Checks), voucherCount, voucherCount + voucherIncrement); voucherCount += voucherIncrement; batchesExtra.Add(batch); } configuration.MaxProcessorCount = 2; var a2IaService = new A2iAStickyConnectionService(engine1, configuration); try { a2IaService.Initialise(); a2IaService.BatchComplete += BatchCompleteHandler; // Act Debug.WriteLine("Act"); foreach (var batch in batches) { a2IaService.ProcessBatch(batch); } Debug.WriteLine(string.Format("timer {0}", DateTime.Now.ToString("hh:mm:ss.fff"))); //a2IaService.CloseOcrChannel(); //foreach (var batch in batchesExtra) //{ // a2IaService.ProcessBatch(batch); //} Thread.Sleep(configuration.StickyChannelTimeout + 5000); } finally { //a2IaService.CloseOcrChannel(); a2IaService.Shutdown(); } //System.Threading.Thread.Sleep(35000); //foreach (var batch in batchesExtra) //{ // a2IaService.RegisterBatch(batch); //} //Debug.WriteLine("Second Pre Process {0} vouchers queued", a2IaService.voucherQueue.Count); //a2IaService.ProcessVoucherBatchAsync(); //Debug.WriteLine("Second Post Process {0} vouchers queued", a2IaService.voucherQueue.Count); //await a2IaService.WaitResults(); //a2IaService.ReleaseResources(); // Assert var resultFile = Path.Combine(ResultPath, ResultFilename); var batchCount = 1; foreach (var batch in batches) { batchCount += batch.Vouchers.Count(); } var results = new string[batchCount]; var index = 0; results[index++] = "Voucher Id, Amount, Score"; foreach (var batch in batches) { foreach (var voucher in batch.Vouchers) { results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score); } } File.WriteAllLines(resultFile, results); a2IaService.Shutdown(); a2IaService.BatchComplete -= BatchCompleteHandler; }
public void A2iAOcrProcessingService_Test_Credit_Slips() { var batch1 = new OcrBatch { JobIdentifier = "5830015", Vouchers = new List<OcrVoucher>() }; var VouchersPath = Path.Combine(VouchersBasePath, mixed_batch); GetAllTestVouchers(batch1, Path.Combine(VouchersPath, Checks)); configuration.MaxProcessorCount = 2; var a2IaService = new A2iAStickyConnectionService(engine1, configuration); //a2IaService.SetParameters(ParamPath, TableFile, LoadMethod.File); a2IaService.Initialise(); a2IaService.ProcessBatch(batch1); const int confidence = 800; var subset = batch1.Vouchers.Where(v => int.Parse(v.AmountResult.Score) < confidence).ToList(); Debug.WriteLine("{0}/{2} vouchers with confidence less than {1}", subset.Count(), confidence, batch1.Vouchers.Count()); foreach (var voucher in subset) { Debug.WriteLine("v {0,-15}\tamt {1,-25}\tscore {2,-15}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score); } a2IaService.Shutdown(); }