Exemple #1
0
        public async Task <IActionResult> GetOSRoadLink(string toid)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Controller.GetOSRoadLink"))
            {
                string methodName = typeof(NetworkManagerController) + "." + nameof(GetOSRoadLink);
                loggingHelper.LogMethodEntry(methodName, priority, entryEventId);

                try
                {
                    string result;

                    result = await networkManagerBusinessService.GetOSRoadLink(toid);

                    loggingHelper.LogMethodExit(methodName, priority, exitEventId);
                    return(Ok(result));
                }
                catch (AggregateException ae)
                {
                    foreach (var exception in ae.InnerExceptions)
                    {
                        loggingHelper.Log(exception, TraceEventType.Error);
                    }

                    var realExceptions = ae.Flatten().InnerException;
                    throw realExceptions;
                }
            }
        }
        /// <summary>
        /// Fetch the delivery units for user.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>
        /// List of <see cref="UnitLocationDTO"/>.
        /// </returns>
        public List <UnitLocationDTO> FetchDeliveryUnitsForUser(Guid userId)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.FetchDeliveryUnitsForUser"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitLocationDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                var result = (from unitLocation in DataContext.UnitLocations.AsNoTracking()
                              join userRoleUnit in DataContext.UserRoleUnits.AsNoTracking() on unitLocation.ID equals userRoleUnit.Unit_GUID
                              where userRoleUnit.User_GUID == userId && unitLocation.UnitBoundryPolygon != null
                              select new UnitLocationDTO
                {
                    ID = unitLocation.ID,
                    UnitName = unitLocation.UnitName,
                    Area = (
                        from postcodeDistrict in DataContext.PostcodeDistricts
                        join postcodeSector in DataContext.PostcodeSectors on postcodeDistrict.ID equals postcodeSector.DistrictGUID
                        join unitPostcodeSector in DataContext.UnitPostcodeSectors on postcodeSector.ID equals unitPostcodeSector.PostcodeSector_GUID
                        where unitPostcodeSector.Unit_GUID == unitLocation.ID
                        select postcodeDistrict.Area).FirstOrDefault() ?? "",
                    UnitAddressUDPRN = unitLocation.UnitAddressUDPRN,
                    UnitBoundryPolygon = unitLocation.UnitBoundryPolygon,
                    ExternalId = unitLocation.ExternalId
                }).ToList();

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitLocationDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(result);
            }
        }
Exemple #3
0
        /// <summary>
        /// Get current users Unit by passing unit ID
        /// </summary>
        /// <param name="userUnit"></param>
        /// <returns></returns>
        private string GetUnitNameByUnitId(Guid userUnit)
        {
            string unitName = string.Empty;

            using (loggingHelper.RMTraceManager.StartTrace("Business.GetUnitNameByUnitId"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodEntryEventId, LoggerTraceConstants.Title);

                List <string> categoryNames = new List <string> {
                    ReferenceDataCategoryNames.UnitLocationType
                };

                var referenceDataCategoryList = searchIntegrationService.GetReferenceDataSimpleLists(categoryNames).Result;

                var locationtypeId = searchIntegrationService.GetUnitLocationTypeId(userUnit).Result;

                if (referenceDataCategoryList != null && referenceDataCategoryList.Count > 0)
                {
                    var referenceData = referenceDataCategoryList.SingleOrDefault().ReferenceDatas;
                    unitName = referenceData.Where(n => n.ID == locationtypeId).SingleOrDefault().ReferenceDataValue;
                }

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(unitName);
            }
        }
        public IActionResult CreateAccessLink(Guid operationalObjectId, Guid operationalObjectTypeId)
        {
            using (loggingHelper.RMTraceManager.StartTrace("WebService.CreateAccessLink"))
            {
                bool success = false;
                try
                {
                    string methodName = typeof(AccessLinkController) + "." + nameof(CreateAccessLink);
                    loggingHelper.LogMethodEntry(methodName, priority, entryEventId);

                    success = accessLinkBusinessService.CreateAccessLink(operationalObjectId, operationalObjectTypeId);
                    loggingHelper.LogMethodExit(methodName, priority, exitEventId);
                }
                catch (AggregateException ex)
                {
                    foreach (var exception in ex.InnerExceptions)
                    {
                        loggingHelper.Log(exception, TraceEventType.Error);
                    }

                    var realExceptions = ex.Flatten().InnerException;

                    throw realExceptions;
                }

                return(Ok(success));
            }
        }
        /// <summary>
        /// Web API call to save postalAddress to PostalAddress table
        /// </summary>
        /// <param name="lstAddress">List of mapped address dto to validate each records</param>
        /// <param name="fileName">File Name</param>
        /// <returns>If success returns true else returns false</returns>
        public async Task <bool> SaveNybDetails(List <PostalAddressDTO> lstAddress, string fileName)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Service.SaveNybDetails"))
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionStarted, LoggerTraceConstants.COLON);
                bool isNybDetailsInserted = false;
                try
                {
                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.NYBPriority, LoggerTraceConstants.NYBLoaderMethodEntryEventId, LoggerTraceConstants.Title);
                    isNybDetailsInserted = true;
                    var result = await httpHandler.PostAsJsonAsync(strFMOWebAPIName + fileName, lstAddress, isBatchJob : true);

                    if (!result.IsSuccessStatusCode)
                    {
                        var responseContent = result.ReasonPhrase;
                        this.loggingHelper.Log(responseContent, TraceEventType.Error);
                        isNybDetailsInserted = false;
                    }
                }
                catch (Exception ex)
                {
                    this.loggingHelper.Log(ex, TraceEventType.Error);
                    isNybDetailsInserted = false;
                }
                finally
                {
                    LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionCompleted, LoggerTraceConstants.COLON);
                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.NYBPriority, LoggerTraceConstants.NYBLoaderMethodExitEventId, LoggerTraceConstants.Title);
                }

                return(isNybDetailsInserted);
            }
        }
        public async Task <SearchResultDTO> BasicSearch(string searchText)
        {
            string methodName = typeof(SearchBusinessService) + "." + nameof(BasicSearch);

            using (loggingHelper.RMTraceManager.StartTrace("Business.BasicSearch"))
            {
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.SearchManagerAPIPriority, LoggerTraceConstants.SearchManagerControllerMethodEntryEventId);
                try
                {
                    return(await searchBussinessService.GetBasicSearchDetails(searchText, this.CurrentUserUnit, this.CurrentUserUnitType));
                }
                catch (AggregateException ae)
                {
                    foreach (var exception in ae.InnerExceptions)
                    {
                        loggingHelper.Log(exception, TraceEventType.Error);
                    }

                    var realExceptions = ae.Flatten().InnerException;
                    throw realExceptions;
                }
                finally
                {
                    loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.SearchManagerAPIPriority, LoggerTraceConstants.SearchManagerControllerMethodExitEventId);
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Save block sequence in database
        /// </summary>
        /// <param name="blockSequenceDTO">blockSequenceDTO</param>
        /// <param name="deliveryRouteId">deliveryRouteId</param>
        /// <returns>bool</returns>
        public async Task <bool> AddBlockSequence(BlockSequenceDTO blockSequenceDTO, Guid deliveryRouteId)
        {
            bool isBlockSequencInserted = false;

            try
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                using (loggingHelper.RMTraceManager.StartTrace(methodName))
                {
                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                    var block_Guid = await(from dr in DataContext.DeliveryRouteBlocks.AsNoTracking()
                                           join b in DataContext.Blocks.AsNoTracking() on dr.Block_GUID equals b.ID
                                           where b.BlockType == UnSequenced && dr.DeliveryRoute_GUID == deliveryRouteId
                                           select b.ID).SingleOrDefaultAsync();

                    BlockSequence blockSequenceEntity = GenericMapper.Map <BlockSequenceDTO, BlockSequence>(blockSequenceDTO);
                    blockSequenceEntity.Block_GUID = block_Guid;
                    DataContext.BlockSequences.Add(blockSequenceEntity);
                    DataContext.SaveChanges();
                    isBlockSequencInserted = true;
                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                throw new DbConcurrencyException(ErrorConstants.Err_Concurrency);
            }
            catch (DbUpdateException dbUpdateException)
            {
                throw new DataAccessException(dbUpdateException, string.Format(ErrorConstants.Err_SqlAddException, string.Concat("creating block sequence for selected delivery route")));
            }

            return(isBlockSequencInserted);
        }
Exemple #8
0
        /// <summary>
        /// Fetch postcode for basic search
        /// </summary>
        /// <param name="searchText">The text to be searched</param>
        /// <param name="unitGuid">The unit unique identifier.</param>
        /// <returns>
        /// The result set of post code
        /// </returns>
        public async Task <List <PostCodeDTO> > FetchPostCodeUnitForBasicSearch(string searchText, Guid unitGuid)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.FetchPostCodeUnitForBasicSearch"))
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PostCodePriority, LoggerTraceConstants.PostCodeDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                int takeCount = Convert.ToInt32(ConfigurationManager.AppSettings[SearchResultCount]);
                searchText = searchText ?? string.Empty;
                var postCodeDetailsDto = await(from p in DataContext.Postcodes.AsNoTracking()
                                               join s in DataContext.PostcodeSectors.AsNoTracking() on p.SectorGUID equals s.ID
                                               join u in DataContext.UnitPostcodeSectors.AsNoTracking() on s.ID equals u.PostcodeSector_GUID
                                               where p.PostcodeUnit.StartsWith(searchText) &&
                                               u.Unit_GUID == unitGuid
                                               select new PostCodeDTO
                {
                    PostcodeUnit = p.PostcodeUnit,
                    InwardCode   = p.InwardCode,
                    OutwardCode  = p.OutwardCode,
                    Sector       = p.Sector
                }).Take(takeCount).ToListAsync();

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PostCodePriority, LoggerTraceConstants.PostCodeDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(postCodeDetailsDto);
            }
        }
Exemple #9
0
        public IActionResult SaveMapImage([FromBody] PrintMapDTO printMapDTO)
        {
            using (loggingHelper.RMTraceManager.StartTrace("WebService.SaveMapImage"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerControllerMethodEntryEventId, LoggerTraceConstants.Title);

                var result = mapGeneratorBusinessService.SaveImage(printMapDTO);
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerControllerMethodExitEventId, LoggerTraceConstants.Title);
                return(Ok(result));
            }
        }
Exemple #10
0
        /// <summary>
        /// Fetch the Delivery Scenario by passing the operationstateID and deliveryUnitID.
        /// </summary>
        /// <param name="operationStateID">Guid operationStateID</param>
        /// <param name="deliveryUnitID">Guid deliveryUnitID</param>
        /// <returns>List</returns>
        public List <DTO.ScenarioDTO> FetchScenario(Guid operationStateID, Guid deliveryUnitID)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.FetchScenario"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.ScenarioDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                IEnumerable <Scenario> result = DataContext.Scenarios.AsNoTracking().ToList().Where(x => x.OperationalState_GUID == operationStateID && x.Unit_GUID == deliveryUnitID);
                var fetchScenario             = GenericMapper.MapList <Scenario, DTO.ScenarioDTO>(result.ToList());
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.ScenarioDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(fetchScenario);
            }
        }
Exemple #11
0
        /// <summary>
        /// Add new notification to the database
        /// </summary>
        /// <param name="notificationDTO">NotificationDTO object</param>
        /// <returns>Task<int></returns>
        public async Task<int> AddNewNotification(NotificationDTO notificationDTO)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Business.AddNewNotification"))
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.NotificationAPIPriority, LoggerTraceConstants.NotificationBusinessServiceMethodEntryEventId, LoggerTraceConstants.Title);

                try
                {
                    NotificationDataDTO notificationDataDTO = new NotificationDataDTO
                    {
                        ID = notificationDTO.ID,
                        Notification_Heading = notificationDTO.Notification_Heading,
                        Notification_Message = notificationDTO.Notification_Message,
                        NotificationDueDate = notificationDTO.NotificationDueDate,
                        NotificationActionLink = notificationDTO.NotificationActionLink,
                        NotificationSource = notificationDTO.NotificationSource,
                        PostcodeDistrict = notificationDTO.PostcodeDistrict,
                        PostcodeSector = notificationDTO.PostcodeSector,
                        NotificationTypeGUID = notificationDTO.NotificationType_GUID,
                        NotificationPriorityGUID = notificationDTO.NotificationPriority_GUID
                    };

                    return await notificationDataService.AddNewNotification(notificationDataDTO);
                }
                finally
                {
                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.NotificationAPIPriority, LoggerTraceConstants.NotificationBusinessServiceMethodExitEventId, LoggerTraceConstants.Title);
                }
            }
        }
        public IActionResult GetNameValueReferenceData(string appGroupName, string appItemName)
        {
            using (loggingHelper.RMTraceManager.StartTrace("WebService.GetNameValueReferenceData"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataControllerMethodEntryEventId, LoggerTraceConstants.Title);

                if (string.IsNullOrEmpty(appGroupName) || string.IsNullOrEmpty(appItemName))
                {
                    return(BadRequest());
                }

                var nameValuePairsObject = referenceDataBusinessService.GetReferenceDataByNameValuePairs(appGroupName, appItemName);

                Tuple <string, NameValuePair> nameValueSingleResource = new Tuple <string, NameValuePair>(NameValuePair, nameValuePairsObject);

                if (nameValuePairsObject == null)
                {
                    throw new BusinessLogicException(ErrorConstants.Err_MisMatchConfigFile, HttpStatusCode.ExpectationFailed);
                }

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataControllerMethodExitEventId, LoggerTraceConstants.Title);

                return(Ok(nameValueSingleResource));
            }
        }
Exemple #13
0
        /// <summary> Gets all reference data. </summary> <param name="group">group is recorded as
        /// the category name</param> <returns>List of <see cref="ReferenceDataCategoryDTO"></returns>
        public NameValuePair GetReferenceDataByNameValuePairs(string appGroupName, string appItemName)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Business.GetReferenceDataByNameValuePairs"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataBusinessServiceMethodEntryEventId, LoggerTraceConstants.Title);

                var itemName     = default(string);
                var categoryName = referenceDataMapping.CategoryNames
                                   .Where(a => a.AppCategoryName.Equals(appGroupName, StringComparison.InvariantCultureIgnoreCase) ||
                                          a.DBCategoryName.Equals(appGroupName, StringComparison.InvariantCultureIgnoreCase))
                                   .Select(s => s.DBCategoryName).FirstOrDefault();

                if (categoryName != null)
                {
                    itemName = referenceDataMapping.CategoryNames
                               .Where(a => (a.AppCategoryName.Equals(appGroupName, StringComparison.InvariantCultureIgnoreCase) ||
                                            a.DBCategoryName.Equals(appGroupName, StringComparison.InvariantCultureIgnoreCase)) &&
                                      a.ReferenceDataNames.Any(b => b.AppReferenceDataName.Equals(appItemName, StringComparison.InvariantCultureIgnoreCase) ||
                                                               b.DBReferenceDataName.Equals(appItemName, StringComparison.InvariantCultureIgnoreCase)))
                               .Select(s => s.ReferenceDataNames.Select(t => t.DBReferenceDataName).FirstOrDefault()).FirstOrDefault();
                }

                var getNameValueReferenceData = referenceDataDataService.GetNameValueReferenceData(categoryName, itemName);
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataBusinessServiceMethodExitEventId, LoggerTraceConstants.Title);

                return(getNameValueReferenceData);
            }
        }
        /// <summary>
        /// Gets the user unit information.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <returns>Guid</returns>
        public async Task <Guid> GetUserUnitInfo(string userName)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetUserUnitInfo"))
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ActionManagerAPIPriority, LoggerTraceConstants.UserRoleUnitDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                var userUnit = await(from r in DataContext.UserRoleUnits.AsNoTracking()
                                     join u in DataContext.Users on r.User_GUID equals u.ID
                                     where u.UserName == userName
                                     select r.Unit_GUID).FirstOrDefaultAsync();

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ActionManagerAPIPriority, LoggerTraceConstants.UserRoleUnitDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(userUnit);
            }
        }
Exemple #15
0
        /// <summary>
        /// Get the postcode sector by the UDPRN id
        /// </summary>
        /// <param name="uDPRN">UDPRN id</param>
        /// <returns>PostCodeSectorDTO object</returns>
        public async Task <PostCodeSectorDTO> GetPostCodeSectorByUDPRN(int uDPRN)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetPostCodeSectorByUDPRN"))
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PostCodePriority, LoggerTraceConstants.PostCodeSectorDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                PostalAddress postalAddress = await DataContext.PostalAddresses.AsNoTracking().Where(pa => pa.UDPRN == uDPRN).SingleOrDefaultAsync();

                PostcodeSector    postCodeSector    = postalAddress.Postcode1.PostcodeSector;
                PostCodeSectorDTO postCodeSectorDTO = new PostCodeSectorDTO();
                GenericMapper.Map(postCodeSector, postCodeSectorDTO);
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PostCodePriority, LoggerTraceConstants.PostCodeSectorDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(postCodeSectorDTO);
            }
        }
Exemple #16
0
        /// <summary>
        /// This method is used to fetch Delivery Point by udprn.
        /// </summary>
        /// <param name="udprn">udprn as int</param>
        /// <returns>DeliveryPointDTO</returns>
        public async Task<DeliveryPointDTO> GetDeliveryPointByUDPRN(int udprn)
        {
            try
            {
                /* POC data modal change comment*/
                var objDeliveryPoint = await DataContext.DeliveryPoints.AsNoTracking().Include(s=>s.PostalAddress).Where(n => n.PostalAddress.UDPRN == udprn).SingleOrDefaultAsync();
                
                Mapper.Initialize(cfg =>
                {
                    cfg.CreateMap<DeliveryPoint, DeliveryPointDTO>();
                    cfg.CreateMap<DeliveryPointStatus, DeliveryPointStatusDTO>();
                    cfg.CreateMap<PostalAddress, PostalAddressDTO>().IgnoreAllUnmapped();
                });

                    Mapper.Configuration.CreateMapper();

                    return Mapper.Map<DeliveryPoint, DeliveryPointDTO>(objDeliveryPoint);
                }
                catch (InvalidOperationException ex)
                {
                    ex.Data.Add(ErrorConstants.UserFriendlyErrorMessage, ErrorConstants.Err_Default);
                    throw new SystemException(ErrorConstants.Err_InvalidOperationExceptionForCountAsync, ex);
                }
                finally
                {
                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.DeliveryPointAPIPriority, LoggerTraceConstants.DeliveryPointDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                }
            }
        public async Task <IActionResult> GenerateRouteLog([FromBody] RouteDTO deliveryRoute)
        {
            using (loggingHelper.RMTraceManager.StartTrace($"WebService.{nameof(GenerateRouteLog)}"))
            {
                string methodName = typeof(RouteLogController) + "." + nameof(GenerateRouteLog);
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.RouteLogAPIPriority, LoggerTraceConstants.RouteLogControllerMethodEntryEventId);

                // Initialize the PDF document file name
                string pdfFilename = string.Empty;

                try
                {
                    // Generate the route log summary report for the specified delivery route
                    pdfFilename = await routeLogBusinessService.GenerateRouteLog(deliveryRoute);
                }
                catch (AggregateException ex)
                {
                    foreach (var exception in ex.InnerExceptions)
                    {
                        loggingHelper.Log(exception, TraceEventType.Error);
                    }

                    var realExceptions = ex.Flatten().InnerException;
                    throw realExceptions;
                }

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.RouteLogAPIPriority, LoggerTraceConstants.RouteLogControllerMethodExitEventId);
                return(Ok(pdfFilename));
            }
        }
 private void OnFileSystemWatcherError(object sender, ErrorEventArgs e)
 {
     try
     {
         var watcher = (FileSystemWatcher)sender;
         watcher.EnableRaisingEvents = false;
         watcher.Dispose();
     }
     catch (Exception ex)
     {
         loggingHelper.Log(ex, TraceEventType.Error);
     }
     finally
     {
         Start();
     }
 }
        public async Task <IActionResult> GetRoutesForBasicSearch(string searchText)
        {
            if (string.IsNullOrEmpty(searchText))
            {
                throw new ArgumentNullException(nameof(searchText));
            }

            using (loggingHelper.RMTraceManager.StartTrace("WebService.GetRoutesForBasicSearch"))
            {
                string methodName = typeof(DeliveryRouteController) + "." + nameof(GetRoutesForBasicSearch);
                try
                {
                    loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteControllerMethodEntryEventId);

                    List <RouteDTO> deliveryRoutes = await deliveryRouteLogBusinessService.GetRoutesForBasicSearch(searchText, CurrentUserUnit);

                    loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteControllerMethodExitEventId);
                    return(Ok(deliveryRoutes));
                }
                catch (AggregateException ae)
                {
                    foreach (var exception in ae.InnerExceptions)
                    {
                        loggingHelper.Log(exception, TraceEventType.Error);
                    }

                    var realExceptions = ae.Flatten().InnerException;
                    throw realExceptions;
                }
            }
        }
        /// <summary>
        /// Load the XML data from file to Message Queue.
        /// </summary>
        /// <param name="strPath"></param>
        public void LoadUSRDetailsFromXML(string strPath)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Service.LoadUSRDetailsFromXML"))
            {
                List <AddressLocationUSRDTO> lstUSRFiles       = null;
                List <AddressLocationUSRDTO> lstUSRInsertFiles = null;

                string methodName = MethodBase.GetCurrentMethod().Name;
                LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionStarted, LoggerTraceConstants.COLON);
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ThirdPartyPriority, LoggerTraceConstants.ThirdPartyLoaderMethodEntryEventId, LoggerTraceConstants.Title);

                if (CheckFileName(new FileInfo(strPath).Name))
                {
                    if (IsFileValid(strPath))
                    {
                        lstUSRFiles = GetValidRecords(strPath);

                        lstUSRInsertFiles = lstUSRFiles.Where(insertFiles => insertFiles.ChangeType == ThirdPartyLoaderConstants.INSERT || insertFiles.ChangeType == ThirdPartyLoaderConstants.DELETE || insertFiles.ChangeType == ThirdPartyLoaderConstants.UPDATE).ToList();

                        lstUSRInsertFiles.ForEach(addressLocation =>
                        {
                            //Message is created and the Postal Address DTO is passed as the object to be queued along with the queue name and queue path where the object
                            //needs to be queued.
                            IMessage USRMsg = msgBroker.CreateMessage(addressLocation, ThirdPartyLoaderConstants.QUEUETHIRDPARTY, ThirdPartyLoaderConstants.QUEUEPATH);

                            //The messge object created in the above code is then pushed onto the queue. This internally uses the MSMQ Send function to push the message
                            //to the queue.
                            msgBroker.SendMessage(USRMsg);
                        });

                        fileMover.MoveFile(new string[] { strPath }, new string[] { processed, AppendTimeStamp(new FileInfo(strPath).Name) });
                    }
                    else
                    {
                        loggingHelper.Log(string.Format(ThirdPartyLoaderConstants.LOGMESSAGEFORUSRDATAVALIDATION, new FileInfo(strPath).Name, DateTime.UtcNow.ToString()), TraceEventType.Information, null);
                        fileMover.MoveFile(new string[] { strPath }, new string[] { error, AppendTimeStamp(new FileInfo(strPath).Name) });
                    }
                }

                LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionCompleted, LoggerTraceConstants.COLON);
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ThirdPartyPriority, LoggerTraceConstants.ThirdPartyLoaderMethodExitEventId, LoggerTraceConstants.Title);
            }
        }
        /// <summary>
        /// Gets all reference data for category type nameValuePair.
        /// </summary>
        /// <param name="dbGroupName">dbGroupName is recorded as the category name</param>
        /// <param name="dbItemName">dbItemName is recorded as the item name</param>
        /// <returns>List of <see cref="ReferenceDataCategoryDTO"></returns>
        public NameValuePair GetNameValueReferenceData(string dbGroupName, string dbItemName)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetNameValueReferenceData"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                RM.Common.ReferenceData.WebAPI.Entities.ReferenceData referenceData = null;

                var referenceDataCategories = DataContext.ReferenceDataCategories.AsNoTracking().Include(m => m.ReferenceDatas)
                                              .Where(n => n.CategoryName.Equals(dbGroupName, StringComparison.OrdinalIgnoreCase) &&
                                                     n.CategoryType.Equals(ReferenceDataCategoryTypeForNameValuePair)).SingleOrDefault();

                if (referenceDataCategories?.ReferenceDatas != null && referenceDataCategories.ReferenceDatas.Count > 0)
                {
                    referenceData = referenceDataCategories.ReferenceDatas
                                    .Where(n => n.ReferenceDataName.Trim().Equals(dbItemName, StringComparison.OrdinalIgnoreCase)).SingleOrDefault();
                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                }

                if (referenceData != null)
                {
                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataDataServiceMethodExitEventId, LoggerTraceConstants.Title);

                    return(new NameValuePair
                    {
                        Id = referenceData.ID,
                        Group = referenceDataCategories.CategoryName,
                        Name = referenceData.ReferenceDataName,
                        Value = referenceData.ReferenceDataValue,
                        DisplayText = referenceData.DisplayText,
                        Description = referenceData.DataDescription,
                        maintainable = referenceDataCategories.Maintainable
                    });
                }
                else
                {
                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                    return(null);
                }
            }
        }
Exemple #22
0
        /// <summary>
        /// Method to generate pdf
        /// </summary>
        /// <param name="xml">xml</param>
        /// <param name="fileName">fileName</param>
        /// <returns>byte array</returns>
        public async Task <string> GenerateReportWithMap(string xml, string fileName)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Integration.GenerateReportWithMap"))
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerIntegrationServiceMethodEntryEventId, LoggerTraceConstants.Title);

                HttpResponseMessage result = await httpHandler.PostAsJsonAsync(pdfGeneratorWebAPIName + "PDFReports", xml);

                if (!result.IsSuccessStatusCode)
                {
                    // LOG ERROR WITH Statuscode
                    var responseContent = result.ReasonPhrase;
                    throw new ServiceException(responseContent);
                }

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerIntegrationServiceMethodEntryEventId, LoggerTraceConstants.Title);
                return(result.Content.ReadAsStringAsync().Result);
            }
        }
        /// <summary>
        /// On Start windows service method.
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;

            LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionStarted);
            try
            {
                //instantiate timer
                Thread t = new Thread(new ThreadStart(this.InitTimer));
                t.Start();
            }
            catch (Exception ex)
            {
                loggingHelper.Log(ex, TraceEventType.Error);
            }
            finally
            {
                LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionCompleted);
            }
        }
Exemple #24
0
 /// <summary>
 /// Timer Elapsed event handler to handle the Elapsed event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void m_mainTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     using (loggingHelper.RMTraceManager.StartTrace("Service.m_mainTimer_Elapsed"))
     {
         string methodName = MethodBase.GetCurrentMethod().Name;
         try
         {
             loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PAFPriority, LoggerTraceConstants.PAFReceiverMethodEntryEventId, LoggerTraceConstants.Title);
             PAFMessageReceived();
         }
         catch (Exception ex)
         {
             loggingHelper.Log(ex, TraceEventType.Error);
         }
         loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PAFPriority, LoggerTraceConstants.PAFReceiverMethodExitEventId, LoggerTraceConstants.Title);
     }
 }
Exemple #25
0
        public async Task <IActionResult> GetAddressLocationByUDPRNJson(int udprn)
        {
            using (loggingHelper.RMTraceManager.StartTrace("WebService.GetAddressLocationByUDPRNJson"))
            {
                if (udprn == 0)
                {
                    throw new ArgumentException(nameof(udprn));
                }

                try
                {
                    string methodName = typeof(ThirdPartyAddressLocationController) + "." + nameof(GetAddressLocationByUDPRNJson);
                    loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationControllerMethodEntryEventId);
                    object addressLocationJson = await this.thirdPartyAddressLocationBusinessService.GetAddressLocationByUDPRNJson(udprn);

                    loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationControllerMethodExitEventId);
                    return(Ok(addressLocationJson));
                }
                catch (AggregateException ae)
                {
                    foreach (var exception in ae.InnerExceptions)
                    {
                        loggingHelper.Log(exception, TraceEventType.Error);
                    }

                    var realExceptions = ae.Flatten().InnerException;
                    throw realExceptions;
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="categoryName"></param>
        /// <param name="itemName"></param>
        /// <returns></returns>
        public async Task <Guid> GetReferenceDataGuId(string categoryName, string itemName)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Integration.GetReferenceDataGuId"))
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PostalAddressAPIPriority, LoggerTraceConstants.PostalAddressIntegrationServiceMethodEntryEventId, LoggerTraceConstants.Title);

                Guid referenceId           = Guid.Empty;
                HttpResponseMessage result = await httpHandler.GetAsync(referenceDataWebAPIName + "simpleLists?listName=" + categoryName);

                if (!result.IsSuccessStatusCode)
                {
                    var responseContent = result.ReasonPhrase;
                    throw new ServiceException(responseContent);
                }

                Tuple <string, SimpleListDTO> apiResult = JsonConvert.DeserializeObject <Tuple <string, SimpleListDTO> >(result.Content.ReadAsStringAsync().Result);
                if (apiResult != null && apiResult.Item2 != null && apiResult.Item2.ListItems != null && apiResult.Item2.ListItems.Count > 0)
                {
                    referenceId = apiResult.Item2.ListItems.Where(n => n.Value.Equals(itemName, StringComparison.OrdinalIgnoreCase)).SingleOrDefault().Id;
                }

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PostalAddressAPIPriority, LoggerTraceConstants.PostalAddressIntegrationServiceMethodExitEventId, LoggerTraceConstants.Title);

                return(referenceId);
            }
        }
        public async Task <IActionResult> CreateDeliveryGroup([FromBody] DeliveryPointGroupDTO deliveryPointGroupDto)
        {
            try
            {
                using (loggingHelper.RMTraceManager.StartTrace("WebService.AddDeliveryPoint"))
                {
                    DeliveryPointGroupDTO createDeliveryPointGroupModelDTO = null;
                    string methodName = typeof(DeliveryPointGroupController) + "." + nameof(CreateDeliveryGroup);
                    loggingHelper.LogMethodEntry(methodName, priority, entryEventId);

                    // validate the method argument.
                    if (deliveryPointGroupDto == null)
                    {
                        throw new ArgumentNullException(nameof(deliveryPointGroupDto));
                    }

                    // validate the model state.
                    if (!ModelState.IsValid)
                    {
                        return(BadRequest(ModelState));
                    }

                    createDeliveryPointGroupModelDTO = deliveryPointGroupBusinessService.CreateDeliveryPointGroup(deliveryPointGroupDto);
                    loggingHelper.LogMethodExit(methodName, priority, exitEventId);

                    return(Ok(createDeliveryPointGroupModelDTO));
                }
            }
            catch (AggregateException ae)
            {
                foreach (var exception in ae.InnerExceptions)
                {
                    loggingHelper.Log(exception, TraceEventType.Error);
                }

                var realExceptions = ae.Flatten().InnerException;
                throw realExceptions;
            }
        }
        public async Task <List <RoleAccessDTO> > GetRoleBasedAccessFunctions(UserUnitInfoDTO userUnitInfo)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetRoleBasedAccessFunctions"))
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ActionManagerAPIPriority, LoggerTraceConstants.ActionManagerDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                var roleAccessDto = await DataContext.AccessFunctions.AsNoTracking()
                                    .Where(x => x.UserName.Equals(userUnitInfo.UserName) && x.Unit_GUID.Equals(userUnitInfo.UnitGuid))
                                    .Select(x => new RoleAccessDTO
                {
                    RoleName     = x.RoleName,
                    Unit_GUID    = x.Unit_GUID,
                    UserName     = x.UserName,
                    FunctionName = x.FunctionName,
                    ActionName   = x.ActionName,
                    UserId       = x.UserId
                }).ToListAsync();

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ActionManagerAPIPriority, LoggerTraceConstants.ActionManagerDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(roleAccessDto);
            }
        }
        /// <summary> Gets the name of the reference data categories by category. </summary> <param
        /// name="categoryNames">The category names.</param> <returns>List of <see cref="ReferenceDataCategoryDTO"></returns>
        public async Task <List <ReferenceDataCategoryDTO> > GetReferenceDataSimpleLists(List <string> categoryNames)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Integration.GetReferenceDataSimpleLists"))
            {
                string methodName = MethodHelper.GetActualAsyncMethodName();
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteIntegrationServiceMethodEntryEventId, LoggerTraceConstants.Title);

                List <ReferenceDataCategoryDTO> listReferenceCategories = new List <ReferenceDataCategoryDTO>();

                HttpResponseMessage result = await httpHandler.PostAsJsonAsync(referenceDataWebAPIName + "simpleLists", categoryNames);

                if (!result.IsSuccessStatusCode)
                {
                    var responseContent = result.ReasonPhrase;
                    throw new ServiceException(responseContent);
                }

                List <SimpleListDTO> apiResult = JsonConvert.DeserializeObject <List <SimpleListDTO> >(result.Content.ReadAsStringAsync().Result);
                listReferenceCategories.AddRange(ReferenceDataHelper.MapDTO(apiResult));
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteIntegrationServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(listReferenceCategories);
            }
        }
Exemple #30
0
        /// <summary>
        /// Get the postcode sector by the UDPRN id
        /// </summary>
        /// <param name="udprn">UDPRN id</param>
        /// <returns>PostCodeSectorDTO object</returns>
        public async Task <PostcodeSectorDTO> GetPostcodeSectorByUdprn(int udprn)
        {
            string methodName = typeof(UnitLocationBusinessService) + "." + nameof(GetPostcodeSectorByUdprn);

            using (loggingHelper.RMTraceManager.StartTrace("Business.GetPostCodeSectorByUdprn"))
            {
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodEntryEventId);

                var postCodeSector = await postcodeSectorDataService.GetPostcodeSectorByUdprn(udprn);

                PostcodeSectorDTO postCodeSectorDto = GenericMapper.Map <PostcodeSectorDataDTO, PostcodeSectorDTO>(postCodeSector);

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(postCodeSectorDto);
            }
        }