private static string GetPostcode( InputLocationDetailsUKLocation ukLocation, InputLocationDetailsMultiLineLocation mlLocation ) { return((ukLocation != null) ? ukLocation.Postcode : (mlLocation != null) ? mlLocation.LocationLine6 : string.Empty); } // GetPostcode
} // 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
} // 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
} //GetServiceOutput private void GetCallCreditData(InputLocationDetailsUKLocation ukLocation, string firstName, string surname, DateTime?birthDate, string postcode, int customerId, int?directorId) { if (!CurrentValues.Instance.CallCreditEnabled) { Log.InfoFormat( "Not retrieving CallCredit data for customer {0} director {1}: CallCredit is disabled.", customerId, directorId ); return; } // if try { Log.InfoFormat("Retrieving CallCredit data for customer {0} director {1}", customerId, directorId); var searchRequest = new CT_searchapplicant { dob = birthDate ?? DateTime.UtcNow, dobSpecified = birthDate.HasValue, name = new[] { new CT_inputname { forename = firstName, surname = surname, } }, address = new[] { new CT_inputaddress { postcode = ukLocation.Postcode, street1 = ukLocation.Street, street2 = ukLocation.Street2, startdateSpecified = false, enddateSpecified = false, buildingname = ukLocation.HouseName, buildingno = ukLocation.HouseNumber, posttown = ukLocation.PostTown, } }, tpoptout = 0, tpoptoutSpecified = true }; CallCreditLib.CallCreditGetData callCreditGetData = new CallCreditGetData(searchRequest); CT_SearchResult searchResponse = callCreditGetData.GetSearch07a(); Log.InfoFormat( "Saving to ServiceLog CallCredit data fro customer {0} director {1}", customerId, directorId ); Utils.WriteLog( searchRequest, searchResponse, ExperianServiceType.CallCredit, customerId, directorId, firstName, surname, birthDate, postcode ); } catch (Exception ex) { Log.Error("Failed retrieve from data CallCredit", ex); } //try } //GetCallCreditData
} // 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