protected override void PreProcessVouchers(A2iAOcrService a2IaOcrService)
 {
     base.PreProcessVouchers(a2IaOcrService);
     if (stickyChannelTimeout == 0) return;
     var timeSpan = (int)TimeSpan.FromMinutes(stickyChannelTimeout).TotalMilliseconds;
     StartStickyConnection(CloseChannel, a2IaOcrService, timeSpan, cancellationTokenSource.Token);
 }
Beispiel #2
0
        protected override void PreProcessVouchers(A2iAOcrService a2IaOcrService)
        {
            base.PreProcessVouchers(a2IaOcrService);
            if (stickyChannelTimeout == 0)
            {
                return;
            }
            var timeSpan = (int)TimeSpan.FromMinutes(stickyChannelTimeout).TotalMilliseconds;

            StartStickyConnection(CloseChannel, a2IaOcrService, timeSpan, cancellationTokenSource.Token);
        }
 private async void StartStickyConnection(Action<A2iAOcrService> action, A2iAOcrService service, int timeout, CancellationToken token)
 {
     if (timeout == 0) return;
     try
     {
         await Task.Delay(timeout, token);
     }
     catch (TaskCanceledException)
     {
     }
     if (!token.IsCancellationRequested) action(service);
 }
Beispiel #4
0
        private void CloseChannel(A2iAOcrService service)
        {
            var timeSpan = (int)TimeSpan.FromMinutes(stickyChannelTimeout).TotalMilliseconds;

            if (batchProcessing)
            {
                StartStickyConnection(CloseChannel, service, timeSpan, cancellationTokenSource.Token);
            }
            else
            {
                service.CloseOcrChannel();
            }
        }
Beispiel #5
0
 private async void StartStickyConnection(Action <A2iAOcrService> action, A2iAOcrService service, int timeout, CancellationToken token)
 {
     if (timeout == 0)
     {
         return;
     }
     try
     {
         await Task.Delay(timeout, token);
     }
     catch (TaskCanceledException)
     {
     }
     if (!token.IsCancellationRequested)
     {
         action(service);
     }
 }
        private void CheckProcessorConfiguration()
        {
            var typeCheck = new Dictionary <VoucherType, int>
            {
                { VoucherType.Credit, configuration.CreditMaxProcessorCount },
                { VoucherType.Debit, configuration.DebitMaxProcessorCount }
            };

            var reConfigure = new Dictionary <VoucherType, Action <int> >
            {
                { VoucherType.Credit, v => configuration.CreditMaxProcessorCount = v },
                { VoucherType.Debit, v => configuration.DebitMaxProcessorCount = v }
            };

            var result = Enum.GetValues(typeof(VoucherType)).Cast <VoucherType>().Sum(voucherType => typeCheck[voucherType]);

            if (!A2iAOcrService.ExceedsMaxProcessors(result))
            {
                return;
            }
            // example credit uses 35 threads
            //         debit  uses  5 threads
            // on a 24 core server with 48 threads, this is fine
            // however if the server only has 4 cores with 8 threads
            // factor = 7 / 40
            // credit = 35 * factor = 6
            // debit = 5 * factor = 1
            if (A2iAOcrService.ProcessorCount < MinimumProcessorCount)
            {
                throw new ApplicationException(string.Format("Processor count of {0} must be at least {1} to use multiple document configurations", A2iAOcrService.ProcessorCount, MinimumProcessorCount));
            }
            var factor = A2iAOcrService.ProcessorCount / result;

            foreach (VoucherType voucherType in Enum.GetValues(typeof(VoucherType)))
            {
                reConfigure[voucherType].Invoke(factor * typeCheck[voucherType]);
            }
        }
 protected virtual void PreProcessVouchers(A2iAOcrService a2IaOcrService)
 {
     a2IaOcrService.OpenOcrChannel();
 }
        //private readonly IA2iaConfiguration configuration;

        public A2iACombinedTableService(API a2IaEngine, IA2iaConfiguration configuration)
        {
            a2iAOcrService = new A2iAOcrService(a2IaEngine, configuration);
        }
 private void CloseChannel(A2iAOcrService service)
 {
     var timeSpan = (int)TimeSpan.FromMinutes(stickyChannelTimeout).TotalMilliseconds;
     if (batchProcessing) StartStickyConnection(CloseChannel, service, timeSpan, cancellationTokenSource.Token);
     else service.CloseOcrChannel();
 }
 protected virtual void PreProcessVouchers(A2iAOcrService a2IaOcrService)
 {
     a2IaOcrService.OpenOcrChannel();
 }
        //private readonly IA2iaConfiguration configuration;

        public A2iACombinedTableService(API a2IaEngine, IA2iaConfiguration configuration)
        {
            a2iAOcrService = new A2iAOcrService(a2IaEngine, configuration);
        }