/// <summary> /// Gets all reference data for category type nameValuePair using Guid Id /// </summary> /// <param name="id">Guid Id</param> /// <returns>NameValuePair</returns> public NameValuePair GetNameValueReferenceData(Guid id) { using (loggingHelper.RMTraceManager.StartTrace("DataService.GetNameValueReferenceData")) { string methodName = typeof(ReferenceDataDataService) + "." + nameof(GetNameValueReferenceData); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); RM.Common.ReferenceData.WebAPI.Entities.ReferenceData referenceData = null; referenceData = DataContext.ReferenceDatas.Include(m => m.ReferenceDataCategory) .Where(n => n.ID == id && n.ReferenceDataCategory.CategoryType.Equals(ReferenceDataCategoryTypeForNameValuePair)).SingleOrDefault(); if (referenceData != null) { loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(new NameValuePair { Id = referenceData.ID, Group = referenceData.ReferenceDataCategory.CategoryName, Name = referenceData.ReferenceDataName, Value = referenceData.ReferenceDataValue, DisplayText = referenceData.DisplayText, Description = referenceData.DataDescription, maintainable = referenceData.ReferenceDataCategory.Maintainable }); } else { loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(null); } } }
/// <summary> /// Get the nearest street for operational object. /// </summary> /// <param name="operationalObjectPoint">Operational object unique identifier.</param> /// <param name="streetName">Street name.</param> /// <returns>Nearest street and the intersection point.</returns> public async Task <Tuple <NetworkLinkDTO, SqlGeometry> > GetNearestNamedRoad(DbGeometry operationalObjectPoint, string streetName) { using (loggingHelper.RMTraceManager.StartTrace("Integration.GetNearestNamedRoad")) { string methodName = typeof(AccessLinkIntegrationService) + "." + nameof(GetNearestNamedRoad); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); var jsonSerializerSettings = new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var operationalObjectPointJson = JsonConvert.SerializeObject(operationalObjectPoint, jsonSerializerSettings); HttpResponseMessage result = await httpHandler.PostAsJsonAsync(networkManagerDataWebAPIName + "/nearestnamedroad/" + streetName, operationalObjectPointJson); if (!result.IsSuccessStatusCode) { var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } Tuple <NetworkLinkDTO, DBGeometryDTO> nearestNamedRoad = JsonConvert.DeserializeObject <Tuple <NetworkLinkDTO, DBGeometryDTO> >(result.Content.ReadAsStringAsync().Result); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(new Tuple <NetworkLinkDTO, SqlGeometry>(nearestNamedRoad.Item1, nearestNamedRoad.Item2?.Geometry?.ToSqlGeometry())); } }
/// <summary> /// Generate token /// </summary> /// <param name="context">http context</param> /// <returns>Generated token</returns> public Task Invoke(HttpContext context) { string methodName = typeof(TokenProviderMiddleware) + "." + nameof(Invoke); using (loggingHelper.RMTraceManager.StartTrace("Middleware.Invoke")) { loggingHelper.LogMethodEntry(methodName, priority, entryEventId); // If the request path doesn't match, skip if (!context.Request.Path.Equals(options.Path, StringComparison.Ordinal)) { return(next(context)); } // Request must be POST with Content-Type: application/x-www-form-urlencoded if (!context.Request.Method.Equals("POST") || !context.Request.HasFormContentType) { context.Response.StatusCode = 400; return(context.Response.WriteAsync("Bad request.")); } loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(GenerateToken(context)); } }
/// <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> > GetReferenceDataNameValuePairs(List <string> categoryNames) { using (loggingHelper.RMTraceManager.StartTrace("Integration.GetReferenceDataNameValuePairs")) { string methodName = typeof(NetworkManagerIntegrationService) + "." + nameof(GetReferenceDataNameValuePairs); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); List <ReferenceDataCategoryDTO> listReferenceCategories = new List <ReferenceDataCategoryDTO>(); List <NameValuePair> nameValuePairs = new List <NameValuePair>(); foreach (var category in categoryNames) { HttpResponseMessage result = await httpHandler.GetAsync(referenceDataWebAPIName + "nameValuePairs?appGroupName=" + category); if (!result.IsSuccessStatusCode) { var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } Tuple <string, List <NameValuePair> > apiResult = JsonConvert.DeserializeObject <Tuple <string, List <NameValuePair> > >(result.Content.ReadAsStringAsync().Result); nameValuePairs.AddRange(apiResult.Item2); } listReferenceCategories.AddRange(ReferenceDataHelper.MapDTO(nameValuePairs)); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(listReferenceCategories); } }
/// <summary> /// This method fetches role based functions for the current user /// </summary> /// <param name="userUnitInfo">user unit information</param> /// <returns>functions available for current user</returns> public async Task <List <RoleAccessDataDTO> > GetRoleBasedAccessFunctions(UserUnitInfoDataDTO userUnitInfo) { string methodName = typeof(ActionManagerDataService) + "." + nameof(GetRoleBasedAccessFunctions); using (loggingHelper.RMTraceManager.StartTrace("DataService.GetRoleBasedAccessFunctions")) { loggingHelper.LogMethodEntry(methodName, priority, entryEventId); var roleAccessDataDto = await DataContext.AccessFunctions.AsNoTracking() .Where(x => x.UserName.Equals(userUnitInfo.UserName) && x.LocationID.Equals(userUnitInfo.LocationId)) .Select(x => new RoleAccessDataDTO { RoleName = x.RoleName, Unit_GUID = x.LocationID, UserName = x.UserName, FunctionName = x.FunctionName, ActionName = x.ActionName, UserId = x.UserId, UnitType = userUnitInfo.UnitType, UnitName = userUnitInfo.UnitName }).ToListAsync(); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(roleAccessDataDto); } }
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> /// Gets the all delivery units for an user. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="postcodeTypeDistrictGUID">The postcode type district unique identifier.</param> /// <returns> /// List of <see cref="UnitLocationDTO"/>. /// </returns> public async Task <IEnumerable <UnitLocationDataDTO> > GetUnitsByUser(Guid userId, Guid postcodeTypeDistrictGUID) { string methodName = typeof(UnitLocationDataService) + "." + nameof(GetUnitsByUser); using (loggingHelper.RMTraceManager.StartTrace("DataService.GetUnitsByUser")) { loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitLocationDataServiceMethodEntryEventId); var unitLocation = await(from postalAddressIdentifier in DataContext.PostalAddressIdentifiers.AsNoTracking() join location in DataContext.Locations.AsNoTracking() on postalAddressIdentifier.ID equals location.ID join userRoleLocation in DataContext.UserRoleLocations.AsNoTracking() on postalAddressIdentifier.ID equals userRoleLocation.LocationID where userRoleLocation.UserID == userId select new UnitLocationDataDTO { LocationId = postalAddressIdentifier.ID, Name = postalAddressIdentifier.Name, Shape = location.Shape, Area = ( from postcode in DataContext.PostcodeHierarchies join sector in DataContext.PostcodeHierarchies on postcode.ParentPostcode equals sector.Postcode join district in DataContext.PostcodeHierarchies on sector.ParentPostcode equals district.Postcode join lh in DataContext.LocationPostcodeHierarchies on postcode.ID equals lh.PostcodeHierarchyID where postcode.ID == lh.PostcodeHierarchyID && district.PostcodeTypeGUID == postcodeTypeDistrictGUID && location.ID == lh.LocationID select district.ParentPostcode).FirstOrDefault() ?? string.Empty, }).ToListAsync(); loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitLocationDataServiceMethodExitEventId); return(unitLocation); } }
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); } } }
/// <summary> /// Get the nearest street for operational object. /// </summary> /// <param name="operationalObjectPoint">The operational object unique identifier.</param> /// <param name="streetName">The street name.</param> /// <returns>The nearest street and the intersection point.</returns> public Tuple <NetworkLinkDTO, SqlGeometry> GetNearestNamedRoad(DbGeometry operationalObjectPoint, string streetName) { using (loggingHelper.RMTraceManager.StartTrace("Business.GetNearestNamedRoad")) { string methodName = typeof(NetworkManagerBusinessService) + "." + nameof(GetNearestNamedRoad); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); List <string> categoryNamesSimpleLists = new List <string> { ReferenceDataCategoryNames.NetworkLinkType, }; var referenceDataCategoryList = networkManagerIntegrationService.GetReferenceDataSimpleLists(categoryNamesSimpleLists).Result; Tuple <NetworkLinkDataDTO, SqlGeometry> getNearestNamedRoad = streetNetworkDataService.GetNearestNamedRoad(operationalObjectPoint, streetName, referenceDataCategoryList); NetworkLinkDTO networkLink = null; if (getNearestNamedRoad != null && getNearestNamedRoad.Item1 != null) { networkLink = new NetworkLinkDTO() { Id = getNearestNamedRoad.Item1.ID, LinkGeometry = getNearestNamedRoad.Item1.LinkGeometry, NetworkLinkType_GUID = getNearestNamedRoad.Item1.NetworkLinkTypeGUID, TOID = getNearestNamedRoad.Item1.TOID }; } Tuple <NetworkLinkDTO, SqlGeometry> nearestRoad = new Tuple <NetworkLinkDTO, SqlGeometry>(networkLink, getNearestNamedRoad.Item2); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(nearestRoad); } }
/// <summary> /// Gets reference data using Guid Id /// </summary> /// <param name="id">Guid Id</param> /// <returns>NameValuePair</returns> public NameValuePair GetReferenceDataByNameValuePairs(Guid id) { using (loggingHelper.RMTraceManager.StartTrace("Business.GetReferenceDataByNameValuePairs")) { string methodName = typeof(ReferenceDataBusinessService) + "." + nameof(GetReferenceDataByNameValuePairs); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); var getNameValueReferenceData = referenceDataDataService.GetNameValueReferenceData(id); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(getNameValueReferenceData); } }
public async Task <List <ReferenceDataCategoryDTO> > GetReferenceDataSimpleLists(List <string> listNames) { using (loggingHelper.RMTraceManager.StartTrace($"IntegrationService.{nameof(GetReferenceDataSimpleLists)}")) { string methodName = typeof(DeliveryPointGroupIntegrationService) + "." + nameof(GetReferenceDataSimpleLists); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); List <CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO> listReferenceCategories = new List <ReferenceDataCategoryDTO>(); HttpResponseMessage result = await httpHandler.PostAsJsonAsync(referenceDataWebAPIName + "/simpleLists", listNames); if (!result.IsSuccessStatusCode) { // LOG ERROR WITH Statuscode 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.LogMethodExit(methodName, priority, exitEventId); return(listReferenceCategories); } }
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)); } }
public async Task <IActionResult> SearchAddressdetails(string searchText) { try { string methodName = typeof(UnitManagerController) + "." + nameof(SearchAddressdetails); using (loggingHelper.RMTraceManager.StartTrace("Controller.SearchAddressdetails")) { loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerControllerMethodEntryEventId); List <string> postalAddressList = await unitLocationBusinessService.GetPostalAddressSearchDetails(searchText, CurrentUserUnit); loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerControllerMethodExitEventId); return(Ok(postalAddressList)); } } catch (AggregateException ae) { foreach (var exception in ae.InnerExceptions) { loggingHelper.Log(exception, System.Diagnostics.TraceEventType.Error); } var realExceptions = ae.Flatten().InnerException; throw realExceptions; } }
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> /// Find AddressLocation by UDPRN /// </summary> /// <param name="udprn">UDPRN id</param> /// <returns>boolean value</returns> public async Task <bool> AddressLocationExists(int udprn) { using (loggingHelper.RMTraceManager.StartTrace("DataService.AddressLocationExists")) { string methodName = typeof(AddressLocationDataService) + "." + nameof(AddressLocationExists); loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodEntryEventId); bool addressLocationExists = await DataContext.AddressLocations.AsNoTracking().Where(n => n.UDPRN == udprn).AnyAsync(); loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodExitEventId); return(addressLocationExists); } }
public IActionResult GetNameValueReferenceData(Guid id) { using (loggingHelper.RMTraceManager.StartTrace("WebService.GetNameValueReferenceDataByGuid")) { string methodName = typeof(ReferenceDataController) + "." + nameof(GetNameValueReferenceData); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); var nameValuePairsObject = referenceDataBusinessService.GetReferenceDataByNameValuePairs(id); Tuple <string, NameValuePair> nameValueSingleResource = new Tuple <string, NameValuePair>(NameValuePair, nameValuePairsObject); if (nameValuePairsObject == null) { throw new BusinessLogicException(ErrorConstants.Err_MisMatchConfigFile, HttpStatusCode.ExpectationFailed); } loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(Ok(nameValueSingleResource)); } }
/// <summary> /// This method fetches role based functions for the current user /// </summary> /// <param name="userUnitInfo">user unit information</param> /// <returns>functions available for current user</returns> public async Task <List <RoleAccessDTO> > GetRoleBasedAccessFunctions(UserUnitInfoDTO userUnitInfo) { string methodName = typeof(ActionManagerBusinessService) + "." + nameof(GetRoleBasedAccessFunctions); using (loggingHelper.RMTraceManager.StartTrace("BusinessService.GetRoleBasedAccessFunctions")) { loggingHelper.LogMethodEntry(methodName, priority, entryEventId); // mapping public DTO to dataDTO UserUnitInfoDataDTO userUnitInfoDataDTO = GenericMapper.Map <UserUnitInfoDTO, UserUnitInfoDataDTO>(userUnitInfo); var roleAccessDataDto = await actionManagerDataService.GetRoleBasedAccessFunctions(userUnitInfoDataDTO); loggingHelper.LogMethodExit(methodName, priority, exitEventId); // mapping dataDTO to public DTO List <RoleAccessDTO> roleAccessDTO = GenericMapper.MapList <RoleAccessDataDTO, RoleAccessDTO>(roleAccessDataDto); return(roleAccessDTO); } }
public string GetDeliveryPointGroups(string boundaryBox, Guid unitGuid) { using (loggingHelper.RMTraceManager.StartTrace($"Business.{nameof(GetDeliveryPointGroups)}")) { string methodName = typeof(DeliveryPointGroupBusinessService) + "." + nameof(GetDeliveryPointGroups); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); string deliveryPointGroupJsonData = null; if (!string.IsNullOrEmpty(boundaryBox)) { var deliveryGroupCoordinates = GetGroupCoordinatesDataByBoundingBox(boundaryBox.Split(Comma[0])); var deliveryGroups = deliveryPointGroupDataService.GetDeliveryGroups(deliveryGroupCoordinates, unitGuid); deliveryPointGroupJsonData = GetDeliveryGroupsJsonData(deliveryGroups); } loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(deliveryPointGroupJsonData); } }
/// <summary> /// Get route details specific to scenario. /// </summary> /// <param name="scenarioID">ID of the selected scenario</param> /// <returns>Returns list of route on the basis of selected scenario</returns> public async Task <List <RouteDTO> > GetScenarioRoutes(Guid scenarioID) { if (scenarioID == Guid.Empty) { throw new ArgumentNullException(nameof(scenarioID)); } using (loggingHelper.RMTraceManager.StartTrace("Business.GetRoutes")) { string methodName = typeof(DeliveryRouteBusinessService) + "." + nameof(GetScenarioRoutes); loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodEntryEventId); var routeDetails = await deliveryRouteDataService.GetScenarioRoutes(scenarioID); List <RouteDTO> routes = GenericMapper.MapList <RouteDataDTO, RouteDTO>(routeDetails); loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodExitEventId); return(routes.OrderBy(n => n.DisplayText).ToList()); } }
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; } }
/// <summary> /// Retrieves the route log the specified delivery route /// </summary> /// <param name="deliveryRoute">The delivery route</param> /// <returns>The route log for the specified delivery route</returns> public async Task <RouteLogSummaryDTO> GetRouteLog(RouteDTO deliveryRoute) { using (loggingHelper.RMTraceManager.StartTrace($"Integration.{nameof(GetRouteLog)}")) { string methodName = typeof(RouteLogIntegrationService) + "." + nameof(GetRouteLog); loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.RouteLogAPIPriority, LoggerTraceConstants.RouteLogIntegrationServiceMethodEntryEventId); HttpResponseMessage result = await httpHandler.PostAsJsonAsync(deliveryRouteWebAPIName + "deliveryroute/deliveryroutesummaries/", deliveryRoute); if (!result.IsSuccessStatusCode) { var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } // Get the route log from the result var routeLog = JsonConvert.DeserializeObject <RouteLogSummaryDTO>(result.Content.ReadAsStringAsync().Result); loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.RouteLogAPIPriority, LoggerTraceConstants.RouteLogIntegrationServiceMethodExitEventId); return(routeLog); } }
public IActionResult GetNearestNamedRoad([FromBody] string operationalObjectPointJson, string streetName) { using (loggingHelper.RMTraceManager.StartTrace("Controller.GetNearestNamedRoad")) { string methodName = typeof(NetworkManagerController) + "." + nameof(GetNearestNamedRoad); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); Tuple <NetworkLinkDTO, SqlGeometry> result; result = networkManagerBusinessService.GetNearestNamedRoad(JsonConvert.DeserializeObject <DbGeometry>(operationalObjectPointJson, new DbGeometryConverter()), streetName); var convertedResult = new Tuple <NetworkLinkDTO, DBGeometryDTO>(result.Item1, new DBGeometryDTO { Geometry = result.Item2.IsNull ? null : result.Item2.ToDbGeometry() }); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(Ok(convertedResult)); } }
/// <summary> /// Get results from entities using basic search /// </summary> /// <param name="searchText">The text to be searched from the entities.</param> /// <param name="userUnit">The user unit.</param> /// <param name="currentUserUnitType">The user unit type.</param> /// <returns>The result set after filtering the values.</returns> public async Task <SearchResultDTO> GetBasicSearchDetails(string searchText, Guid userUnit, string currentUserUnitType) { string methodName = typeof(SearchBusinessService) + "." + nameof(GetBasicSearchDetails); using (loggingHelper.RMTraceManager.StartTrace("Business.GetBasicSearchDetails")) { loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.SearchManagerAPIPriority, LoggerTraceConstants.SearchManagerBusinessServiceMethodEntryEventId); SearchResultDTO searchResultDTO = null; string unitName = currentUserUnitType; var deliveryRoutes = await searchIntegrationService.FetchDeliveryRouteForBasicSearch(searchText); var deliveryRouteCount = await searchIntegrationService.GetDeliveryRouteCount(searchText); var postcodes = await searchIntegrationService.FetchPostCodeUnitForBasicSearch(searchText); var postCodeCount = await searchIntegrationService.GetPostCodeUnitCount(searchText); var deliveryPoints = await searchIntegrationService.FetchDeliveryPointsForBasicSearch(searchText); var deliveryPointsCount = await searchIntegrationService.GetDeliveryPointsCount(searchText); var streetNames = await searchIntegrationService.FetchStreetNamesForBasicSearch(searchText); var streetNetworkCount = await searchIntegrationService.GetStreetNameCount(searchText); if (string.Equals(UserUnit.CollectionUnit.GetDescription(), unitName.Trim(), StringComparison.OrdinalIgnoreCase)) { searchResultDTO = MapSearchResultsForCollectionUnit(deliveryRoutes, deliveryRouteCount, postcodes, postCodeCount, deliveryPoints, deliveryPointsCount, streetNames, streetNetworkCount); } else { searchResultDTO = MapSearchResultsForDeliveryUnit(deliveryRoutes, deliveryRouteCount, postcodes, postCodeCount, deliveryPoints, deliveryPointsCount, streetNames, streetNetworkCount); } loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.SearchManagerAPIPriority, LoggerTraceConstants.SearchManagerBusinessServiceMethodExitEventId); return(searchResultDTO); } }
/// <summary> /// Get all units for a user. /// </summary> /// <param name="userId">user Id.</param> /// <param name="currentUserUnitType">current user unit type.</param> /// <returns> /// List of <see cref="UnitLocationDTO" />. /// </returns> public async Task <IEnumerable <UnitLocationDTO> > GetUnitsByUser(Guid userId, string currentUserUnitType) { string methodName = typeof(UnitLocationBusinessService) + "." + nameof(GetUnitsByUser); using (loggingHelper.RMTraceManager.StartTrace("Business.GetUnitsByUser")) { loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodEntryEventId); // reference data value for PostcodeDistrict with Category - Postcode Type Guid postcodeTypeGUID = unitManagerIntegrationService.GetReferenceDataGuId(PostCodeType, PostCodeTypeCategory.PostcodeDistrict.GetDescription()).Result; IEnumerable <UnitLocationDataDTO> unitLocationDataDtoList = null; if (!currentUserUnitType.Equals(UserUnit.National.GetDescription())) { unitLocationDataDtoList = await unitLocationDataService.GetUnitsByUser(userId, postcodeTypeGUID); } else { unitLocationDataDtoList = await unitLocationDataService.GetUnitsByUserForNational(userId, postcodeTypeGUID); } var unitLocationDtoList = unitLocationDataDtoList.Select(x => new UnitLocationDTO { ID = x.LocationId, Area = x.Area, UnitBoundryPolygon = x.Shape, UnitName = currentUserUnitType.Equals(UserUnit.National.ToString()) ? currentUserUnitType : x.Name }).ToList(); foreach (var unitLocationDto in unitLocationDtoList) { try { // take the unit boundry plus 1 mile envelope var unitBoundary = SqlGeometry.STPolyFromWKB(new SqlBytes(unitLocationDto.UnitBoundryPolygon.Envelope.Buffer(1609.34).Envelope.AsBinary()), BNGCOORDINATESYSTEM).MakeValid(); unitLocationDto.BoundingBoxCenter = new List <double> { unitBoundary.STCentroid().STPointN(1).STX.Value, unitBoundary.STCentroid().STPointN(1).STY.Value }; unitLocationDto.BoundingBox = new List <double> { unitBoundary.STPointN(1).STX.Value, unitBoundary.STPointN(1).STY.Value, unitBoundary.STPointN(3).STX.Value, unitBoundary.STPointN(3).STY.Value }; } catch (Exception ex) { } } loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodExitEventId); return(unitLocationDtoList); } }
/// <summary> /// This method is used to fetch Road routes data. /// </summary> /// <param name="boundingBoxCoordinates">BoundingBox Coordinates</param> /// <param name="locationID">location unique identifier.</param> /// <param name="currentUserUnitType">Current user unit type.</param> /// <returns>List of NetworkLinkDTO</returns> public List <NetworkLinkDataDTO> GetRoadRoutes(string boundingBoxCoordinates, Guid locationID, List <ReferenceDataCategoryDTO> referenceDataCategoryList, string currentUserUnitType) { using (loggingHelper.RMTraceManager.StartTrace("DataService.GetRoadRoutes")) { string methodName = typeof(RoadNameDataService) + "." + nameof(GetRoadRoutes); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); List <NetworkLink> result = GetRoadNameCoordinatesDatabyBoundingbox(boundingBoxCoordinates, locationID, referenceDataCategoryList, currentUserUnitType).ToList(); var networkLink = GenericMapper.MapList <NetworkLink, NetworkLinkDataDTO>(result); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(networkLink); } }
/// <summary> /// Gets first five postcodeunits for an unit for a given search text /// </summary> /// <param name="searchInputs">SearchInputDataDto</param> /// <returns>collection of PostcodeDataDTO</returns> public async Task <IEnumerable <PostcodeDataDTO> > GetPostcodeUnitForBasicSearch(SearchInputDataDto searchInputs) { string methodName = typeof(UnitLocationDataService) + "." + nameof(GetPostcodeUnitForBasicSearch); using (loggingHelper.RMTraceManager.StartTrace("DataService.GetPostcodeUnitForBasicSearch")) { loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.PostCodeDataServiceMethodEntryEventId); var postCodeDataDto = await(from p in DataContext.PostcodeHierarchies.AsNoTracking() join s in DataContext.LocationPostcodeHierarchies.AsNoTracking() on p.ID equals s.PostcodeHierarchyID join l in DataContext.Locations.AsNoTracking() on s.LocationID equals l.ID where p.Postcode.StartsWith(searchInputs.SearchText ?? string.Empty) && p.PostcodeTypeGUID == searchInputs.PostcodeTypeGUID && l.ID == searchInputs.UserUnitLocationId select new PostcodeDataDTO { PostcodeUnit = p.Postcode, ID = p.ID }).Take(searchInputs.SearchResultCount).ToListAsync(); loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.PostCodeDataServiceMethodExitEventId); return(postCodeDataDto); } }
/// <summary> /// Get street names for advance search /// </summary> /// <param name="searchText">searchText as string</param> /// <param name="locationID">The location unique identifier.</param> /// <param name="currentUserUnitType">The current user unit type.</param> /// <returns>StreetNames</returns> public async Task <List <StreetNameDataDTO> > GetStreetNamesForAdvanceSearch(string searchText, Guid locationID, string currentUserUnitType) { using (loggingHelper.RMTraceManager.StartTrace("DataService.GetStreetNamesForAdvanceSearch")) { string methodName = typeof(StreetNetworkDataService) + "." + nameof(GetStreetNamesForAdvanceSearch); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); DbGeometry polygon = null; List <StreetNameDataDTO> streetNamesDto = new List <StreetNameDataDTO>(); if (!currentUserUnitType.Equals(UserUnit.National.GetDescription(), StringComparison.OrdinalIgnoreCase)) { polygon = DataContext.Locations.Where(x => x.ID == locationID) .Select(x => x.Shape) .SingleOrDefault(); } if (polygon != null) { streetNamesDto = await DataContext.StreetNames.AsNoTracking() .Where( l => l.Geometry.Intersects(polygon) && (l.NationalRoadCode.StartsWith(searchText) || l.DesignatedName.StartsWith(searchText))) .Select(l => new StreetNameDataDTO { ID = l.ID, NationalRoadCode = l.NationalRoadCode, DesignatedName = l.DesignatedName }).OrderBy(l => l.NationalRoadCode).ThenBy(l => l.DesignatedName).ToListAsync(); } else { streetNamesDto = await DataContext.StreetNames.AsNoTracking() .Where( l => l.NationalRoadCode.StartsWith(searchText) || l.DesignatedName.StartsWith(searchText)) .Select(l => new StreetNameDataDTO { ID = l.ID, NationalRoadCode = l.NationalRoadCode, DesignatedName = l.DesignatedName }).OrderBy(l => l.NationalRoadCode).ThenBy(l => l.DesignatedName).ToListAsync(); } loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(streetNamesDto); } }
/// <summary> /// This Method is used to Access Link data for defined coordinates. /// </summary> /// <param name="boundingBoxCoordinates">BoundingBox Coordinates</param> /// <param name="unitGuid">unit unique identifier.</param> /// <returns>List of Access Link Dto</returns> public List <AccessLinkDataDTO> GetAccessLinks(string boundingBoxCoordinates, Guid unitGuid) { using (loggingHelper.RMTraceManager.StartTrace("DataService.GetAccessLinks")) { string methodName = typeof(AccessLinkDataService) + "." + nameof(GetAccessLinks); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); var resultValue = GetAccessLinkCoordinatesDataByBoundingBox(boundingBoxCoordinates, unitGuid).ToList(); ConfigureMapper(); var accesslink = Mapper.Map <List <AccessLink>, List <AccessLinkDataDTO> >(resultValue); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(accesslink); } }
/// <summary> /// Delete the Postal Addresses with Pending Delete status and having no reference. /// </summary> public void BatchDelete() { using (loggingHelper.RMTraceManager.StartTrace("EXE.BatchDelete")) { try { string methodName = typeof(DataBatchDelete) + "." + nameof(BatchDelete); loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteControllerMethodEntryEventId); string pafDeleteHousekeepingUrl = configurationHelper.ReadAppSettingsConfigurationValues(DELETEPAFHOUSEKEEPING); httpHandler.DeleteAsync(pafDeleteHousekeepingUrl, true); loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteControllerMethodExitEventId); } catch (Exception ex) { loggingHelper.Log(ex, TraceEventType.Error); } } }
/// <summary> /// Log exception if the PAF and NYB record insertion fails /// </summary> /// <param name="fileProcessingLogDTO"> /// Expects DTO object to save exception while saving records in DB /// </param> public void LogFileException(FileProcessingLogDTO fileProcessingLogDTO) { try { using (loggingHelper.RMTraceManager.StartTrace("BusinessService.SavePostalAddressForNYB")) { string methodName = typeof(FileProcessingLogDataService) + "." + nameof(LogFileException); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); var entity = GenericMapper.Map <FileProcessingLogDTO, FileProcessingLog>(fileProcessingLogDTO); DataContext.FileProcessingLogs.Add(entity); DataContext.SaveChanges(); loggingHelper.LogMethodExit(methodName, priority, exitEventId); } } catch (Exception ex) { this.loggingHelper.Log(ex, TraceEventType.Error); } }