// this method only performs a call to Ret on Organisation if there are actual changes public void Ret(string uuid, string newValue, string newShortKey, DateTime timestamp, RegistreringType1 registration) { log.Debug("Attempting Ret on Address with uuid " + uuid); AdressePortType channel = StubUtil.CreateChannel <AdressePortType>(AdresseStubHelper.SERVICE, "Ret", helper.CreatePort()); try { RetInputType1 input = new RetInputType1(); input.UUIDIdentifikator = uuid; input.AttributListe = registration.AttributListe; input.TilstandListe = registration.TilstandListe; input.RelationListe = registration.RelationListe; // compare latest property to the local object EgenskabType latestProperty = StubUtil.GetLatestProperty(input.AttributListe); if (latestProperty == null || !latestProperty.AdresseTekst.Equals(newValue) || (newShortKey != null && !latestProperty.BrugervendtNoegleTekst.Equals(newShortKey))) { // create a new property EgenskabType newProperty = new EgenskabType(); newProperty.Virkning = helper.GetVirkning(timestamp); newProperty.BrugervendtNoegleTekst = ((newShortKey != null) ? newShortKey : latestProperty.BrugervendtNoegleTekst); newProperty.AdresseTekst = newValue; // create a new set of properties input.AttributListe = new EgenskabType[1]; input.AttributListe[0] = newProperty; } else { log.Debug("No changes on Address, so returning without calling Organisation"); // if there are no changes to the attributes, we do not call the Organisation service return; } // send Ret request retRequest request = new retRequest(); request.RetRequest1 = new RetRequestType(); request.RetRequest1.RetInput = input; request.RetRequest1.AuthorityContext = new AuthorityContextType(); request.RetRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetMunicipality(); retResponse response = channel.ret(request); int statusCode = Int32.Parse(response.RetResponse1.RetOutput.StandardRetur.StatusKode); if (statusCode != 20) { string message = StubUtil.ConstructSoapErrorMessage(statusCode, "Ret", AdresseStubHelper.SERVICE, response.RetResponse1.RetOutput.StandardRetur.FejlbeskedTekst); log.Error(message); throw new SoapServiceException(message); } log.Debug("Ret successful on Address with uuid " + uuid); } 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 Ret service on Adresse", ex); } }
public retResponse Update(RetInputType1 input) { // send Ret request retRequest request = new retRequest(); request.RetRequest1 = new RetRequestType(); request.RetRequest1.RetInput = input; request.RetRequest1.AuthorityContext = new AuthorityContextType(); request.RetRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetCurrentMunicipality(); AdressePortType channel = StubUtil.CreateChannel <AdressePortType>(AdresseStubHelper.SERVICE, "Ret", helper.CreatePort()); try { return(channel.ret(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 Ret service on Adresse", ex); } }