示例#1
0
        public HttpResponseMessage PostScanned([FromBody] FinancialTransactionScannedCheck financialTransactionScannedCheck)
        {
            financialTransactionScannedCheck.CheckMicrEncrypted = Encryption.EncryptString(financialTransactionScannedCheck.ScannedCheckMicr);
            FinancialTransaction financialTransaction = FinancialTransaction.FromJson(financialTransactionScannedCheck.ToJson());

            return(this.Post(financialTransaction));
        }
        public HttpResponseMessage PostScanned([FromBody] FinancialTransactionScannedCheck financialTransactionScannedCheck)
        {
            FinancialTransaction financialTransaction = financialTransactionScannedCheck.FinancialTransaction;

            financialTransaction.CheckMicrEncrypted = Encryption.EncryptString(financialTransactionScannedCheck.ScannedCheckMicr);
            financialTransaction.CheckMicrHash      = Encryption.GetSHA1Hash(financialTransactionScannedCheck.ScannedCheckMicr);
            return(this.Post(financialTransaction));
        }
示例#3
0
        public HttpResponseMessage PostScanned([FromBody] FinancialTransactionScannedCheck financialTransactionScannedCheck)
        {
            FinancialTransaction financialTransaction = financialTransactionScannedCheck.FinancialTransaction;

            financialTransaction.CheckMicrEncrypted = Encryption.EncryptString(financialTransactionScannedCheck.ScannedCheckMicrData);

            // note: BadMicr scans don't get checked for duplicates, but just in case, make sure that CheckMicrHash isn't set if this has a bad MICR read
            if (financialTransaction.MICRStatus != MICRStatus.Fail)
            {
                financialTransaction.CheckMicrHash = Encryption.GetSHA1Hash(financialTransactionScannedCheck.ScannedCheckMicrData);
            }

            financialTransaction.CheckMicrParts = Encryption.EncryptString(financialTransactionScannedCheck.ScannedCheckMicrParts);
            return(this.Post(financialTransaction));
        }
示例#4
0
        /// <summary>
        /// Uploads the scanned item.
        /// </summary>
        /// <param name="scannedDocInfo">The scanned document information.</param>
        private void UploadScannedItem( ScannedDocInfo scannedDocInfo )
        {
            RockRestClient client = EnsureUploadScanRestClient();

            // upload image of front of doc
            string frontImageFileName = string.Format( "image1_{0}.png", DateTime.Now.ToString( "o" ).RemoveSpecialCharacters() );
            int frontImageBinaryFileId = client.UploadBinaryFile( frontImageFileName, Rock.Client.SystemGuid.BinaryFiletype.CONTRIBUTION_IMAGE.AsGuid(), scannedDocInfo.FrontImagePngBytes, false );

            // upload image of back of doc (if it exists)
            int? backImageBinaryFileId = null;
            if ( scannedDocInfo.BackImageData != null )
            {
                // upload image of back of doc
                string backImageFileName = string.Format( "image2_{0}.png", DateTime.Now.ToString( "o" ).RemoveSpecialCharacters() );
                backImageBinaryFileId = client.UploadBinaryFile( backImageFileName, Rock.Client.SystemGuid.BinaryFiletype.CONTRIBUTION_IMAGE.AsGuid(), scannedDocInfo.BackImagePngBytes, false );
            }

            FinancialPaymentDetail financialPaymentDetail = new FinancialPaymentDetail();
            financialPaymentDetail.CurrencyTypeValueId = scannedDocInfo.CurrencyTypeValue.Id;
            financialPaymentDetail.Guid = Guid.NewGuid();
            var financialPaymentDetailId = client.PostData<FinancialPaymentDetail>( "api/FinancialPaymentDetails", financialPaymentDetail ).AsIntegerOrNull();

            FinancialTransaction financialTransaction = new FinancialTransaction();

            financialTransaction.BatchId = batchPage.SelectedFinancialBatch.Id;
            financialTransaction.TransactionCode = string.Empty;
            financialTransaction.Summary = string.Empty;

            financialTransaction.Guid = Guid.NewGuid();
            financialTransaction.TransactionDateTime = batchPage.SelectedFinancialBatch.BatchStartDateTime;

            financialTransaction.FinancialPaymentDetailId = financialPaymentDetailId;
            financialTransaction.SourceTypeValueId = scannedDocInfo.SourceTypeValue.Id;

            financialTransaction.TransactionTypeValueId = transactionTypeValueContribution.Id;

            int? uploadedTransactionId;

            if ( scannedDocInfo.IsCheck )
            {
                financialTransaction.TransactionCode = scannedDocInfo.CheckNumber;
                financialTransaction.MICRStatus = scannedDocInfo.BadMicr ? MICRStatus.Fail : MICRStatus.Success;

                FinancialTransactionScannedCheck financialTransactionScannedCheck = new FinancialTransactionScannedCheck();

                // Rock server will encrypt CheckMicrPlainText to this since we can't have the DataEncryptionKey in a RestClient
                financialTransactionScannedCheck.FinancialTransaction = financialTransaction;
                financialTransactionScannedCheck.ScannedCheckMicrData = scannedDocInfo.ScannedCheckMicrData;
                financialTransactionScannedCheck.ScannedCheckMicrParts = scannedDocInfo.ScannedCheckMicrParts;

                uploadedTransactionId = client.PostData<FinancialTransactionScannedCheck>( "api/FinancialTransactions/PostScanned", financialTransactionScannedCheck ).AsIntegerOrNull();
            }
            else
            {
                uploadedTransactionId = client.PostData<FinancialTransaction>( "api/FinancialTransactions", financialTransaction as FinancialTransaction ).AsIntegerOrNull();
            }

            // upload FinancialTransactionImage records for front/back
            FinancialTransactionImage financialTransactionImageFront = new FinancialTransactionImage();
            financialTransactionImageFront.BinaryFileId = frontImageBinaryFileId;
            financialTransactionImageFront.TransactionId = uploadedTransactionId.Value;
            financialTransactionImageFront.Order = 0;
            financialTransactionImageFront.Guid = Guid.NewGuid();
            client.PostData<FinancialTransactionImage>( "api/FinancialTransactionImages", financialTransactionImageFront );

            if ( backImageBinaryFileId.HasValue )
            {
                FinancialTransactionImage financialTransactionImageBack = new FinancialTransactionImage();
                financialTransactionImageBack.BinaryFileId = backImageBinaryFileId.Value;
                financialTransactionImageBack.TransactionId = uploadedTransactionId.Value;
                financialTransactionImageBack.Order = 1;
                financialTransactionImageBack.Guid = Guid.NewGuid();
                client.PostData<FinancialTransactionImage>( "api/FinancialTransactionImages", financialTransactionImageBack );
            }

            scannedDocInfo.TransactionId = uploadedTransactionId;
            financialTransaction.Id = uploadedTransactionId ?? 0;
            financialTransaction.CreatedDateTime = financialTransaction.CreatedDateTime ?? DateTime.Now;

            var transactionList = batchPage.grdBatchItems.DataContext as BindingList<FinancialTransaction>;
            transactionList.Insert( 0, financialTransaction );

            _itemsUploaded++;
            ShowUploadStats();
            ShowUploadSuccess();
        }
 /// <summary>
 /// Copies the base properties from a source FinancialTransactionScannedCheck object
 /// </summary>
 /// <param name="source">The source.</param>
 public void CopyPropertiesFrom( FinancialTransactionScannedCheck source )
 {
     this.FinancialTransaction = source.FinancialTransaction;
     this.ScannedCheckMicrData = source.ScannedCheckMicrData;
     this.ScannedCheckMicrParts = source.ScannedCheckMicrParts;
 }
示例#6
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 = SelectedFinancialBatch.Id;
                financialTransactionScannedCheck.TransactionCode = string.Empty;
                financialTransactionScannedCheck.Summary = string.Format( "Scanned Check from {0}", appInfo );
                financialTransactionScannedCheck.Guid = Guid.NewGuid();
                financialTransactionScannedCheck.TransactionDateTime = SelectedFinancialBatch.BatchStartDateTime;
                financialTransactionScannedCheck.CurrencyTypeValueId = currencyTypeValueCheck.Id;
                financialTransactionScannedCheck.CreditCardTypeValueId = null;
                financialTransactionScannedCheck.SourceTypeValueId = null;
                financialTransactionScannedCheck.AuthorizedPersonId = null;
                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;
            }
        }
示例#7
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;
            }
        }
示例#8
0
        /// <summary>
        /// Uploads the scanned item.
        /// </summary>
        /// <param name="scannedDocInfo">The scanned document information.</param>
        public static void UploadScannedItem(ScannedDocInfo scannedDocInfo)
        {
            RockRestClient client = EnsureUploadScanRestClient();

            // upload image of front of doc (if was successfully scanned)
            int?frontImageBinaryFileId = null;

            if (scannedDocInfo.FrontImageData != null)
            {
                string frontImageFileName = string.Format("image1_{0}.png", DateTime.Now.ToString("o").RemoveSpecialCharacters());
                frontImageBinaryFileId = client.UploadBinaryFile(frontImageFileName, Rock.Client.SystemGuid.BinaryFiletype.CONTRIBUTION_IMAGE.AsGuid(), scannedDocInfo.FrontImagePngBytes, false);
            }

            // upload image of back of doc (if it exists)
            int?backImageBinaryFileId = null;

            if (scannedDocInfo.BackImageData != null)
            {
                // upload image of back of doc
                string backImageFileName = string.Format("image2_{0}.png", DateTime.Now.ToString("o").RemoveSpecialCharacters());
                backImageBinaryFileId = client.UploadBinaryFile(backImageFileName, Rock.Client.SystemGuid.BinaryFiletype.CONTRIBUTION_IMAGE.AsGuid(), scannedDocInfo.BackImagePngBytes, false);
            }

            FinancialPaymentDetail financialPaymentDetail = new FinancialPaymentDetail();

            financialPaymentDetail.CurrencyTypeValueId = scannedDocInfo.CurrencyTypeValue.Id;
            financialPaymentDetail.Guid = Guid.NewGuid();
            var financialPaymentDetailId = client.PostData <FinancialPaymentDetail>("api/FinancialPaymentDetails", financialPaymentDetail).AsIntegerOrNull();

            FinancialTransaction financialTransaction = new FinancialTransaction();

            financialTransaction.BatchId         = batchPage.SelectedFinancialBatch.Id;
            financialTransaction.TransactionCode = string.Empty;
            financialTransaction.Summary         = string.Empty;

            financialTransaction.Guid = Guid.NewGuid();
            financialTransaction.TransactionDateTime = batchPage.SelectedFinancialBatch.BatchStartDateTime;

            financialTransaction.FinancialPaymentDetailId = financialPaymentDetailId;
            financialTransaction.SourceTypeValueId        = scannedDocInfo.SourceTypeValue.Id;

            financialTransaction.TransactionTypeValueId = transactionTypeValueContribution.Id;
            var accounts = scannedDocInfo.AccountAmountCaptureList;

            if (accounts != null)
            {
                var accountsWithValues = accounts.Where(a => a.Amount > 0).ToList();
                if (accountsWithValues != null && accountsWithValues.Count() > 0)
                {
                    AddFinancialTransactionDetailForEachAccount(accountsWithValues, financialTransaction);
                }
            }
            int?uploadedTransactionId;

            if (scannedDocInfo.IsCheck)
            {
                financialTransaction.TransactionCode = scannedDocInfo.CheckNumber;
                financialTransaction.MICRStatus      = scannedDocInfo.BadMicr ? MICRStatus.Fail : MICRStatus.Success;

                FinancialTransactionScannedCheck financialTransactionScannedCheck = new FinancialTransactionScannedCheck();

                // Rock server will encrypt CheckMicrPlainText to this since we can't have the DataEncryptionKey in a RestClient
                financialTransactionScannedCheck.FinancialTransaction  = financialTransaction;
                financialTransactionScannedCheck.ScannedCheckMicrData  = scannedDocInfo.ScannedCheckMicrData;
                financialTransactionScannedCheck.ScannedCheckMicrParts = scannedDocInfo.ScannedCheckMicrParts;
                uploadedTransactionId = client.PostData <FinancialTransactionScannedCheck>("api/FinancialTransactions/PostScanned", financialTransactionScannedCheck).AsIntegerOrNull();
            }
            else
            {
                //FinancialTransactionDetail
                uploadedTransactionId = client.PostData <FinancialTransaction>("api/FinancialTransactions", financialTransaction as FinancialTransaction).AsIntegerOrNull();
            }

            // upload FinancialTransactionImage records for front/back
            if (frontImageBinaryFileId.HasValue)
            {
                FinancialTransactionImage financialTransactionImageFront = new FinancialTransactionImage();
                financialTransactionImageFront.BinaryFileId  = frontImageBinaryFileId.Value;
                financialTransactionImageFront.TransactionId = uploadedTransactionId.Value;
                financialTransactionImageFront.Order         = 0;
                financialTransactionImageFront.Guid          = Guid.NewGuid();
                client.PostData <FinancialTransactionImage>("api/FinancialTransactionImages", financialTransactionImageFront);
            }

            if (backImageBinaryFileId.HasValue)
            {
                FinancialTransactionImage financialTransactionImageBack = new FinancialTransactionImage();
                financialTransactionImageBack.BinaryFileId  = backImageBinaryFileId.Value;
                financialTransactionImageBack.TransactionId = uploadedTransactionId.Value;
                financialTransactionImageBack.Order         = 1;
                financialTransactionImageBack.Guid          = Guid.NewGuid();
                client.PostData <FinancialTransactionImage>("api/FinancialTransactionImages", financialTransactionImageBack);
            }

            scannedDocInfo.TransactionId         = uploadedTransactionId;
            financialTransaction.Id              = uploadedTransactionId ?? 0;
            financialTransaction.CreatedDateTime = financialTransaction.CreatedDateTime ?? DateTime.Now;
            batchPage.SelectedFinancialBatch.Transactions.Add(financialTransaction);

            var transactionList = batchPage.grdBatchItems.DataContext as BindingList <FinancialTransaction>;

            transactionList.Insert(0, financialTransaction);

            ItemsUploaded++;
        }
示例#9
0
 /// <summary>
 /// Copies the base properties from a source FinancialTransactionScannedCheck object
 /// </summary>
 /// <param name="source">The source.</param>
 public void CopyPropertiesFrom(FinancialTransactionScannedCheck source)
 {
     this.FinancialTransaction  = source.FinancialTransaction;
     this.ScannedCheckMicrData  = source.ScannedCheckMicrData;
     this.ScannedCheckMicrParts = source.ScannedCheckMicrParts;
 }
示例#10
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.Name, assemblyName.Version );

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

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

            foreach ( ScannedDocInfo scannedDocInfo in ScannedDocList.Where( a => !a.Uploaded ) )
            {
                // upload image of front of doc
                string frontImageFileName = string.Format( "image1_{0}.png", RockDateTime.Now.ToString( "o" ).RemoveSpecialCharacters() );
                int frontImageBinaryFileId = client.UploadBinaryFile( frontImageFileName, Rock.SystemGuid.BinaryFiletype.CONTRIBUTION_IMAGE.AsGuid(), scannedDocInfo.FrontImagePngBytes, false );

                // upload image of back of doc (if it exists)
                int? backImageBinaryFileId = null;
                if ( scannedDocInfo.BackImageData != null )
                {
                    // upload image of back of doc
                    string backImageFileName = string.Format( "image2_{0}.png", RockDateTime.Now.ToString( "o" ).RemoveSpecialCharacters() );
                    backImageBinaryFileId = client.UploadBinaryFile( backImageFileName, Rock.SystemGuid.BinaryFiletype.CONTRIBUTION_IMAGE.AsGuid(), scannedDocInfo.BackImagePngBytes, false );
                }

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

                FinancialTransaction financialTransactionScanned = new FinancialTransaction();

                Guid transactionGuid = Guid.NewGuid();

                financialTransactionScanned.BatchId = SelectedFinancialBatch.Id;
                financialTransactionScanned.TransactionCode = string.Empty;
                financialTransactionScanned.Summary = "Scanned from Check Scanner Utility";

                financialTransactionScanned.Guid = transactionGuid;
                financialTransactionScanned.TransactionDateTime = SelectedFinancialBatch.BatchStartDateTime;

                financialTransactionScanned.CurrencyTypeValueId = scannedDocInfo.CurrencyTypeValue.Id;
                financialTransactionScanned.SourceTypeValueId = scannedDocInfo.SourceTypeValue.Id;

                financialTransactionScanned.TransactionTypeValueId = transactionTypeValueContribution.Id;

                if ( scannedDocInfo.IsCheck )
                {
                    FinancialTransactionScannedCheck financialTransactionScannedCheck = new FinancialTransactionScannedCheck();

                    // Rock server will encrypt CheckMicrPlainText to this since we can't have the DataEncryptionKey in a RestClient
                    financialTransactionScannedCheck.FinancialTransaction = financialTransactionScanned;
                    financialTransactionScannedCheck.ScannedCheckMicr = scannedDocInfo.ScannedCheckMicr;

                    client.PostData<FinancialTransactionScannedCheck>( "api/FinancialTransactions/PostScanned", financialTransactionScannedCheck );
                }
                else
                {
                    client.PostData<FinancialTransaction>( "api/FinancialTransactions", financialTransactionScanned as FinancialTransaction );
                }

                // get the FinancialTransaction back from server so that we can get it's Id
                int transactionId = client.GetIdFromGuid( "api/FinancialTransactions/", transactionGuid );
                

                // upload FinancialTransactionImage records for front/back
                FinancialTransactionImage financialTransactionImageFront = new FinancialTransactionImage();
                financialTransactionImageFront.BinaryFileId = frontImageBinaryFileId;
                financialTransactionImageFront.TransactionId = transactionId;
                financialTransactionImageFront.Order = 0;
                client.PostData<FinancialTransactionImage>( "api/FinancialTransactionImages", financialTransactionImageFront );

                if ( backImageBinaryFileId.HasValue )
                {
                    FinancialTransactionImage financialTransactionImageBack = new FinancialTransactionImage();
                    financialTransactionImageBack.BinaryFileId = backImageBinaryFileId.Value;
                    financialTransactionImageBack.TransactionId = transactionId;
                    financialTransactionImageBack.Order = 1;
                    client.PostData<FinancialTransactionImage>( "api/FinancialTransactionImages", financialTransactionImageBack );
                }

                scannedDocInfo.Uploaded = true;
                scannedDocInfo.TransactionId = transactionId;
            }

            ScanningPage.ClearScannedDocHistory();
        }