Пример #1
0
        /// <summary>
        /// Method to update the DP location based on UDPRN.
        /// </summary>
        /// <param name="addressLocationUSRPOSTDTO"></param>
        /// <param name="notificationType">Notification Type</param>
        private async Task UpdateDPLocation(AddressLocationUSRPOSTDTO addressLocationUSRPOSTDTO, Guid notificationType)
        {
            DbGeometry spatialLocationXY = GetSpatialLocation(addressLocationUSRPOSTDTO);

            PostalAddressDataDTO postalAddressDataDTO = await addressLocationDataService.GetPostalAddressData(addressLocationUSRPOSTDTO.UDPRN.Value);

            // If Delivery Point Exists for the given Postal Address
            if (postalAddressDataDTO != null && postalAddressDataDTO.DeliveryPoints != null && postalAddressDataDTO.DeliveryPoints.Count > 0 && spatialLocationXY != null)
            {
                DeliveryPointDTO deliveryPointDTO = await thirdPartyAddressLocationIntegrationService.GetDeliveryPointByPostalAddress(postalAddressDataDTO.ID);

                if (deliveryPointDTO != null && deliveryPointDTO.LocationXY != null)
                {
                    double?toleranceDistance = spatialLocationXY.Distance(deliveryPointDTO.LocationXY);

                    deliveryPointDTO.LocationXY = spatialLocationXY;

                    // Update the location details for the delivery point
                    await thirdPartyAddressLocationIntegrationService.UpdateDeliveryPointById(deliveryPointDTO);

                    // Check Tolerance. Story: RFMO-279
                    CheckToleranceForLocation(toleranceDistance, false, notificationType, addressLocationUSRPOSTDTO.UDPRN.Value, postalAddressDataDTO);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Method to update the Address location based on UDPRN.
        /// </summary>
        /// <param name="addressLocationUSRPOSTDTO"></param>
        private async Task UpdateAddressLocationByUDPRN(AddressLocationUSRPOSTDTO addressLocationUSRPOSTDTO)
        {
            DbGeometry spatialLocationXY = GetSpatialLocation(addressLocationUSRPOSTDTO);

            AddressLocationDataDTO updateAddressLocationDTO = new AddressLocationDataDTO()
            {
                UDPRN      = (int)addressLocationUSRPOSTDTO.UDPRN,
                LocationXY = spatialLocationXY,
                Lattitude  = (decimal)addressLocationUSRPOSTDTO.Latitude,
                Longitude  = (decimal)addressLocationUSRPOSTDTO.Longitude
            };

            // Update the address location data record to the database.
            await addressLocationDataService.UpdateExistingAddressLocationByUDPRN(updateAddressLocationDTO);
        }
Пример #3
0
        /// <summary>
        /// Get the geometry equivalent of the X-Y co-ordinate of address location
        /// </summary>
        /// <param name="addressLocationUSRPOSTDTO">AddressLocationUSRPOSTDTO object</param>
        /// <returns>DbGeometry object</returns>
        private DbGeometry GetSpatialLocation(AddressLocationUSRPOSTDTO addressLocationUSRPOSTDTO)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Business.GetSpatialLocation"))
            {
                string methodName = typeof(ThirdPartyAddressLocationBusinessService) + "." + nameof(GetSpatialLocation);
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodEntryEventId);

                string sbLocationXY = string.Format(
                    ThirdPartyAddressLocationConstants.USRGEOMETRYPOINT,
                    Convert.ToString(addressLocationUSRPOSTDTO.XCoordinate),
                    Convert.ToString(addressLocationUSRPOSTDTO.YCoordinate));

                // Convert the location from string type to geometry type
                DbGeometry spatialLocationXY = DbGeometry.FromText(sbLocationXY.ToString(), ThirdPartyAddressLocationConstants.BNGCOORDINATESYSTEM);

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodExitEventId);
                return(spatialLocationXY);
            }
        }
Пример #4
0
        /// <summary>
        /// Method to delete the list of Third Party Address Location data into the database.
        /// </summary>
        /// <param name="addressLocationUsrpostdtos">List of Address Locations</param>
        /// <returns>Task</returns>
        public async Task DeleteUSRDetails(AddressLocationUSRPOSTDTO addressLocationUsrpostdtos)
        {
            int fileUdprn;

            using (loggingHelper.RMTraceManager.StartTrace("Business.DeleteUSRDetails"))
            {
                string methodName = typeof(ThirdPartyAddressLocationBusinessService) + "." + nameof(DeleteUSRDetails);
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodEntryEventId);

                List <string> categoryNamesSimpleLists = new List <string>
                {
                    ThirdPartyAddressLocationConstants.TASKNOTIFICATION,
                    ThirdPartyAddressLocationConstants.NETWORKLINKDATAPROVIDER,
                    ThirdPartyAddressLocationConstants.DeliveryPointUseIndicator,
                    ThirdPartyAddressLocationConstants.APPROXLOCATION,
                    ReferenceDataCategoryNames.DeliveryPointOperationalStatus,
                    ReferenceDataCategoryNames.NetworkNodeType
                };

                // Get all the reference data Guids required for the below
                Guid locationProviderInternalId = GetReferenceData(categoryNamesSimpleLists, ThirdPartyAddressLocationConstants.NETWORKLINKDATAPROVIDER, ThirdPartyAddressLocationConstants.INTERNAL);

                Guid notificationTypeId_GUID = await thirdPartyAddressLocationIntegrationService.GetReferenceDataId(ThirdPartyAddressLocationConstants.USRCATEGORY, ThirdPartyAddressLocationConstants.USRREFERENCEDATANAME);

                // Get the udprn id for each USR record.
                fileUdprn = (int)addressLocationUsrpostdtos.UDPRN;
                var addressLocation = addressLocationDataService.GetAddressLocationByUDPRN(fileUdprn).Result;

                if (addressLocation != null)
                {
                    // Delete the address location data record to the database.
                    await addressLocationDataService.DeleteAddressLocation(addressLocation);

                    PostalAddressDataDTO postalAddressDataDTO = await addressLocationDataService.GetPostalAddressData((int)fileUdprn);

                    // Check if the delivery point exists
                    if (postalAddressDataDTO.DeliveryPoints != null && postalAddressDataDTO.DeliveryPoints.Count > 0)
                    {
                        DeliveryPointDTO deliveryPointDTO = await thirdPartyAddressLocationIntegrationService.GetDeliveryPointByPostalAddress(postalAddressDataDTO.ID);

                        deliveryPointDTO.LocationProvider_GUID = locationProviderInternalId;

                        // Update the location provider for the delivery point
                        await thirdPartyAddressLocationIntegrationService.UpdateDeliveryPointById(deliveryPointDTO);

                        // Get the Postcode Sector by UDPRN
                        PostCodeSectorDTO postCodeSectorDTO =
                            await thirdPartyAddressLocationIntegrationService.GetPostCodeSectorByUDPRN(fileUdprn);

                        PostalAddressDataDTO postalAddressDTO = await addressLocationDataService.GetPostalAddressData(fileUdprn);

                        NotificationDTO notificationDO = new NotificationDTO
                        {
                            ID = Guid.NewGuid(),
                            NotificationType_GUID = notificationTypeId_GUID,
                            NotificationDueDate   = DateTime.UtcNow.AddHours(ThirdPartyAddressLocationConstants.NOTIFICATIONDUE),
                            NotificationSource    = ThirdPartyAddressLocationConstants.USRNOTIFICATIONSOURCE,
                            Notification_Heading  = ThirdPartyAddressLocationConstants.USRDELETEACTION,
                            Notification_Message  = Notification_Body(postalAddressDTO),
                            PostcodeDistrict      = (postCodeSectorDTO == null || postCodeSectorDTO.District == null)
                                    ? string.Empty
                                    : postCodeSectorDTO.District,
                            NotificationActionLink = string.Format(ThirdPartyAddressLocationConstants.USRNOTIFICATIONLINK, fileUdprn)
                        };

                        // Insert the new notification.
                        await thirdPartyAddressLocationIntegrationService.AddNewNotification(notificationDO);
                    }
                }
                else
                {
                    // Log error
                    loggingHelper.Log(string.Format(ThirdPartyAddressLocationConstants.USRERRORLOGMESSAGE, ThirdPartyAddressLocationConstants.ErrorMessageForAddressTypeUSRNotFound, fileUdprn, null, FileType.Usr, DateTime.UtcNow), TraceEventType.Error);
                }

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodExitEventId);
            }
        }