}         // CacheNotExpired

        private NonLimitedResults GetOneNotLimitedBusinessData(
            string refNumber,
            int customerId,
            bool checkInCacheOnly,
            bool forceCheck
            )
        {
            try {
                DateTime?created = GetNonLimitedCreationTime(refNumber);

                if (forceCheck || (!checkInCacheOnly && CacheExpired(created)))
                {
                    string requestXml = GetResource("ExperianLib.Ebusiness.NonLimitedBusinessRequest.xml", refNumber);

                    var newResponse = MakeRequest(requestXml);

                    Utils.WriteLog(
                        requestXml,
                        newResponse,
                        ExperianServiceType.NonLimitedData,
                        customerId,
                        companyRefNum: refNumber
                        );

                    return(BuildResponseFromDb(refNumber));
                }                 // if

                if (created == null)
                {
                    return(null);
                }

                NonLimitedResults res = BuildResponseFromDb(refNumber);
                res.CacheHit = true;
                return(res);
            } catch (Exception e) {
                log.Error(e,
                          "Failed to get one non limited result for a company {0} and customer {1} (cache only: {2}, force: {3}).",
                          refNumber, customerId,
                          checkInCacheOnly ? "yes" : "no",
                          forceCheck ? "yes" : "no"
                          );

                return(new NonLimitedResults(e));
            }     // try
        }         // GetOneNotLimitedBusinessData
Exemple #2
0
        private ActionResult ProcessOneLine(SafeReader sr, bool bRowsetStart)
        {
            int      loanId         = sr["loanID"];
            DateTime startDate      = sr["StartDate"];
            DateTime dateClose      = sr["DateClose"];
            decimal  currentBalance = sr["CurrentBalance"];
            string   gender         = sr["Gender"];
            string   firstName      = sr["FirstName"];
            string   middleInitial  = sr["MiddleInitial"];
            string   surname        = sr["Surname"];
            string   refNumber      = sr["RefNumber"];
            string   line1          = sr["Line1"];
            string   line2          = sr["Line2"];
            string   line3          = sr["Line3"];
            string   town           = sr["Town"];
            string   county         = sr["County"];
            string   postcode       = sr["Postcode"];
            DateTime dateOfBirth    = sr["DateOfBirth"];
            string   manualCaisFlag = sr["ManualCaisFlag"];

            DateTime?minLsDate = null;
            DateTime tmp       = sr["MinLSDate"];

            if (tmp != default(DateTime))
            {
                minLsDate = tmp;
            }
            decimal loanAmount          = sr["LoanAmount"];
            int     scheduledRepayments = sr["ScheduledRepayments"];
            string  companyType         = sr["CompanyType"];
            string  experianRefNum      = sr["ExperianRefNum"];
            string  experianCompanyName = sr["ExperianCompanyName"];
            string  customerState       = sr["CustomerState"];
            string  sortCode            = sr["SortCode"];
            bool    isDefaulted         = sr["IsDefaulted"];
            string  caisAccountStatus   = sr["CaisAccountStatus"];
            string  maritalStatus       = sr["MaritalStatus"];
            int     customerId          = sr["CustomerId"];
            string  genderPrefix;

            if (gender == "M")
            {
                genderPrefix = "Mr.";
            }
            else
            {
                genderPrefix = maritalStatus == "Married" ? "Mrs." : "Ms.";
            }

            if (!string.IsNullOrEmpty(caisAccountStatus) && caisAccountStatus != "Calculated value")
            {
                accountStatus = caisAccountStatus;
            }
            else
            {
                accountStatus = GetAccountStatus(minLsDate, dateClose, startDate, isDefaulted, currentBalance);

                if (accountStatus == "8")
                {
                    originalDefaultBalance = currentBalance;
                    dateClose = DateTime.UtcNow;
                }
                else
                {
                    originalDefaultBalance = 0;
                }
            }

            string line23   = string.Format("{0} {1}", line2, line3);
            string fullName = string.Format("{0} {1} {2} {3}", genderPrefix, firstName, middleInitial, surname);

            if (scheduledRepayments != 0)
            {
                monthlyPayment = loanAmount / scheduledRepayments;
            }
            else
            {
                monthlyPayment = 0;
            }

            if (accountStatus != "8" && dateClose > startDate)
            {
                currentBalance = 0;
            }

            string transferredToCollectionFlag = customerState == "Collection" ? "Y" : string.Empty;
            string accountNumber = refNumber + loanId;

            string caisFlag = null;

            if (!string.IsNullOrEmpty(manualCaisFlag) && manualCaisFlag != "Calculated value")
            {
                caisFlag = manualCaisFlag;
            }

            if (companyType == "Entrepreneur")
            {
                var file = CaisFileManager.GetCaisFileData();
                var h    = file.Header;
                h.SourceCodeNumber          = 402;
                h.DateCreation              = DateTime.UtcNow;
                h.CompanyPortfolioName      = "Orange Money";
                h.OverdraftReportingCutOff  = 0;
                h.IsCardsBehaviouralSharing = false;

                var account = CreateConsumerRecord(accountNumber, startDate, dateClose, scheduledRepayments, currentBalance, fullName, line1, line23, town, county, postcode, dateOfBirth, transferredToCollectionFlag, caisFlag);

                file.Accounts.Add(account);

                consumerCounter++;
                if (accountStatus == "0")
                {
                    consumerGoodCounter++;
                }
                else if (accountStatus == "8")
                {
                    consumerDefaultsCounter++;
                }
            }
            else
            {
                fullName = experianCompanyName;
                switch (companyType)
                {
                case "LLP":
                case "Limited": {
                    companyTypeCode = "L";
                    if (string.IsNullOrEmpty(experianCompanyName) && !string.IsNullOrEmpty(experianRefNum) && experianRefNum != "NotFound")
                    {
                        var res = service.GetLimitedBusinessData(experianRefNum, customerId, true, false);
                        if (res != null)
                        {
                            if (!string.IsNullOrEmpty(res.CompanyName))
                            {
                                fullName = res.CompanyName;
                            }

                            if (!string.IsNullOrEmpty(res.PostCode))
                            {
                                line1    = res.AddressLine1;
                                line23   = res.AddressLine2;
                                town     = res.AddressLine3;
                                county   = res.AddressLine4;
                                postcode = res.PostCode;
                            }
                        }
                    }
                }
                break;

                case "PShip":
                case "SoleTrader":
                case "PShip3P":
                    companyTypeCode = "N";
                    if (string.IsNullOrEmpty(experianCompanyName) && !string.IsNullOrEmpty(experianRefNum) && experianRefNum != "NotFound")
                    {
                        ExperianLib.Ebusiness.NonLimitedResults res = null;
                        try {
                            res = service.GetNotLimitedBusinessData(experianRefNum, customerId, true, false);
                        } catch (Exception e) {
                            Log.Warn("Exception during retrieval of non limited data. For customer:{0} experianRefNum:{1} Error:{2}", customerId, experianRefNum, e);
                        }

                        if (res != null)
                        {
                            if (!string.IsNullOrEmpty(res.CompanyName))
                            {
                                fullName = res.CompanyName;
                            }

                            if (!string.IsNullOrEmpty(res.PostCode))
                            {
                                line1    = res.AddressLine1;
                                line23   = res.AddressLine2 + res.AddressLine3 == null ? "" : " " + res.AddressLine3;
                                town     = res.AddressLine4;
                                county   = res.AddressLine5;
                                postcode = res.PostCode;
                            }
                        }
                    }
                    break;
                }

                var cais = CaisFileManager.GetBusinessCaisFileData();
                cais.Header.CompanyPortfolioName             = "Orange Money";
                cais.Header.CreditCardBehaviouralSharingFlag = "";
                cais.Header.DateOfCreation = DateTime.UtcNow;
                cais.Header.SourceCode     = 721;

                var record = CreateBusinessRecord(accountNumber, fullName, line1, line23, town, county, postcode, startDate, dateClose, scheduledRepayments, currentBalance, transferredToCollectionFlag, sortCode, experianRefNum);
                cais.Accounts.Add(record);

                businessCounter++;
                if (accountStatus == "0")
                {
                    businessGoodCounter++;
                }
                else if (accountStatus == "8")
                {
                    businessDefaultsCounter++;
                }
            }             // if

            DB.ExecuteNonQuery("UpdateLastReportedCAISstatus",
                               CommandSpecies.StoredProcedure,
                               new QueryParameter("LoanId", loanId),
                               new QueryParameter("CAISStatus", accountStatus)
                               );

            return(ActionResult.Continue);
        }