Пример #1
0
 private static string GetPostcode(
     InputLocationDetailsUKLocation ukLocation,
     InputLocationDetailsMultiLineLocation mlLocation
     )
 {
     return((ukLocation != null)
                         ? ukLocation.Postcode
                         : (mlLocation != null) ? mlLocation.LocationLine6 : string.Empty);
 }         // GetPostcode
Пример #2
0
        public static InputLocationDetailsMultiLineLocation ShiftLocation(InputLocationDetailsMultiLineLocation mlLocation)
        {
            if (mlLocation == null)
            {
                return(null);
            }

            var oSrcLines = new List <string> {
                mlLocation.LocationLine1,
                mlLocation.LocationLine2,
                mlLocation.LocationLine3,
                mlLocation.LocationLine4,
                mlLocation.LocationLine5,
                mlLocation.LocationLine6,
            };

            var oDstLines = new List <string>();

            // If one of lines is "Flat" (without numbers) we got an error 'Location not resolved'.

            foreach (string sLine in oSrcLines)
            {
                if (!string.IsNullOrEmpty(sLine) && sLine.ToLower() != "flat")
                {
                    oDstLines.Add(sLine);
                }
            }

            while (oDstLines.Count < 6)
            {
                oDstLines.Add(null);
            }

            string[] lines = oDstLines.ToArray();

            mlLocation = new InputLocationDetailsMultiLineLocation
            {
                LocationLine1 = lines[0],
                LocationLine2 = lines[1],
                LocationLine3 = lines[2],
                LocationLine4 = lines[3],
                LocationLine5 = lines[4],
                LocationLine6 = lines[5],
            };

            return(mlLocation);
        }         // ShiftLocation
Пример #3
0
        }         // CanUsePrevAddress

        private bool GetConsumerInfoAndSave(AddressCurrency oAddressCurrency)
        {
            InputLocationDetailsMultiLineLocation location = this.addressLines.GetLocation(oAddressCurrency);

            var ukAddress = new Models.CustomerAddressModel {
                Line1    = location.LocationLine1,
                Line2    = location.LocationLine2,
                Line3    = location.LocationLine3,
                PostCode = location.LocationLine6,
                City     = location.LocationLine4
            };

            ukAddress.FillDetails();

            InputLocationDetailsUKLocation ukLokation = new InputLocationDetailsUKLocation {
                Postcode    = ukAddress.PostCode,
                HouseName   = ukAddress.HouseName,
                HouseNumber = ukAddress.HouseNumber,
                Flat        = ukAddress.FlatOrApartmentNumber,
                PostTown    = ukAddress.City,
                Street      = ukAddress.Address1,
                Street2     = ukAddress.Address2,
                POBox       = ukAddress.POBox
            };
            var consumerService = new ConsumerService();

            Result = consumerService.GetConsumerInfo(
                this.personalData.FirstName,
                this.personalData.Surname,
                this.personalData.Gender,
                this.personalData.DateOfBirth,
                ukLokation,
                location,
                "PL", this.customerId, this.directorId,
                false, this.directorId != null, this.forceCheck
                );

            if (Result != null && !Result.HasExperianError)
            {
                Score = Result.BureauScore.HasValue ? Result.BureauScore.Value : 0;
            }

            return(Result == null || !Result.HasExperianError);
        }         // GetConsumerInfoAndSave
Пример #4
0
        public void TestShiftLocation()
        {
            var loc = new InputLocationDetailsMultiLineLocation()
            {
                LocationLine1 = "1 Dibgate Cottages".ToUpper(),
                LocationLine2 = "Newington".ToUpper(),
                LocationLine3 = "".ToUpper(),
                LocationLine4 = "Folkestone".ToUpper(),
                LocationLine5 = "Kent".ToUpper(),
                LocationLine6 = "CT18 8BJ".ToUpper(),
            };

            loc = ConsumerService.ShiftLocation(loc);

            Assert.That(loc.LocationLine1 != null);
            Assert.That(loc.LocationLine2 != null);
            Assert.That(loc.LocationLine3 != null);
            Assert.That(loc.LocationLine4 != null);
            Assert.That(loc.LocationLine5 != null);
            Assert.That(loc.LocationLine6 == null);
        }
Пример #5
0
        }         // constructor

        public ExperianConsumerData GetConsumerInfo(
            string firstName,
            string surname,
            string gender,
            DateTime?birthDate,
            InputLocationDetailsUKLocation ukLocation,
            InputLocationDetailsMultiLineLocation mlLocation,
            string applicationType,
            int customerId,
            int?directorId,
            bool checkInCacheOnly,
            bool isDirector,
            bool forceCheck
            )
        {
            try
            {
                mlLocation = ShiftLocation(mlLocation);
                string postcode = GetPostcode(ukLocation, mlLocation);

                Log.InfoFormat("GetConsumerInfo: checking cache for {2} id {3} firstName: {0}, surname: {1} birthday: {4}, postcode: {5} gender {6}  apptype: {7} \n {8} {9}",
                               firstName, surname, isDirector ? "director" : "customer", isDirector ? directorId : customerId, birthDate, postcode, gender, applicationType,
                               JsonConvert.SerializeObject(ukLocation, new JsonSerializerSettings {
                    Formatting = Formatting.Indented
                }),
                               JsonConvert.SerializeObject(mlLocation, new JsonSerializerSettings {
                    Formatting = Formatting.Indented
                }));

                ExperianConsumerData cachedResponse = ObjectFactory.GetInstance <IEzServiceAccessor>()
                                                      .LoadExperianConsumer(1, customerId, isDirector ?  directorId : (int?)null, null);

                // debug mode
                if (surname.StartsWith("TestSurnameDebugMode") || surname == "TestSurnameOne" || surname == "TestSurnameFile")
                {
                    //if (force check) or (no data in cache) or (data expired and not cache only mode)
                    if (forceCheck ||
                        cachedResponse.ServiceLogId == null ||
                        (!checkInCacheOnly && cachedResponse.ServiceLogId != null && !CacheNotExpired(cachedResponse.InsertDate)))
                    {
                        var data = ConsumerDebugResult(surname, customerId);
                        return(data);
                    }
                    return(cachedResponse);
                }                 // if test

                if (!forceCheck)
                {
                    if (cachedResponse.ServiceLogId != null)
                    {
                        if (CacheNotExpired(cachedResponse.InsertDate) || checkInCacheOnly)
                        {
                            return(cachedResponse);
                        }
                    }
                    else if (checkInCacheOnly)
                    {
                        return(null);
                    }
                }                 // if

                return(GetServiceOutput(gender, ukLocation, mlLocation, applicationType, customerId, directorId, firstName, surname, birthDate, postcode));
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(new ExperianConsumerData
                {
                    HasExperianError = true,
                    Error = "Exception: " + ex.Message
                });
            }     // try
        }         // GetConsumerInfo
Пример #6
0
        }         // SaveDefaultAccountIntoDb

        private ExperianConsumerData GetServiceOutput(
            string gender,
            InputLocationDetailsUKLocation ukLocation,
            InputLocationDetailsMultiLineLocation mlLocation,
            string applicationType,
            int customerId,
            int?directorId,
            string firstName,
            string surname,
            DateTime?birthDate,
            string postcode
            )
        {
            var service = new InteractiveService();

            var inputControl = new InputControl
            {
                ExperianReference = "",
                ReprocessFlag     = "N",
                Parameters        = new InputControlParameters
                {
                    AuthPlusRequired = "Y",
                    FullFBLRequired  = "Y",
                    DetectRequired   = "N",
                    InteractiveMode  = interactiveMode
                }
            };

            // 1 applicant
            var applicant = new InputApplicant
            {
                ApplicantIdentifier = "1",
                Name = new InputApplicantName {
                    Forename = firstName, Surname = surname
                },
                Gender = gender
            };

            if (birthDate != null)
            {
                applicant.DateOfBirth = new InputApplicantDateOfBirth
                {
                    CCYY          = birthDate.Value.Year,
                    DD            = birthDate.Value.Day,
                    MM            = birthDate.Value.Month,
                    CCYYSpecified = true,
                    DDSpecified   = true,
                    MMSpecified   = true
                };
            }

            // 1 address
            var address = new InputLocationDetails
            {
                LocationIdentifier = 1,
                UKLocation         = null,
                MultiLineLocation  = mlLocation
            };

            // 1 Residency Information
            var residencyInfo = new InputResidency
            {
                LocationIdentifier = "1",
                ResidencyDateTo    =
                    new InputResidencyResidencyDateTo
                {
                    CCYY = DateTime.Now.Year,
                    MM   = DateTime.Now.Month,
                    DD   = DateTime.Now.Day
                },
                ResidencyDateFrom = new InputResidencyResidencyDateFrom {
                    CCYY = 2010, MM = 01, DD = 01
                },
                ApplicantIdentifier = "1",
                LocationCode        = "01"
            };

            // 1 Third Party Data (TPD) block
            var tpd = new InputThirdPartyData
            {
                OutcomeCode       = "",
                OptOut            = "N",
                TransientAssocs   = "N",
                HHOAllowed        = "N",
                OptoutValidCutOff = ""
            };

            var application = new InputApplication
            {
                ApplicationChannel = "",
                SearchConsent      = "Y",
                ApplicationType    = applicationType
            };

            var input = new Input
            {
                Control         = inputControl,
                Applicant       = new[] { applicant },
                LocationDetails = new[] { address },
                Residency       = new[] { residencyInfo },
                ThirdPartyData  = tpd,
                Application     = application
            };



            WriteToLogPackage.OutputData serviceLog;

            try {
                Log.InfoFormat("GetConsumerInfo: request Experian service.");
                var output = service.GetOutput(input);
                serviceLog = Utils.WriteLog(input, output, ExperianServiceType.Consumer, customerId, directorId, firstName, surname, birthDate, postcode);
                SaveDefaultAccountIntoDb(output, customerId, serviceLog.ServiceLog);
            } catch (Exception ex) {
                serviceLog = new WriteToLogPackage.OutputData();
            }

            //retrieving data from call credit api
            GetCallCreditData(ukLocation, firstName, surname, birthDate, postcode, customerId, directorId);

            return(serviceLog.ExperianConsumer);
        }        //GetServiceOutput