コード例 #1
0
 public void CreateXQueryElements_MunicipalityCode_2([Values("851", "217", "905")] string municipalityCode)
 {
     var soegObject = new SoegObjektType()
     {
         SoegAttributListe = new SoegAttributListeType()
         {
             SoegRegisterOplysning = new RegisterOplysningType[]
             {
                 new RegisterOplysningType()
                 {
                     Item = new CprBorgerType()
                     {
                         FolkeregisterAdresse = new AdresseType()
                         {
                             Item = new DanskAdresseType()
                             {
                                 AddressComplete = new AddressCompleteType()
                                 {
                                     AddressAccess = new AddressAccessType()
                                     {
                                         MunicipalityCode = municipalityCode
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     };
     var ret = PersonRegistration.CreateXQueryElements(soegObject);
 }
コード例 #2
0
        public static List <WhereCondition> CreateXQueryElements(SoegObjektType soegObject)
        {
            var personRegistration = soegObject.ToRegistreringType1();
            var xml = CprBroker.Utilities.Strings.SerializeObject(personRegistration);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(xml);
            return(XQueryCondition.CreateXQueryElements(doc.DocumentElement, "Contents"));
        }
コード例 #3
0
            public void GetUuidsByCriteria_EmptyCriteriaWithRegistratioId_NonZero()
            {
                var soegObject = new SoegObjektType();

                using (var dataContext = new PartDataContext())
                {
                    var pRegIds = dataContext.PersonRegistrations.Select(pr => pr.PersonRegistrationId).Take(2).ToArray();
                    var ret     = PersonRegistrationKey.GetByCriteria(dataContext, soegObject, pRegIds);
                    Assert.IsNotEmpty(ret.ToArray());
                }
            }
コード例 #4
0
ファイル: Converters.cs プロジェクト: OS2CPRbroker/CPReader
        public List <SoegObjektType> ToSoegObjektTypes(String name, String address)
        {
            List <NavnStrukturType> navnStrukturTypes = new List <NavnStrukturType>();
            List <SoegObjektType>   soegObjekts       = new List <SoegObjektType>();

            if (name != "" && name.Split(' ').Length == 1)
            {
                for (int i = 0; i < 3; i++)
                {
                    navnStrukturTypes.Add(ToNavnStrukturType(name, i));
                }
            }
            else
            {
                navnStrukturTypes.Add(ToNavnStrukturType(name));
            }

            foreach (NavnStrukturType navnStrukturType in navnStrukturTypes)
            {
                AdresseType addressObject = ToAddressType(address);
                if (navnStrukturType == null && addressObject == null)
                {
                    return(null);
                }

                SoegAttributListeType soegAttributListeType = new SoegAttributListeType();

                // Now fill Egenskab & registerOplysning
                SoegEgenskabType soegEgenskabType = new SoegEgenskabType();
                soegEgenskabType.NavnStruktur      = navnStrukturType;
                soegAttributListeType.SoegEgenskab = new SoegEgenskabType[] { soegEgenskabType };

                if (addressObject != null)
                {
                    RegisterOplysningType registerOplysningType = new RegisterOplysningType();

                    CprBorgerType cprBorgerType = new CprBorgerType();
                    cprBorgerType.FolkeregisterAdresse = addressObject;
                    registerOplysningType.Item         = cprBorgerType;

                    soegAttributListeType.SoegRegisterOplysning = new RegisterOplysningType[] { registerOplysningType };
                }

                SoegObjektType soegObjekt = new SoegObjektType();
                soegObjekt.SoegAttributListe = soegAttributListeType;

                soegObjekts.Add(soegObjekt);
            }

            return(soegObjekts);
        }
コード例 #5
0
            public void GetUuidsByCriteria_MunicipalityCode_5([Values("851")] string municipalityCode)
            {
                var soegObject = new SoegObjektType()
                {
                    SoegAttributListe = new SoegAttributListeType()
                    {
                        SoegRegisterOplysning = new RegisterOplysningType[]
                        {
                            new RegisterOplysningType()
                            {
                                Item = new CprBorgerType()
                                {
                                    FolkeregisterAdresse = new AdresseType()
                                    {
                                        Item = new DanskAdresseType()
                                        {
                                            AddressComplete = new AddressCompleteType()
                                            {
                                                AddressAccess = new AddressAccessType()
                                                {
                                                    MunicipalityCode = municipalityCode
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                };

                using (var dataContext = new PartDataContext())
                {
                    var ret = PersonRegistration.GetUuidsByCriteria(dataContext, soegObject, 0, 5).ToArray();
                    Assert.AreEqual(5, ret.Count());
                    var empty = ret.Where(r => r == null);
                    Assert.IsEmpty(empty);
                }
            }
コード例 #6
0
            public void GetUuidsByCriteria_MunicipalityCode_NotZero([Values("851")] string municipalityCode)
            {
                var soegObject = new SoegObjektType()
                {
                    SoegAttributListe = new SoegAttributListeType()
                    {
                        SoegRegisterOplysning = new RegisterOplysningType[]
                        {
                            new RegisterOplysningType()
                            {
                                Item = new CprBorgerType()
                                {
                                    FolkeregisterAdresse = new AdresseType()
                                    {
                                        Item = new DanskAdresseType()
                                        {
                                            AddressComplete = new AddressCompleteType()
                                            {
                                                AddressAccess = new AddressAccessType()
                                                {
                                                    MunicipalityCode = municipalityCode
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                };

                using (var dataContext = new PartDataContext())
                {
                    var ret   = PersonRegistrationKey.GetByCriteria(dataContext, soegObject, null);
                    var first = ret.First();
                    Assert.NotNull(first);
                }
            }
コード例 #7
0
ファイル: Converters.cs プロジェクト: OS2CPRbroker/CPReader
        public SoegObjektType AddressToSoegObjekt(IAddress address)
        {
            if (address == null)
            {
                return(null);
            }

            SoegAttributListeType soegAttributListeType = new SoegAttributListeType();

            // Now fill Egenskab & registerOplysning
            SoegEgenskabType soegEgenskabType = new SoegEgenskabType();

            soegEgenskabType.NavnStruktur      = null;
            soegAttributListeType.SoegEgenskab = new SoegEgenskabType[] { soegEgenskabType };

            if (address != null)
            {
                RegisterOplysningType registerOplysningType = new RegisterOplysningType();

                CprBorgerType cprBorgerType = new CprBorgerType();
                AdresseType   addressObject = getAdresseType(address);
                if (addressObject == null)
                {
                    return(null);
                }

                cprBorgerType.FolkeregisterAdresse = addressObject;
                registerOplysningType.Item         = cprBorgerType;

                soegAttributListeType.SoegRegisterOplysning = new RegisterOplysningType[] { registerOplysningType };
            }

            SoegObjektType soegObjekt = new SoegObjektType();

            soegObjekt.SoegAttributListe = soegAttributListeType;
            return(soegObjekt);
        }
コード例 #8
0
            public void GetUuidsByCriteria_MunicipalityCodeIndexOutOfRange_Zero([Values("851", "217", "905")] string municipalityCode)
            {
                var soegObject = new SoegObjektType()
                {
                    SoegAttributListe = new SoegAttributListeType()
                    {
                        SoegRegisterOplysning = new RegisterOplysningType[]
                        {
                            new RegisterOplysningType()
                            {
                                Item = new CprBorgerType()
                                {
                                    FolkeregisterAdresse = new AdresseType()
                                    {
                                        Item = new DanskAdresseType()
                                        {
                                            AddressComplete = new AddressCompleteType()
                                            {
                                                AddressAccess = new AddressAccessType()
                                                {
                                                    MunicipalityCode = municipalityCode
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                };

                using (var dataContext = new PartDataContext())
                {
                    var ret = PersonRegistration.GetUuidsByCriteria(dataContext, soegObject, 10000000, 10);
                    Assert.AreEqual(0, ret.Count());
                }
            }
コード例 #9
0
            public void GetUuidsByCriteria_MunicipalityCodeAndRandomPersonRegistratioId_Zero([Values("851")] string municipalityCode)
            {
                var soegObject = new SoegObjektType()
                {
                    SoegAttributListe = new SoegAttributListeType()
                    {
                        SoegRegisterOplysning = new RegisterOplysningType[]
                        {
                            new RegisterOplysningType()
                            {
                                Item = new CprBorgerType()
                                {
                                    FolkeregisterAdresse = new AdresseType()
                                    {
                                        Item = new DanskAdresseType()
                                        {
                                            AddressComplete = new AddressCompleteType()
                                            {
                                                AddressAccess = new AddressAccessType()
                                                {
                                                    MunicipalityCode = municipalityCode
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                };

                using (var dataContext = new PartDataContext())
                {
                    var ret = PersonRegistrationKey.GetByCriteria(dataContext, soegObject, Guid.NewGuid(), Guid.NewGuid());
                    Assert.IsEmpty(ret.ToArray());
                }
            }
コード例 #10
0
 public BasicOutputType <ChangeSubscriptionType> SubscribeOnCriteria(ChannelBaseType NotificationChannel, SoegObjektType Criteria)
 {
     return(SubscriptionManager.SubscribeOnCriteria(applicationHeader.UserToken, applicationHeader.ApplicationToken, NotificationChannel, Criteria));
 }
コード例 #11
0
        public static BasicOutputType <ChangeSubscriptionType> SubscribeOnCriteria(string userToken, string appToken, ChannelBaseType notificationChannel, SoegObjektType criteria)
        {
            SubscribeOnCriteriaFacadeMethod facade = new SubscribeOnCriteriaFacadeMethod(notificationChannel, criteria, appToken, userToken);

            return(GetMethodOutput <ChangeSubscriptionType>(facade));
        }
コード例 #12
0
        public static IEnumerable <PersonRegistrationKey> GetByCriteria(PartDataContext dataContext, SoegObjektType soegObject, params Guid[] personRegistrationIds)
        {
            var elements = PersonRegistration.CreateXQueryElements(soegObject);

            if (personRegistrationIds != null)
            {
                if (personRegistrationIds.Length == 0)
                {
                    return(new PersonRegistrationKey[0]);
                }
                else
                {
                    elements.Add(
                        new InWhereCondition()
                    {
                        ColumnName = "PersonRegistrationId",
                        Values     = personRegistrationIds.Select(
                            id => id.ToString()
                            ).ToArray()
                    });
                }
            }
            var byCriteria = WhereCondition.GetMatchingObjects <PersonRegistrationKey>(dataContext, elements, "PersonRegistration", new string[] { "PersonRegistrationId", "UUID" });

            return(byCriteria);
        }
コード例 #13
0
        public static IEnumerable <Guid> GetUuidsByCriteria(PartDataContext dataContext, SoegObjektType soegObject, int startIndex, int maxCount)
        {
            var elements = PersonRegistration.CreateXQueryElements(soegObject);

#if Mono
            var byCriteriaStr = WhereCondition.GetMatchingObjects <object>(dataContext, elements, "PersonRegistration", true, new string[] { "UUID" }, startIndex, maxCount, "UUID");
            var byCriteria    = byCriteriaStr.Select(o => new Guid(o.ToString()));
#else
            var byCriteria = WhereCondition.GetMatchingObjects <Guid>(dataContext, elements, "PersonRegistration", true, new string[] { "UUID" }, startIndex, maxCount, "UUID");
#endif

            return(byCriteria);
        }
コード例 #14
0
 public SubscribeOnCriteriaFacadeMethod(ChannelBaseType notificationChannel, SoegObjektType criterion, string appToken, string userToken)
     : base(appToken, userToken)
 {
     NotificationChannel = notificationChannel;
     Criterion           = criterion;
 }
コード例 #15
0
        /// <summary>
        /// Adds a new Subscription object to the <paramref name="dataContext"/>
        /// This method inserts rows in Subscription, Channel (and children) and  SubscriptionPerson
        /// A later call to SubmitChanges() is required to save to the database
        /// </summary>
        /// <param name="dataContext"></param>
        /// <param name="subscriptionType"></param>
        /// <param name="applicationId"></param>
        /// <param name="PersonCivilRegistrationIdentifiers"></param>
        /// <param name="notificationChannel"></param>
        /// <returns></returns>
        private Subscription AddSubscription(EventBrokerDataContext dataContext, CprBroker.EventBroker.Data.SubscriptionType.SubscriptionTypes subscriptionType, Guid applicationId, ChannelBaseType notificationChannel, Guid[] personUuids, SoegObjektType soegObject)
        {
            List <Guid> listOfPersonsIDs = new List <Guid>();

            Subscription subscription = new Subscription();

            subscription.SubscriptionId     = Guid.NewGuid();
            subscription.SubscriptionTypeId = (int)subscriptionType;
            subscription.ApplicationId      = applicationId;
            subscription.Created            = DateTime.Now;
            if (soegObject != null)
            {
                var xml = Strings.SerializeObject(soegObject);
                subscription.Criteria        = System.Xml.Linq.XElement.Load(new StringReader(xml));
                subscription.LastCheckedUUID = Guid.Empty;
            }


            #region Set IsForAllPersons
            if (personUuids != null && personUuids.Length > 0)
            {
                subscription.IsForAllPersons = false;
            }
            else
            {
                subscription.IsForAllPersons = true;
            }
            #endregion

            #region Set the channel
            var dbChannel = Channel.FromXmlType(notificationChannel);
            subscription.Channels.Add(dbChannel);
            #endregion

            // Mark the new objects to be inserted later
            dataContext.Subscriptions.InsertOnSubmit(subscription);

            if (!subscription.IsForAllPersons && personUuids != null)
            {
                dataContext.SubscriptionPersons.InsertAllOnSubmit(
                    from PersonUuid in personUuids
                    select new SubscriptionPerson()
                {
                    SubscriptionPersonId = Guid.NewGuid(), SubscriptionId = subscription.SubscriptionId, PersonUuid = PersonUuid, Created = subscription.Created
                }
                    );
            }
            dataContext.Channels.InsertOnSubmit(dbChannel);

            return(subscription);
        }
コード例 #16
0
 /// <summary>
 /// Interface implementation
 /// </summary>
 public ChangeSubscriptionType SubscribeOnCriteria(ChannelBaseType notificationChannel, SoegObjektType criteria)
 {
     using (EventBrokerDataContext dataContext = new EventBrokerDataContext())
     {
         /*
          * For now we assign this data type as a data change type.
          */
         Data.Subscription subscription = AddSubscription(dataContext, Data.SubscriptionType.SubscriptionTypes.DataChange /* May be changed later */, CprBroker.Engine.BrokerContext.Current.ApplicationId.Value, notificationChannel, new Guid[0], criteria);
         if (subscription != null)
         {
             subscription.DataSubscription = new DataSubscription();
         }
         dataContext.SubmitChanges();
         if (subscription != null)
         {
             // Now get the subscription from the database to make sure everything is OK
             return(GetActiveSubscriptionsList(subscription.SubscriptionId).SingleOrDefault() as ChangeSubscriptionType);
         }
     }
     return(null);
 }