Simple Client Model for FinancialTransactionImage
 /// <summary>
 /// Copies the base properties from a source FinancialTransactionImage object
 /// </summary>
 /// <param name="source">The source.</param>
 public void CopyPropertiesFrom(FinancialTransactionImage source)
 {
     this.Id           = source.Id;
     this.BinaryFileId = source.BinaryFileId;
     this.ForeignGuid  = source.ForeignGuid;
     this.ForeignKey   = source.ForeignKey;
     this.ModifiedAuditValuesAlreadyUpdated = source.ModifiedAuditValuesAlreadyUpdated;
     this.Order                   = source.Order;
     this.TransactionId           = source.TransactionId;
     this.CreatedDateTime         = source.CreatedDateTime;
     this.ModifiedDateTime        = source.ModifiedDateTime;
     this.CreatedByPersonAliasId  = source.CreatedByPersonAliasId;
     this.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     this.Guid      = source.Guid;
     this.ForeignId = source.ForeignId;
 }
Example #2
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();
        }
Example #3
0
 /// <summary>
 /// Copies the base properties from a source FinancialTransactionImage object
 /// </summary>
 /// <param name="source">The source.</param>
 public void CopyPropertiesFrom( FinancialTransactionImage source )
 {
     this.Id = source.Id;
     this.BinaryFileId = source.BinaryFileId;
     this.Order = source.Order;
     this.TransactionId = source.TransactionId;
     this.Guid = source.Guid;
     this.ForeignId = source.ForeignId;
 }
 /// <summary>
 /// Copies the base properties from a source FinancialTransactionImage object
 /// </summary>
 /// <param name="source">The source.</param>
 public void CopyPropertiesFrom( FinancialTransactionImage source )
 {
     this.Id = source.Id;
     this.BinaryFileId = source.BinaryFileId;
     this.ForeignGuid = source.ForeignGuid;
     this.ForeignKey = source.ForeignKey;
     this.ModifiedAuditValuesAlreadyUpdated = source.ModifiedAuditValuesAlreadyUpdated;
     this.Order = source.Order;
     this.TransactionId = source.TransactionId;
     this.CreatedDateTime = source.CreatedDateTime;
     this.ModifiedDateTime = source.ModifiedDateTime;
     this.CreatedByPersonAliasId = source.CreatedByPersonAliasId;
     this.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     this.Guid = source.Guid;
     this.ForeignId = source.ForeignId;
 }