示例#1
0
        public void Importer(PersonData person)
        {
            // create ShortKey and Uuid if not supplied
            EnsureKeys(person);

            log.Debug("Attempting Import on Person with uuid " + person.Uuid);

            // create timestamp object to be used on all registrations, properties and relations
            VirkningType virkning = helper.GetVirkning(person.Timestamp);

            // setup registration
            RegistreringType1 registration = helper.CreateRegistration(person.Timestamp, LivscyklusKodeType.Importeret);

            // add properties
            helper.AddProperties(person.Name, person.ShortKey, person.Cpr, virkning, registration);

            // wire everything together
            PersonType      personType  = helper.GetPersonType(person.Uuid, registration);
            ImportInputType importInput = new ImportInputType();

            importInput.Person = personType;

            // construct request
            importerRequest request = new importerRequest();

            request.ImporterRequest1                  = new ImporterRequestType();
            request.ImporterRequest1.ImportInput      = importInput;
            request.ImporterRequest1.AuthorityContext = new AuthorityContextType();
            request.ImporterRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetCurrentMunicipality();

            // send request
            PersonPortType channel = StubUtil.CreateChannel <PersonPortType>(PersonStubHelper.SERVICE, "Import", helper.CreatePort());

            try
            {
                importerResponse response = channel.importer(request);
                int statusCode            = Int32.Parse(response.ImporterResponse1.ImportOutput.StandardRetur.StatusKode);
                if (statusCode != 20)
                {
                    string message = StubUtil.ConstructSoapErrorMessage(statusCode, "Import", PersonStubHelper.SERVICE, response.ImporterResponse1.ImportOutput.StandardRetur.FejlbeskedTekst);
                    log.Error(message);
                    throw new SoapServiceException(message);
                }

                log.Debug("Import successful on Person with uuid " + person.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 Person", ex);
            }
        }
示例#2
0
        public importerResponse Create(ImportInputType importInput)
        {
            // construct request
            importerRequest request = new importerRequest();

            request.ImporterRequest1                  = new ImporterRequestType();
            request.ImporterRequest1.ImportInput      = importInput;
            request.ImporterRequest1.AuthorityContext = new AuthorityContextType();
            request.ImporterRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetCurrentMunicipality();

            // send request
            PersonPortType channel = StubUtil.CreateChannel <PersonPortType>(PersonStubHelper.SERVICE, "Importer", helper.CreatePort());

            try
            {
                return(channel.importer(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 Importer service on Person", ex);
            }
        }