コード例 #1
0
        /// <summary>
        /// Parses given record and creates instance of <see cref="DetailAcknowledgment"/>
        /// </summary>
        /// <remarks>
        /// Some fields are Signed Values listed as S9(x) [Always positive]
        /// Here x is number of digits and least significant digit is in EBCDIC !!
        /// So S9(4) means the field has 4 digits with LSD in EBCDIC.
        /// One more example:
        /// S9(6)V99 means total 8 digits, of which last two are decimal places and LSD in EBCDIC.
        /// </remarks>
        /// <param name="record"></param>
        /// <param name="recordNumber"></param>
        /// <returns></returns>
        internal DetailAcknowledgment Parse(string record, int recordNumber)
        {
            SignedValueConverter signedValueConverter = new SignedValueConverter();;
            DetailAcknowledgment detailAcknowledgment = new DetailAcknowledgment();

            RecordNumber = recordNumber;

            int    recordPos   = 0;
            bool   recordValid = true;
            string stringField = null;
            string convertedString;
            long   convertedNum;

            ParsingUtilities parsingUtilities = new ParsingUtilities(RecordTypeDescriptor, RecordNumber, FileName, AcknowledgmentConstants.TimeFieldLength, Log);

            // RecordId
            recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Record ID", RecordType,
                                                        AcknowledgmentConstants.RecordTypeLength, recordValid);

            // Card Token : S9(16)
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.TokenLength, recordValid);
            recordValid = signedValueConverter.TryGetStringFromSignedData(stringField, out convertedString);
            detailAcknowledgment.Token = convertedString;

            // TransactionCode
            recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Transaction Code", TransactionCode,
                                                        AcknowledgmentConstants.TransactionCodeLength, recordValid);

            // TransactionAmount :  S9(6)V99
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.TransactionAmountLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            detailAcknowledgment.TransactionAmount = (decimal)convertedNum / 100;

            // TransactionDate : S9(4) format [MMDD]
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.TransactionDateLength, recordValid);
            recordValid = signedValueConverter.TryGetStringFromSignedData(stringField, out convertedString);
            detailAcknowledgment.TransactionDate = recordValid ? GetDateTimeFromString(convertedString) : DateTime.Now;

            // Authorization Code
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.AuthorizationCodeLength, recordValid);
            detailAcknowledgment.AuthorizationCode = stringField;

            // Authorization Date
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.AuthorizationDateLength, recordValid);
            detailAcknowledgment.AuthorizationDate = stringField;

            // Acknowledgment Code : S9(4)
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.AcknowledgmentCodeLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            // We will not get overflow as ack code is at most 4 digits long
            detailAcknowledgment.AcknowledgementCode = Convert.ToInt32(convertedNum);

            // Reference Number :  S9(8)
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.ReferenceNumberLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            detailAcknowledgment.ReferenceNumber = convertedNum;

            // Record Sequence Number : S9(6)
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.RecordSequenceNumberLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            detailAcknowledgment.RecordSequenceNumber = convertedNum;

            // Merchant Descriptor
// TODO : Make this 21 and ignore the filler below. Side effect of using Bing Offers in merchant description
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.MerchantDescriptorLength, recordValid);
            detailAcknowledgment.MerchantDescriptor = stringField;

            // Filler
//            recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Filler", Filler,
//                                                        AcknowledgmentConstants.FillerLength, recordValid);

            // Card Type
            recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Card Type", CardType,
                                                        AcknowledgmentConstants.CardTypeLength, recordValid);

            // If the record is not valid, return a null value.
            if (recordValid == false)
            {
                detailAcknowledgment = null;
            }

            return(detailAcknowledgment);
        }
コード例 #2
0
        /// <summary>
        /// Parses given record and creates instance of <see cref="GeneralAcknowledgment"/>
        /// </summary>
        /// <remarks>
        /// Some fields are Signed Values listed as S9(x) [Always positive]
        /// Here x is number of digits and least significant digit is in EBCDIC !!
        /// So S9(4) means the field has 4 digits with LSD in EBCDIC.
        /// One more example:
        /// S9(6)V99 means total 8 digits, of which last two are decimal places and LSD in EBCDIC.
        /// </remarks>
        /// <param name="record"></param>
        /// <param name="recordNumber"></param>
        /// <returns></returns>
        internal GeneralAcknowledgment Parse(string record, int recordNumber)
        {
            SignedValueConverter  signedValueConverter  = new SignedValueConverter();;
            GeneralAcknowledgment generalAcknowledgment = new GeneralAcknowledgment();

            RecordNumber = recordNumber;

            int    recordPos   = 0;
            bool   recordValid = true;
            string stringField = null;
            string convertedString;
            long   convertedNum;

            ParsingUtilities parsingUtilities = new ParsingUtilities(RecordTypeDescriptor, RecordNumber, FileName, AcknowledgmentConstants.TimeFieldLength, Log);

            // RecordId
            recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Record ID", RecordType,
                                                        AcknowledgmentConstants.RecordTypeLength, recordValid);

            // SalesDepositAmount :  S9(7)V99
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.SalesDepositAmountLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            generalAcknowledgment.SalesDepositAmount = (decimal)convertedNum / 100;

            // CreditAmount : S9(7)V99
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.CreditAmountLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            generalAcknowledgment.CreditAmount = (decimal)convertedNum / 100;

            // Cash Advance Deposit Amount : S9(7)V99
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.CashAdvanceDepositAmountLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            generalAcknowledgment.CashAdvanceDepositAmount = (decimal)convertedNum / 100;

            // Acknowledgment Code : S9(4)
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.AcknowledgmentCodeLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            // We will not get overflow as ack code is at most 4 digits long
            generalAcknowledgment.AcknowledgementCode = Convert.ToInt32(convertedNum);

            // FiveSpaceFiller
            recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Filler", FiveSpaceFiller,
                                                        AcknowledgmentConstants.FiveSpaceFillerLength, recordValid);

            // Record Sequence Number : S9(6)
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.RecordSequenceNumberLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            generalAcknowledgment.RecordSequenceNumber = convertedNum;

            // Submission Id : S9(9)
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.SubmissionID, recordValid);
            recordValid = signedValueConverter.TryGetStringFromSignedData(stringField, out convertedString);
            generalAcknowledgment.SubmissionId = convertedString;

            // EightSpaceFiller
            recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Filler", EightSpaceFiller,
                                                        AcknowledgmentConstants.EightSpaceFillerLength, recordValid);

            // Deposit Authorization Request Amount : S9(7)V99
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.DepositAuthorizationRequestAmountLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            generalAcknowledgment.DepositAuthorizationRequestAmount = (decimal)convertedNum / 100;

            // Cash Advance Deposit Auth Request Amount : S9(7)V99
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.CashAdvanceDepositAuthRequestAmountLength, recordValid);
            recordValid = signedValueConverter.TryGetNumberFromSignedData(stringField, out convertedNum);
            generalAcknowledgment.CashAdvanceDepositAuthAmount = (decimal)convertedNum / 100;

            // Follow-up Ack Indicator
            recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField,
                                                          AcknowledgmentConstants.FollowupAckIndicatorLength, recordValid);
            generalAcknowledgment.FollowUpAcknowledgmentIndicator = stringField;

            // Single Space Filler
            recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Filler", SingleSpaceFiller,
                                                        AcknowledgmentConstants.SingleSpaceFillerLength, recordValid);

            // If the record is not valid, return a null value.
            if (recordValid == false)
            {
                generalAcknowledgment = null;
            }

            return(generalAcknowledgment);
        }