public async Task <StockportGovUK.NetStandard.Models.Verint.Address> GetPropertyAsync(string id) { var propertySearch = new FWTObjectID { ObjectReference = new[] { id }, ObjectType = VerintConstants.PropertyObjectType }; var result = await _verintConnection.retrievePropertyAsync(propertySearch); var address = new StockportGovUK.NetStandard.Models.Verint.Address { UPRN = result.FWTProperty.UPRN?.Trim(), AddressLine1 = result.FWTProperty.AddressLine1?.Trim(), AddressLine2 = result.FWTProperty.AddressLine2?.Trim(), City = result.FWTProperty.City?.Trim(), Postcode = result.FWTProperty.Postcode?.Trim(), Number = result.FWTProperty.AddressNumber?.Trim(), USRN = result.FWTProperty.USRN?.Trim(), Easting = result.FWTProperty.GPSItmGeoCode?.Trim(), Northing = result.FWTProperty.GPSUtmGeoCode?.Trim() }; return(address); }
private FWTObjectID GetRaisedByObjects(StockportGovUK.NetStandard.Models.Verint.Case crmCase) { FWTObjectID raisedBy = null; if (crmCase.Customer != null && crmCase.RaisedByBehaviour == RaisedByBehaviourEnum.Individual) { raisedBy = new FWTObjectID { ObjectType = VerintConstants.IndividualObjectType, ObjectReference = new string[] { crmCase.Customer.CustomerReference } }; } else if (crmCase.Organisation != null && crmCase.RaisedByBehaviour == RaisedByBehaviourEnum.Organisation) { raisedBy = new FWTObjectID { ObjectType = VerintConstants.OrganisationObjectType, ObjectReference = new string[] { crmCase.Organisation.Reference } }; } _logger.LogDebug($"InteractionService: GetRaisedByObject - Raised By: {raisedBy.ObjectReference.First()}, {raisedBy.ObjectType}"); return(raisedBy); }
public async Task <StockportGovUK.NetStandard.Models.Verint.Organisation> GetAsync(string id) { var objectID = new FWTObjectID { ObjectReference = new string [] { id }, ObjectType = VerintConstants.OrganisationObjectType }; _logger.LogDebug($"OrganisationService.GetAsync: Retrieve - {id}"); var result = await _verintConnection.retrieveOrganisationAsync(objectID); _logger.LogDebug($"OrganisationService.GetAsync: Map - {id}"); return(result.FWTOrganisation.Map()); }
private async Task <FWTObjectID> SearchAsync(FWTPartySearch searchCriteria, Customer customer) { searchCriteria.SearchType = "individual"; var matchingIndividuals = await _verintConnection.searchForPartyAsync(searchCriteria); _logger.LogDebug($"IndividualService.SearchIndividuals:{customer.Surname}: {matchingIndividuals.FWTObjectBriefDetailsList?.Count()} name matchings found for Customer"); FWTObjectID individual = null; if (matchingIndividuals.FWTObjectBriefDetailsList.Any() && matchingIndividuals != null) { individual = await GetBestMatchingAsync(matchingIndividuals.FWTObjectBriefDetailsList.Take(30).ToArray(), customer); } return(individual); }
private async Task <FWTObjectID> GetBestMatchingAsync(FWTObjectBriefDetails[] individualResults, Customer customer) { FWTIndividual bestMatch = null; FWTObjectID bestMatchingObjectID = null; var bestMatchScore = 0; var tasks = new List <Task <retrieveIndividualResponse> >(); _logger.LogDebug($"IndividualService.GetBestMatchingAsync:{customer.Surname}: Retrieving results for {individualResults.Count()} results"); foreach (var individualResult in individualResults) { tasks.Add(Task.Run(async() => { _logger.LogDebug($"IndividualService.GetBestMatchingAsync:{customer.Surname}: Retrievingindividual"); return(await _verintConnection.retrieveIndividualAsync(individualResult.ObjectID)); })); } var results = await Task.WhenAll(tasks); _logger.LogDebug($"IndividualService.GetBestMatchingAsync:{customer.Surname}: Retrieved all search result objects"); results.ToList().ForEach(result => { var individual = result.FWTIndividual; var score = 0; _individualWeightings.ToList().ForEach(_ => score += _.Calculate(individual, customer)); if (score > bestMatchScore) { bestMatchScore = score; bestMatch = individual; } }); if (bestMatch != null && bestMatchScore >= 1) { _logger.LogDebug($"IndividualService.GetBestMatchingAsync:{customer.Surname}: Match found, score: {bestMatchScore}"); await UpdateIndividual(bestMatch, customer); bestMatchingObjectID = bestMatch.BriefDetails.ObjectID; } return(bestMatchingObjectID); }
public async Task <IEnumerable <StockportGovUK.NetStandard.Models.Verint.Address> > GetPropertiesAsync(string propertySearch) { var fWTPropertySearch = new FWTPropertySearch { Postcode = propertySearch }; var propertySearchResults = await _verintConnection.searchForPropertyAsync(fWTPropertySearch); var addressResults = propertySearchResults.FWTObjectBriefDetailsList.Select(result => new AddressSearchResult { UniqueId = result.ObjectID.ObjectReference[0], Name = result.ObjectDescription }); var addressList = new List <StockportGovUK.NetStandard.Models.Verint.Address>(); foreach (var address in addressResults) { var fWTObjectID = new FWTObjectID { ObjectReference = new[] { address.UniqueId }, ObjectType = VerintConstants.PropertyObjectType }; var result = await _verintConnection.retrievePropertyAsync(fWTObjectID); addressList.Add(new StockportGovUK.NetStandard.Models.Verint.Address { UPRN = result.FWTProperty.UPRN?.Trim(), Description = address.Name?.Trim(), AddressLine1 = result.FWTProperty.AddressLine1?.Trim(), AddressLine2 = result.FWTProperty.AddressLine2?.Trim(), City = result.FWTProperty.City?.Trim(), Postcode = result.FWTProperty.Postcode?.Trim(), Number = result.FWTProperty.AddressNumber?.Trim(), USRN = result.FWTProperty.USRN?.Trim(), Easting = result.FWTProperty.GPSItmGeoCode?.Trim(), Northing = result.FWTProperty.GPSUtmGeoCode?.Trim() }); } return(addressList); }
private async Task <FWTObjectID> GetBestMatchingOrganisationAsync(FWTObjectBriefDetails[] searchResults, StockportGovUK.NetStandard.Models.Verint.Organisation organisation) { FWTOrganisation bestMatch = null; FWTObjectID bestMatchingObjectID = null; var bestMatchScore = 0; var tasks = new List <Task <retrieveOrganisationResponse> >(); foreach (var result in searchResults) { tasks.Add(Task.Run(async() => { _logger.LogDebug($"OrganisationService.GetBestMatchingOrganisationAsync - Get core Orgnisation Record : { result.ObjectID }"); return(await _verintConnection.retrieveOrganisationAsync(result.ObjectID)); })); } var results = await Task.WhenAll(tasks); results.ToList().ForEach((result) => { var orgnisationResult = result.FWTOrganisation; var score = 0; _organisationWeightings.ToList().ForEach(_ => score += _.Calculate(orgnisationResult, organisation)); _logger.LogDebug($"OrganisationService.GetBestMatchingOrganisationAsync - Organisation: { orgnisationResult.Name } Score: { score }"); if (score > bestMatchScore) { bestMatchScore = score; bestMatch = orgnisationResult; } }); if (bestMatch != null && bestMatchScore >= 3) { _logger.LogDebug($"OrganisationService.GetBestMatchingOrganisation Match Found - Organisation: {bestMatch.Name} Score: {bestMatchScore}"); // await UpdateIndividual(bestMatch, customer); bestMatchingObjectID = bestMatch.BriefDetails.ObjectID; } _logger.LogDebug($"OrganisationService.GetBestMatchingOrganisation Match Not Found"); return(bestMatchingObjectID); }
public async Task <FWTObjectID> MatchAsync(StockportGovUK.NetStandard.Models.Verint.Organisation organisation) { _logger.LogDebug($"OrganisationService.MatchAsync - Organisation: {organisation.Name.Trim()}"); var search = new FWTPartySearch { SearchType = "organisation", Name = organisation.Name.Trim() }; if (!string.IsNullOrEmpty(organisation.Telephone)) { search.PhoneNumber = organisation.Telephone; } if (!string.IsNullOrEmpty(organisation.Email)) { search.EmailAddress = organisation.Email; } var searchResults = await _verintConnection.searchForPartyAsync(search); _logger.LogDebug($"OrganisationService.MatchAsync - SearchResults: { searchResults.FWTObjectBriefDetailsList.Count() }"); FWTObjectID matchingOrganisation = null; if (searchResults.FWTObjectBriefDetailsList.Any() && searchResults != null) { matchingOrganisation = await GetBestMatchingOrganisationAsync(searchResults.FWTObjectBriefDetailsList.Take(50).ToArray(), organisation); if (matchingOrganisation != null) { _logger.LogDebug($"OrganisationService.MatchAsync - Organisation Found: { matchingOrganisation.ObjectReference.First() }"); return(matchingOrganisation); } } _logger.LogDebug($"OrganisationService.MatchAsync - Organisation Not Found: { organisation.Name }"); return(null); }
public async Task <StockportGovUK.NetStandard.Models.Verint.Address> GetPropertyByUprnAsync(string uprn) { var fwtPropertySearch = new FWTPropertySearch { UPRN = uprn }; var propertySearchResults = await _verintConnection.searchForPropertyAsync(fwtPropertySearch); if (propertySearchResults == null || !propertySearchResults.FWTObjectBriefDetailsList.Any()) { return(null); } var fWTObjectID = new FWTObjectID { ObjectReference = new[] { propertySearchResults.FWTObjectBriefDetailsList.FirstOrDefault().ObjectID.ObjectReference[0] }, ObjectType = VerintConstants.PropertyObjectType }; var result = await _verintConnection.retrievePropertyAsync(fWTObjectID); var address = new StockportGovUK.NetStandard.Models.Verint.Address { UPRN = result.FWTProperty.UPRN?.Trim(), Description = propertySearchResults.FWTObjectBriefDetailsList.FirstOrDefault().ObjectDescription?.Trim(), AddressLine1 = result.FWTProperty.AddressLine1?.Trim(), AddressLine2 = result.FWTProperty.AddressLine2?.Trim(), City = result.FWTProperty.City?.Trim(), Postcode = result.FWTProperty.Postcode?.Trim(), Number = result.FWTProperty.AddressNumber?.Trim(), USRN = result.FWTProperty.USRN?.Trim(), Easting = result.FWTProperty.GPSItmGeoCode?.Trim(), Northing = result.FWTProperty.GPSUtmGeoCode?.Trim() }; return(address); }
public FWTObjectBriefDetails Resolve(Case crmCase) { var associatedObject = new FWTObjectID(); var associatedObjectBriefDetails = new FWTObjectBriefDetails(); switch (crmCase.AssociatedWithBehaviour) { case AssociatedWithBehaviourEnum.Street: if (crmCase.Street.Reference != null) { associatedObject.ObjectType = VerintConstants.StreetObjectType; associatedObject.ObjectReference = new[] { crmCase.Street.Reference }; associatedObjectBriefDetails.ObjectID = associatedObject; return(associatedObjectBriefDetails); } break; case AssociatedWithBehaviourEnum.Property: if (crmCase.Property.Reference != null) { associatedObject.ObjectType = VerintConstants.PropertyObjectType; associatedObject.ObjectReference = new[] { crmCase.Property.Reference }; associatedObjectBriefDetails.ObjectID = associatedObject; return(associatedObjectBriefDetails); } break; case AssociatedWithBehaviourEnum.Organisation: if (crmCase.Organisation != null && crmCase.Organisation.Reference != null) { associatedObjectBriefDetails.ObjectID = new FWTObjectID { ObjectType = VerintConstants.OrganisationObjectType, ObjectReference = new[] { crmCase.Organisation.Reference } }; return(associatedObjectBriefDetails); } break; case AssociatedWithBehaviourEnum.Individual: if (crmCase.Customer.CustomerReference != null) { associatedObject.ObjectType = VerintConstants.IndividualObjectType; associatedObject.ObjectReference = new[] { crmCase.Customer.CustomerReference }; associatedObjectBriefDetails.Details = crmCase.Customer.FullName; associatedObjectBriefDetails.ObjectID = associatedObject; return(associatedObjectBriefDetails); } break; default: return(null); } return(null); }