示例#1
0
        public static RegistreringType1 CreateFakePerson(bool addSourceObject)
        {
            var ret = new RegistreringType1()
            {
                AttributListe = new AttributListeType()
                {
                    Egenskab          = new EgenskabType[] { },
                    LokalUdvidelse    = null,
                    RegisterOplysning = new RegisterOplysningType[] { },
                    SundhedOplysning  = null,
                },
                RelationListe    = new RelationListeType(),
                TilstandListe    = new TilstandListeType(),
                AktoerRef        = UnikIdType.Create(Guid.NewGuid()),
                LivscyklusKode   = LivscyklusKodeType.Rettet,
                CommentText      = "",
                Virkning         = new VirkningType[] { },
                SourceObjectsXml = null,
                Tidspunkt        = TidspunktType.Create(DateTime.Today)
            };

            if (addSourceObject)
            {
                var o = new object[] { Guid.NewGuid(), Guid.NewGuid() };
                ret.SourceObjectsXml = CprBroker.Utilities.Strings.SerializeObject(o);
            }
            return(ret);
        }
示例#2
0
        internal void AddOrganisationRelation(string organisationUUID, VirkningType virkning, RegistreringType1 registration)
        {
            UnikIdType orgReference = StubUtil.GetReference <UnikIdType>(organisationUUID, ItemChoiceType.UUIDIdentifikator);

            OrganisationFlerRelationType organisationRelationType = new OrganisationFlerRelationType();

            organisationRelationType.Virkning    = virkning;
            organisationRelationType.ReferenceID = orgReference;

            int i = 0;

            OrganisationFlerRelationType[] newRelations = new OrganisationFlerRelationType[1];
            if (registration.RelationListe.TilknyttedeOrganisationer != null && registration.RelationListe.TilknyttedeOrganisationer.Length > 0)
            {
                newRelations = new OrganisationFlerRelationType[registration.RelationListe.TilknyttedeOrganisationer.Length + 1];

                foreach (OrganisationFlerRelationType oldRelation in registration.RelationListe.TilknyttedeOrganisationer)
                {
                    newRelations[i++] = oldRelation;
                }
            }

            registration.RelationListe.TilknyttedeOrganisationer    = newRelations;
            registration.RelationListe.TilknyttedeOrganisationer[i] = organisationRelationType;
        }
示例#3
0
 public PersonFlerRelationType ToPersonFlerRelationType()
 {
     return(new PersonFlerRelationType
     {
         CommentText = this.CommentText,
         ReferenceID = UnikIdType.Create(this.RelatedPersonUuid),
         Virkning = Effect.ToVirkningType(Effect)
     });
 }
示例#4
0
        internal void AddOrganisationRelation(string organisationUUID, VirkningType virkning, RegistreringType1 registration)
        {
            UnikIdType orgReference = StubUtil.GetReference <UnikIdType>(organisationUUID, ItemChoiceType.UUIDIdentifikator);

            OrganisationRelationType organisationRelationType = new OrganisationRelationType();

            organisationRelationType.Virkning    = virkning;
            organisationRelationType.ReferenceID = orgReference;

            registration.RelationListe.Tilhoerer = organisationRelationType;
        }
示例#5
0
        internal ItSystemFlerRelationType CreateItSystemRelation(string uuid, VirkningType virkning)
        {
            UnikIdType itSystemId = StubUtil.GetReference <UnikIdType>(uuid, ItemChoiceType.UUIDIdentifikator);

            ItSystemFlerRelationType itSystemFlerRelationType = new ItSystemFlerRelationType();

            itSystemFlerRelationType.ReferenceID = itSystemId;
            itSystemFlerRelationType.Virkning    = virkning;

            return(itSystemFlerRelationType);
        }
示例#6
0
        internal BrugerFlerRelationType CreateBrugerRelation(string uuid, VirkningType virkning)
        {
            UnikIdType orgEnhedId = StubUtil.GetReference <UnikIdType>(uuid, ItemChoiceType.UUIDIdentifikator);

            BrugerFlerRelationType brugerFlerRelationType = new BrugerFlerRelationType();

            brugerFlerRelationType.ReferenceID = orgEnhedId;
            brugerFlerRelationType.Virkning    = virkning;

            return(brugerFlerRelationType);
        }
示例#7
0
        internal OrganisationEnhedFlerRelationType CreateOrgEnhedRelation(string uuid, VirkningType virkning)
        {
            UnikIdType orgEnhedId = StubUtil.GetReference <UnikIdType>(uuid, ItemChoiceType.UUIDIdentifikator);

            OrganisationEnhedFlerRelationType orgEnhedFlerRelationType = new OrganisationEnhedFlerRelationType();

            orgEnhedFlerRelationType.ReferenceID = orgEnhedId;
            orgEnhedFlerRelationType.Virkning    = virkning;

            return(orgEnhedFlerRelationType);
        }
示例#8
0
        internal KlasseFlerRelationType CreateOpgaveRelation(string uuid, VirkningType virkning)
        {
            UnikIdType klassifikationId = StubUtil.GetReference <UnikIdType>(uuid, ItemChoiceType.UUIDIdentifikator);

            KlasseFlerRelationType klasseFlerRelationType = new KlasseFlerRelationType();

            klasseFlerRelationType.ReferenceID = klassifikationId;
            klasseFlerRelationType.Virkning    = virkning;

            return(klasseFlerRelationType);
        }
示例#9
0
        internal void SetFunktionsType(string funktionsTypeUUID, VirkningType virkning, RegistreringType1 registration)
        {
            UnikIdType funktionsTypeKlasseId = StubUtil.GetReference <UnikIdType>(funktionsTypeUUID, ItemChoiceType.UUIDIdentifikator);

            KlasseRelationType funktionsType = new KlasseRelationType();

            funktionsType.ReferenceID = funktionsTypeKlasseId;
            funktionsType.Virkning    = virkning;

            registration.RelationListe.Funktionstype = funktionsType;
        }
        internal void AddOverordnetEnhed(string overordnetEnhedUUID, VirkningType virkning, RegistreringType1 registration)
        {
            UnikIdType orgUnitReference = StubUtil.GetReference <UnikIdType>(overordnetEnhedUUID, ItemChoiceType.UUIDIdentifikator);

            OrganisationEnhedRelationType organisationEnhedRelationType = new OrganisationEnhedRelationType();

            organisationEnhedRelationType.Virkning    = virkning;
            organisationEnhedRelationType.ReferenceID = orgUnitReference;

            registration.RelationListe.Overordnet = organisationEnhedRelationType;
        }
示例#11
0
        public void Clone_Valid_CorrectType(
            [Values(ItemChoiceType.URNIdentifikator, ItemChoiceType.UUID)] ItemChoiceType type)
        {
            var unikId = new UnikIdType()
            {
                ItemElementName = type
            };
            var result = UnikIdType.Clone(unikId);

            Assert.AreEqual(type, result.ItemElementName);
        }
示例#12
0
        public void Clone_Valid_CorrectType(
            [Values(ItemChoiceType.URNIdentifikator, ItemChoiceType.UUID)] ItemChoiceType type,
            [Values("fjkjhfjkh", "uiyyuyui")] string value)
        {
            var unikId = new UnikIdType()
            {
                ItemElementName = type, Item = value
            };
            var result = UnikIdType.Clone(unikId);

            Assert.AreEqual(value, result.Item);
        }
示例#13
0
 public static ActorRef FromXmlType(UnikIdType oio)
 {
     if (oio != null)
     {
         return(new ActorRef()
         {
             ActorRefId = Guid.NewGuid(),
             Value = oio.Item,
             Type = (int)oio.ItemElementName,
         });
     }
     return(null);
 }
示例#14
0
        internal void AddPersonRelationship(string personUuid, VirkningType virkning, RegistreringType1 registration)
        {
            UnikIdType personReference = new UnikIdType();

            personReference.ItemElementName = ItemChoiceType.UUIDIdentifikator;
            personReference.Item            = personUuid;

            PersonFlerRelationType person = new PersonFlerRelationType();

            person.Virkning    = virkning;
            person.ReferenceID = personReference;

            registration.RelationListe.TilknyttedePersoner    = new PersonFlerRelationType[1];
            registration.RelationListe.TilknyttedePersoner[0] = person;
        }
示例#15
0
 public PersonFlerRelationType[] Filter(string typeFilter, Func <string, Guid> cpr2uuidFunc)
 {
     return(OutputArrayRecord
            .Where(
                per => per.Type == typeFilter && !per.IsUnknown
                )
            .Select(per => new PersonFlerRelationType()
     {
         CommentText = null,
         // TODO: Ensure PNR format is correct
         ReferenceID = UnikIdType.Create(cpr2uuidFunc(per.PNR)),
         Virkning = VirkningType.Create(null, null)
     }
                    )
            .ToArray());
 }
示例#16
0
        public RegistreringType1 ToRegistreringType1(DateTime effectDate, Func <string, Guid> cpr2uuidFunc)
        {
            var ret = new RegistreringType1()
            {
                AktoerRef      = UnikIdType.Create(E_MDataProvider.ActorId),
                AttributListe  = this.ToAttributListeType(effectDate),
                CommentText    = null,
                LivscyklusKode = LivscyklusKodeType.Rettet,
                RelationListe  = this.ToRelationListeType(cpr2uuidFunc),
                Tidspunkt      = this.ToTidspunktType(),
                TilstandListe  = this.ToTilstandListeType(),
                Virkning       = null
            };

            ret.CalculateVirkning();
            return(ret);
        }
示例#17
0
        internal RegistreringType1 CreateRegistration(DateTime timestamp, LivscyklusKodeType registrationType)
        {
            UnikIdType        systemReference = GetOrganisationReference();
            RegistreringType1 registration    = new RegistreringType1();

            registration.Tidspunkt               = timestamp;
            registration.TidspunktSpecified      = true;
            registration.LivscyklusKode          = registrationType;
            registration.LivscyklusKodeSpecified = true;
            registration.BrugerRef               = systemReference;

            registration.AttributListe = new AttributListeType();
            registration.RelationListe = new RelationListeType();
            registration.TilstandListe = new TilstandListeType();

            return(registration);
        }
        internal void AddOverordnetEnhed(string overordnetEnhedUUID, VirkningType virkning, RegistreringType1 registration)
        {
            // allowed to be empty for top-level OU's
            if (String.IsNullOrEmpty(overordnetEnhedUUID))
            {
                return;
            }

            UnikIdType orgUnitReference = StubUtil.GetReference <UnikIdType>(overordnetEnhedUUID, ItemChoiceType.UUIDIdentifikator);

            OrganisationEnhedRelationType organisationEnhedRelationType = new OrganisationEnhedRelationType();

            organisationEnhedRelationType.Virkning    = virkning;
            organisationEnhedRelationType.ReferenceID = orgUnitReference;

            registration.RelationListe.Overordnet = organisationEnhedRelationType;
        }
        internal RegistreringType1 CreateRegistration(OrgUnitData ou, LivscyklusKodeType livcyklusKodeType)
        {
            UnikIdType        systemReference = GetOrganisationReference();
            RegistreringType1 registration    = new RegistreringType1();

            registration.Tidspunkt               = ou.Timestamp;
            registration.TidspunktSpecified      = true;
            registration.LivscyklusKode          = LivscyklusKodeType.Importeret;
            registration.LivscyklusKodeSpecified = true;
            registration.BrugerRef               = systemReference;
            registration.NoteTekst               = (ou.ParentOrgUnitUuid == null) ? "STSOrgSync" : null; // TODO: update according to AP26 once we know how to identify the root OU

            registration.AttributListe = new AttributListeType();
            registration.RelationListe = new RelationListeType();
            registration.TilstandListe = new TilstandListeType();

            return(registration);
        }
示例#20
0
 public override void ProcessPerson(string cprNumberOrUuid)
 {
     using (var dataContext = new PartDataContext(this.BrokerConnectionString))
     {
         CprBroker.Engine.BrokerContext.Initialize(this.ApplicationToken, this.UserToken);
         CprBroker.Engine.Local.Admin.AddNewLog(System.Diagnostics.TraceEventType.Information, GetType().Name, string.Format("Preparing dummy data for failed PNR: {0}", cprNumberOrUuid), "", "");
         RegistreringType1 reg  = new RegistreringType1();
         UnikIdType        uuid = new UnikIdType();
         uuid.Item     = CprBroker.Utilities.Constants.FakeActorId.ToString();
         reg.AktoerRef = uuid;
         reg.Tidspunkt = TidspunktType.Create(new DateTime(2013, 9, 24));
         var dbReg = CprBroker.Data.Part.PersonRegistration.FromXmlType(reg);
         dbReg.BrokerUpdateDate = new DateTime(2013, 9, 24);
         dbReg.UUID             = dataContext.PersonMappings.Where(pm => pm.CprNumber == cprNumberOrUuid).First().UUID;
         var pers = dataContext.Persons.Where(p => p.UUID == dbReg.UUID).FirstOrDefault();
         if (pers == null)
         {
             dataContext.Persons.InsertOnSubmit(new Person()
             {
                 UUID = dbReg.UUID,
                 UserInterfaceKeyText = cprNumberOrUuid,
             }
                                                );
             CprBroker.Engine.Local.Admin.AddNewLog(System.Diagnostics.TraceEventType.Information, GetType().Name, string.Format("Adding {0} to Person", cprNumberOrUuid), "", "");
         }
         else
         {
             CprBroker.Engine.Local.Admin.AddNewLog(System.Diagnostics.TraceEventType.Information, GetType().Name, string.Format("Ignoring {0} - is in Person", cprNumberOrUuid), "", "");
         }
         var persReg = dataContext.PersonRegistrations.Where(p => p.UUID == dbReg.UUID).FirstOrDefault();
         if (persReg == null)
         {
             CprBroker.Engine.Local.Admin.AddNewLog(System.Diagnostics.TraceEventType.Information, GetType().Name, string.Format("Adding {0} to PersonRegistration", cprNumberOrUuid), "", "");
             dataContext.PersonRegistrations.InsertOnSubmit(dbReg);
             dataContext.SubmitChanges();
             CprBroker.Engine.Local.Admin.AddNewLog(System.Diagnostics.TraceEventType.Information, GetType().Name, string.Format("Added dummy data for {0}", cprNumberOrUuid), "", "");
         }
         else
         {
             CprBroker.Engine.Local.Admin.AddNewLog(System.Diagnostics.TraceEventType.Information, GetType().Name, string.Format("Ignoring {0} - is in PersonRegistration", cprNumberOrUuid), "", "");
         }
     }
 }
示例#21
0
        internal AdresseFlerRelationType CreateAddressReference(string uuid, int indeks, string roleUuid, VirkningType virkning)
        {
            UnikIdType type = new UnikIdType();

            type.Item            = UUIDConstants.ADDRESS_TYPE_USER;
            type.ItemElementName = ItemChoiceType.UUIDIdentifikator;

            UnikIdType role = new UnikIdType();

            role.ItemElementName = ItemChoiceType.UUIDIdentifikator;
            role.Item            = roleUuid;

            AdresseFlerRelationType address = new AdresseFlerRelationType();

            address.ReferenceID = StubUtil.GetReference <UnikIdType>(uuid, ItemChoiceType.UUIDIdentifikator);
            address.Virkning    = virkning;
            address.Indeks      = "" + indeks;
            address.Rolle       = role;
            address.Type        = type;

            return(address);
        }
        internal void AddTilknyttedeFunktioner(List <string> tilknytteFunktioner, VirkningType virkning, RegistreringType1 registration)
        {
            if (tilknytteFunktioner == null || tilknytteFunktioner.Count == 0)
            {
                return;
            }

            OrganisationFunktionFlerRelationType[] orgFunktionFlerRelationTypes = new OrganisationFunktionFlerRelationType[tilknytteFunktioner.Count];

            for (int i = 0; i < tilknytteFunktioner.Count; i++)
            {
                UnikIdType tilknytteFunktionId = StubUtil.GetReference <UnikIdType>(tilknytteFunktioner[i], ItemChoiceType.UUIDIdentifikator);

                OrganisationFunktionFlerRelationType orgFunktionFlerRelationType = new OrganisationFunktionFlerRelationType();
                orgFunktionFlerRelationType.ReferenceID = tilknytteFunktionId;
                orgFunktionFlerRelationType.Virkning    = virkning;

                orgFunktionFlerRelationTypes[i] = orgFunktionFlerRelationType;
            }

            registration.RelationListe.TilknyttedeFunktioner = orgFunktionFlerRelationTypes;
        }
        internal void AddOpgaver(List <string> opgaver, VirkningType virkning, RegistreringType1 registration)
        {
            if (opgaver == null || opgaver.Count == 0)
            {
                return;
            }

            KlasseFlerRelationType[] opgaverTypes = new KlasseFlerRelationType[opgaver.Count];

            for (int i = 0; i < opgaver.Count; i++)
            {
                UnikIdType tilknytteFunktionId = StubUtil.GetReference <UnikIdType>(opgaver[i], ItemChoiceType.UUIDIdentifikator);

                KlasseFlerRelationType opgaveType = new KlasseFlerRelationType();
                opgaveType.ReferenceID = tilknytteFunktionId;
                opgaveType.Virkning    = virkning;

                opgaverTypes[i] = opgaveType;
            }

            registration.RelationListe.Opgaver = opgaverTypes;
        }
示例#24
0
        public List <string> Soeg(string antal = null, string offset = null)
        {
            OrganisationEnhedPortType channel = StubUtil.CreateChannel <OrganisationEnhedPortType>(OrganisationEnhedStubHelper.SERVICE, "Soeg", helper.CreatePort());

            SoegInputType1 soegInput = new SoegInputType1();

            soegInput.AttributListe = new AttributListeType();
            soegInput.RelationListe = new RelationListeType();
            soegInput.TilstandListe = new TilstandListeType();

            if (antal != null)
            {
                soegInput.MaksimalAntalKvantitet = antal;
            }
            if (offset != null)
            {
                soegInput.FoersteResultatReference = offset;
            }

            // only search for Active units
            soegInput.TilstandListe.Gyldighed    = new GyldighedType[1];
            soegInput.TilstandListe.Gyldighed[0] = new GyldighedType();
            soegInput.TilstandListe.Gyldighed[0].GyldighedStatusKode = GyldighedStatusKodeType.Aktiv;

            // TODO: these three lines should be removeable once KMD fixes their end
            soegInput.TilstandListe.Gyldighed[0].Virkning = new VirkningType();
            soegInput.TilstandListe.Gyldighed[0].Virkning.FraTidspunkt      = new TidspunktType();
            soegInput.TilstandListe.Gyldighed[0].Virkning.FraTidspunkt.Item = DateTime.Now;

            // only return objects that have a Tilhører relationship top-level Organisation
            UnikIdType orgReference = StubUtil.GetReference <UnikIdType>(registry.MunicipalityOrganisationUUID[OrganisationRegistryProperties.GetCurrentMunicipality()], ItemChoiceType.UUIDIdentifikator);
            OrganisationRelationType organisationRelationType = new OrganisationRelationType();

            organisationRelationType.ReferenceID = orgReference;
            soegInput.RelationListe.Tilhoerer    = organisationRelationType;

            // search
            soegRequest request = new soegRequest();

            request.SoegRequest1                  = new SoegRequestType();
            request.SoegRequest1.SoegInput        = soegInput;
            request.SoegRequest1.AuthorityContext = new AuthorityContextType();
            request.SoegRequest1.AuthorityContext.MunicipalityCVR = OrganisationRegistryProperties.GetCurrentMunicipality();

            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", OrganisationEnhedStubHelper.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 OrganisationEnhed", ex);
            }
        }
        internal bool UpdateOpgaver(List <string> opgaver, VirkningType virkning, RegistreringType1 registration, DateTime timestamp)
        {
            if (registryProperties.DisableKleOpgaver)
            {
                return(false);
            }

            bool changes = false;

            // make sure we have a list to work with below, and that there are no duplicates
            opgaver = (opgaver != null) ? opgaver : new List <string>();
            opgaver = opgaver.Distinct().ToList();

            // find those we need to add (at the end of this method)
            var toAdd = new List <string>();

            foreach (var opgave in opgaver)
            {
                bool add = true;

                if (registration.RelationListe?.Opgaver != null)
                {
                    foreach (var opgaveRelation in registration.RelationListe.Opgaver)
                    {
                        string uuid = opgaveRelation.ReferenceID?.Item;

                        if (opgave.Equals(uuid))
                        {
                            add = false;
                            break;
                        }
                    }
                }

                if (add)
                {
                    changes = true;
                    toAdd.Add(opgave);
                }
            }

            if (registration.RelationListe?.Opgaver != null)
            {
                IEqualityComparer <KlasseFlerRelationType> comparer = new KlasseFlerRelationTypeComparer();

                // remove duplicates from registration.RelationListe.Opgaver (because sometimes we get duplicates back from KMD)
                registration.RelationListe.Opgaver = registration.RelationListe.Opgaver.Distinct(comparer).ToArray();

                // terminate virkning on elements no longer in local
                foreach (var opgaveRelation in registration.RelationListe.Opgaver)
                {
                    string uuid = opgaveRelation.ReferenceID?.Item;

                    if (uuid != null && !opgaver.Contains(uuid))
                    {
                        changes = true;
                        StubUtil.TerminateVirkning(opgaveRelation.Virkning, timestamp);
                    }
                }
            }

            // actually add the new ones to this registration
            if (toAdd.Count > 0)
            {
                if (registration.RelationListe.Opgaver == null || registration.RelationListe.Opgaver.Length == 0)
                {
                    AddOpgaver(toAdd, virkning, registration);
                }
                else
                {
                    KlasseFlerRelationType[] opgaverTypes = new KlasseFlerRelationType[toAdd.Count + registration.RelationListe.Opgaver.Length];

                    // add new
                    for (int i = 0; i < toAdd.Count; i++)
                    {
                        UnikIdType tilknytteFunktionId = StubUtil.GetReference <UnikIdType>(toAdd[i], ItemChoiceType.UUIDIdentifikator);

                        KlasseFlerRelationType opgaveType = new KlasseFlerRelationType();
                        opgaveType.ReferenceID = tilknytteFunktionId;
                        opgaveType.Virkning    = virkning;

                        opgaverTypes[i] = opgaveType;
                    }

                    // copy existing
                    for (int j = 0, i = toAdd.Count; i < opgaverTypes.Length && j < registration.RelationListe.Opgaver.Length; i++, j++)
                    {
                        opgaverTypes[i] = registration.RelationListe.Opgaver[j];
                    }

                    registration.RelationListe.Opgaver = opgaverTypes;
                }
            }

            return(changes);
        }
示例#26
0
        public void Clone_Null_ReturnsNull()
        {
            var result = UnikIdType.Clone(null);

            Assert.Null(result);
        }
        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);
            }
        }
示例#28
0
 public UnikIdType ToAktoerRefType()
 {
     return(UnikIdType.Create(Constants.ActorId));
 }