public soegResponse Search(SoegInputType1 soegInput) { // construct request soegRequest request = new soegRequest(); request.SoegRequest1 = new SoegRequestType(); request.SoegRequest1.SoegInput = soegInput; request.SoegRequest1.AuthorityContext = new AuthorityContextType(); request.SoegRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetCurrentMunicipality(); // send request OrganisationFunktionPortType channel = StubUtil.CreateChannel <OrganisationFunktionPortType>(OrganisationFunktionStubHelper.SERVICE, "Soeg", helper.CreatePort()); try { return(channel.soeg(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 Soeg service on OrganisationFunktion", ex); } }
private List <string> Soeg(string functionsTypeUuid, string userUuid, string unitUuid, string itSystemUuid) { OrganisationFunktionPortType channel = StubUtil.CreateChannel <OrganisationFunktionPortType>(OrganisationFunktionStubHelper.SERVICE, "Soeg", helper.CreatePort()); SoegInputType1 soegInput = new SoegInputType1(); soegInput.AttributListe = new AttributListeType(); soegInput.RelationListe = new RelationListeType(); soegInput.TilstandListe = new TilstandListeType(); // only return objects that have a Tilhører relationship top-level Organisation UnikIdType orgReference = StubUtil.GetReference <UnikIdType>(registry.MunicipalityOrganisationUUID[OrganisationRegistryProperties.GetMunicipality()], ItemChoiceType.UUIDIdentifikator); soegInput.RelationListe.TilknyttedeOrganisationer = new OrganisationFlerRelationType[1]; soegInput.RelationListe.TilknyttedeOrganisationer[0] = new OrganisationFlerRelationType(); soegInput.RelationListe.TilknyttedeOrganisationer[0].ReferenceID = orgReference; if (!String.IsNullOrEmpty(functionsTypeUuid)) { UnikIdType reference = new UnikIdType(); reference.Item = functionsTypeUuid; reference.ItemElementName = ItemChoiceType.UUIDIdentifikator; KlasseRelationType funktionsType = new KlasseRelationType(); funktionsType.ReferenceID = reference; soegInput.RelationListe.Funktionstype = funktionsType; } if (!String.IsNullOrEmpty(userUuid)) { UnikIdType reference = new UnikIdType(); reference.Item = userUuid; reference.ItemElementName = ItemChoiceType.UUIDIdentifikator; soegInput.RelationListe.TilknyttedeBrugere = new BrugerFlerRelationType[1]; soegInput.RelationListe.TilknyttedeBrugere[0] = new BrugerFlerRelationType(); soegInput.RelationListe.TilknyttedeBrugere[0].ReferenceID = reference; } if (!String.IsNullOrEmpty(unitUuid)) { UnikIdType reference = new UnikIdType(); reference.Item = unitUuid; reference.ItemElementName = ItemChoiceType.UUIDIdentifikator; soegInput.RelationListe.TilknyttedeEnheder = new OrganisationEnhedFlerRelationType[1]; soegInput.RelationListe.TilknyttedeEnheder[0] = new OrganisationEnhedFlerRelationType(); soegInput.RelationListe.TilknyttedeEnheder[0].ReferenceID = reference; } if (!String.IsNullOrEmpty(itSystemUuid)) { UnikIdType reference = new UnikIdType(); reference.Item = itSystemUuid; reference.ItemElementName = ItemChoiceType.UUIDIdentifikator; soegInput.RelationListe.TilknyttedeItSystemer = new ItSystemFlerRelationType[1]; soegInput.RelationListe.TilknyttedeItSystemer[0] = new ItSystemFlerRelationType(); soegInput.RelationListe.TilknyttedeItSystemer[0].ReferenceID = reference; } // search soegRequest request = new soegRequest(); request.SoegRequest1 = new SoegRequestType(); request.SoegRequest1.SoegInput = soegInput; request.SoegRequest1.AuthorityContext = new AuthorityContextType(); request.SoegRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetMunicipality(); try { soegResponse response = channel.soeg(request); int statusCode = Int32.Parse(response.SoegResponse1.SoegOutput.StandardRetur.StatusKode); if (statusCode != 20 && statusCode != 44) // 44 is empty search result { string message = StubUtil.ConstructSoapErrorMessage(statusCode, "Soeg", OrganisationFunktionStubHelper.SERVICE, response.SoegResponse1.SoegOutput.StandardRetur.FejlbeskedTekst); log.Error(message); throw new SoapServiceException(message); } List <string> functions = new List <string>(); if (statusCode == 20) { foreach (string id in response.SoegResponse1.SoegOutput.IdListe) { functions.Add(id); } } return(functions); } 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 Soeg service on OrganisationFunktion", ex); } }