/// <summary>
        /// Get a list of messages that are available for retrieval.
        /// </summary>
        /// <param name="listRequest">The parameters for the list operation.</param>
        /// <param name="endpointUrl">The endpoint URL for the SMR service.</param>
        /// <returns>A list of available messages.</returns>
        public MessageListType List(list listRequest, Uri endpointUrl)
        {
            Validation.ValidateArgumentRequired("listRequest", listRequest);
            Validation.ValidateArgumentRequired("endpointUrl", endpointUrl);
            Validation.ValidateArgumentRequired("listRequest.receiverOrganisation", listRequest.receiverOrganisation);

            if (smrClient is Nehta.SMD2010.SMR.SealedMessageRetrievalClient)
            {
                Nehta.SMD2010.SMR.SealedMessageRetrievalClient client = (Nehta.SMD2010.SMR.SealedMessageRetrievalClient)smrClient;
                client.Endpoint.Address = new EndpointAddress(endpointUrl);
            }

            listRequest request = new listRequest();

            request.list = listRequest;

            listResponse1 response = smrClient.list(request);

            if (response != null && response.listResponse != null)
            {
                return(response.listResponse.list);
            }
            else
            {
                throw new ApplicationException(Properties.Resources.UnexpectedServiceResponse);
            }
        }
        public FiltreretOejebliksbilledeType[] GetLatestRegistrations(string[] uuids)
        {
            ListInputType listInput = new ListInputType();

            listInput.UUIDIdentifikator = uuids;

            listRequest request = new listRequest();

            request.ListRequest1                  = new ListRequestType();
            request.ListRequest1.ListInput        = listInput;
            request.ListRequest1.AuthorityContext = new AuthorityContextType();
            request.ListRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetMunicipality();

            OrganisationFunktionPortType channel = StubUtil.CreateChannel <OrganisationFunktionPortType>(OrganisationFunktionStubHelper.SERVICE, "List", helper.CreatePort());

            try
            {
                listResponse response = channel.list(request);

                int statusCode = Int32.Parse(response.ListResponse1.ListOutput.StandardRetur.StatusKode);
                if (statusCode != 20)
                {
                    // note that statusCode 44 means that the objects does not exists, so that is a valid response
                    if (statusCode != 44)
                    {
                        log.Warn("Lookup on OrgFunction with uuids '" + string.Join(",", uuids) + "' failed with statuscode " + statusCode);
                    }
                    else
                    {
                        log.Debug("Lookup on OrgFunction with uuids '" + string.Join(",", uuids) + "' failed with statuscode " + statusCode);
                    }

                    return(null);
                }

                if (response.ListResponse1.ListOutput.FiltreretOejebliksbillede == null || response.ListResponse1.ListOutput.FiltreretOejebliksbillede.Length == 0)
                {
                    log.Debug("Lookup on OrgFunction with uuids '" + string.Join(",", uuids) + "' returned an empty resultset");
                    return(null);
                }

                return(response.ListResponse1.ListOutput.FiltreretOejebliksbillede);
            }
            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 OrganisationFunktion", ex);
            }
        }
Exemple #3
0
        public Dictionary <string, RegistreringType1> GetLatestRegistrations(List <string> uuids)
        {
            var result = new Dictionary <string, RegistreringType1>();

            ListInputType listInput = new ListInputType();

            listInput.UUIDIdentifikator = uuids.ToArray();

            listRequest request = new listRequest();

            request.ListRequest1                  = new ListRequestType();
            request.ListRequest1.ListInput        = listInput;
            request.ListRequest1.AuthorityContext = new AuthorityContextType();
            request.ListRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetCurrentMunicipality();

            PersonPortType channel = StubUtil.CreateChannel <PersonPortType>(PersonStubHelper.SERVICE, "List", helper.CreatePort());

            try
            {
                listResponse response = channel.list(request);

                int statusCode = Int32.Parse(response.ListResponse1.ListOutput.StandardRetur.StatusKode);
                if (statusCode != 20)
                {
                    // note that statusCode 44 means that the object does not exists, so that is a valid response
                    log.Debug("List on Person failed with statuscode " + statusCode);
                    return(result);
                }

                if (response.ListResponse1.ListOutput.FiltreretOejebliksbillede == null || response.ListResponse1.ListOutput.FiltreretOejebliksbillede.Length == 0)
                {
                    log.Debug("List on Person has 0 hits");
                    return(result);
                }

                foreach (var person in response.ListResponse1.ListOutput.FiltreretOejebliksbillede)
                {
                    RegistreringType1[] resultSet = person.Registrering;
                    if (resultSet.Length == 0)
                    {
                        log.Warn("Person with uuid '" + person.ObjektType.UUIDIdentifikator + "' exists, but has no registration");
                        continue;
                    }

                    RegistreringType1 reg = null;
                    if (resultSet.Length > 1)
                    {
                        log.Warn("Person with uuid " + person.ObjektType.UUIDIdentifikator + " 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)
                            {
                                reg    = res;
                                winner = res.Tidspunkt;
                            }
                        }
                    }
                    else
                    {
                        reg = 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 (reg.LivscyklusKode.Equals(LivscyklusKodeType.Slettet) || reg.LivscyklusKode.Equals(LivscyklusKodeType.Passiveret))
                    {
                        continue;
                    }

                    result.Add(person.ObjektType.UUIDIdentifikator, reg);
                }

                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 List service on Person", ex);
            }
        }