Exemplo n.º 1
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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 3
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);
 }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 6
0
        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]);
            }
        }
Exemplo n.º 7
0
 protected virtual void PreProcessVouchers(A2iAOcrService a2IaOcrService)
 {
     a2IaOcrService.OpenOcrChannel();
 }
Exemplo n.º 8
0
        //private readonly IA2iaConfiguration configuration;

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

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