Inheritance: System.Configuration.ApplicationSettingsBase
コード例 #1
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();
                }
            }
        }
コード例 #2
0
ファイル: BatchPage.xaml.cs プロジェクト: VijayMVC/Rock-1
        /// <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()));
            }
        }
コード例 #3
0
ファイル: ScanningPageUtility.cs プロジェクト: xiaodelea/Rock
        /// <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);
        }
コード例 #4
0
ファイル: OptionsPage.xaml.cs プロジェクト: xiaodelea/Rock
        /// <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;
        }
コード例 #5
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);
        }
コード例 #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)
        {
            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());
        }
コード例 #7
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);
        }
コード例 #8
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();
            }
        }
コード例 #9
0
ファイル: BatchPage.xaml.cs プロジェクト: VijayMVC/Rock-1
        /// <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;
            }
        }
コード例 #10
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)
        {
            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;
            }
        }
コード例 #11
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;
        }
コード例 #12
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");
        }
コード例 #13
0
ファイル: BatchPage.xaml.cs プロジェクト: VijayMVC/Rock-1
        /// <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);
            }
        }
コード例 #14
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);
        }
コード例 #15
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);
        }
コード例 #16
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);
            }
        }
コード例 #17
0
ファイル: ScanningPageUtility.cs プロジェクト: xiaodelea/Rock
        /// <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);
            }
        }
コード例 #18
0
ファイル: OptionsPage.xaml.cs プロジェクト: xiaodelea/Rock
 /// <summary>
 /// Initializes a new instance of the <see cref="OptionsPage"/> class.
 /// </summary>
 public OptionsPage(BatchPage batchPage)
 {
     InitializeComponent();
     this.BatchPage   = batchPage;
     this._rockConfig = RockConfig.Load();
 }
コード例 #19
0
ファイル: OptionsPage.xaml.cs プロジェクト: xiaodelea/Rock
        /// <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);
        }
コード例 #20
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);
            }
        }
コード例 #21
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();
        }
コード例 #22
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();
        }
コード例 #23
0
ファイル: BatchPage.xaml.cs プロジェクト: VijayMVC/Rock-1
        /// <summary>
        /// Updates the batch UI.
        /// </summary>
        /// <param name="selectedBatch">The selected batch.</param>
        private void UpdateBatchUI(FinancialBatch selectedBatch)
        {
            if (selectedBatch == null)
            {
                grdBatchItems.DataContext = null;
                DisplayTransactionCount();
                HideBatch();
                return;
            }
            else
            {
                ShowBatch(false);
            }

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

            client.Login(rockConfig.Username, rockConfig.Password);
            SelectedFinancialBatch       = selectedBatch;
            lblBatchNameReadOnly.Content = selectedBatch.Name;
            lblBatchIdReadOnly.Content   = string.Format("Batch Id: {0}", selectedBatch.Id);

            lblBatchCampusReadOnly.Content = selectedBatch.CampusId.HasValue ? client.GetData <Campus>(string.Format("api/Campuses/{0}", selectedBatch.CampusId ?? 0)).Name : string.Empty;
            lblBatchDateReadOnly.Content   = selectedBatch.BatchStartDateTime.Value.ToString("d");
            var createdByPerson = client.GetData <Person>(string.Format("api/People/GetByPersonAliasId/{0}", selectedBatch.CreatedByPersonAliasId ?? 0));

            if (createdByPerson != null)
            {
                lblBatchCreatedByReadOnly.Content = string.Format("{0} {1}", createdByPerson.NickName, createdByPerson.LastName);
            }
            else
            {
                lblBatchCreatedByReadOnly.Content = string.Empty;
            }

            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");
            txtNote.Text             = selectedBatch.Note;

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

            Rock.Wpf.WpfHelper.FadeOut(lblCount, 0);
            lblCount.Content = "Loading...";
            Rock.Wpf.WpfHelper.FadeIn(lblCount, 300);
            List <FinancialTransaction> transactions = null;

            grdBatchItems.DataContext = null;
            bw.DoWork += delegate(object s, DoWorkEventArgs ee)
            {
                ee.Result = null;

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

            bw.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs ee)
            {
                this.Cursor = null;
                foreach (var transaction in transactions)
                {
                    if (transaction.FinancialPaymentDetailId.HasValue)
                    {
                        transaction.FinancialPaymentDetail = transaction.FinancialPaymentDetail ?? client.GetData <FinancialPaymentDetail>(string.Format("api/FinancialPaymentDetails/{0}", transaction.FinancialPaymentDetailId ?? 0));
                        if (transaction.FinancialPaymentDetail != null)
                        {
                            transaction.FinancialPaymentDetail.CurrencyTypeValue = this.CurrencyValueList.FirstOrDefault(a => a.Id == transaction.FinancialPaymentDetail.CurrencyTypeValueId);
                        }
                    }
                }

                // sort starting with most recent first
                var bindingList = new BindingList <FinancialTransaction>(transactions.OrderByDescending(a => a.CreatedDateTime).ToList());
                bindingList.RaiseListChangedEvents = true;
                bindingList.ListChanged           += bindingList_ListChanged;

                grdBatchItems.DataContext = bindingList;
                DisplayTransactionCount();
            };

            this.Cursor = Cursors.Wait;
            bw.RunWorkerAsync();
        }
コード例 #24
0
ファイル: BatchPage.xaml.cs プロジェクト: VijayMVC/Rock-1
        /// <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)
        {
            try
            {
                RockConfig     rockConfig = RockConfig.Load();
                RockRestClient client     = new RockRestClient(rockConfig.RockBaseUrl);
                client.Login(rockConfig.Username, rockConfig.Password);

                FinancialBatch financialBatch = null;
                if (SelectedFinancialBatch == null || SelectedFinancialBatch.Id == 0)
                {
                    financialBatch = new FinancialBatch {
                        Id = 0, Guid = Guid.NewGuid(), Status = BatchStatus.Pending, CreatedByPersonAliasId = LoggedInPerson.PrimaryAliasId
                    };
                }
                else
                {
                    financialBatch = client.GetData <FinancialBatch>(string.Format("api/FinancialBatches/{0}", SelectedFinancialBatch.Id));
                }

                txtBatchName.Text = txtBatchName.Text.Trim();
                if (string.IsNullOrWhiteSpace(txtBatchName.Text))
                {
                    txtBatchName.Style = this.FindResource("textboxStyleError") as Style;
                    return;
                }
                else
                {
                    txtBatchName.Style = this.FindResource("textboxStyle") as Style;
                }

                financialBatch.Name = txtBatchName.Text;
                Campus selectedCampus = cbCampus.SelectedItem as Campus;
                if (selectedCampus.Id > 0)
                {
                    financialBatch.CampusId = selectedCampus.Id;
                }
                else
                {
                    financialBatch.CampusId = null;
                }

                financialBatch.BatchStartDateTime = dpBatchDate.SelectedDate;

                if (!string.IsNullOrWhiteSpace(txtControlAmount.Text))
                {
                    financialBatch.ControlAmount = decimal.Parse(txtControlAmount.Text.Replace("$", string.Empty));
                }
                else
                {
                    financialBatch.ControlAmount = 0.00M;
                }

                txtNote.Text        = txtNote.Text.Trim();
                financialBatch.Note = txtNote.Text;

                if (financialBatch.Id == 0)
                {
                    client.PostData <FinancialBatch>("api/FinancialBatches/", financialBatch);
                }
                else
                {
                    client.PutData <FinancialBatch>("api/FinancialBatches/", financialBatch, financialBatch.Id);
                }

                if (SelectedFinancialBatch == null || SelectedFinancialBatch.Id == 0)
                {
                    // refetch the batch to get the Id if it was just Inserted
                    financialBatch = client.GetDataByGuid <FinancialBatch>("api/FinancialBatches", financialBatch.Guid);

                    SelectedFinancialBatch = financialBatch;
                }

                LoadFinancialBatchesGrid();
                UpdateBatchUI(financialBatch);

                ShowBatch(false);
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }
コード例 #25
0
ファイル: RockConfig.cs プロジェクト: pkdevbox/Rock
        /// <summary>
        /// Loads this instance.
        /// </summary>
        /// <returns></returns>
        public static RockConfig Load()
        {
            try
            {
                if ( _rockConfig != null )
                {
                    return _rockConfig;
                }

                if ( File.Exists( fileName ) )
                {
                    FileStream fs = new FileStream( fileName, FileMode.OpenOrCreate );
                    try
                    {
                        DataContractSerializer s = new DataContractSerializer( typeof( RockConfig ) );
                        _rockConfig = s.ReadObject( fs ) as RockConfig;
                        return _rockConfig;
                    }
                    finally
                    {
                        fs.Close();
                    }
                }

                return new RockConfig();
            }
            catch
            {
                return new RockConfig();
            }
        }
コード例 #26
0
ファイル: BatchPage.xaml.cs プロジェクト: VijayMVC/Rock-1
        /// <summary>
        /// Connects to scanner.
        /// </summary>
        /// <returns></returns>
        public bool ConnectToScanner()
        {
            var rockConfig = RockConfig.Load();

            if (rockConfig.ScannerInterfaceType == RockConfig.InterfaceType.MICRImageRS232)
            {
                if (micrImage == null)
                {
                    // no MagTek driver
                    return(false);
                }

                micrImage.CommPort = rockConfig.MICRImageComPort;
                micrImage.PortOpen = false;

                UpdateScannerStatusForMagtek(false);

                object dummy = null;

                // converted from VB6 from MagTek's sample app
                if (!micrImage.PortOpen)
                {
                    micrImage.PortOpen = true;
                    if (micrImage.DSRHolding)
                    {
                        // Sets Switch Settings
                        // If you use the MicrImage1.Save command then these do not need to be sent
                        // every time you open the device
                        micrImage.MicrTimeOut = 1;
                        micrImage.MicrCommand("SWA 00100010", ref dummy);
                        micrImage.MicrCommand("SWB 00100010", ref dummy);
                        micrImage.MicrCommand("SWC 00100000", ref dummy);
                        micrImage.MicrCommand("HW 00111100", ref dummy);
                        micrImage.MicrCommand("SWE 00000010", ref dummy);
                        micrImage.MicrCommand("SWI 00000000", ref dummy);

                        // The OCX will work with any Micr Format.  You just need to know which
                        // format is being used to parse it using the FindElement Method
                        micrImage.FormatChange("6200");
                        micrImage.MicrTimeOut = 5;

                        // get Version to test if we have a good connection to the device
                        string version = "-1";
                        try
                        {
                            this.Cursor = Cursors.Wait;
                            version     = micrImage.Version();
                        }
                        finally
                        {
                            this.Cursor = null;
                        }

                        if (!version.Equals("-1"))
                        {
                            UpdateScannerStatusForMagtek(true);
                        }
                        else
                        {
                            MessageBox.Show(string.Format("MagTek Device is not responding on COM{0}.", micrImage.CommPort), "Scanner Error");
                            return(false);
                        }
                    }
                    else
                    {
                        MessageBox.Show(string.Format("MagTek Device is not attached to COM{0}.", micrImage.CommPort), "Missing Scanner");
                        return(false);
                    }
                }

                ScannerFeederType = FeederType.SingleItem;
            }
            else
            {
                try
                {
                    if (this.rangerScanner == null)
                    {
                        // no ranger driver
                        return(false);
                    }
                }
                catch
                {
                    return(false);
                }

                try
                {
                    this.Cursor = Cursors.Wait;
                    rangerScanner.StartUp();
                }
                finally
                {
                    this.Cursor = null;
                }

                string feederTypeName = rangerScanner.GetTransportInfo("MainHopper", "FeederType");
                if (feederTypeName.Equals("MultipleItems"))
                {
                    ScannerFeederType = FeederType.MultipleItems;
                }
                else
                {
                    ScannerFeederType = FeederType.SingleItem;
                }
            }

            return(true);
        }
コード例 #27
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)
        {
            var financialTransaction = this.FinancialTransaction;
            var images = financialTransaction.Images.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;
            }

            lblFront.Visibility = imgFront.Source != null ? Visibility.Visible : Visibility.Collapsed;
            lblBack.Visibility  = imgBack.Source != null ? Visibility.Visible : Visibility.Collapsed;

            lblScannedDateTime.Content     = financialTransaction.CreatedDateTime.HasValue ? financialTransaction.CreatedDateTime.Value.ToString("g") : null;
            lblTransactionDateTime.Content = financialTransaction.TransactionDateTime.HasValue ? financialTransaction.TransactionDateTime.Value.ToString("g") : null;
            lblBatch.Content = batchPage.SelectedFinancialBatch.Name;

            financialTransaction.SourceTypeValue = financialTransaction.SourceTypeValue ?? batchPage.SourceTypeValueList.FirstOrDefault(a => a.Id == financialTransaction.SourceTypeValueId);
            lblSource.Content = financialTransaction.SourceTypeValue != null ? financialTransaction.SourceTypeValue.Value : null;

            // only show Transaction Code if it has one
            lblTransactionCodeValue.Content = financialTransaction.TransactionCode;
            bool hasTransactionCode = !string.IsNullOrWhiteSpace(financialTransaction.TransactionCode);

            lblTransactionCodeLabel.Visibility = hasTransactionCode ? Visibility.Visible : Visibility.Collapsed;
            lblTransactionCodeValue.Visibility = hasTransactionCode ? Visibility.Visible : Visibility.Collapsed;

            if (financialTransaction.FinancialPaymentDetailId.HasValue)
            {
                financialTransaction.FinancialPaymentDetail = financialTransaction.FinancialPaymentDetail ?? client.GetData <FinancialPaymentDetail>(string.Format("api/FinancialPaymentDetails/{0}", financialTransaction.FinancialPaymentDetailId ?? 0));
            }

            if (financialTransaction.FinancialPaymentDetail != null)
            {
                financialTransaction.FinancialPaymentDetail.CurrencyTypeValue = financialTransaction.FinancialPaymentDetail.CurrencyTypeValue ?? batchPage.CurrencyValueList.FirstOrDefault(a => a.Id == financialTransaction.FinancialPaymentDetail.CurrencyTypeValueId);
                lblCurrencyType.Content = financialTransaction.FinancialPaymentDetail.CurrencyTypeValue != null ? financialTransaction.FinancialPaymentDetail.CurrencyTypeValue.Value : null;
            }
            else
            {
                lblCurrencyType.Content = string.Empty;
            }
        }
コード例 #28
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 = chkRangerDoubleDocDetection.IsChecked == true;
            rockConfig.EnableSmartScan          = chkEnableSmartScan.IsChecked == true;

            if (cboTransactionSourceType.SelectedItem == null)
            {
                lblTransactionSourceType.Style = this.FindResource("labelStyleError") as Style;
                return;
            }
            else
            {
                lblTransactionSourceType.Style = this.FindResource("labelStyle") as Style;
            }

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

            rockConfig.Save();

            switch (rockConfig.ScannerInterfaceType)
            {
            case RockConfig.InterfaceType.RangerApi:
                if (this.BatchPage.rangerScanner != null)
                {
                    this.BatchPage.rangerScanner.ShutDown();
                    this.BatchPage.rangerScanner.StartUp();
                }
                else
                {
                    lblScannerDriverError.Visibility = Visibility.Visible;
                    return;
                }
                break;

            case RockConfig.InterfaceType.MICRImageRS232:
                if (this.BatchPage.micrImage == null)
                {
                    lblScannerDriverError.Visibility = Visibility.Visible;
                    return;
                }
                break;

            case RockConfig.InterfaceType.MagTekImageSafe:
                //Do Nothing Uses a Callback Function
                break;

            default:
                break;
            }

            this.NavigationService.Navigate(this.BatchPage.ScanningPage);
        }
コード例 #29
0
        /// <summary>
        /// Handles the DoWork event of the bwUploadScannedChecks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
        private void bwUploadScannedChecks_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bw = sender as BackgroundWorker;

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

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

            AssemblyName assemblyName = Assembly.GetExecutingAssembly().GetName();
            string       appInfo      = string.Format("{0}, version: {1}", assemblyName.FullName, assemblyName.Version);

            BinaryFileType binaryFileTypeContribution       = client.GetDataByGuid <BinaryFileType>("api/BinaryFileTypes", new Guid(Rock.SystemGuid.BinaryFiletype.CONTRIBUTION_IMAGE));
            DefinedValue   currencyTypeValueCheck           = client.GetDataByGuid <DefinedValue>("api/DefinedValues", new Guid(Rock.SystemGuid.DefinedValue.CURRENCY_TYPE_CHECK));
            DefinedValue   transactionTypeValueContribution = client.GetDataByGuid <DefinedValue>("api/DefinedValues", new Guid(Rock.SystemGuid.DefinedValue.TRANSACTION_TYPE_CONTRIBUTION));
            DefinedValue   transactionImageTypeValueFront   = client.GetDataByGuid <DefinedValue>("api/DefinedValues", new Guid(Rock.SystemGuid.DefinedValue.TRANSACTION_IMAGE_TYPE_CHECK_FRONT));
            DefinedValue   transactionImageTypeValueBack    = client.GetDataByGuid <DefinedValue>("api/DefinedValues", new Guid(Rock.SystemGuid.DefinedValue.TRANSACTION_IMAGE_TYPE_CHECK_BACK));

            int totalCount = ScannedCheckList.Where(a => !a.Uploaded).Count();
            int position   = 1;

            foreach (ScannedCheckInfo scannedCheckInfo in ScannedCheckList.Where(a => !a.Uploaded))
            {
                // upload image of front of check
                BinaryFile binaryFileFront = new BinaryFile();
                binaryFileFront.Guid             = Guid.NewGuid();
                binaryFileFront.FileName         = string.Format("{0}_{1}_{2}_front.png", scannedCheckInfo.RoutingNumber, scannedCheckInfo.MaskedAccountNumber, scannedCheckInfo.CheckNumber);
                binaryFileFront.BinaryFileTypeId = binaryFileTypeContribution.Id;
                binaryFileFront.IsSystem         = false;
                binaryFileFront.MimeType         = "image/png";
                client.PostData <BinaryFile>("api/BinaryFiles/", binaryFileFront);

                // upload image data content of front of check
                binaryFileFront.Data         = new BinaryFileData();
                binaryFileFront.Data.Content = scannedCheckInfo.FrontImagePngBytes;
                binaryFileFront.Data.Id      = client.GetDataByGuid <BinaryFile>("api/BinaryFiles/", binaryFileFront.Guid).Id;
                client.PostData <BinaryFileData>("api/BinaryFileDatas/", binaryFileFront.Data);

                // upload image of back of check (if it exists)
                BinaryFile binaryFileBack = null;

                if (scannedCheckInfo.BackImageData != null)
                {
                    binaryFileBack          = new BinaryFile();
                    binaryFileBack.Guid     = Guid.NewGuid();
                    binaryFileBack.FileName = string.Format("{0}_{1}_{2}_back.png", scannedCheckInfo.RoutingNumber, scannedCheckInfo.MaskedAccountNumber, scannedCheckInfo.CheckNumber);

                    // upload image of back of check
                    binaryFileBack.BinaryFileTypeId = binaryFileTypeContribution.Id;
                    binaryFileBack.IsSystem         = false;
                    binaryFileBack.MimeType         = "image/png";
                    client.PostData <BinaryFile>("api/BinaryFiles/", binaryFileBack);

                    // upload image data content of back of check
                    binaryFileBack.Data         = new BinaryFileData();
                    binaryFileBack.Data.Content = scannedCheckInfo.BackImagePngBytes;
                    binaryFileBack.Data.Id      = client.GetDataByGuid <BinaryFile>("api/BinaryFiles/", binaryFileBack.Guid).Id;
                    client.PostData <BinaryFileData>("api/BinaryFileDatas/", binaryFileBack.Data);
                }

                int percentComplete = position++ *100 / totalCount;
                bw.ReportProgress(percentComplete);

                FinancialTransactionScannedCheck financialTransactionScannedCheck = new FinancialTransactionScannedCheck();
                financialTransactionScannedCheck.BatchId                = SelectedFinancialBatchId;
                financialTransactionScannedCheck.Amount                 = 0.00M;
                financialTransactionScannedCheck.TransactionCode        = string.Empty;
                financialTransactionScannedCheck.Summary                = string.Format("Scanned Check from {0}", appInfo);
                financialTransactionScannedCheck.Guid                   = Guid.NewGuid();
                financialTransactionScannedCheck.TransactionDateTime    = DateTime.Now;
                financialTransactionScannedCheck.CurrencyTypeValueId    = currencyTypeValueCheck.Id;
                financialTransactionScannedCheck.CreditCardTypeValueId  = null;
                financialTransactionScannedCheck.SourceTypeValueId      = null;
                financialTransactionScannedCheck.AuthorizedPersonId     = this.LoggedInPerson.Id;
                financialTransactionScannedCheck.TransactionTypeValueId = transactionTypeValueContribution.Id;

                // Rock server will encrypt CheckMicrPlainText to this since we can't have the DataEncryptionKey in a RestClient
                financialTransactionScannedCheck.CheckMicrEncrypted = null;

                financialTransactionScannedCheck.ScannedCheckMicr = string.Format("{0}_{1}_{2}", scannedCheckInfo.RoutingNumber, scannedCheckInfo.AccountNumber, scannedCheckInfo.CheckNumber);

                client.PostData <FinancialTransactionScannedCheck>("api/FinancialTransactions/PostScanned", financialTransactionScannedCheck);

                // get the FinancialTransaction back from server so that we can get it's Id
                financialTransactionScannedCheck.Id = client.GetDataByGuid <FinancialTransaction>("api/FinancialTransactions", financialTransactionScannedCheck.Guid).Id;

                // get the BinaryFiles back so that we can get their Ids
                binaryFileFront.Id = client.GetDataByGuid <BinaryFile>("api/BinaryFiles", binaryFileFront.Guid).Id;

                // upload FinancialTransactionImage records for front/back
                FinancialTransactionImage financialTransactionImageFront = new FinancialTransactionImage();
                financialTransactionImageFront.BinaryFileId  = binaryFileFront.Id;
                financialTransactionImageFront.TransactionId = financialTransactionScannedCheck.Id;
                financialTransactionImageFront.TransactionImageTypeValueId = transactionImageTypeValueFront.Id;
                client.PostData <FinancialTransactionImage>("api/FinancialTransactionImages", financialTransactionImageFront);

                if (binaryFileBack != null)
                {
                    // get the BinaryFiles back so that we can get their Ids
                    binaryFileBack.Id = client.GetDataByGuid <BinaryFile>("api/BinaryFiles", binaryFileBack.Guid).Id;
                    FinancialTransactionImage financialTransactionImageBack = new FinancialTransactionImage();
                    financialTransactionImageBack.BinaryFileId  = binaryFileBack.Id;
                    financialTransactionImageBack.TransactionId = financialTransactionScannedCheck.Id;
                    financialTransactionImageBack.TransactionImageTypeValueId = transactionImageTypeValueBack.Id;
                    client.PostData <FinancialTransactionImage>("api/FinancialTransactionImages", financialTransactionImageBack);
                }

                scannedCheckInfo.Uploaded = true;
            }
        }
コード例 #30
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();
        }
コード例 #31
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)
        {
            try
            {
                RockConfig     rockConfig = RockConfig.Load();
                RockRestClient client     = new RockRestClient(rockConfig.RockBaseUrl);
                client.Login(rockConfig.Username, rockConfig.Password);

                FinancialBatch financialBatch = null;
                if (SelectedFinancialBatchId.Equals(0))
                {
                    financialBatch = new FinancialBatch {
                        Id = 0, Guid = Guid.NewGuid(), Status = BatchStatus.Pending, CreatedByPersonId = LoggedInPerson.Id
                    };
                }
                else
                {
                    financialBatch = client.GetData <FinancialBatch>(string.Format("api/FinancialBatches/{0}", SelectedFinancialBatchId));
                }

                txtBatchName.Text = txtBatchName.Text.Trim();

                financialBatch.Name = txtBatchName.Text;
                Campus selectedCampus = cbCampus.SelectedItem as Campus;
                if (selectedCampus.Id > 0)
                {
                    financialBatch.CampusId = selectedCampus.Id;
                }
                else
                {
                    financialBatch.CampusId = null;
                }

                financialBatch.BatchStartDateTime = dpBatchDate.SelectedDate;

                if (!string.IsNullOrWhiteSpace(txtControlAmount.Text))
                {
                    financialBatch.ControlAmount = decimal.Parse(txtControlAmount.Text.Replace("$", string.Empty));
                }
                else
                {
                    financialBatch.ControlAmount = 0.00M;
                }

                if (financialBatch.Id == 0)
                {
                    client.PostData <FinancialBatch>("api/FinancialBatches/", financialBatch);
                }
                else
                {
                    client.PutData <FinancialBatch>("api/FinancialBatches/", financialBatch);
                }

                if (SelectedFinancialBatchId.Equals(0))
                {
                    // refetch the batch to get the Id if it was just Inserted
                    financialBatch = client.GetDataByGuid <FinancialBatch>("api/FinancialBatches", financialBatch.Guid);

                    SelectedFinancialBatchId = financialBatch.Id;
                }

                LoadFinancialBatchesGrid();

                ShowBatch(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }