/// <summary>
        /// Fetch the  Route.
        /// </summary>
        /// <param name="operationStateId">Guid operationStateID</param>
        /// <param name="deliveryScenarioId">Guid deliveryScenarioID</param>
        /// <param name="userUnit">The user unit.</param>
        /// <returns>List</returns>
        public List <RouteDTO> FetchRoutes(Guid operationStateId, Guid deliveryScenarioId, Guid userUnit, string UnitName)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.FetchRoutes"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteDataServiceMethodEntryEventId, LoggerTraceConstants.Title);
                List <RouteDTO> routedetails = null;

                if (string.Equals(UserUnit.CollectionUnit.GetDescription(), UnitName.Trim(), StringComparison.OrdinalIgnoreCase))
                {
                    IEnumerable <CollectionRoute> result = DataContext.CollectionRoutes.AsNoTracking()
                                                           .Where(x => x.Scenario.Unit_GUID == userUnit && x.CollectionScenario_GUID == deliveryScenarioId &&
                                                                  x.Scenario.OperationalState_GUID == operationStateId).ToList();
                    routedetails = GenericMapper.MapList <CollectionRoute, RouteDTO>(result.ToList());
                }
                else
                {
                    IEnumerable <DeliveryRoute> result = DataContext.DeliveryRoutes.AsNoTracking()
                                                         .Where(x => x.Scenario.Unit_GUID == userUnit && x.DeliveryScenario_GUID == deliveryScenarioId &&
                                                                x.Scenario.OperationalState_GUID == operationStateId).ToList();
                    routedetails = GenericMapper.MapList <DeliveryRoute, RouteDTO>(result.ToList());
                }

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

                return(routedetails);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fetch the Route log status.
        /// </summary>
        /// <returns>List</returns>
        public List <ReferenceDataDTO> RouteLogStatus()
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.RouteLogStatus"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataCategoryDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                try
                {
                    List <ReferenceDataDTO> lstReferenceDt = new List <ReferenceDataDTO>();
                    string categoryname = "Delivery Point Operational Status";
                    var    query        = DataContext.ReferenceDataCategories.AsNoTracking().Include(m => m.ReferenceDatas).Where(n => n.CategoryName.Trim().Equals(categoryname, StringComparison.OrdinalIgnoreCase)).SingleOrDefault();
                    if (query?.ReferenceDatas != null && query.ReferenceDatas.Count > 0)
                    {
                        lstReferenceDt = GenericMapper.MapList <ReferenceData, ReferenceDataDTO>(query.ReferenceDatas.ToList());
                    }

                    loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataCategoryDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                    return(lstReferenceDt);
                }
                catch (InvalidOperationException ex)
                {
                    ex.Data.Add(ErrorConstants.UserFriendlyErrorMessage, ErrorConstants.Err_Default);
                    throw new SystemException(ErrorConstants.Err_InvalidOperationExceptionForSingleorDefault, ex);
                }
            }
        }
        /// <summary>
        /// Get filtered routes on basis of search text for Advance Search .
        /// </summary>
        /// <param name="searchText">Text to search</param>
        /// <param name="locationId">selected unit's location ID</param>
        /// <returns>Returns list of routes that matches the search text</returns>
        public async Task <List <RouteDTO> > GetRoutesForAdvanceSearch(string searchText, Guid locationId)
        {
            if (string.IsNullOrEmpty(searchText))
            {
                throw new ArgumentNullException(nameof(searchText));
            }

            if (locationId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(locationId));
            }

            using (loggingHelper.RMTraceManager.StartTrace("Business.GetRouteForAdvanceSearch"))
            {
                string methodName = typeof(DeliveryRouteBusinessService) + "." + nameof(GetRoutesForAdvanceSearch);
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodEntryEventId);

                var routeDetails = await deliveryRouteDataService.GetRoutesForAdvanceSearch(searchText, locationId);

                List <RouteDTO> routes = GenericMapper.MapList <RouteDataDTO, RouteDTO>(routeDetails);

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodExitEventId);

                return(routes);
            }
        }
        public async Task <List <PostCodeDTO> > GetPostCodes(List <Guid> postcodeGuids, Guid unitGuid)
        {
            var result = await(from pc in DataContext.Postcodes.AsNoTracking()
                               join ul in DataContext.UnitLocationPostcodes.AsNoTracking() on pc.ID equals ul.PoscodeUnit_GUID
                               where postcodeGuids.Contains(pc.ID) && ul.Unit_GUID == unitGuid
                               select pc).ToListAsync();

            return(GenericMapper.MapList <Postcode, PostCodeDTO>(result));
        }
        /// <summary>
        /// Get route details specific to postcode
        /// </summary>
        /// <param name="postcodeUnit">Post code</param>
        /// <param name="locationId">selected unit's location ID</param>
        /// <returns>List of routes</returns>
        public async Task <List <RouteDTO> > GetPostcodeSpecificRoutes(string postcodeUnit, Guid locationId)
        {
            if (string.IsNullOrEmpty(postcodeUnit))
            {
                throw new ArgumentNullException(nameof(postcodeUnit));
            }

            if (locationId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(locationId));
            }

            using (loggingHelper.RMTraceManager.StartTrace("Business.GetPostcodeSpecificRoutes"))
            {
                string          methodName = typeof(DeliveryRouteBusinessService) + "." + nameof(GetPostcodeSpecificRoutes);
                List <RouteDTO> routes     = new List <RouteDTO>();
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodEntryEventId);

                var postcode = await postCodeDataService.GetPostcode(postcodeUnit);

                var routeDetails = await deliveryRouteDataService.GetRoutesByLocation(locationId);

                if (routeDetails != null && routeDetails.Count > 0)
                {
                    if (postcode != null && (postcode.PrimaryRouteGUID != null || postcode.SecondaryRouteGUID != null))
                    {
                        foreach (var route in routeDetails)
                        {
                            if (route.ID == postcode.PrimaryRouteGUID)
                            {
                                routes.Add(new RouteDTO {
                                    ID = route.ID, RouteName = DeliveryRouteConstants.PrimaryRoute + route.RouteName
                                });
                            }
                            else if (route.ID == postcode.SecondaryRouteGUID)
                            {
                                routes.Add(new RouteDTO {
                                    ID = route.ID, RouteName = DeliveryRouteConstants.SecondaryRoute + route.RouteName
                                });
                            }
                        }
                    }
                    else
                    {
                        routes = GenericMapper.MapList <RouteDataDTO, RouteDTO>(routeDetails);
                    }
                }

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodExitEventId);

                return(routes.OrderBy(n => n.RouteName).ToList());
            }
        }
        /// <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 <AccessLinkDTO> GetAccessLinks(string boundingBoxCoordinates, Guid unitGuid)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetAccessLinks"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Information, null, LoggerTraceConstants.Category, LoggerTraceConstants.AccessLinkAPIPriority, LoggerTraceConstants.AccessLinkDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                List <AccessLink> result = GetAccessLinkCoordinatesDataByBoundingBox(boundingBoxCoordinates, unitGuid).ToList();
                var accessLink           = GenericMapper.MapList <AccessLink, AccessLinkDTO>(result);
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Information, null, LoggerTraceConstants.Category, LoggerTraceConstants.AccessLinkAPIPriority, LoggerTraceConstants.AccessLinkDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(accessLink);
            }
        }
Exemplo n.º 7
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);
            }
        }
        /// <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>
        /// Fetch street names for advance search
        /// </summary>
        /// <param name="searchText">searchText as string</param>
        /// <param name="unitGuid">The unit unique identifier.</param>
        /// <param name="currentUserUnitType">The current user unit type.</param>
        /// <returns>StreetNames</returns>
        public async Task <List <StreetNameDTO> > GetStreetNamesForAdvanceSearch(string searchText, Guid unitGuid, string currentUserUnitType)
        {
            using (loggingHelper.RMTraceManager.StartTrace("Business.GetStreetNamesForAdvanceSearch"))
            {
                string methodName = typeof(NetworkManagerBusinessService) + "." + nameof(GetStreetNamesForAdvanceSearch);
                loggingHelper.LogMethodEntry(methodName, priority, entryEventId);

                var fetchStreetNamesForAdvanceSearch = await streetNetworkDataService.GetStreetNamesForAdvanceSearch(searchText, unitGuid, currentUserUnitType).ConfigureAwait(false);

                var streetNameDTO = GenericMapper.MapList <StreetNameDataDTO, StreetNameDTO>(fetchStreetNamesForAdvanceSearch);

                loggingHelper.LogMethodExit(methodName, priority, exitEventId);
                return(streetNameDTO);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Get the list of route scenarios by the operationstateID and locationID.
        /// </summary>
        /// <param name="operationStateID">The operationstate id.</param>
        /// <param name="locationID">The location id.</param>
        /// <returns>List</returns>
        public async Task <IEnumerable <ScenarioDTO> > GetRouteScenarios(Guid operationStateID, Guid locationID)
        {
            string methodName = typeof(UnitLocationBusinessService) + "." + nameof(GetRouteScenarios);

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

                var scenarioDataList = await scenarioDataService.GetScenariosByOperationStateAndDeliveryUnit(operationStateID, locationID);

                List <ScenarioDTO> scenariolist = GenericMapper.MapList <ScenarioDataDTO, ScenarioDTO>(scenarioDataList.ToList());

                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodExitEventId);
                return(scenariolist);
            }
        }
Exemplo n.º 11
0
        /// <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 <RouteDataDTO> > GetScenarioRoutes(Guid scenarioID)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetRoutes"))
            {
                string methodName = typeof(DeliveryRouteDataService) + "." + nameof(GetScenarioRoutes);
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteDataServiceMethodEntryEventId);

                var routes = await(from r in DataContext.Routes.AsNoTracking()
                                   join s in DataContext.ScenarioRoutes.AsNoTracking() on r.ID equals s.RouteID
                                   where s.ScenarioID == scenarioID
                                   select r).ToListAsync();
                List <RouteDataDTO> routedetails = GenericMapper.MapList <Route, RouteDataDTO>(routes);

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteDataServiceMethodExitEventId);

                return(routedetails);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Gets postcode details by postcode guids
        /// </summary>
        /// <param name="postcodeGuids"></param>
        /// <returns>List</returns>
        public async Task <IEnumerable <PostcodeDTO> > GetPostcodes(List <Guid> postcodeGuids)
        {
            string methodName = typeof(UnitLocationBusinessService) + "." + nameof(GetPostcodes);

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

                // reference data value for Postcode with Category - Postcode Type
                Guid postcodeTypeGUID = unitManagerIntegrationService.GetReferenceDataGuId(PostCodeType, PostCodeTypeCategory.PostcodeSector.GetDescription()).Result;

                var postcodeDataDto = await unitLocationDataService.GetPostcodes(postcodeGuids, postcodeTypeGUID);

                var postCodeDto = GenericMapper.MapList <PostcodeDataDTO, PostcodeDTO>(postcodeDataDto.ToList());

                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodExitEventId);
                return(postCodeDto);
            }
        }
        /// <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);
            }
        }
        /// <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());
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Get filtred routes on basis of search text for Advance Search .
        /// </summary>
        /// <param name="searchText">Text to search</param>
        /// <param name="locationId">selected unit's location ID</param>
        /// <returns>Returns list of routes that matches the search text</returns>
        public async Task <List <RouteDataDTO> > GetRoutesForAdvanceSearch(string searchText, Guid locationId)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetRouteForAdvanceSearch"))
            {
                string methodName = typeof(DeliveryRouteDataService) + "." + nameof(GetRoutesForAdvanceSearch);
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteDataServiceMethodEntryEventId);

                var routes = await(from r in DataContext.Routes.AsNoTracking()
                                   join sr in DataContext.ScenarioRoutes.AsNoTracking() on r.ID equals sr.RouteID
                                   join s in DataContext.Scenarios.AsNoTracking() on sr.ScenarioID equals s.ID
                                   where s.LocationID == locationId && (r.RouteName.StartsWith(searchText) || r.RouteNumber.StartsWith(searchText))
                                   orderby r.RouteName, r.RouteNumber
                                   select r).ToListAsync();

                List <RouteDataDTO> routedetails = GenericMapper.MapList <Route, RouteDataDTO>(routes);

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteDataServiceMethodExitEventId);

                return(routedetails);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Fetch the Route log selection type.
        /// </summary>
        /// <returns>List</returns>
        public List <ReferenceDataDTO> RouteLogSelectionType()
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.RouteLogSelectionType"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataCategoryDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                List <ReferenceDataDTO> lstReferenceDt = null;
                var query = DataContext.ReferenceDataCategories.Include(m => m.ReferenceDatas)
                            .AsNoTracking().SingleOrDefault(n => n.CategoryName.Equals(
                                                                "UI_RouteLogSearch_SelectionType",
                                                                StringComparison.OrdinalIgnoreCase));
                if (query?.ReferenceDatas != null && query.ReferenceDatas.Count > 0)
                {
                    lstReferenceDt = GenericMapper.MapList <ReferenceData, ReferenceDataDTO>(query.ReferenceDatas.ToList());
                }

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ReferenceDataAPIPriority, LoggerTraceConstants.ReferenceDataCategoryDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(lstReferenceDt);
            }
        }
        /// <summary>
        /// SaveUSRDetails to save the USR data by calling the WebApi services.
        /// </summary>
        /// <param name="addressLocationUSRDTO"></param>
        /// <returns></returns>
        private async Task SaveUSRDetails(List <AddressLocationUSRDTO> addressLocationUSRDTO)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;

            LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionStarted);
            try
            {
                var addressLocationUSRPOSTDTO = GenericMapper.MapList <AddressLocationUSRDTO, AddressLocationUSRPOSTDTO>(addressLocationUSRDTO);
                addressLocationUSRPOSTDTO.ForEach(addressLocation =>
                {
                    LogMethodInfoBlock(
                        methodName,
                        string.Format(
                            REQUESTLOG,
                            addressLocation.UDPRN == null ? string.Empty : addressLocation.UDPRN.ToString(),
                            addressLocation.XCoordinate == null ? string.Empty : addressLocation.XCoordinate.ToString(),
                            addressLocation.YCoordinate == null ? string.Empty : addressLocation.YCoordinate.ToString(),
                            addressLocation.Latitude == null ? string.Empty : addressLocation.Latitude.ToString(),
                            addressLocation.Longitude == null ? string.Empty : addressLocation.Longitude.ToString(),
                            addressLocation.ChangeType == null ? string.Empty : addressLocation.ChangeType
                            ));
                });
                var result = await httpHandler.PostAsJsonAsync(USRWebApiName, addressLocationUSRPOSTDTO, isBatchJob : true);

                if (!result.IsSuccessStatusCode)
                {
                    var responseContent = result.ReasonPhrase;
                    this.loggingHelper.Log(responseContent, TraceEventType.Error);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionCompleted);
            }
        }
        /// <summary> Get the Network Links crossing the operational Object for a given extent</summary>
        /// <param name="boundingBoxCoordinates">bbox coordinates</param>
        /// <param name="accessLink">accesslink coordinate array</param>
        /// <returns>List<NetworkLinkDTO></returns>
        public List <NetworkLinkDataDTO> GetCrossingNetworkLink(string boundingBoxCoordinates, DbGeometry accessLink)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetCrossingNetworkLink"))
            {
                string methodName = typeof(StreetNetworkDataService) + "." + nameof(GetCrossingNetworkLink);
                loggingHelper.LogMethodEntry(methodName, priority, entryEventId);

                List <NetworkLinkDataDTO> networkLinkDTOs = new List <NetworkLinkDataDTO>();
                DbGeometry extent = DbGeometry.FromText(boundingBoxCoordinates.ToString(), BNGCOORDINATESYSTEM);

                List <NetworkLink>        crossingNetworkLinks    = DataContext.NetworkLinks.AsNoTracking().Where(nl => nl.LinkGeometry != null && nl.LinkGeometry.Intersects(extent) && nl.LinkGeometry.Crosses(accessLink)).ToList();
                List <NetworkLinkDataDTO> crossingNetworkLinkDTOs = GenericMapper.MapList <NetworkLink, NetworkLinkDataDTO>(crossingNetworkLinks);
                networkLinkDTOs.AddRange(crossingNetworkLinkDTOs);

                List <NetworkLink>        overLappingNetworkLinks    = DataContext.NetworkLinks.AsNoTracking().Where(nl => nl.LinkGeometry != null && nl.LinkGeometry.Intersects(extent) && nl.LinkGeometry.Overlaps(accessLink)).ToList();
                List <NetworkLinkDataDTO> overLappingNetworkLinkDTOs = GenericMapper.MapList <NetworkLink, NetworkLinkDataDTO>(overLappingNetworkLinks);
                networkLinkDTOs.AddRange(overLappingNetworkLinkDTOs);

                loggingHelper.LogMethodExit(methodName, priority, exitEventId);
                return(networkLinkDTOs);
            }
        }
        /// <summary>
        /// Generates the route log.
        /// </summary>
        /// <param name="routeDetails">Route Details</param>
        /// <param name="userUnit">The user unit.</param>
        /// <returns>byte[]</returns>
        public async Task <RouteLogSummaryDTO> GenerateRouteLog(RouteDTO routeDetails)
        {
            if (routeDetails == null)
            {
                throw new ArgumentNullException(nameof(routeDetails));
            }

            using (loggingHelper.RMTraceManager.StartTrace("Business.GenerateRouteLog"))
            {
                string methodName = typeof(DeliveryRouteBusinessService) + "." + nameof(GenerateRouteLog);
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodEntryEventId);
                RouteLogSummaryDTO routeLogSummary = new RouteLogSummaryDTO();
                routeLogSummary.Route = routeDetails;
                var routeLogSequencedPoints = await deliveryRouteDataService.GetSequencedRouteDetails(routeDetails.ID);

                routeLogSummary.RouteLogSequencedPoints = GenericMapper.MapList <RouteLogSequencedPointsDataDTO, RouteLogSequencedPointsDTO>(routeLogSequencedPoints);

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteBusinessServiceMethodExitEventId);

                return(routeLogSummary);
            }
        }
        /// <summary>
        /// this method is used to get the access links crossing the created access link
        /// </summary>
        /// <param name="boundingBoxCoordinates">bbox coordinates</param>
        /// <param name="accessLink">access link coordinate array</param>
        /// <returns>List<AccessLinkDTO> </returns>
        public List <AccessLinkDTO> GetAccessLinksCrossingOperationalObject(string boundingBoxCoordinates, DbGeometry accessLink)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetAccessLinksCrossingOperationalObject"))
            {
                string methodName = MethodBase.GetCurrentMethod().Name;
                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Information, null, LoggerTraceConstants.Category, LoggerTraceConstants.AccessLinkAPIPriority, LoggerTraceConstants.AccessLinkDataServiceMethodEntryEventId, LoggerTraceConstants.Title);

                List <AccessLinkDTO> accessLinkDTOs = new List <AccessLinkDTO>();
                DbGeometry           extent         = System.Data.Entity.Spatial.DbGeometry.FromText(boundingBoxCoordinates.ToString(), BNGCOORDINATESYSTEM);

                List <AccessLink>    crossingAccessLinks    = DataContext.AccessLinks.AsNoTracking().Where(al => al.AccessLinkLine != null && al.AccessLinkLine.Intersects(extent) && al.AccessLinkLine.Crosses(accessLink)).ToList();
                List <AccessLinkDTO> crossingAccessLinkDTOs = GenericMapper.MapList <AccessLink, AccessLinkDTO>(crossingAccessLinks);
                accessLinkDTOs.AddRange(crossingAccessLinkDTOs);

                List <AccessLink>    overLappingAccessLinks    = DataContext.AccessLinks.AsNoTracking().Where(al => al.AccessLinkLine != null && al.AccessLinkLine.Intersects(extent) && al.AccessLinkLine.Overlaps(accessLink)).ToList();
                List <AccessLinkDTO> overLappingAccessLinkDTOs = GenericMapper.MapList <AccessLink, AccessLinkDTO>(overLappingAccessLinks);
                accessLinkDTOs.AddRange(overLappingAccessLinkDTOs);

                loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Information, null, LoggerTraceConstants.Category, LoggerTraceConstants.AccessLinkAPIPriority, LoggerTraceConstants.AccessLinkDataServiceMethodExitEventId, LoggerTraceConstants.Title);
                return(accessLinkDTOs);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        ///Get filtered routes on basis of search text for basic Search .
        /// </summary>
        /// <param name="searchText">Text to search</param>
        /// <param name="locationId">selected unit's location ID</param>
        /// <returns>Returns list of routes that matches the search text</returns>
        public async Task <List <RouteDataDTO> > GetRoutesForBasicSearch(string searchText, Guid locationId)
        {
            using (loggingHelper.RMTraceManager.StartTrace("DataService.GetRouteForBasicSearch"))
            {
                string methodName = typeof(DeliveryRouteDataService) + "." + nameof(GetRoutesForBasicSearch);
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteDataServiceMethodEntryEventId);
                int takeCount = Convert.ToInt32(configurationHelper.ReadAppSettingsConfigurationValues(DeliveryRouteConstants.SearchResultCount));
                searchText = searchText ?? string.Empty;

                var routes = await(from r in DataContext.Routes.AsNoTracking()
                                   join sr in DataContext.ScenarioRoutes.AsNoTracking() on r.ID equals sr.RouteID
                                   join s in DataContext.Scenarios.AsNoTracking() on sr.ScenarioID equals s.ID
                                   where s.LocationID == locationId && (r.RouteName.StartsWith(searchText) || r.RouteNumber.StartsWith(searchText))
                                   orderby r.RouteName, r.RouteNumber
                                   select r).Take(takeCount).ToListAsync();

                List <RouteDataDTO> routedetails = GenericMapper.MapList <Route, RouteDataDTO>(routes);

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.DeliveryRouteAPIPriority, LoggerTraceConstants.DeliveryRouteDataServiceMethodExitEventId);

                return(routedetails);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Gets the name of the reference data by category.
        /// </summary>
        /// <param name="categoryName">The string categoryname.</param>
        /// <returns>List ReferenceDataDTO</returns>
        public List <ReferenceDataDTO> GetReferenceDataByCategoryName(string categoryName)
        {
            var referenceData = DataContext.ReferenceDatas.AsNoTracking().Where(n => n.ReferenceDataCategory.CategoryName.Trim().Equals(categoryName, StringComparison.OrdinalIgnoreCase)).ToList();

            return(GenericMapper.MapList <ReferenceData, ReferenceDataDTO>(referenceData));
        }