/// <summary> /// Starts the ranger feeding when ready. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> public void StartRangerFeedingWhenReady( object sender, AxRANGERLib._DRangerEvents_TransportReadyToFeedStateEvent e ) { // only fire this event once batchPage.rangerScanner.TransportReadyToFeedState -= StartRangerFeedingWhenReady; if ( _keepScanning ) { batchPage.rangerScanner.StartFeeding( FeedSource.FeedSourceMainHopper, FeedItemCount.FeedOne ); } }
/// <summary> /// Rangers the scanner_ transport feeding stopped. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> public void rangerScanner_TransportFeedingStopped( object sender, AxRANGERLib._DRangerEvents_TransportFeedingStoppedEvent e ) { System.Diagnostics.Debug.WriteLine( string.Format( "{0} : rangerScanner_TransportFeedingStopped", DateTime.Now.ToString( "o" ) ) ); if ( pnlPromptForUpload.Visibility != Visibility.Visible ) { btnStart.IsEnabled = true; } btnClose.IsEnabled = true; if ( pnlPromptForUpload.Visibility != Visibility.Visible ) { btnStopScanning.IsEnabled = false; } if ( _itemsScanned == 0 ) { // show the Startup Info "Welcome" message if no check images are shown yet if ( lblFront.Visibility != Visibility.Visible ) { lblStartupInfo.Visibility = Visibility.Visible; } // show a "No Items" warning if they clicked Start but no items were scanned, and this is the 2nd+ time they tried if ( !_firstNoItemsWarning ) { lblNoItemsFound.Visibility = Visibility.Visible; } _firstNoItemsWarning = false; } }
/// <summary> /// Rangers the scanner_ transport item in pocket. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> public void rangerScanner_TransportSetItemOutput( object sender, AxRANGERLib._DRangerEvents_TransportSetItemOutputEvent e ) { System.Diagnostics.Debug.WriteLine( string.Format( "{0} : rangerScanner_TransportSetItemOutput", DateTime.Now.ToString( "o" ) ) ); var currentPage = Application.Current.MainWindow.Content; if ( currentPage != this ) { // only accept scans when the scanning page is showing batchPage.micrImage.ClearBuffer(); return; } try { lblStartupInfo.Visibility = Visibility.Collapsed; RockConfig rockConfig = RockConfig.Load(); ScannedDocInfo scannedDoc = new ScannedDocInfo(); // mark it as Upload, but we'll set it to false if anything bad happens before we actually upload scannedDoc.Upload = true; scannedDoc.CurrencyTypeValue = batchPage.SelectedCurrencyValue; scannedDoc.SourceTypeValue = batchPage.SelectedSourceTypeValue; scannedDoc.FrontImageData = GetImageBytesFromRanger( Sides.TransportFront ); if ( rockConfig.EnableRearImage ) { scannedDoc.BackImageData = GetImageBytesFromRanger( Sides.TransportRear ); } if ( scannedDoc.IsCheck ) { string checkMicr = batchPage.rangerScanner.GetMicrText( 1 ); WriteToDebugLog( string.Format( "[{0}] - '{1}'", DateTime.Now.ToString( "o" ), checkMicr ) ); string remainingMicr = checkMicr; string accountNumber = string.Empty; string routingNumber = string.Empty; string checkNumber = string.Empty; // there should always be two transit symbols ('d'). The transit number is between them int transitSymbol1 = remainingMicr.IndexOf( 'd' ); int transitSymbol2 = remainingMicr.LastIndexOf( 'd' ); int transitStart = transitSymbol1 + 1; int transitLength = transitSymbol2 - transitSymbol1 - 1; if ( transitLength > 0 ) { routingNumber = remainingMicr.Substring( transitStart, transitLength ); remainingMicr = remainingMicr.Remove( transitStart - 1, transitLength + 2 ); } // the last 'On-Us' symbol ('c') signifies the end of the account number int lastOnUsPosition = remainingMicr.LastIndexOf( 'c' ); if ( lastOnUsPosition > 0 ) { int accountNumberDigitPosition = lastOnUsPosition - 1; // read all digits to the left of the last 'c' until you run into another 'c' or 'd' while ( accountNumberDigitPosition >= 0 ) { char accountNumberDigit = remainingMicr[accountNumberDigitPosition]; if ( accountNumberDigit == 'c' || accountNumberDigit == 'd' ) { break; } else { accountNumber = accountNumberDigit + accountNumber; accountNumber = accountNumber.Trim(); } accountNumberDigitPosition--; } remainingMicr = remainingMicr.Remove( accountNumberDigitPosition + 1, lastOnUsPosition - accountNumberDigitPosition ); } // any remaining digits that aren't the account number and transit number are probably the check number string[] remainingMicrParts = remainingMicr.Split( new char[] { 'c', ' ' }, StringSplitOptions.RemoveEmptyEntries ); if ( remainingMicrParts.Any() ) { checkNumber = remainingMicrParts.Last(); } scannedDoc.RoutingNumber = routingNumber; scannedDoc.AccountNumber = accountNumber; scannedDoc.CheckNumber = checkNumber; scannedDoc.ScannedCheckMicrData = checkMicr; // look for the "can't read" symbol (or completely blank read ) to detect if the check micr couldn't be read // from http://www.sbulletsupport.com/forum/index.php?topic=172.0 if ( checkMicr.Contains('!') || string.IsNullOrWhiteSpace(checkMicr) ) { scannedDoc.BadMicr = true; scannedDoc.Upload = false; } } ShowScannedDocStatusAndUpload( scannedDoc ); } catch ( Exception ex ) { if ( ex is AggregateException ) { ShowException( ( ex as AggregateException ).Flatten() ); } else { ShowException( ex ); } } }
/// <summary> /// Rangers the scanner_ transport item in pocket. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void rangerScanner_TransportItemInPocket( object sender, AxRANGERLib._DRangerEvents_TransportItemInPocketEvent e ) { BitmapImage bitImageFront = GetCheckImage( Sides.TransportFront ); BitmapImage bitImageBack = GetCheckImage( Sides.TransportRear ); string checkMicr = rangerScanner.GetMicrText( 1 ).Replace( "-", string.Empty ).Replace( "!", string.Empty ).Trim(); string fileName = checkMicr.Replace( " ", "_" ); string[] micrParts = checkMicr.Split( new char[] { 'c', 'd', ' ' }, StringSplitOptions.RemoveEmptyEntries ); string routingNumber = micrParts.Length > 0 ? micrParts[0] : "??"; string accountNumber = micrParts.Length > 1 ? micrParts[1] : "??"; string checkNumber = micrParts.Length > 2 ? micrParts[2] : "??"; ScannedCheckInfo scannedCheck = new ScannedCheckInfo(); scannedCheck.FrontImageData = ( bitImageFront.StreamSource as MemoryStream ).ToArray(); scannedCheck.BackImageData = ( bitImageBack.StreamSource as MemoryStream ).ToArray(); scannedCheck.RoutingNumber = routingNumber; scannedCheck.AccountNumber = accountNumber; scannedCheck.CheckNumber = checkNumber; ScanningPage.ShowCheckInformation( scannedCheck ); if ( ( micrParts.Length < 3 ) || routingNumber.Length != 9 ) { ScanningPage.lblScanWarning.Visibility = Visibility.Visible; rangerScanner.StopFeeding(); } else { ScanningPage.lblScanWarning.Visibility = Visibility.Collapsed; ScannedCheckList.Enqueue( scannedCheck ); } }
/// <summary> /// Rangers the scanner_ transport feeding stopped. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> public void rangerScanner_TransportFeedingStopped( object sender, AxRANGERLib._DRangerEvents_TransportFeedingStoppedEvent e ) { RangerFeedingStoppedReasons rangerFeedingStoppedReason = (RangerFeedingStoppedReasons)e.reason; System.Diagnostics.Debug.WriteLine( string.Format( "{0} : rangerScanner_TransportFeedingStopped, reason:", DateTime.Now.ToString( "o" ), rangerFeedingStoppedReason.ConvertToString() ) ); if ( pnlPromptForUpload.Visibility != Visibility.Visible ) { btnStart.IsEnabled = true; } btnClose.IsEnabled = true; if ( pnlPromptForUpload.Visibility != Visibility.Visible ) { btnStopScanning.IsEnabled = false; } if ( _itemsScanned == 0 ) { // show the Startup Info "Welcome" message if no check images are shown yet if ( lblFront.Visibility != Visibility.Visible ) { lblStartupInfo.Visibility = Visibility.Visible; } // show a "No Items" warning if they clicked Start but it stopped because of MainHopperEmpty if ( rangerFeedingStoppedReason == RangerFeedingStoppedReasons.MainHopperEmpty ) { lblNoItemsFound.Visibility = Visibility.Visible; } } }
/// <summary> /// Rangers the new state of the scanner_ transport. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void rangerScanner_TransportNewState( object sender, AxRANGERLib._DRangerEvents_TransportNewStateEvent e ) { mnuConnect.IsEnabled = false; btnScan.Visibility = Visibility.Hidden; ScanningPage.btnDone.Visibility = Visibility.Visible; string status = rangerScanner.GetTransportStateString().Replace( "Transport", string.Empty ).SplitCase(); shapeStatus.ToolTip = status; switch ( (XportStates)e.currentState ) { case XportStates.TransportReadyToFeed: shapeStatus.Fill = new SolidColorBrush( Colors.LimeGreen ); btnScan.Content = "Scan"; if ( ScannerFeederType.Equals( FeederType.MultipleItems ) ) { ScanningPage.btnStartStop.Content = ScanButtonText.Scan; } else { ScanningPage.btnStartStop.Content = ScanButtonText.ScanCheck; } btnScan.Visibility = Visibility.Visible; break; case XportStates.TransportShutDown: shapeStatus.Fill = new SolidColorBrush( Colors.Red ); mnuConnect.IsEnabled = true; break; case XportStates.TransportFeeding: shapeStatus.Fill = new SolidColorBrush( Colors.Blue ); btnScan.Content = "Stop"; ScanningPage.btnStartStop.Content = ScanButtonText.Stop; ScanningPage.btnDone.Visibility = Visibility.Hidden; btnScan.Visibility = Visibility.Visible; break; case XportStates.TransportStartingUp: shapeStatus.Fill = new SolidColorBrush( Colors.Yellow ); break; default: shapeStatus.Fill = new SolidColorBrush( Colors.White ); break; } ScanningPage.shapeStatus.ToolTip = this.shapeStatus.ToolTip; ScanningPage.shapeStatus.Fill = this.shapeStatus.Fill; }
/// <summary> /// Rangers the state of the scanner_ transport change options. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void rangerScanner_TransportChangeOptionsState( object sender, AxRANGERLib._DRangerEvents_TransportChangeOptionsStateEvent e ) { if ( e.previousState == (int)XportStates.TransportStartingUp ) { // enable imaging rangerScanner.SetGenericOption( "OptionalDevices", "NeedImaging", "True" ); // limit splash screen rangerScanner.SetGenericOption( "Ranger GUI", "DisplaySplashOncePerDay", "True" ); // turn on either color, grayscale, or bitonal options depending on selected option rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage1", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage1", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage2", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage2", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage3", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage3", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage4", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage4", "False" ); switch ( RockConfig.Load().ImageColorType ) { case ImageColorType.ImageColorTypeColor: rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage3", "True" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage3", "True" ); break; case ImageColorType.ImageColorTypeGrayscale: rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage2", "True" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage2", "True" ); break; default: rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage1", "True" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage1", "True" ); break; } rangerScanner.EnableOptions(); } }
public void rangerScanner_TransportItemSuspended( object sender, AxRANGERLib._DRangerEvents_TransportItemSuspendedEvent e ) { System.Diagnostics.Debug.WriteLine( string.Format( "{0} : rangerScanner_TransportItemSuspended", DateTime.Now.ToString( "o" ) ) ); }
public void rangerScanner_TransportReadyToSetEndorsement( object sender, AxRANGERLib._DRangerEvents_TransportReadyToSetEndorsementEvent e ) { System.Diagnostics.Debug.WriteLine( string.Format( "{0} : rangerScanner_TransportReadyToSetEndorsement", DateTime.Now.ToString( "o" ) ) ); }
/// <summary> /// Rangers the scanner_ transport item in pocket. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void rangerScanner_TransportSetItemOutput( object sender, AxRANGERLib._DRangerEvents_TransportSetItemOutputEvent e ) { try { RockConfig rockConfig = RockConfig.Load(); ScannedDocInfo scannedDoc = new ScannedDocInfo(); scannedDoc.CurrencyTypeValue = this.SelectedCurrencyValue; scannedDoc.SourceTypeValue = this.SelectedSourceTypeValue; scannedDoc.FrontImageData = GetImageBytesFromRanger( Sides.TransportFront ); if ( rockConfig.EnableRearImage ) { scannedDoc.BackImageData = GetImageBytesFromRanger( Sides.TransportRear ); } if ( scannedDoc.IsCheck ) { string checkMicr = rangerScanner.GetMicrText( 1 ).Trim(); string remainingMicr = checkMicr; string accountNumber = string.Empty; string routingNumber = string.Empty; string checkNumber = string.Empty; // there should always be two transit symbols ('d'). The transit number is between them int transitSymbol1 = remainingMicr.IndexOf( 'd' ); int transitSymbol2 = remainingMicr.LastIndexOf( 'd' ); int transitStart = transitSymbol1 + 1; int transitLength = transitSymbol2 - transitSymbol1 - 1; if ( transitLength > 0 ) { routingNumber = remainingMicr.Substring( transitStart, transitLength ); remainingMicr = remainingMicr.Remove( transitStart - 1, transitLength + 2 ); } // the last 'On-Us' symbol ('c') signifys the end of the account number int lastOnUsPosition = remainingMicr.LastIndexOf( 'c' ); if ( lastOnUsPosition > 0 ) { int accountNumberDigitPosition = lastOnUsPosition - 1; // read all digits to the left of the last 'c' until you run into a non-numeric (except for '!' whichs means invalid) while ( accountNumberDigitPosition >= 0 ) { char accountNumberDigit = remainingMicr[accountNumberDigitPosition]; if ( char.IsNumber( accountNumberDigit ) || accountNumberDigit.Equals( '!' ) ) { accountNumber = accountNumberDigit + accountNumber; } else { break; } accountNumberDigitPosition--; } remainingMicr = remainingMicr.Remove( accountNumberDigitPosition + 1, lastOnUsPosition - accountNumberDigitPosition ); } // any remaining digits that aren't the account number and transit number are probably the check number string[] remainingMicrParts = remainingMicr.Split( new char[] { 'c', ' ' }, StringSplitOptions.RemoveEmptyEntries ); if ( remainingMicrParts.Length == 1 ) { checkNumber = remainingMicrParts[0]; } scannedDoc.RoutingNumber = routingNumber; scannedDoc.AccountNumber = accountNumber; scannedDoc.CheckNumber = checkNumber; if ( routingNumber.Length != 9 || string.IsNullOrEmpty( accountNumber ) || checkMicr.Contains('!') || string.IsNullOrEmpty(checkNumber) ) { scannedDoc.BadMicr = true; rangerScanner.StopFeeding(); } else { if ( IsDuplicateScan( scannedDoc ) ) { scannedDoc.Duplicate = true; rangerScanner.StopFeeding(); rangerScanner.ClearTrack(); } else { ScannedDocList.Enqueue( scannedDoc ); } } } else { ScannedDocList.Enqueue( scannedDoc ); } ScanningPage.ShowScannedDocStatus( scannedDoc ); } catch ( Exception ex ) { if ( ex is AggregateException ) { ScanningPage.ShowException( ( ex as AggregateException ).Flatten() ); } else { ScanningPage.ShowException( ex ); } } }
/// <summary> /// Rangers the new state of the scanner_ transport. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void rangerScanner_TransportNewState( object sender, AxRANGERLib._DRangerEvents_TransportNewStateEvent e ) { mnuConnect.IsEnabled = false; btnScan.Visibility = Visibility.Hidden; ScanningPage.btnSave.Visibility = Visibility.Visible; ScanningPage.btnCancel.Visibility = Visibility.Visible; string status = rangerScanner.GetTransportStateString().Replace( "Transport", string.Empty ).SplitCase(); Color statusColor = Colors.Transparent; switch ( (XportStates)e.currentState ) { case XportStates.TransportReadyToFeed: statusColor = Colors.LimeGreen; btnScan.Content = "Scan"; btnScan.Visibility = Visibility.Visible; break; case XportStates.TransportShutDown: statusColor = Colors.Red; mnuConnect.IsEnabled = true; break; case XportStates.TransportFeeding: statusColor = Colors.Blue; btnScan.Content = "Stop"; btnScan.Visibility = Visibility.Visible; break; case XportStates.TransportStartingUp: statusColor = Colors.Yellow; break; default: statusColor = Colors.White; break; } this.shapeStatus.Fill = new SolidColorBrush( statusColor ); this.shapeStatus.ToolTip = status; ScanningPage.ShowScannerStatus( (XportStates)e.currentState, statusColor, status ); }
/// <summary> /// Rangers the new state of the scanner_ transport. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void rangerScanner_TransportNewState( object sender, AxRANGERLib._DRangerEvents_TransportNewStateEvent e ) { ScanningPage.btnClose.Visibility = Visibility.Visible; string status = rangerScanner.GetTransportStateString().Replace( "Transport", string.Empty ).SplitCase(); Color statusColor = Colors.Transparent; RangerTransportStates xportState = (RangerTransportStates)e.currentState; switch ( xportState ) { case RangerTransportStates.TransportReadyToFeed: statusColor = Colors.LimeGreen; btnScan.Content = "Scan"; break; case RangerTransportStates.TransportShutDown: statusColor = Colors.Red; break; case RangerTransportStates.TransportFeeding: statusColor = Colors.Blue; btnScan.Content = "Stop"; break; case RangerTransportStates.TransportStartingUp: statusColor = Colors.Yellow; break; case RangerTransportStates.TransportExceptionInProgress: statusColor = Colors.Black; break; default: statusColor = Colors.White; break; } this.shapeStatus.Fill = new SolidColorBrush( statusColor ); this.shapeStatus.ToolTip = status; ScanningPage.ShowScannerStatus( xportState, statusColor, status ); }
/// <summary> /// Rangers the state of the scanner_ transport change options. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void rangerScanner_TransportChangeOptionsState( object sender, AxRANGERLib._DRangerEvents_TransportChangeOptionsStateEvent e ) { if ( e.previousState == (int)RangerTransportStates.TransportStartingUp ) { // enable imaging rangerScanner.SetGenericOption( "OptionalDevices", "NeedImaging", "True" ); // limit splash screen rangerScanner.SetGenericOption( "Ranger GUI", "DisplaySplashOncePerDay", "true" ); // turn on either color, grayscale, or bitonal(black and white) options depending on selected option rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage1", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage1", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage2", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage2", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage3", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage3", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage4", "False" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage4", "False" ); var rockConfig = RockConfig.Load(); switch ( rockConfig.ImageColorType ) { case RangerImageColorTypes.ImageColorTypeColor: rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage3", "True" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage3", rockConfig.EnableRearImage.ToTrueFalse() ); break; case RangerImageColorTypes.ImageColorTypeGrayscale: rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage2", "True" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage2", rockConfig.EnableRearImage.ToTrueFalse() ); break; default: rangerScanner.SetGenericOption( "OptionalDevices", "NeedFrontImage1", "True" ); rangerScanner.SetGenericOption( "OptionalDevices", "NeedRearImage1", rockConfig.EnableRearImage.ToTrueFalse() ); break; } rangerScanner.SetGenericOption( "OptionalDevices", "NeedDoubleDocDetection", rockConfig.EnableDoubleDocDetection.ToTrueFalse() ); // Ranger assigns a score of 1-255 on how confident it is that the character was read correctly (1 unsure, 255 very sure) // If the score is less than 255, it will assign another score to its next best guess. // For example, if it pretty sure it was a '3', but it thinks it might have been an '8', it might set the score for '3' as 240, but a score of 150 to '8'. // If the difference (Plurality) between the scores isn't high enough, it will reject the char. rangerScanner.SetDriverOption( "MICR", "Sensitivity", rockConfig.Sensitivity); rangerScanner.SetDriverOption( "MICR", "Plurality", rockConfig.Plurality ); rangerScanner.EnableOptions(); } }
/// <summary> /// Rangers the state of the scanner_ transport ready to feed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> public void rangerScanner_TransportReadyToFeedState( object sender, AxRANGERLib._DRangerEvents_TransportReadyToFeedStateEvent e ) { // remove so we just fire this event once this.BatchPage.rangerScanner.TransportReadyToFeedState -= rangerScanner_TransportReadyToFeedState; this.BatchPage.ScanningPage.StartScanningRanger(); }