Load() public static method

Loads this instance.
public static Load ( ) : RockConfig
return RockConfig
Example #1
0
        /// <summary>
        /// Shows the upload warnings.
        /// </summary>
        private void ShowUploadWarnings(ScannedDocInfo scannedDocInfo)
        {
            var rockConfig = RockConfig.Load();

            ConfirmUploadBadScannedDoc = scannedDocInfo;
            lblScanCheckWarningDuplicate.Visibility = scannedDocInfo.Duplicate ? Visibility.Visible : Visibility.Collapsed;
            lblScanCheckWarningBadMicr.Visibility   = scannedDocInfo.BadMicr ? Visibility.Visible : Visibility.Collapsed;
            lblScanItemUploadSuccess.Visibility     = Visibility.Collapsed;
            pnlPromptForUpload.Visibility           = scannedDocInfo.Duplicate || scannedDocInfo.BadMicr ? Visibility.Visible : Visibility.Collapsed;
            btnStart.IsEnabled        = false;
            btnStopScanning.IsEnabled = true;
        }
Example #2
0
        /// <summary>
        /// Updates the UI.
        /// </summary>
        /// <param name="scanningChecks">if set to <c>true</c> [scanning checks].</param>
        private void UpdateUI(bool scanningChecks)
        {
            RockConfig rockConfig = RockConfig.Load();
            bool       supportsDoubleDocDetection;

            if (rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.MagTekImageSafe || rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.MICRImageRS232)
            {
                this.chkPromptToScanRearImage.Visibility = Visibility.Visible;
                supportsDoubleDocDetection = false;
            }
            else
            {
                this.chkPromptToScanRearImage.Visibility = Visibility.Hidden;
                supportsDoubleDocDetection = true;
            }

            if (scanningChecks || supportsDoubleDocDetection)
            {
                this.spRangerOrCheckOptions.Visibility = Visibility.Visible;
            }
            else
            {
                this.spRangerOrCheckOptions.Visibility = Visibility.Collapsed;
            }

            if (supportsDoubleDocDetection)
            {
                chkRangerDoubleDocDetection.Visibility = Visibility.Visible;
            }
            else
            {
                chkRangerDoubleDocDetection.Visibility = Visibility.Collapsed;
            }


            chkRangerDoubleDocDetection.IsChecked = scanningChecks;
            chkEnableSmartScan.Visibility         = scanningChecks ? Visibility.Visible : Visibility.Collapsed;

            radDoubleSided.IsChecked           = rockConfig.EnableRearImage;
            radSingleSided.IsChecked           = !rockConfig.EnableRearImage;
            chkPromptToScanRearImage.IsChecked = rockConfig.PromptToScanRearImage;
            if (rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.RangerApi)
            {
                spRangerScanSettings.Visibility = Visibility.Visible;
                spMagTekScanSettings.Visibility = Visibility.Collapsed;
            }
            else
            {
                spRangerScanSettings.Visibility = Visibility.Collapsed;
                spMagTekScanSettings.Visibility = Visibility.Visible;
            }
        }
Example #3
0
        /// <summary>
        /// Handles the Loaded event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (RockConfig.Load().ScannerInterfaceType == RockConfig.InterfaceType.RangerApi)
            {
                btnStartStop.Visibility = Visibility.Visible;
            }
            else
            {
                btnStartStop.Visibility = Visibility.Hidden;
            }

            ShowStartupPage();
        }
Example #4
0
        /// <summary>
        /// Updates the scan instructions.
        /// </summary>
        private void UpdateScanInstructions()
        {
            bool scanningChecks = RockConfig.Load().TenderTypeValueGuid.AsGuid() == Rock.SystemGuid.DefinedValue.CURRENCY_TYPE_CHECK.AsGuid();

            if (RockConfig.Load().ScannerInterfaceType == RockConfig.InterfaceType.MICRImageRS232)
            {
                lblScanInstructions.Content = string.Format("INFO: Ready to scan next {0}.", scanningChecks ? "check" : "item");
            }
            else
            {
                lblScanInstructions.Content = string.Format("INFO: Insert {0} into the scanner to continue.", scanningChecks ? "a check" : "an item");
            }
        }
Example #5
0
        /// <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();
            }
        }
Example #6
0
        /// <summary>
        /// Handles the Loaded event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            HideLoginWarning(null, null);
            RockConfig rockConfig = RockConfig.Load();

            bool promptForUrl = string.IsNullOrWhiteSpace(rockConfig.RockBaseUrl) || ForceRockURLVisible;

            lblRockUrl.Visibility = promptForUrl ? Visibility.Visible : Visibility.Collapsed;
            txtRockUrl.Visibility = promptForUrl ? Visibility.Visible : Visibility.Collapsed;

            txtRockUrl.Text      = rockConfig.RockBaseUrl;
            txtUsername.Text     = rockConfig.Username;
            txtPassword.Password = rockConfig.Password;
        }
Example #7
0
 /// <summary>
 /// Silently tries to log the exception to the server's exception log service
 /// </summary>
 /// <param name="ex">The ex.</param>
 public static void LogException(Exception ex)
 {
     try
     {
         RockConfig     config = RockConfig.Load();
         RockRestClient client = new RockRestClient(config.RockBaseUrl);
         client.Login(config.Username, config.Password);
         client.PostData <Exception>("api/ExceptionLogs/LogException", ex);
     }
     catch
     {
         // intentionally ignore if we can't log the exception to the server
     }
 }
Example #8
0
        /// <summary>
        /// Adds the scanned doc to a history of scanned docs, and shows info and status.
        /// </summary>
        /// <param name="scannedDocInfo">The scanned check info.</param>
        public void ShowScannedDocStatus(ScannedDocInfo scannedDocInfo)
        {
            lblExceptions.Visibility = Visibility.Collapsed;
            CurrentScannedDocInfo    = scannedDocInfo;
            if (!ScannedDocInfoHistory.Contains(scannedDocInfo))
            {
                ScannedDocInfoHistory.Add(scannedDocInfo);
            }

            if (ScannedDocInfoHistory.Count > 1)
            {
                gScannedChecksNavigation.Visibility = Visibility.Visible;
            }
            else
            {
                gScannedChecksNavigation.Visibility = Visibility.Collapsed;
            }

            NavigateTo(ScannedDocInfoHistory.Count - 1);

            ExpectingMagTekBackScan = false;

            var rockConfig = RockConfig.Load();

            // If we have the front image and valid routing number, but not the back (and it's a MagTek).  Inform them to scan the back;
            if (rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.MICRImageRS232)
            {
                if ((imgFront.Source != null) && (imgBack.Source == null))
                {
                    if (rockConfig.PromptToScanRearImage)
                    {
                        if (scannedDocInfo.IsCheck && (scannedDocInfo.RoutingNumber.Length != 9 || string.IsNullOrWhiteSpace(scannedDocInfo.AccountNumber)))
                        {
                            ExpectingMagTekBackScan     = false;
                            lblScanInstructions.Content = "INFO: Ready to re-scan check";
                        }
                        else
                        {
                            ExpectingMagTekBackScan     = true;
                            lblScanInstructions.Content = string.Format("INFO: Insert the {0} again facing the other direction to get an image of the back.", scannedDocInfo.IsCheck ? "check" : "item");
                        }
                    }
                }
                else
                {
                    UpdateScanInstructions();
                }
            }
        }
Example #9
0
        /// <summary>
        /// Handles the Click event of the btnScan control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnScan_Click(object sender, RoutedEventArgs e)
        {
            var rockConfig = RockConfig.Load();

            // make sure we can connect (
            // NOTE: If ranger is powered down after the app starts, it might report that is is connected.  We'll catch that later when they actually start scanning
            if (ConnectToScanner())
            {
                this.NavigationService.Navigate(this.ScanningPromptPage);
            }
            else
            {
                MessageBox.Show(string.Format("Unable to connect to {0} scanner. Verify that the scanner is turned on and plugged in", rockConfig.ScannerInterfaceType.ConvertToString().SplitCase()));
            }
        }
Example #10
0
        /// <summary>
        /// Initializes the RestClient for Uploads and loads any data that is needed for the scan session (if it isn't already initialized)
        /// </summary>
        /// <returns></returns>
        public static RockRestClient EnsureUploadScanRestClient()
        {
            if (UploadScannedItemClient == null)
            {
                RockConfig rockConfig = RockConfig.Load();
                UploadScannedItemClient = new RockRestClient(rockConfig.RockBaseUrl);
                UploadScannedItemClient.Login(rockConfig.Username, rockConfig.Password);
            }

            if (binaryFileTypeContribution == null || transactionTypeValueContribution == null)
            {
                binaryFileTypeContribution       = UploadScannedItemClient.GetDataByGuid <BinaryFileType>("api/BinaryFileTypes", new Guid(Rock.Client.SystemGuid.BinaryFiletype.CONTRIBUTION_IMAGE));
                transactionTypeValueContribution = UploadScannedItemClient.GetDataByGuid <DefinedValue>("api/DefinedValues", new Guid(Rock.Client.SystemGuid.DefinedValue.TRANSACTION_TYPE_CONTRIBUTION));
            }

            return(UploadScannedItemClient);
        }
Example #11
0
        /// <summary>
        /// Loads the financial accounts.
        /// </summary>
        /// <param name="campusId">The campus identifier.</param>
        private void LoadFinancialAccounts(int?campusId)
        {
            var client     = this.RestClient;
            var rockConfig = RockConfig.Load();

            _allAccounts = client.GetData <List <FinancialAccount> >("api/FinancialAccounts?$filter=IsActive eq true");

            if (campusId.HasValue)
            {
                _allAccounts = _allAccounts.Where(a => !a.CampusId.HasValue || a.CampusId.Value == campusId).ToList();
            }

            _displayAccounts = new ObservableCollection <DisplayAccountModel>(_allAccounts.OrderBy(a => a.Order).ThenBy(a => a.Name).Where(a => a.ParentAccountId == null).Select(a => new DisplayAccountModel(a, _allAccounts, rockConfig.SelectedAccountForAmountsIds)).ToList());

            tvAccountsForBatches.ItemsSource = null;
            tvAccountsForBatches.Items.Clear();
            tvAccountsForBatches.ItemsSource = _displayAccounts;
        }
Example #12
0
        /// <summary>
        /// Handles the Click event of the btnNext control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            var rockConfig = RockConfig.Load();

            var selectedTenderButton = spTenderButtons.Children.OfType <ToggleButton>().Where(a => a.IsChecked == true).FirstOrDefault();

            if (selectedTenderButton != null)
            {
                rockConfig.TenderTypeValueGuid = selectedTenderButton.Tag.ToString();
            }

            rockConfig.EnableRearImage          = radDoubleSided.IsChecked == true;
            rockConfig.PromptToScanRearImage    = chkPromptToScanRearImage.IsChecked == true;
            rockConfig.EnableDoubleDocDetection = chkDoubleDocDetection.IsChecked == true;

            rockConfig.Save();

            // restart the scanner so that options will be reloaded
            if (rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.RangerApi)
            {
                if (this.BatchPage.rangerScanner != null)
                {
                    this.BatchPage.rangerScanner.ShutDown();
                    this.BatchPage.rangerScanner.StartUp();

                    this.BatchPage.rangerScanner.TransportReadyToFeedState += rangerScanner_TransportReadyToFeedState;
                }
                else
                {
                    lblScannerDriverError.Visibility = Visibility.Visible;
                    return;
                }
            }
            else
            {
                if (this.BatchPage.micrImage == null)
                {
                    lblScannerDriverError.Visibility = Visibility.Visible;
                    return;
                }
            }

            this.NavigationService.Navigate(this.BatchPage.ScanningPage);
        }
        /// <summary>
        /// Handles the Loaded event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            lblScannerDriverError.Visibility = Visibility.Collapsed;
            RockConfig rockConfig = RockConfig.Load();

            spTenderButtons.Children.Clear();
            foreach (var currency in this.BatchPage.CurrencyValueList.OrderBy(a => a.Order).ThenBy(a => a.Value))
            {
                ToggleButton btnToggle = new ToggleButton();
                btnToggle.Margin    = new Thickness(0, 12, 0, 0);
                btnToggle.Padding   = new Thickness(0, 12, 0, 8);
                btnToggle.Style     = this.FindResource("toggleButtonStyle") as Style;
                btnToggle.Content   = currency.Value;
                btnToggle.Tag       = currency.Guid;
                btnToggle.IsChecked = rockConfig.TenderTypeValueGuid.AsGuid() == currency.Guid;
                btnToggle.Click    += btnToggle_Click;

                spTenderButtons.Children.Add(btnToggle);
            }

            var scanningChecks = rockConfig.TenderTypeValueGuid.AsGuid() == Rock.Client.SystemGuid.DefinedValue.CURRENCY_TYPE_CHECK.AsGuid();

            chkDoubleDocDetection.IsChecked = scanningChecks;
            chkEnableSmartScan.Visibility   = scanningChecks ? Visibility.Visible : Visibility.Collapsed;

            radDoubleSided.IsChecked           = rockConfig.EnableRearImage;
            radSingleSided.IsChecked           = !rockConfig.EnableRearImage;
            chkPromptToScanRearImage.IsChecked = rockConfig.PromptToScanRearImage;
            if (rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.RangerApi)
            {
                spRangerScanSettings.Visibility = Visibility.Visible;
                spMagTekScanSettings.Visibility = Visibility.Collapsed;
            }
            else
            {
                spRangerScanSettings.Visibility = Visibility.Collapsed;
                spMagTekScanSettings.Visibility = Visibility.Visible;
            }

            cboTransactionSourceType.DisplayMemberPath = "Value";
            cboTransactionSourceType.ItemsSource       = this.BatchPage.SourceTypeValueListSelectable.OrderBy(a => a.Order).ThenBy(a => a.Value).ToList();
            cboTransactionSourceType.SelectedItem      = (cboTransactionSourceType.ItemsSource as List <DefinedValue>).FirstOrDefault(a => a.Guid == rockConfig.SourceTypeValueGuid.AsGuid());
        }
Example #14
0
        /// <summary>
        /// Updates the batch UI.
        /// </summary>
        /// <param name="selectedBatch">The selected batch.</param>
        private void UpdateBatchUI(FinancialBatch selectedBatch)
        {
            if (selectedBatch == null)
            {
                HideBatch();
                return;
            }
            else
            {
                ShowBatch(false);
            }

            RockConfig     rockConfig = RockConfig.Load();
            RockRestClient client     = new RockRestClient(rockConfig.RockBaseUrl);

            client.Login(rockConfig.Username, rockConfig.Password);
            SelectedFinancialBatchId     = selectedBatch.Id;
            lblBatchNameReadOnly.Content = selectedBatch.Name;

            lblBatchCampusReadOnly.Content        = selectedBatch.CampusId.HasValue ? client.GetData <Campus>(string.Format("api/Campus/{0}", selectedBatch.CampusId)).Name : None.Text;
            lblBatchDateReadOnly.Content          = selectedBatch.BatchStartDateTime.Value.ToString("d");
            lblBatchCreatedByReadOnly.Content     = client.GetData <Person>(string.Format("api/People/{0}", selectedBatch.CreatedByPersonId)).FullName;
            lblBatchControlAmountReadOnly.Content = selectedBatch.ControlAmount.ToString("F");

            txtBatchName.Text = selectedBatch.Name;
            if (selectedBatch.CampusId.HasValue)
            {
                cbCampus.SelectedValue = selectedBatch.CampusId;
            }
            else
            {
                cbCampus.SelectedValue = 0;
            }

            dpBatchDate.SelectedDate = selectedBatch.BatchStartDateTime;
            lblCreatedBy.Content     = lblBatchCreatedByReadOnly.Content as string;
            txtControlAmount.Text    = selectedBatch.ControlAmount.ToString("F");

            List <FinancialTransaction> transactions = client.GetData <List <FinancialTransaction> >("api/FinancialTransactions/", string.Format("BatchId eq {0}", selectedBatch.Id));

            grdBatchItems.DataContext = transactions.OrderByDescending(a => a.TransactionDateTime);
        }
Example #15
0
        /// <summary>
        /// Loads the financial batches grid.
        /// </summary>
        public void LoadFinancialBatchesGrid()
        {
            RockConfig     config = RockConfig.Load();
            RockRestClient client = new RockRestClient(config.RockBaseUrl);

            client.Login(config.Username, config.Password);
            List <FinancialBatch> pendingBatches = client.GetDataByEnum <List <FinancialBatch> >("api/FinancialBatches", "Status", BatchStatus.Pending);

            // Order by Batch Id starting with most recent
            grdBatches.DataContext = pendingBatches.OrderByDescending(a => a.Id);
            if (pendingBatches.Count > 0)
            {
                if (SelectedFinancialBatch != null)
                {
                    // try to set the selected batch in the grid to our current batch (if it still exists in the database)
                    grdBatches.SelectedValue = pendingBatches.FirstOrDefault(a => a.Id.Equals(SelectedFinancialBatch.Id));
                }

                // if there still isn't a selected batch, set it to the first one
                if (grdBatches.SelectedValue == null)
                {
                    grdBatches.SelectedIndex = 0;
                }
            }
            else
            {
                SelectedFinancialBatch = null;
            }

            bool startWithNewBatch = !pendingBatches.Any();

            if (startWithNewBatch)
            {
                // don't let them start without having at least one batch, so just show the list with the Add button
                HideBatch();
            }
            else
            {
                gBatchDetailList.Visibility = Visibility.Visible;
            }
        }
Example #16
0
        /// <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();
            }
        }
        /// <summary>
        /// Handles the Loaded event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var images = FinancialTransactionImages.OrderBy(a => a.Order).ToList();

            RockConfig     config = RockConfig.Load();
            RockRestClient client = new RockRestClient(config.RockBaseUrl);

            client.Login(config.Username, config.Password);

            if (images.Count > 0)
            {
                var imageUrl   = string.Format("{0}GetImage.ashx?Id={1}", config.RockBaseUrl.EnsureTrailingForwardslash(), images[0].BinaryFileId);
                var imageBytes = client.DownloadData(imageUrl);

                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = new MemoryStream(imageBytes);
                bitmapImage.EndInit();
                imgFront.Source = bitmapImage;
            }
            else
            {
                imgFront.Source = null;
            }

            if (images.Count > 1)
            {
                var imageUrl   = string.Format("{0}GetImage.ashx?Id={1}", config.RockBaseUrl.EnsureTrailingForwardslash(), images[1].BinaryFileId);
                var imageBytes = client.DownloadData(imageUrl);

                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = new MemoryStream(imageBytes);
                bitmapImage.EndInit();
                imgBack.Source = bitmapImage;
            }
            else
            {
                imgBack.Source = null;
            }
        }
Example #18
0
        /// <summary>
        /// Loads the combo boxes.
        /// </summary>
        private void LoadComboBoxes()
        {
            RockConfig     rockConfig = RockConfig.Load();
            RockRestClient client     = new RockRestClient(rockConfig.RockBaseUrl);

            client.Login(rockConfig.Username, rockConfig.Password);
            List <Campus> campusList = client.GetData <List <Campus> >("api/Campus");

            cbCampus.SelectedValuePath = "Id";
            cbCampus.DisplayMemberPath = "Name";
            cbCampus.Items.Clear();
            cbCampus.Items.Add(new Campus {
                Id = None.Id, Name = None.Text
            });
            foreach (var campus in campusList.OrderBy(a => a.Name))
            {
                cbCampus.Items.Add(campus);
            }

            cbCampus.SelectedIndex = 0;
        }
Example #19
0
        /// <summary>
        /// Shows the transaction grid item detail.
        /// </summary>
        private void ShowTransactionGridItemDetail()
        {
            try
            {
                FinancialTransaction financialTransaction = grdBatchItems.SelectedValue as FinancialTransaction;

                if (financialTransaction != null)
                {
                    RockConfig     config = RockConfig.Load();
                    RockRestClient client = new RockRestClient(config.RockBaseUrl);
                    client.Login(config.Username, config.Password);
                    financialTransaction.Images              = client.GetData <List <FinancialTransactionImage> >("api/FinancialTransactionImages", string.Format("TransactionId eq {0}", financialTransaction.Id));
                    BatchItemDetailPage.batchPage            = this;
                    BatchItemDetailPage.FinancialTransaction = financialTransaction;
                    this.NavigationService.Navigate(BatchItemDetailPage);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }
Example #20
0
        private void LoadFinancialTransactionDetails(FinancialTransaction financialTransaction)
        {
            decimal sum = 0;
            List <DisplayFinancialTransactionDetailModel> displayFinancialTransactionDetailList = new List <DisplayFinancialTransactionDetailModel>();

            // first, make sure all the accounts that are part of the existing transaction are included, even if they aren't included in the configured selected accounts
            if (financialTransaction.TransactionDetails != null)
            {
                foreach (var detail in financialTransaction.TransactionDetails)
                {
                    sum           += detail.Amount;
                    detail.Account = ScanningPageUtility.Accounts.FirstOrDefault(a => a.Id == detail.AccountId);
                    displayFinancialTransactionDetailList.Add(new DisplayFinancialTransactionDetailModel(detail));
                }
            }

            RockConfig rockConfig = RockConfig.Load();

            List <DisplayAccountValueModel> sortedDisplayedAccountList = ScanningPageUtility.GetVisibleAccountsSortedAndFlattened();

            // now, add accounts that aren't part of the Transaction in case they want to split to different accounts
            foreach (var displayAccount in sortedDisplayedAccountList)
            {
                if (!displayFinancialTransactionDetailList.Any(a => a.AccountId == displayAccount.AccountId))
                {
                    FinancialTransactionDetail financialTransactionDetail = new FinancialTransactionDetail();
                    financialTransactionDetail.Guid      = Guid.NewGuid();
                    financialTransactionDetail.AccountId = displayAccount.AccountId;
                    financialTransactionDetail.Account   = displayAccount.Account;
                    displayFinancialTransactionDetailList.Add(new DisplayFinancialTransactionDetailModel(financialTransactionDetail));
                }
            }

            // show displayed accounts sorted by its position in sortedDisplayedAccountList
            displayFinancialTransactionDetailList = displayFinancialTransactionDetailList.OrderBy(a => sortedDisplayedAccountList.FirstOrDefault(s => s.AccountId == a.AccountId)?.DisplayIndex).ToList();

            this.lvAccountDetails.ItemsSource = displayFinancialTransactionDetailList;
            this.lblTotals.Content            = sum.ToString("C");
        }
Example #21
0
        /// <summary>
        /// Gets the check image.
        /// </summary>
        /// <param name="side">The side.</param>
        /// <returns></returns>
        private BitmapImage GetCheckImage(Sides side)
        {
            ImageColorType colorType = RockConfig.Load().ImageColorType;

            int imageByteCount;

            imageByteCount = rangerScanner.GetImageByteCount((int)side, (int)colorType);
            byte[] imageBytes = new byte[imageByteCount];

            // create the pointer and assign the Ranger image address to it
            IntPtr imgAddress = new IntPtr(rangerScanner.GetImageAddress((int)side, (int)colorType));

            // Copy the bytes from unmanaged memory to managed memory
            Marshal.Copy(imgAddress, imageBytes, 0, imageByteCount);

            BitmapImage bitImage = new BitmapImage();

            bitImage.BeginInit();
            bitImage.StreamSource = new MemoryStream(imageBytes);
            bitImage.EndInit();

            return(bitImage);
        }
Example #22
0
        /// <summary>
        /// Loads the financial batches grid.
        /// </summary>
        private void LoadFinancialBatchesGrid()
        {
            RockConfig     config = RockConfig.Load();
            RockRestClient client = new RockRestClient(config.RockBaseUrl);

            client.Login(config.Username, config.Password);
            List <FinancialBatch> pendingBatches = client.GetDataByEnum <List <FinancialBatch> >("api/FinancialBatches", "Status", BatchStatus.Pending);

            grdBatches.DataContext = pendingBatches.OrderByDescending(a => a.BatchStartDateTime).ThenBy(a => a.Name);
            if (pendingBatches.Count > 0)
            {
                if (SelectedFinancialBatchId > 0)
                {
                    grdBatches.SelectedValue = pendingBatches.FirstOrDefault(a => a.Id.Equals(SelectedFinancialBatchId));
                }
                else
                {
                    grdBatches.SelectedIndex = 0;
                }
            }

            UpdateBatchUI(grdBatches.SelectedValue as FinancialBatch);
        }
Example #23
0
        /// <summary>
        /// Gets the doc image.
        /// </summary>
        /// <param name="side">The side.</param>
        /// <returns></returns>
        public static byte[] GetImageBytesFromRanger(RangerSides side)
        {
            RangerImageColorTypes colorType = RockConfig.Load().ImageColorType;

            int imageByteCount;

            imageByteCount = batchPage.rangerScanner.GetImageByteCount(( int )side, ( int )colorType);
            if (imageByteCount > 0)
            {
                byte[] imageBytes = new byte[imageByteCount];

                // create the pointer and assign the Ranger image address to it
                IntPtr imgAddress = new IntPtr(batchPage.rangerScanner.GetImageAddress(( int )side, ( int )colorType));

                // Copy the bytes from unmanaged memory to managed memory
                Marshal.Copy(imgAddress, imageBytes, 0, imageByteCount);

                return(imageBytes);
            }
            else
            {
                return(null);
            }
        }
Example #24
0
        /// <summary>
        /// Handles the RowEdit event of the grdBatchItems control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseButtonEventArgs"/> instance containing the event data.</param>
        protected void grdBatchItems_RowEdit(object sender, MouseButtonEventArgs e)
        {
            try
            {
                FinancialTransaction financialTransaction = grdBatchItems.SelectedValue as FinancialTransaction;

                if (financialTransaction != null)
                {
                    RockConfig     config = RockConfig.Load();
                    RockRestClient client = new RockRestClient(config.RockBaseUrl);
                    client.Login(config.Username, config.Password);
                    financialTransaction.Images = client.GetData <List <FinancialTransactionImage> >("api/FinancialTransactionImages", string.Format("TransactionId eq {0}", financialTransaction.Id));
                    foreach (var image in financialTransaction.Images)
                    {
                        image.BinaryFile = client.GetData <BinaryFile>(string.Format("api/BinaryFiles/{0}", image.BinaryFileId));
                        try
                        {
                            image.BinaryFile.Data = client.GetData <BinaryFileData>(string.Format("api/BinaryFileDatas/{0}", image.BinaryFileId));
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Error getting check image data: " + ex.Message);
                        }
                    }

                    BatchItemDetailPage.TransactionImageTypeValueFront = client.GetDataByGuid <DefinedValue>("api/DefinedValues", new Guid(Rock.SystemGuid.DefinedValue.TRANSACTION_IMAGE_TYPE_CHECK_FRONT));
                    BatchItemDetailPage.TransactionImageTypeValueBack  = client.GetDataByGuid <DefinedValue>("api/DefinedValues", new Guid(Rock.SystemGuid.DefinedValue.TRANSACTION_IMAGE_TYPE_CHECK_BACK));
                    BatchItemDetailPage.FinancialTransaction           = financialTransaction;
                    this.NavigationService.Navigate(BatchItemDetailPage);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Example #25
0
        /// <summary>
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            lblLoginWarning.Visibility = Visibility.Hidden;
            txtUsername.Text           = txtUsername.Text.Trim();
            txtRockUrl.Text            = txtRockUrl.Text.Trim();
            RockRestClient rockRestClient = new RockRestClient(txtRockUrl.Text);

            string userName = txtUsername.Text;
            string password = txtPassword.Password;

            // start a background thread to Login since this could take a little while and we want a Wait cursor
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += delegate(object s, DoWorkEventArgs ee)
            {
                ee.Result = null;
                rockRestClient.Login(userName, password);
            };

            // when the Background Worker is done with the Login, run this
            bw.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs ee)
            {
                this.Cursor        = null;
                btnLogin.IsEnabled = true;
                try
                {
                    if (ee.Error != null)
                    {
                        throw ee.Error;
                    }

                    Person person = rockRestClient.GetData <Person>(string.Format("api/People/GetByUserName/{0}", userName));
                    person.Aliases = rockRestClient.GetData <List <PersonAlias> >("api/PersonAlias/", "PersonId eq " + person.Id);
                    RockConfig rockConfig = RockConfig.Load();
                    rockConfig.RockBaseUrl = txtRockUrl.Text;
                    rockConfig.Username    = txtUsername.Text;
                    rockConfig.Password    = txtPassword.Password;
                    rockConfig.Save();

                    BatchPage batchPage = new BatchPage(person);

                    if (this.NavigationService.CanGoBack)
                    {
                        // if we got here from some other Page, go back
                        this.NavigationService.GoBack();
                    }
                    else
                    {
                        this.NavigationService.Navigate(batchPage);
                    }
                }
                catch (WebException wex)
                {
                    // show WebException on the form, but any others should end up in the ExceptionDialog
                    HttpWebResponse response = wex.Response as HttpWebResponse;
                    if (response != null)
                    {
                        if (response.StatusCode.Equals(HttpStatusCode.Unauthorized))
                        {
                            lblLoginWarning.Content    = "Invalid Login";
                            lblLoginWarning.Visibility = Visibility.Visible;
                            return;
                        }
                    }

                    string message = wex.Message;
                    if (wex.InnerException != null)
                    {
                        message += "\n" + wex.InnerException.Message;
                    }

                    lblRockUrl.Visibility      = Visibility.Visible;
                    txtRockUrl.Visibility      = Visibility.Visible;
                    lblLoginWarning.Content    = message;
                    lblLoginWarning.Visibility = Visibility.Visible;
                    return;
                }
            };

            // set the cursor to Wait, disable the login button, and start the login background process
            this.Cursor        = Cursors.Wait;
            btnLogin.IsEnabled = false;
            bw.RunWorkerAsync();
        }
Example #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OptionsPage"/> class.
 /// </summary>
 public OptionsPage(BatchPage batchPage)
 {
     InitializeComponent();
     this.BatchPage   = batchPage;
     this._rockConfig = RockConfig.Load();
 }
Example #27
0
        /// <summary>
        /// Gets the configuration values.
        /// These values are saved at
        /// C:\Users\[username]\AppData\Local\Spark_Development_Network
        /// </summary>
        private void GetConfigValues()
        {
            var rockConfig = RockConfig.Load();

            txtRockUrl.Text = rockConfig.RockBaseUrl;
            chkCaptureAmountOnScan.IsChecked     = rockConfig.CaptureAmountOnScan;
            chkRequireControlAmount.IsChecked    = rockConfig.RequireControlAmount;
            chkRequireControlItemCount.IsChecked = rockConfig.RequireControlItemCount;

            if (rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.MICRImageRS232)
            {
                cboScannerInterfaceType.SelectedItem = "MagTek COM";
                lblMakeModel.Content = "MagTek COM";
                string version = "-1";
                try
                {
                    this.Cursor = Cursors.Wait;
                    if (BatchPage.micrImage != null)
                    {
                        version = BatchPage.micrImage.Version();
                    }
                }
                finally
                {
                    this.Cursor = null;
                }

                if (!version.Equals("-1"))
                {
                    lblInterfaceVersion.Content = version;
                }
                else
                {
                    lblInterfaceVersion.Content = "error";
                }
            }
            else if (rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.MagTekImageSafe)
            {
                cboScannerInterfaceType.SelectedItem = "MagTek Image Safe";
                lblMakeModel.Content = "MagTek Image Safe";
                string version = "-1";
                try
                {
                    this.Cursor = Cursors.Wait;

                    version = BatchPage.GetImageSafeVersion();
                }
                finally
                {
                    this.Cursor = null;
                }

                if (!version.Equals("-1"))
                {
                    lblInterfaceVersion.Content = version;
                }
                else
                {
                    lblInterfaceVersion.Content = "error";
                }
            }
            else
            {
                cboScannerInterfaceType.SelectedItem = "Ranger";
                if (BatchPage.rangerScanner != null)
                {
                    lblMakeModel.Content        = string.Format("Scanner Type: {0} {1}", BatchPage.rangerScanner.GetTransportInfo("General", "Make"), BatchPage.rangerScanner.GetTransportInfo("General", "Model"));
                    lblInterfaceVersion.Content = string.Format("Interface Version: {0}", BatchPage.rangerScanner.GetVersion());
                }
                else
                {
                    lblMakeModel.Content        = "Scanner Type: ERROR";
                    lblInterfaceVersion.Content = "Interface Version: ERROR";
                }
            }

            switch (rockConfig.ImageColorType)
            {
            case RangerImageColorTypes.ImageColorTypeGrayscale:
                cboImageOption.SelectedValue = "Grayscale";
                break;

            case RangerImageColorTypes.ImageColorTypeColor:
                cboImageOption.SelectedValue = "Color";
                break;

            default:
                cboImageOption.SelectedIndex = 0;
                break;
            }

            if (cboMagTekCommPort.Items.Count > 0)
            {
                cboMagTekCommPort.SelectedItem = string.Format("COM{0}", rockConfig.MICRImageComPort);
            }

            if (rockConfig.Sensitivity.AsInteger() == 0)
            {
                txtSensitivity.Text = string.Empty;
            }
            else
            {
                txtSensitivity.Text = rockConfig.Sensitivity;
            }

            if (rockConfig.Plurality.AsInteger() == 0)
            {
                txtPlurality.Text = string.Empty;
            }
            else
            {
                txtPlurality.Text = rockConfig.Plurality;
            }

            LoadFinancialAccounts(rockConfig.CampusIdFilter);
        }
Example #28
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        private void ShowDetail()
        {
            LoadDropDowns();

            lblAlert.Visibility = Visibility.Collapsed;

            var rockConfig = RockConfig.Load();

            txtRockUrl.Text = rockConfig.RockBaseUrl;

            if (rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.MICRImageRS232)
            {
                cboScannerInterfaceType.SelectedItem = "MagTek";
                lblMakeModel.Content = "MagTek";

                string version = null;
                try
                {
                    this.Cursor = Cursors.Wait;
                    version     = BatchPage.micrImage.Version();
                }
                finally
                {
                    this.Cursor = null;
                }

                if (!version.Equals("-1"))
                {
                    lblInterfaceVersion.Content = version;
                }
                else
                {
                    lblInterfaceVersion.Content = "error";
                }
            }
            else
            {
                cboScannerInterfaceType.SelectedItem = "Ranger";
                lblMakeModel.Content        = string.Format("Scanner Type: {0} {1}", BatchPage.rangerScanner.GetTransportInfo("General", "Make"), BatchPage.rangerScanner.GetTransportInfo("General", "Model"));
                lblInterfaceVersion.Content = string.Format("Interface Version: {0}", BatchPage.rangerScanner.GetVersion());
            }

            string feederFriendlyNameType = BatchPage.ScannerFeederType.Equals(FeederType.MultipleItems) ? "Multiple Items" : "Single Item";

            lblFeederType.Content = string.Format("Feeder Type: {0}", feederFriendlyNameType);

            switch ((ImageColorType)rockConfig.ImageColorType)
            {
            case ImageColorType.ImageColorTypeGrayscale:
                cboImageOption.SelectedValue = "Grayscale";
                break;

            case ImageColorType.ImageColorTypeColor:
                cboImageOption.SelectedValue = "Color";
                break;

            default:
                cboImageOption.SelectedIndex = 0;
                break;
            }

            if (cboMagTekCommPort.Items.Count > 0)
            {
                cboMagTekCommPort.SelectedItem = string.Format("COM{0}", rockConfig.MICRImageComPort);
            }
        }
Example #29
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            RockConfig rockConfig = RockConfig.Load();

            try
            {
                txtRockUrl.Text = txtRockUrl.Text.Trim();
                RockRestClient client = new RockRestClient(txtRockUrl.Text);
                client.Login(rockConfig.Username, rockConfig.Password);
                BatchPage.LoggedInPerson = client.GetData <Person>(string.Format("api/People/GetByUserName/{0}", rockConfig.Username));
            }
            catch (WebException wex)
            {
                HttpWebResponse response = wex.Response as HttpWebResponse;
                if (response != null)
                {
                    if (response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        // valid URL but invalid login, so navigate back to the LoginPage
                        rockConfig.RockBaseUrl = txtRockUrl.Text;
                        rockConfig.Save();
                        LoginPage loginPage = new LoginPage(true);
                        this.NavigationService.Navigate(loginPage);
                        return;
                    }
                }

                lblAlert.Content    = wex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }
            catch (Exception ex)
            {
                lblAlert.Content    = ex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }

            rockConfig.RockBaseUrl = txtRockUrl.Text;

            if (cboScannerInterfaceType.SelectedItem.Equals("MagTek"))
            {
                rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.MICRImageRS232;
            }
            else
            {
                rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.RangerApi;
            }

            string imageOption = cboImageOption.SelectedValue as string;

            switch (imageOption)
            {
            case "Grayscale":
                rockConfig.ImageColorType = ImageColorType.ImageColorTypeGrayscale;
                break;

            case "Color":
                rockConfig.ImageColorType = ImageColorType.ImageColorTypeColor;
                break;

            default:
                rockConfig.ImageColorType = ImageColorType.ImageColorTypeBitonal;
                break;
            }

            string comPortName = cboMagTekCommPort.SelectedItem as string;

            if (!string.IsNullOrWhiteSpace(comPortName))
            {
                rockConfig.MICRImageComPort = short.Parse(comPortName.Replace("COM", string.Empty));
            }

            rockConfig.Save();

            this.NavigationService.GoBack();
        }
Example #30
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            RockConfig rockConfig = RockConfig.Load();

            try
            {
                txtRockUrl.Text = txtRockUrl.Text.Trim();
                Uri rockUrl      = new Uri(txtRockUrl.Text);
                var validSchemes = new string[] { Uri.UriSchemeHttp, Uri.UriSchemeHttps };
                if (!validSchemes.Contains(rockUrl.Scheme))
                {
                    txtRockUrl.Text = "http://" + rockUrl.AbsoluteUri;
                }

                RockRestClient client = new RockRestClient(txtRockUrl.Text);
                client.Login(rockConfig.Username, rockConfig.Password);
                BatchPage.LoggedInPerson         = client.GetData <Person>(string.Format("api/People/GetByUserName/{0}", rockConfig.Username));
                BatchPage.LoggedInPerson.Aliases = client.GetData <List <PersonAlias> >("api/PersonAlias/", "PersonId eq " + BatchPage.LoggedInPerson.Id);
            }
            catch (WebException wex)
            {
                HttpWebResponse response = wex.Response as HttpWebResponse;
                if (response != null)
                {
                    if (response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        // valid URL but invalid login, so navigate back to the LoginPage
                        rockConfig.RockBaseUrl = txtRockUrl.Text;
                        rockConfig.Save();
                        LoginPage loginPage = new LoginPage(true);
                        this.NavigationService.Navigate(loginPage);
                        return;
                    }
                }

                lblAlert.Content    = wex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }
            catch (Exception ex)
            {
                lblAlert.Content    = ex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }

            rockConfig.RockBaseUrl = txtRockUrl.Text;

            if (cboScannerInterfaceType.SelectedItem.Equals("MagTek"))
            {
                rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.MICRImageRS232;
            }
            else
            {
                rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.RangerApi;
            }

            string imageOption = cboImageOption.SelectedValue as string;

            switch (imageOption)
            {
            case "Grayscale":
                rockConfig.ImageColorType = ImageColorType.ImageColorTypeGrayscale;
                break;

            case "Color":
                rockConfig.ImageColorType = ImageColorType.ImageColorTypeColor;
                break;

            default:
                rockConfig.ImageColorType = ImageColorType.ImageColorTypeBitonal;
                break;
            }

            string comPortName = cboMagTekCommPort.SelectedItem as string;

            if (!string.IsNullOrWhiteSpace(comPortName))
            {
                rockConfig.MICRImageComPort = short.Parse(comPortName.Replace("COM", string.Empty));
            }

            rockConfig.SourceTypeValueGuid = (cboTransactionSourceType.SelectedItem as DefinedValue).Guid.ToString();

            rockConfig.Save();

            // shutdown the scanner so that options will be reloaded when the batch page loads
            if (BatchPage.rangerScanner != null)
            {
                BatchPage.rangerScanner.ShutDown();
            }

            this.NavigationService.GoBack();
        }