public TransformAnprResponse(AnprResComplexType response, Guid transactionToken) { Continue = response != null && response.Result.Equals("result",StringComparison.CurrentCultureIgnoreCase); Result = Continue ? new AnprResponse() : new AnprResponse().WasAFailure(response != null ? response.Result : "Null Response from Anpr"); _response = response; _transactionToken = transactionToken; }
public void CallTheDataProvider(ICollection<IPointToLaceProvider> response) { try { _certificate = new CoOrdinateCertificateFactory( new CoOrdinateCertificateRequest(GetValidLatitudeCoordinate(_dataProvider.GetRequest<IAmAnprRequest>().Latitude), GetValidLongitudeCoordinate(_dataProvider.GetRequest<IAmAnprRequest>().Latitude)), _repository); _logCommand.LogConfiguration(new {Certficate = _certificate}, null); if (!_certificate.IsSuccessfull || _certificate.Certificate == null || string.IsNullOrEmpty(_certificate.Certificate.Endpoint)) throw new Exception("Certificate for ANPR request could not be generated"); var proxy = new AnprServiceSoapClient(_certificate.Certificate.Endpoint); if (proxy.State == CommunicationState.Closed) proxy.Open(); var builder = new BuildAnprRequest(_dataProvider.GetRequest<IAmAnprRequest>()).Build(); _logCommand.LogRequest(new ConnectionTypeIdentifier(proxy.Endpoint.Address.Uri.ToString()).ForWebApiType(), new { builder.AnprRequest }); _anprResponse = proxy.AnprProcessRecognition(builder.AnprRequest); proxy.Close(); _logCommand.LogResponse(_anprResponse != null ? DataProviderState.Successful : DataProviderState.Failed, new ConnectionTypeIdentifier(proxy.Endpoint.Address.Uri.ToString()).ForWebApiType(), new { builder.AnprRequest }); TransformResponse(response); } catch (Exception ex) { _log.ErrorFormat("Error calling Anpr Web Service {0}",ex, ex.Message); _logCommand.LogFault(new {ex.Message}, new {ErrorMessage = "Error calling Anpr Web Service"}); AnprResponseFailed(response); } }