Interaction logic for ScanningPage.xaml
Inheritance: System.Windows.Controls.Page
Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BatchPage"/> class.
 /// </summary>
 public BatchPage()
 {
     InitializeComponent();
     ScanningPage        = new ScanningPage(this);
     ScannedCheckList    = new ConcurrentQueue <ScannedCheckInfo>();
     BatchItemDetailPage = new BatchItemDetailPage();
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BatchPage"/> class.
 /// </summary>
 public BatchPage()
 {
     InitializeComponent();
     ScanningPage = new ScanningPage( this );
     ScannedCheckList = new ConcurrentQueue<ScannedCheckInfo>();
     BatchItemDetailPage = new BatchItemDetailPage();
 }
Esempio n. 3
0
        /// <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>
        /// Initializes a new instance of the <see cref="BatchPage" /> class.
        /// </summary>
        /// <param name="loggedInPerson">The logged in person.</param>
        public BatchPage( Person loggedInPerson )
        {
            LoggedInPerson = loggedInPerson;
            InitializeComponent();
            ScanningPage = new ScanningPage( this );
            ScanningPromptPage = new ScanningPromptPage( this );
            ScannedDocList = new ConcurrentQueue<ScannedDocInfo>();
            BatchItemDetailPage = new BatchItemDetailPage();
            FirstPageLoad = true;

            try
            {
                var micrImageHostPage = new MicrImageHostPage();
                this.micrImage = micrImageHostPage.micrImage;
                this.micrImage.MicrDataReceived += micrImage_MicrDataReceived;
            }
            catch
            {
                // intentionally nothing.  means they don't have the MagTek driver
            }

            try
            {
                var rangerScannerHostPage = new RangerScannerHostPage();
                this.rangerScanner = rangerScannerHostPage.rangerScanner;
                this.rangerScanner.TransportNewState += rangerScanner_TransportNewState;
                this.rangerScanner.TransportChangeOptionsState += rangerScanner_TransportChangeOptionsState;
                this.rangerScanner.TransportSetItemOutput += rangerScanner_TransportSetItemOutput;
            }
            catch
            {
                // intentionally nothing.  means they don't have the Ranger driver
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BatchPage" /> class.
        /// </summary>
        /// <param name="loggedInPerson">The logged in person.</param>
        public BatchPage(Person loggedInPerson)
        {
            LoggedInPerson = loggedInPerson;
            InitializeComponent();
            ScanningPage        = new ScanningPage(this);
            ScanningPromptPage  = new ScanningPromptPage(this);
            BatchItemDetailPage = new BatchItemDetailPage();
            FirstPageLoad       = true;

            try
            {
                var micrImageHostPage = new MicrImageHostPage();
                this.micrImage = micrImageHostPage.micrImage;
                this.micrImage.MicrDataReceived += ScanningPage.micrImage_MicrDataReceived;
            }
            catch
            {
                // intentionally nothing.  means they don't have the MagTek driver
            }

            try
            {
                var rangerScannerHostPage = new RangerScannerHostPage();
                this.rangerScanner = rangerScannerHostPage.rangerScanner;

                this.rangerScanner.TransportFeedingState       += ScanningPage.rangerScanner_TransportFeedingState;
                this.rangerScanner.TransportFeedingStopped     += ScanningPage.rangerScanner_TransportFeedingStopped;
                this.rangerScanner.TransportNewItem            += ScanningPage.rangerScanner_TransportNewItem;
                this.rangerScanner.TransportSetItemOutput      += ScanningPage.rangerScanner_TransportSetItemOutput;
                this.rangerScanner.TransportIsDead             += ScanningPage.rangerScanner_TransportIsDead;
                this.rangerScanner.TransportNewState           += rangerScanner_TransportNewState;
                this.rangerScanner.TransportChangeOptionsState += rangerScanner_TransportChangeOptionsState;

                // debug output only
                this.rangerScanner.TransportEnablingOptionsState += rangerScannerHostPage.rangerScanner_TransportEnablingOptionsState;
                this.rangerScanner.TransportExceptionComplete    += rangerScannerHostPage.rangerScanner_TransportExceptionComplete;
                this.rangerScanner.TransportInExceptionState     += rangerScannerHostPage.rangerScanner_TransportInExceptionState;

                this.rangerScanner.TransportItemInPocket          += rangerScannerHostPage.rangerScanner_TransportItemInPocket;
                this.rangerScanner.TransportItemSuspended         += rangerScannerHostPage.rangerScanner_TransportItemSuspended;
                this.rangerScanner.TransportOverrideOptions       += rangerScannerHostPage.rangerScanner_TransportOverrideOptions;
                this.rangerScanner.TransportPassthroughEvent      += rangerScannerHostPage.rangerScanner_TransportPassthroughEvent;
                this.rangerScanner.TransportReadyToFeedState      += rangerScannerHostPage.rangerScanner_TransportReadyToFeedState;
                this.rangerScanner.TransportReadyToSetEndorsement += rangerScannerHostPage.rangerScanner_TransportReadyToSetEndorsement;
                this.rangerScanner.TransportShuttingDownState     += rangerScannerHostPage.rangerScanner_TransportShuttingDownState;
                this.rangerScanner.TransportShutDownState         += rangerScannerHostPage.rangerScanner_TransportShutDownState;
                this.rangerScanner.TransportStartingUpState       += rangerScannerHostPage.rangerScanner_TransportStartingUpState;
                this.rangerScanner.TransportTrackIsClear          += rangerScannerHostPage.rangerScanner_TransportTrackIsClear;
            }
            catch
            {
                // intentionally nothing.  means they don't have the Ranger driver
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BatchPage" /> class.
        /// </summary>
        /// <param name="loggedInPerson">The logged in person.</param>
        public BatchPage( Person loggedInPerson )
        {
            LoggedInPerson = loggedInPerson;
            InitializeComponent();
            ScanningPage = new ScanningPage( this );
            ScanningPromptPage = new ScanningPromptPage( this );
            BatchItemDetailPage = new BatchItemDetailPage();
            FirstPageLoad = true;

            try
            {
                var micrImageHostPage = new MicrImageHostPage();
                this.micrImage = micrImageHostPage.micrImage;
                this.micrImage.MicrDataReceived += ScanningPage.micrImage_MicrDataReceived;
            }
            catch
            {
                // intentionally nothing.  means they don't have the MagTek driver
            }

            try
            {
                var rangerScannerHostPage = new RangerScannerHostPage();
                this.rangerScanner = rangerScannerHostPage.rangerScanner;

                this.rangerScanner.TransportFeedingState += ScanningPage.rangerScanner_TransportFeedingState;
                this.rangerScanner.TransportFeedingStopped += ScanningPage.rangerScanner_TransportFeedingStopped;
                this.rangerScanner.TransportNewItem += ScanningPage.rangerScanner_TransportNewItem;
                this.rangerScanner.TransportSetItemOutput += ScanningPage.rangerScanner_TransportSetItemOutput;
                this.rangerScanner.TransportIsDead += ScanningPage.rangerScanner_TransportIsDead;
                this.rangerScanner.TransportNewState += rangerScanner_TransportNewState;
                this.rangerScanner.TransportChangeOptionsState += rangerScanner_TransportChangeOptionsState;

                // debug output only
                this.rangerScanner.TransportEnablingOptionsState += rangerScannerHostPage.rangerScanner_TransportEnablingOptionsState;
                this.rangerScanner.TransportExceptionComplete += rangerScannerHostPage.rangerScanner_TransportExceptionComplete;
                this.rangerScanner.TransportInExceptionState += rangerScannerHostPage.rangerScanner_TransportInExceptionState;

                this.rangerScanner.TransportItemInPocket += rangerScannerHostPage.rangerScanner_TransportItemInPocket;
                this.rangerScanner.TransportItemSuspended += rangerScannerHostPage.rangerScanner_TransportItemSuspended;
                this.rangerScanner.TransportOverrideOptions += rangerScannerHostPage.rangerScanner_TransportOverrideOptions;
                this.rangerScanner.TransportPassthroughEvent += rangerScannerHostPage.rangerScanner_TransportPassthroughEvent;
                this.rangerScanner.TransportReadyToFeedState += rangerScannerHostPage.rangerScanner_TransportReadyToFeedState;
                this.rangerScanner.TransportReadyToSetEndorsement += rangerScannerHostPage.rangerScanner_TransportReadyToSetEndorsement;
                this.rangerScanner.TransportShuttingDownState += rangerScannerHostPage.rangerScanner_TransportShuttingDownState;
                this.rangerScanner.TransportShutDownState += rangerScannerHostPage.rangerScanner_TransportShutDownState;
                this.rangerScanner.TransportStartingUpState += rangerScannerHostPage.rangerScanner_TransportStartingUpState;
                this.rangerScanner.TransportTrackIsClear += rangerScannerHostPage.rangerScanner_TransportTrackIsClear;
            }
            catch
            {
                // intentionally nothing.  means they don't have the Ranger driver
            }
        }
Esempio n. 7
0
        /// <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);
        }
Esempio n. 8
0
        /// <summary>
        /// Updates the scanner status for magtek.
        /// </summary>
        /// <param name="connected">if set to <c>true</c> [connected].</param>
        private void UpdateScannerStatusForMagtek(bool connected)
        {
            string status;
            Color  statusColor;

            if (connected)
            {
                statusColor = Colors.LimeGreen;
                status      = "Connected";
            }
            else
            {
                statusColor = Colors.Red;
                status      = "Disconnected";
            }

            this.shapeStatus.ToolTip = status;
            this.shapeStatus.Fill    = new SolidColorBrush(statusColor);

            ScanningPage.ShowScannerStatus(connected ? RangerTransportStates.TransportReadyToFeed : RangerTransportStates.TransportShutDown, statusColor, status);
        }
Esempio n. 9
0
        /// <summary>
        /// Handles the MicrDataReceived event of the micrImage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void micrImage_MicrDataReceived(object sender, System.EventArgs e)
        {
            object dummy = null;

            string imagePath  = string.Empty;
            string imageIndex = string.Empty;
            string statusMsg  = string.Empty;

            ScannedCheckInfo scannedCheck = null;

            if (ScanningPage.ExpectingMagTekBackScan)
            {
                scannedCheck = ScannedCheckList.Last();
            }
            else
            {
                scannedCheck = new ScannedCheckInfo();

                // from MagTek Sample Code
                scannedCheck.RoutingNumber = micrImage.FindElement(0, "T", 0, "TT", ref dummy);
                scannedCheck.AccountNumber = micrImage.FindElement(0, "TT", 0, "A", ref dummy);
                scannedCheck.CheckNumber   = micrImage.FindElement(0, "A", 0, "12", ref dummy);
            }

            imagePath = Path.GetTempPath();
            string checkImageFileName = Path.Combine(imagePath, string.Format("check_{0}_{1}_{2}.tif", scannedCheck.RoutingNumber, scannedCheck.AccountNumber, scannedCheck.CheckNumber).Replace('?', 'X'));

            if (File.Exists(checkImageFileName))
            {
                File.Delete(checkImageFileName);
            }

            try
            {
                micrImage.TransmitCurrentImage(checkImageFileName, ref statusMsg);
                if (!File.Exists(checkImageFileName))
                {
                    throw new Exception("Unable to retrieve image");
                }
                else
                {
                    if (ScanningPage.ExpectingMagTekBackScan)
                    {
                        scannedCheck.BackImageData = File.ReadAllBytes(checkImageFileName);
                    }
                    else
                    {
                        scannedCheck.FrontImageData = File.ReadAllBytes(checkImageFileName);
                    }

                    ScanningPage.ShowCheckInformation(scannedCheck);

                    if (scannedCheck.RoutingNumber.Length != 9)
                    {
                        ScanningPage.lblScanWarning.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        ScanningPage.lblScanWarning.Visibility = Visibility.Collapsed;
                        ScannedCheckList.Enqueue(scannedCheck);
                    }

                    File.Delete(checkImageFileName);
                }
            }
            finally
            {
                micrImage.ClearBuffer();
            }
        }