public laesResponse Read(string uuid) { LaesInputType laesInput = new LaesInputType(); laesInput.UUIDIdentifikator = uuid; laesRequest request = new laesRequest(); request.LaesRequest1 = new LaesRequestType(); request.LaesRequest1.LaesInput = laesInput; request.LaesRequest1.AuthorityContext = new AuthorityContextType(); request.LaesRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetCurrentMunicipality(); AdressePortType channel = StubUtil.CreateChannel <AdressePortType>(AdresseStubHelper.SERVICE, "Laes", helper.CreatePort()); try { return(channel.laes(request)); } catch (Exception ex) when(ex is CommunicationException || ex is IOException || ex is TimeoutException || ex is WebException) { throw new ServiceNotFoundException("Failed to establish connection to the Laes service on Adresse", ex); } }
public RegistreringType1 GetLatestRegistration(string uuid) { LaesInputType laesInput = new LaesInputType(); laesInput.UUIDIdentifikator = uuid; laesRequest request = new laesRequest(); request.LaesRequest1 = new LaesRequestType(); request.LaesRequest1.LaesInput = laesInput; request.LaesRequest1.AuthorityContext = new AuthorityContextType(); request.LaesRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetMunicipality(); AdressePortType channel = StubUtil.CreateChannel <AdressePortType>(AdresseStubHelper.SERVICE, "Laes", helper.CreatePort()); try { laesResponse response = channel.laes(request); int statusCode = Int32.Parse(response.LaesResponse1.LaesOutput.StandardRetur.StatusKode); if (statusCode != 20) { // note that statusCode 44 means that the object does not exists, so that is a valid response log.Debug("Lookup on Adresse with uuid '" + uuid + "' failed with statuscode " + statusCode); return(null); } RegistreringType1[] resultSet = response.LaesResponse1.LaesOutput.FiltreretOejebliksbillede.Registrering; if (resultSet.Length == 0) { log.Warn("Adresse with uuid '" + uuid + "' exists, but has no registration"); return(null); } RegistreringType1 result = null; if (resultSet.Length > 1) { log.Warn("Adresse with uuid " + uuid + " has more than one registration when reading latest registration, this should never happen"); DateTime winner = DateTime.MinValue; foreach (RegistreringType1 res in resultSet) { // first time through will always result in a True evaluation here if (DateTime.Compare(winner, res.Tidspunkt) < 0) { result = res; winner = res.Tidspunkt; } } } else { result = resultSet[0]; } // we cannot perform any kind of updates on Slettet/Passiveret, så it makes sense to filter them out on lookup, // so the rest of the code will default to Import op top of this if (result.LivscyklusKode.Equals(LivscyklusKodeType.Slettet) || result.LivscyklusKode.Equals(LivscyklusKodeType.Passiveret)) { return(null); } return(result); } catch (Exception ex) when(ex is CommunicationException || ex is IOException || ex is TimeoutException || ex is WebException) { throw new ServiceNotFoundException("Failed to establish connection to the Laes service on Adresse", ex); } }