internal OrganisationFunktionType GetOrganisationFunktionType(string uuid, RegistreringType1 registration) { OrganisationFunktionType organisationType = new OrganisationFunktionType(); organisationType.UUIDIdentifikator = uuid; RegistreringType1[] registreringTypes = new RegistreringType1[1]; registreringTypes[0] = registration; organisationType.Registrering = registreringTypes; return(organisationType); }
public void Importer(OrgFunctionData orgFunction) { // create ShortKey and Uuid if not supplied EnsureKeys(orgFunction); log.Debug("Attempting Import on OrgFunction with uuid " + orgFunction.Uuid); // create timestamp object to be used on all registrations, properties and relations VirkningType virkning = helper.GetVirkning(orgFunction.Timestamp); // setup registration RegistreringType1 registration = helper.CreateRegistration(orgFunction.Timestamp, LivscyklusKodeType.Importeret); // add properties helper.AddProperties(orgFunction.ShortKey, orgFunction.Name, virkning, registration); // add relationships on registration helper.AddTilknyttedeBrugere(orgFunction.Users, virkning, registration); helper.AddTilknyttedeEnheder(orgFunction.OrgUnits, virkning, registration); helper.AddTilknyttedeItSystemer(orgFunction.ItSystems, virkning, registration); helper.AddOpgaver(orgFunction.Tasks, virkning, registration); helper.AddOrganisationRelation(StubUtil.GetMunicipalityOrganisationUUID(), virkning, registration); helper.AddAddressReferences(orgFunction.Addresses, virkning, registration); helper.SetFunktionsType(orgFunction.FunctionTypeUuid, virkning, registration); // set Tilstand to Active helper.SetTilstandToActive(virkning, registration, orgFunction.Timestamp); // wire everything together OrganisationFunktionType organisationFunktionType = helper.GetOrganisationFunktionType(orgFunction.Uuid, registration); ImportInputType importInput = new ImportInputType(); importInput.OrganisationFunktion = organisationFunktionType; // construct request importerRequest request = new importerRequest(); request.ImporterRequest1 = new ImporterRequestType(); request.ImporterRequest1.ImportInput = importInput; request.ImporterRequest1.AuthorityContext = new AuthorityContextType(); request.ImporterRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetMunicipality(); // send request OrganisationFunktionPortType channel = StubUtil.CreateChannel <OrganisationFunktionPortType>(OrganisationFunktionStubHelper.SERVICE, "Import", helper.CreatePort()); try { importerResponse result = channel.importer(request); int statusCode = Int32.Parse(result.ImporterResponse1.ImportOutput.StandardRetur.StatusKode); if (statusCode != 20) { string message = StubUtil.ConstructSoapErrorMessage(statusCode, "Import", OrganisationFunktionStubHelper.SERVICE, result.ImporterResponse1.ImportOutput.StandardRetur.FejlbeskedTekst); log.Error(message); throw new SoapServiceException(message); } log.Debug("Import successful on OrgFunction with uuid " + orgFunction.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 Importer service on OrganisationFunktion", ex); } }