/// <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> /// This method updates delivery point location using UDPRN /// </summary> /// <param name="deliveryPointDTO">deliveryPointDTO as DTO</param> /// <returns>updated delivery point</returns> public async Task <int> UpdateDeliveryPointLocationOnUDPRN(DeliveryPointDTO deliveryPointDTO) { using (loggingHelper.RMTraceManager.StartTrace("Integration.UpdateDeliveryPointLocationOnUDPRN")) { string method = typeof(ThirdPartyAddressLocationIntegrationService) + "." + nameof(UpdateDeliveryPointLocationOnUDPRN); loggingHelper.LogMethodEntry(method, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationIntegrationServiceMethodEntryEventId); string methodName = ThirdPartyAddressLocationConstants.UpdateDeliveryPointLocationOnUDPRN; string serviceUrl = configurationHelper.ReadAppSettingsConfigurationValues(DeliveryPointManagerDataWebAPIName); string route = configurationHelper.ReadAppSettingsConfigurationValues(methodName); HttpResponseMessage result = await httpHandler.PostAsJsonAsync(serviceUrl + route, JsonConvert.SerializeObject(deliveryPointDTO, new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() })); if (!result.IsSuccessStatusCode) { // LOG ERROR WITH Statuscode var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } int status = JsonConvert.DeserializeObject <int>(result.Content.ReadAsStringAsync().Result); loggingHelper.LogMethodExit(method, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationIntegrationServiceMethodExitEventId); return(status); } }
/// <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 <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); } }
/// <summary> /// SavePAFDetails to save the PAF data by calling the WebApi services. /// </summary> /// <param name="postalAddress"></param> /// <returns></returns> private async Task <bool> SavePAFDetails(List <PostalAddressDTO> postalAddress) { using (loggingHelper.RMTraceManager.StartTrace("Service.SavePAFDetails")) { string methodName = MethodHelper.GetActualAsyncMethodName(); bool isPAFDetailsInserted = false; try { loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PAFPriority, LoggerTraceConstants.PAFReceiverMethodEntryEventId, LoggerTraceConstants.Title); if (postalAddress != null && postalAddress.Count > 0) { postalAddress.ForEach(objPostalAddress => { LogMethodInfoBlock( methodName, string.Format( REQUESTLOG, objPostalAddress.UDPRN == null ? string.Empty : objPostalAddress.UDPRN.ToString(), objPostalAddress.Postcode == null ? string.Empty : objPostalAddress.Postcode.ToString(), objPostalAddress.AmendmentType == null ? string.Empty : objPostalAddress.AmendmentType.ToString(), objPostalAddress.PostTown == null ? string.Empty : objPostalAddress.PostTown.ToString(), objPostalAddress.SmallUserOrganisationIndicator == null ? string.Empty : objPostalAddress.SmallUserOrganisationIndicator.ToString(), objPostalAddress.DeliveryPointSuffix == null ? string.Empty : objPostalAddress.DeliveryPointSuffix )); }); var result = await httpHandler.PostAsJsonAsync(PAFWebApiName, postalAddress, true); if (!result.IsSuccessStatusCode) { //LOG ERROR WITH Statuscode var responseContent = result.ReasonPhrase; this.loggingHelper.Log(responseContent, TraceEventType.Error); isPAFDetailsInserted = false; } isPAFDetailsInserted = true; } } catch (AggregateException ae) { foreach (var exception in ae.InnerExceptions) { loggingHelper.Log(exception, TraceEventType.Error); } var realExceptions = ae.Flatten().InnerException; throw realExceptions; } loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PAFPriority, LoggerTraceConstants.PAFReceiverMethodExitEventId, LoggerTraceConstants.Title); return(isPAFDetailsInserted); } }
/// <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 async Task AddPgAccount(int level, PgAccount account) { var builder = new UriBuilder($"{_baseurl}/lvl/{level}"); account.AuthService = "ptc"; account.Level = level; account.SystemId = "Account-Manager"; var response = await _client.PostAsJsonAsync(builder.Uri.ToString(), account); if (!response.IsSuccessStatusCode) { _logger.Error(response); } }
/// <summary> /// Create address for a delivery point with PAF/NYB details /// </summary> /// <param name="addDeliveryPointDTO">addDeliveryPointDTO</param> /// <returns>bool</returns> public async Task <CreateDeliveryPointModelDTO> CreateAddressForDeliveryPoint(AddDeliveryPointDTO addDeliveryPointDTO) { using (loggingHelper.RMTraceManager.StartTrace("IntegrationService.CreateAddressAndDeliveryPoint")) { string methodName = typeof(DeliveryPointIntegrationService) + "." + nameof(CreateAddressForDeliveryPoint); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); HttpResponseMessage result = await httpHandler.PostAsJsonAsync(postalAddressManagerWebAPIName + "postaladdress/savedeliverypointaddress/", addDeliveryPointDTO); if (!result.IsSuccessStatusCode) { var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } var createAddressAndDeliveryPoint = JsonConvert.DeserializeObject <CreateDeliveryPointModelDTO>(result.Content.ReadAsStringAsync().Result); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(createAddressAndDeliveryPoint); } }
public async Task <Result> SendAsync(TestRunBase testRun) { await RefreshAccessToken(); var webApiTestRunsUrl = "api/testruns"; switch (testRun) { case ExerciseTestRun _: webApiTestRunsUrl += "/forexercise"; break; case ProjectComponentTestRun _: webApiTestRunsUrl += "/forproject"; break; } var response = await _httpHandler.PostAsJsonAsync(webApiTestRunsUrl, testRun); if (response.StatusCode == HttpStatusCode.Unauthorized) { //retry with token retrieved remotely await RefreshAccessToken(allowCachedToken : false); response = await _httpHandler.PostAsJsonAsync(webApiTestRunsUrl, testRun); } var result = new Result(response.IsSuccessStatusCode); if (!result.Success) { result.Message = await response.Content.ReadAsStringAsync(); } return(result); }
/// <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> /// 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> 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); } }
private async Task <LoginSession> CreateLoginSessionAsync() { return(await _httpHandler.PostAsJsonAsync <Object, LoginSession>("api/auth/loginsession", null)); }