示例#1
0
        internal bool UpdateCreditCard(RowLockingWrapper <CreditCardRow> creditCardRowWrapper,
                                       FluidTrade.Core.IDataModelTransaction dataModelTransaction, bool isValid)
        {
            this.cardMatcher.RemoveRowFromMap(creditCardRowWrapper.Row);

            if (isValid == false)
            {
                return(false);
            }

            //System.Diagnostics.Trace.WriteLine(
            //    string.Format("{0}  Updating CreditCard: {1}", System.Threading.Thread.CurrentThread.Name,
            //                        creditCardRowWrapper.TypedRow["OriginalAccountNumber"]));

            creditCardRowWrapper.AcquireReaderLock();
            try
            {
                //if not valid or rowState is delete/detach all can do is remove the row
                if (creditCardRowWrapper.Row.RowState == DataRowState.Deleted ||
                    creditCardRowWrapper.Row.RowState == DataRowState.Detached)
                {
                    return(false);
                }


                this.cardMatcher.AddTableRowToMap(creditCardRowWrapper);
            }
            finally
            {
                creditCardRowWrapper.ReleaseReaderLock();
            }

            return(true);
        }
示例#2
0
        internal bool UpdateConsumer(RowLockingWrapper <ConsumerRow> consumerRowWrapper,
                                     FluidTrade.Core.IDataModelTransaction dataModelTransaction, bool isValid)
        {
            this.socialMatcher.RemoveRowFromMap(consumerRowWrapper.Row);
            this.lastNameMatcher.RemoveRowFromMap(consumerRowWrapper.Row);
            this.firstNameMatcher.RemoveRowFromMap(consumerRowWrapper.Row);

            if (isValid == false)
            {
                return(false);
            }

            consumerRowWrapper.AcquireReaderLock();
            try
            {
                //if not valid or rowState is delete/detach all can do is remove the row
                if (consumerRowWrapper.Row.RowState == DataRowState.Deleted ||
                    consumerRowWrapper.Row.RowState == DataRowState.Detached)
                {
                    return(false);
                }


                this.socialMatcher.AddTableRowToMap(consumerRowWrapper);
                this.lastNameMatcher.AddTableRowToMap(consumerRowWrapper);
                this.firstNameMatcher.AddTableRowToMap(consumerRowWrapper);
            }
            finally
            {
                consumerRowWrapper.ReleaseReaderLock();
            }

            return(true);
        }
示例#3
0
        private void GetMatchResultsForSocial(RowLockingWrapper <CreditCardRow> creditCardRowToFind,
                                              RowLockingWrapper <ConsumerRow> consumerRowToFind,
                                              object ccNum, object lastName,
                                              List <MatchResult> results, IEnumerable <MatchInfo> snMiList,
                                              IDataModelTransaction dataModelTransaction, Decimal matchThreshold)
        {
            if (snMiList == null)
            {
                return;
            }

            //!!!RM what is faster using the .Consumer row
            //or using the ConsumerRow Fuz Matcher
            foreach (MatchInfo snMi in snMiList)
            {
                ConsumerRow miConsumerRow = (ConsumerRow)snMi.row;

                RowLockingWrapper <ConsumerRow> miConsumerRowWrapper = new RowLockingWrapper <ConsumerRow>(miConsumerRow, dataModelTransaction);
                MatchInfo ssnLnMi = this.lastNameMatcher.Validate(lastName, miConsumerRowWrapper, dataModelTransaction);

                MatchInfo ssnFnMi = null;

                miConsumerRowWrapper.AcquireReaderLock();
                if (miConsumerRow.RowState == DataRowState.Deleted ||
                    miConsumerRow.RowState == DataRowState.Detached)
                {
                    continue;
                }
                try
                {
                    CreditCardRow[] ccRows = miConsumerRow.GetCreditCardRows_NoLockCheck();

                    if (ccRows.Length > 0)
                    {
                        foreach (CreditCardRow snCcRow in ccRows)
                        {
                            RowLockingWrapper <CreditCardRow> snCcRowWrappper = new RowLockingWrapper <CreditCardRow>(snCcRow, dataModelTransaction);

                            MatchInfo   ssnCcMi = this.cardMatcher.Validate(ccNum, snCcRowWrappper, dataModelTransaction);
                            MatchResult mr      = new MatchResult(consumerRowToFind.TypedRow, creditCardRowToFind.TypedRow, ssnCcMi, snMi, ssnLnMi);
                            //if(mr.Strength < 1M)
                            //{
                            if (ssnFnMi == null)
                            {
                                consumerRowToFind.AcquireReaderLock();
                                try
                                {
                                    ssnFnMi = this.firstNameMatcher.Validate(consumerRowToFind.Row[this.firstNameColumn], miConsumerRowWrapper, dataModelTransaction);
                                }
                                finally
                                {
                                    consumerRowToFind.ReleaseReaderLock();
                                }
                            }
                            mr.AddFirstNameMatchInfo(ssnFnMi);
                            //}

                            if (mr.Strength >= matchThreshold)
                            {
                                results.Add(mr);
                            }
                        }
                    }
                    else
                    {
                        MatchResult mr = new MatchResult(consumerRowToFind.TypedRow, creditCardRowToFind.TypedRow, null, snMi, ssnLnMi);

                        consumerRowToFind.AcquireReaderLock();
                        try
                        {
                            mr.AddFirstNameMatchInfo(this.firstNameMatcher.Validate(consumerRowToFind.Row[this.firstNameColumn], miConsumerRowWrapper, dataModelTransaction));
                        }
                        finally
                        {
                            consumerRowToFind.ReleaseReaderLock();
                        }

                        if (mr.Strength >= matchThreshold)
                        {
                            results.Add(mr);
                        }
                    }
                }
                finally
                {
                    miConsumerRowWrapper.ReleaseReaderLock();
                }
            }
        }
示例#4
0
        private void GetMatchResultsForCreditCard(RowLockingWrapper <CreditCardRow> creditCardRowToFind, RowLockingWrapper <ConsumerRow> consumerRowToFind, object ssnNum,
                                                  object lastName, List <MatchResult> results, IEnumerable <MatchInfo> ccMiList,
                                                  IDataModelTransaction dataModelTransaction, Decimal matchThreshold)
        {
            if (ccMiList == null)
            {
                return;
            }

            //!!!RM what is faster using the .Consumer row
            //or using the ConsumerRow Fuz Matcher
            foreach (MatchInfo ccMi in ccMiList)
            {
                ConsumerRow miConsumerRow;
                if (dataModelTransaction != null)
                {
                    ((CreditCardRow)ccMi.row).AcquireReaderLock(dataModelTransaction.TransactionId, ((CreditCardRow)ccMi.row).LockTimeout);
                }

                if (ccMi.row.RowState == DataRowState.Deleted ||
                    ccMi.row.RowState == DataRowState.Detached)
                {
                    if (dataModelTransaction != null)
                    {
                        ((CreditCardRow)ccMi.row).ReleaseReaderLock(dataModelTransaction.TransactionId);
                    }

                    continue;
                }
                try
                {
                    miConsumerRow = ((CreditCardRow)ccMi.row).ConsumerRow;
                }
                finally
                {
                    if (dataModelTransaction != null)
                    {
                        ((CreditCardRow)ccMi.row).ReleaseReaderLock(dataModelTransaction.TransactionId);
                    }
                }

                if (miConsumerRow == null)
                {
                    continue;
                }

                RowLockingWrapper <ConsumerRow> consumerRowWrapper = new RowLockingWrapper <ConsumerRow>(miConsumerRow, dataModelTransaction);

                consumerRowWrapper.AcquireReaderLock();
                if (consumerRowWrapper.Row.RowState == DataRowState.Deleted ||
                    consumerRowWrapper.Row.RowState == DataRowState.Detached)
                {
                    consumerRowWrapper.ReleaseReaderLock();
                    continue;
                }

                try
                {
                    MatchInfo ccSsnMi = socialMatcher.Validate(ssnNum, consumerRowWrapper, dataModelTransaction);
                    MatchInfo ccLnMi  = this.lastNameMatcher.Validate(lastName, consumerRowWrapper, dataModelTransaction);

                    MatchResult mr = new MatchResult(consumerRowToFind.TypedRow, creditCardRowToFind.TypedRow, ccMi, ccSsnMi, ccLnMi);
                    //if(mr.Strength < 1M)
                    //{
                    mr.AddFirstNameMatchInfo(this.firstNameMatcher.Validate(consumerRowToFind.Row[this.firstNameColumn], consumerRowWrapper, dataModelTransaction));
                    //}

                    if (mr.Strength >= matchThreshold)
                    {
                        results.Add(mr);
                    }
                }
                finally
                {
                    consumerRowWrapper.ReleaseReaderLock();
                }
            }
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="creditCardRowToFind"></param>
        /// <param name="consumerRowToFind"></param>
        /// <param name="dataModelTransaction"></param>
        /// <param name="matchThreshold"></param>
        /// <returns></returns>
        public List <MatchResult> FindMatch(RowLockingWrapper <CreditCardRow> creditCardRowToFind, RowLockingWrapper <ConsumerRow> consumerRowToFind,
                                            IDataModelTransaction dataModelTransaction, Decimal matchThreshold)
        {
            //check exact
            object ccNum;

            creditCardRowToFind.AcquireReaderLock();
            try
            {
                ccNum = creditCardRowToFind.Row[this.creditCardColumn];
            }
            finally
            {
                creditCardRowToFind.ReleaseReaderLock();
            }

            object ssnNum;
            object lastName;

            consumerRowToFind.AcquireReaderLock();
            try
            {
                ssnNum   = consumerRowToFind.Row[this.ssnColumn];
                lastName = consumerRowToFind.Row[this.lastNameColumn];
            }
            finally
            {
                consumerRowToFind.ReleaseReaderLock();
            }

            List <MatchResult> results = new List <MatchResult>();

            //search by exact CreditCard
            this.SearchByExactCreditCard(creditCardRowToFind, consumerRowToFind, ccNum, ssnNum, lastName, results, dataModelTransaction, matchThreshold);

            //System.Diagnostics.Trace.WriteLine(
            //    string.Format("{0}  CreditCard search: {1}  {2}  {3}", System.Threading.Thread.CurrentThread.Name,
            //                        ccNum, ssnNum, lastName));
            //System.Diagnostics.Trace.Indent();
            //foreach(MatchResult mr in results)
            //    System.Diagnostics.Trace.WriteLine(mr.ToString());
            //System.Diagnostics.Trace.Unindent();

            //if have a ~100% result continue?
            int resultIndex = 0;

            for (; resultIndex < results.Count; resultIndex++)
            {
                MatchResult mr = results[resultIndex];
                if (mr.Strength >= 1M)
                {
                    results.Sort();
                    return(results);
                }
            }
            //search by exact SSN
            this.SearchByExactSocialSecurity(creditCardRowToFind, consumerRowToFind, ccNum, ssnNum, lastName, results, dataModelTransaction, matchThreshold);

            //System.Diagnostics.Trace.WriteLine(
            //        string.Format("{0}  SSN search: {1}  {2}  {3}", System.Threading.Thread.CurrentThread.Name,
            //                            ccNum, ssnNum, lastName));
            //System.Diagnostics.Trace.Indent();
            //foreach(MatchResult mr in results)
            //    System.Diagnostics.Trace.WriteLine(mr.ToString());
            //System.Diagnostics.Trace.Unindent();

            //if have a ~100% result continue? could not have an exact match here
            //and not have had it in the cc, but could have a high % match
            for (; resultIndex < results.Count; resultIndex++)
            {
                MatchResult mr = results[resultIndex];
                if (mr.Strength >= 1M)
                {
                    results.Sort();
                    return(results);
                }
            }

            this.SearchByProbableSocialSecurity(creditCardRowToFind, consumerRowToFind, ccNum, ssnNum, lastName, results, dataModelTransaction, matchThreshold);

            //System.Diagnostics.Trace.WriteLine(
            //        string.Format("{0}  Probable CreditCard search: {1}  {2}  {3}", System.Threading.Thread.CurrentThread.Name,
            //                            ccNum, ssnNum, lastName));
            //System.Diagnostics.Trace.Indent();
            //foreach(MatchResult mr in results)
            //    System.Diagnostics.Trace.WriteLine(mr.ToString());
            //System.Diagnostics.Trace.Unindent();

            this.SearchByProbableCreditCard(creditCardRowToFind, consumerRowToFind, ccNum, ssnNum, lastName, results, dataModelTransaction, matchThreshold);

            results.Sort();

            //System.Diagnostics.Trace.WriteLine(
            //                string.Format("{0}  Probable CreditCard search: {1}  {2}  {3}", System.Threading.Thread.CurrentThread.Name,
            //                                    ccNum, ssnNum, lastName));

            //System.Diagnostics.Trace.Indent();
            //foreach(MatchResult mr in results)
            //    System.Diagnostics.Trace.WriteLine(mr.ToString());
            //System.Diagnostics.Trace.Unindent();

            if (results.Count == 0)
            {
                return(null);
            }

            return(results);
        }
        /// <summary>
        /// Extract information from the settlementRow to send to GCS
        /// </summary>
        /// <param name="rawSettlementRow"></param>
        private void ProcessSettlement(ConsumerTrustSettlementRow rawSettlementRow)
        {
            List <PaymentInfo> paymentInfoList  = new List <PaymentInfo>();
            String             gcsAccountNumber = String.Empty;

            try
            {
                using (TransactionScope transactionScope = new TransactionScope())
                {
                    // This provides a context for any transactions.
                    DataModelTransaction dataModelTransaction = DataModelTransaction.Current;

                    if (rawSettlementRow != null)
                    {
                        rawSettlementRow.AcquireReaderLock(dataModelTransaction.TransactionId, DataModel.LockTimeout);
                        bool settlementDeletedOrDetached = false;
                        try
                        {
                            settlementDeletedOrDetached = rawSettlementRow.RowState == DataRowState.Deleted ||
                                                          rawSettlementRow.RowState == DataRowState.Detached;
                        }
                        finally
                        {
                            rawSettlementRow.ReleaseReaderLock(dataModelTransaction.TransactionId);
                        }

                        //If the settlement was removed by the time we got to this, then there is no need to continue
                        if (settlementDeletedOrDetached == true)
                        {
                            return;
                        }
                    }

                    RowLockingWrapper <ConsumerTrustSettlementRow> settlementRow = new RowLockingWrapper <ConsumerTrustSettlementRow>(rawSettlementRow, dataModelTransaction);
                    settlementRow.AcquireReaderLock();
                    try
                    {
                        //We need GCS account id for this payment.  We cannot find a GCS account number then we cannot process this payment.
                        Guid creditCardId = Guid.Empty;
                        ConsumerTrustNegotiationRow negotiationRow = settlementRow.TypedRow.ConsumerTrustNegotiationRow;
                        negotiationRow.AcquireReaderLock(dataModelTransaction.TransactionId, DataModel.LockTimeout);
                        try
                        {
                            creditCardId = negotiationRow.CreditCardId;
                        }
                        finally
                        {
                            negotiationRow.ReleaseReaderLock(dataModelTransaction.TransactionId);
                            //no longer usable
                            negotiationRow = null;
                        }

                        //HACK - add error reporting
                        if (creditCardId == Guid.Empty)
                        {
                            return;
                        }

                        //Determine the consumer
                        Guid          consumerId    = Guid.Empty;
                        CreditCardRow creditcardRow = DataModel.CreditCard.CreditCardKey.Find(creditCardId);
                        creditcardRow.AcquireReaderLock(dataModelTransaction.TransactionId, DataModel.LockTimeout);
                        try
                        {
                            consumerId = creditcardRow.ConsumerId;
                        }
                        finally
                        {
                            creditcardRow.ReleaseReaderLock(dataModelTransaction.TransactionId);
                            //no longer usable
                            creditcardRow = null;
                        }

                        //HACK - add error reporting
                        if (consumerId == Guid.Empty)
                        {
                            return;
                        }

                        //Determine the consumerTrust
                        ConsumerTrustRow consumerTrustRow = null;
                        ConsumerRow      consumerRow      = DataModel.Consumer.ConsumerKey.Find(consumerId);
                        consumerRow.AcquireReaderLock(dataModelTransaction.TransactionId, DataModel.LockTimeout);
                        try
                        {
                            consumerTrustRow = consumerRow.GetConsumerTrustRows_NoLockCheck().First();
                        }
                        finally
                        {
                            consumerRow.ReleaseReaderLock(dataModelTransaction.TransactionId);
                            //no longer usable
                            consumerRow = null;
                        }

                        //HACK - add error reporting
                        if (consumerTrustRow == null)
                        {
                            return;
                        }

                        consumerTrustRow.AcquireReaderLock(dataModelTransaction.TransactionId, DataModel.LockTimeout);
                        try
                        {
                            gcsAccountNumber = (consumerTrustRow.IsSavingsAccountNull()) ? String.Empty : consumerTrustRow.SavingsAccount;
                        }
                        finally
                        {
                            consumerTrustRow.ReleaseReaderLock(dataModelTransaction.TransactionId);
                            //no longer usable
                            consumerTrustRow = null;
                        }

                        //HACK - add error reporting
                        if (String.IsNullOrEmpty(gcsAccountNumber))
                        {
                            return;
                        }


                        foreach (ConsumerTrustPaymentRow paymentRow in settlementRow.TypedRow.GetConsumerTrustPaymentRows())
                        {
                            paymentRow.AcquireReaderLock(dataModelTransaction.TransactionId, DataModel.LockTimeout);
                            try
                            {
                                if (paymentRow.RowState != DataRowState.Deleted &&
                                    paymentRow.RowState != DataRowState.Detached)
                                {
                                    paymentInfoList.Add(new PaymentInfo(paymentRow));
                                }
                            }
                            finally
                            {
                                paymentRow.ReleaseReaderLock(dataModelTransaction.TransactionId);
                            }
                        }
                    }
                    finally
                    {
                        settlementRow.ReleaseReaderLock();
                    }
                }
            }
            catch (Exception ex)
            {
                EventLog.Error(ex);
            }

            if (String.IsNullOrEmpty(gcsAccountNumber) == false && paymentInfoList.Count != 0)
            {
                SendPaymentsToGCS(gcsAccountNumber, paymentInfoList);
            }
        }