Esempio n. 1
0
            public void EnsurePersonExists_New_Saved()
            {
                var uuid = Guid.NewGuid();
                var pnr  = Utilities.RandomCprNumber();

                using (var dataContext = new PartDataContext())
                {
                    var person = CprBroker.Engine.Local.UpdateDatabase.EnsurePersonExists(dataContext, new CprBroker.Schemas.PersonIdentifier()
                    {
                        CprNumber = pnr, UUID = uuid
                    });
                    Assert.NotNull(person);
                    Assert.AreEqual(uuid, person.UUID);
                    Assert.AreEqual(pnr, person.UserInterfaceKeyText);

                    Assert.AreEqual(1, dataContext.GetChangeSet().Inserts.Count);
                    Assert.AreEqual(0, dataContext.GetChangeSet().Updates.Count);
                    Assert.AreEqual(0, dataContext.GetChangeSet().Deletes.Count);
                    dataContext.SubmitChanges();
                }

                using (var dataContext = new PartDataContext())
                {
                    var person = dataContext.Persons.Where(p => p.UUID == uuid).First();
                    Assert.NotNull(person);
                    Assert.AreEqual(pnr, person.UserInterfaceKeyText);
                }
            }
        public IActionResult Part(long Id)
        {
            var db   = new PartDataContext();
            var part = db.Parts.SingleOrDefault(x => x.Id == Id);

            return(View(part));
        }
 public override string[] LoadCprNumbers()
 {
     using (var dataContext = new PartDataContext())
     {
         return(dataContext.PersonMappings.OrderBy(pm => pm.CprNumber).Select(pm => pm.CprNumber).ToArray());
     }
 }
Esempio n. 4
0
        public static void UpdatePersonUuidArray(string[] cprNumbers, Guid?[] uuids)
        {
            using (var dataContext = new PartDataContext())
            {
                var all = new Dictionary <string, Guid>(cprNumbers.Length);

                for (int i = 0; i < cprNumbers.Length; i++)
                {
                    var uuid = uuids[i];
                    if (uuid.HasValue)
                    {
                        var cprNumber = cprNumbers[i];
                        if (!all.ContainsKey(cprNumber))
                        {
                            all[cprNumber] = uuid.Value;
                        }
                    }
                }
                var mappings = all
                               .Select(kvp => new PersonMapping()
                {
                    CprNumber = kvp.Key,
                    UUID      = kvp.Value
                });

                dataContext.PersonMappings.InsertAllOnSubmit(mappings);
                dataContext.SubmitChanges();
            }
        }
Esempio n. 5
0
            public void MergePersonRegistration_ExistsWithSource_NewWithouSource_NoUpdate(
                [Range(1, 10)] int dummy)
            {
                using (var dataContext = new PartDataContext())
                {
                    // Insert old record
                    var oio = Utilities.CreateFakePerson(true);
                    var pId = new PersonIdentifier()
                    {
                        UUID = Guid.NewGuid(), CprNumber = Utilities.RandomCprNumber()
                    };
                    CprBroker.Engine.Local.UpdateDatabase.MergePersonRegistration(pId, oio, out personRegistrationId);

                    var xml = oio.SourceObjectsXml;
                    oio.SourceObjectsXml = null;
                    var newRet = CprBroker.Engine.Local.UpdateDatabase.MergePersonRegistration(pId, oio, out personRegistrationId);
                    Assert.False(newRet);

                    var dbPersons = dataContext.PersonRegistrations.Where(pr => pr.UUID == pId.UUID).OrderBy(p => p.BrokerUpdateDate).ToArray();
                    Assert.AreEqual(1, dbPersons.Length);

                    var tmpElement = System.Xml.Linq.XElement.Parse(xml);
                    Assert.AreEqual(tmpElement.ToString(), dbPersons[0].SourceObjects.ToString());
                }
            }
Esempio n. 6
0
        public CprBroker.Schemas.Part.RegistreringType1 Read(PersonIdentifier uuid, CprBroker.Schemas.Part.LaesInputType input, Func <string, Guid> cpr2uuidFunc, out QualityLevel?ql)
        {
            Schemas.Part.RegistreringType1 ret = null;
            var fromRegistrationDate           = TidspunktType.ToDateTime(input.RegistreringFraFilter);
            var toRegistrationDate             = TidspunktType.ToDateTime(input.RegistreringTilFilter);

            var fromEffectDate = TidspunktType.ToDateTime(input.VirkningFraFilter);
            var ToEffectDate   = TidspunktType.ToDateTime(input.VirkningTilFilter);

            using (var dataContext = new PartDataContext())
            {
                Data.Part.PersonRegistration.SetChildLoadOptions(dataContext);
                ret =
                    (
                        from personReg in dataContext.PersonRegistrations
                        where personReg.UUID == uuid.UUID
                        // Filter by registration date
                        && (!fromRegistrationDate.HasValue || personReg.RegistrationDate >= fromRegistrationDate) &&
                        (!toRegistrationDate.HasValue || personReg.RegistrationDate <= toRegistrationDate)
                        // TODO: Filter by effect date
                        orderby personReg.RegistrationDate descending, personReg.BrokerUpdateDate descending
                        select Data.Part.PersonRegistration.ToXmlType(personReg)
                    ).FirstOrDefault();
            }
            ql = QualityLevel.LocalCache;
            return(ret);
        }
Esempio n. 7
0
        public static PersonRegistration InsertPerson(PartDataContext dataContext, Person dbPerson, RegistreringType1 oioRegistration)
        {
            var dbReg = Data.Part.PersonRegistration.FromXmlType(oioRegistration);

            dbReg.Person           = dbPerson;
            dbReg.BrokerUpdateDate = DateTime.Now;
            dataContext.PersonRegistrations.InsertOnSubmit(dbReg);
            return(dbReg);
        }
            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());
                }
            }
Esempio n. 9
0
 public override string[] LoadCprNumbers()
 {
     Utilities.UpdateConnectionString(this.BrokerConnectionString);
     using (var dataContext = new PartDataContext())
     {
         return(dataContext
                .PersonMappings
                .Select(pm => pm.CprNumber)
                .ToArray()
                .Where(pnr => !PartInterface.Strings.IsValidPersonNumber(decimal.Parse(pnr).ToPnrDecimalString()))
                .ToArray());
     }
 }
Esempio n. 10
0
        public override string[] LoadCprNumbers()
        {
            Utilities.UpdateConnectionString(this.BrokerConnectionString);

            using (var dataContext = new PartDataContext(this.BrokerConnectionString))
            {
                return(dataContext.PersonRegistrations
                       .Where(pr => pr.SourceObjects != null && pr.ActorRef.Value == ActorId.ToString())
                       .OrderBy(pr => pr.PersonRegistrationId)
                       .Select(pr => pr.PersonRegistrationId.ToString())
                       .ToArray());
            }
        }
Esempio n. 11
0
 public static void UpdatePersonUuid(string cprNumber, Guid uuid)
 {
     using (var dataContext = new PartDataContext())
     {
         PersonMapping map = new PersonMapping()
         {
             CprNumber = cprNumber,
             UUID      = uuid
         };
         dataContext.PersonMappings.InsertOnSubmit(map);
         dataContext.SubmitChanges();
     }
 }
Esempio n. 12
0
 public void MergePersonRegistration_New_True(
     [Range(1, 10)] int dummy)
 {
     using (var dataContext = new PartDataContext())
     {
         var oio = Utilities.CreateFakePerson();
         var pId = new PersonIdentifier()
         {
             UUID = Guid.NewGuid(), CprNumber = Utilities.RandomCprNumber()
         };
         var ret = CprBroker.Engine.Local.UpdateDatabase.MergePersonRegistration(pId, oio, out personRegistrationId);
         Assert.True(ret);
     }
 }
Esempio n. 13
0
        public override void ProcessPerson(string pnr)
        {
            var  arr  = pnr.Split(',');
            Guid uuid = new Guid(arr[0]);
            Guid personRegistrationId = new Guid(arr[1]);

            using (var dataContext = new PartDataContext(this.BrokerConnectionString))
            {
                var dbReg = dataContext.PersonRegistrations.Where(pr => pr.UUID == uuid && pr.PersonRegistrationId == personRegistrationId).FirstOrDefault();
                var oio   = PersonRegistration.ToXmlType(dbReg);
                oio.OrderByStartDate(false);
                dbReg.SetContents(oio);
                dataContext.SubmitChanges();
            }
        }
Esempio n. 14
0
 public void MergePersonRegistration_FromExisting_False(
     [Random(0, 99, 10)] int index)
 {
     using (var dataContext = new PartDataContext())
     {
         var dbPerson = dataContext.PersonRegistrations.Where(pr => pr.Person != null).Skip(index).First();
         var oio      = PersonRegistration.ToXmlType(dbPerson);
         var pId      = new PersonIdentifier()
         {
             UUID = dbPerson.UUID, CprNumber = dbPerson.Person.UserInterfaceKeyText
         };
         var ret = CprBroker.Engine.Local.UpdateDatabase.MergePersonRegistration(pId, oio, out personRegistrationId);
         Assert.False(ret);
     }
 }
Esempio n. 15
0
        public static Person EnsurePersonExists(PartDataContext dataContext, PersonIdentifier personIdentifier)
        {
            var dbPerson = (from dbPers in dataContext.Persons
                            where dbPers.UUID == personIdentifier.UUID
                            select dbPers).FirstOrDefault();

            if (dbPerson == null)
            {
                dbPerson = new CprBroker.Data.Part.Person()
                {
                    UUID = personIdentifier.UUID.Value,
                    UserInterfaceKeyText = personIdentifier.CprNumber
                };
                dataContext.Persons.InsertOnSubmit(dbPerson);
            }
            return(dbPerson);
        }
Esempio n. 16
0
        public FiltreretOejebliksbilledeType ReadPeriod(DateTime fromDate, DateTime toDate, PersonIdentifier pId, Func <string, Guid> cpr2uuidFunc)
        {
            var targetVirkning = VirkningType.Create(fromDate, toDate);

            using (var dataContext = new PartDataContext())
            {
                var oioRegs = dataContext
                              .PersonRegistrations
                              // TODO: Shall we also filter by ActorRef.Value to only include CPR Direct?
                              .Where(pr => pr.UUID == pId.UUID)
                              .OrderBy(pr => pr.RegistrationDate)
                              .Select(pr => PersonRegistration.ToXmlType(pr))
                              .ToArray();

                return(RegistreringType1.Merge(pId, targetVirkning, oioRegs));
            }
        }
Esempio n. 17
0
        public Guid GetUuid(string pnr)
        {
            if (_UUIDMap == null)
            {
                _UUIDMap = new Dictionary <string, Guid>();
                using (var dataContext = new PartDataContext())
                {
                    _UUIDMap = dataContext.PersonMappings.ToDictionary(pm => pm.CprNumber, pm => pm.UUID);
                }
            }
            if (!_UUIDMap.ContainsKey(pnr))
            {
                _UUIDMap[pnr] = Guid.NewGuid();
            }

            return(_UUIDMap[pnr]);
        }
Esempio n. 18
0
            public void InsertPerson_New_CorrectOutput()
            {
                using (var dataContext = new PartDataContext())
                {
                    var dbPerson = new Person()
                    {
                        UserInterfaceKeyText = Utilities.RandomCprNumber(), UUID = Guid.NewGuid()
                    };
                    var oioRegistration   = Utilities.CreateFakePerson();
                    var newDbRegistration = CprBroker.Engine.Local.UpdateDatabase.InsertPerson(dataContext, dbPerson, oioRegistration);

                    Assert.Greater(dataContext.GetChangeSet().Inserts.Count, 0);
                    Assert.AreEqual(0, dataContext.GetChangeSet().Updates.Count);
                    Assert.AreEqual(0, dataContext.GetChangeSet().Deletes.Count);

                    dataContext.SubmitChanges();
                }
            }
Esempio n. 19
0
        public IEnumerable <SubscriptionCriteriaMatch> GetDataChangeEventMatches(DataChangeEvent[] dataChangeEvents)
        {
            var personRegistrationIds = dataChangeEvents.Select(dce => dce.PersonRegistrationId).ToArray();

            var soegObject = Strings.Deserialize <SoegObjektType>(this.Criteria.ToString());

            using (var partDataContext = new PartDataContext())
            {
                // Add new persons
                var matchingPersons = CprBroker.Data.Part.PersonRegistrationKey.GetByCriteria(partDataContext, soegObject, personRegistrationIds).ToArray();
                var temp            = matchingPersons.Select(prk => new SubscriptionCriteriaMatch()
                {
                    SubscriptionCriteriaMatchId = Guid.NewGuid(),
                    DataChangeEventId           = dataChangeEvents.Where(dce => dce.PersonRegistrationId == prk.PersonRegistrationId).Select(dce => dce.DataChangeEventId).First(),
                });
                return(temp);
            }
        }
Esempio n. 20
0
        public override void ProcessPerson(string personRegId)
        {
            BrokerContext.Initialize(this.ApplicationToken, this.UserToken);

            var personRegistrationId = new Guid(personRegId);

            using (var dataContext = new PartDataContext(this.BrokerConnectionString))
            {
                CprBroker.Engine.Local.Admin.AddNewLog(System.Diagnostics.TraceEventType.Information, GetType().Name, string.Format("Processing registration {0}", personRegId), "", "");

                try
                {
                    var dbReg = dataContext.PersonRegistrations.Where(pr => pr.PersonRegistrationId == personRegistrationId).First();
                    var pnr   = dataContext.PersonMappings.Where(pm => pm.UUID == dbReg.UUID).Select(pm => pm.CprNumber).First();
                    Func <string, Guid> cpr2uuidFunc = relPnr =>
                    {
                        relPnr = relPnr.PadLeft(10, ' ');
                        return(dataContext.PersonMappings.Where(pm => pm.CprNumber == relPnr).Select(pm => pm.UUID).First());
                    };

                    //string oldContentsXml, oldSourceXml, newContentsXml, newSourceXml;

                    //TakeCopies(dbReg, out oldContentsXml, out oldSourceXml);

                    var oioReg = CreateXmlType(pnr, dbReg, cpr2uuidFunc);

                    dbReg.SourceObjects = System.Xml.Linq.XElement.Parse(oioReg.SourceObjectsXml);
                    dbReg.SetContents(oioReg);

                    //TakeCopies(dbReg, out newContentsXml, out newSourceXml);

                    //CompareContents(oioReg, oldContentsXml, newContentsXml);
                    //CompareSource(oldSourceXml, newSourceXml);

                    dataContext.SubmitChanges();
                    CprBroker.Engine.Local.Admin.AddNewLog(System.Diagnostics.TraceEventType.Information, GetType().Name, string.Format("Finished registration {0}", personRegId), "", "");
                }
                catch (Exception ex)
                {
                    CprBroker.Engine.Local.Admin.LogException(ex);
                    throw ex;
                }
            }
        }
Esempio n. 21
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), "", "");
         }
     }
 }
Esempio n. 22
0
            public void MergePersonRegistration_NewWithSource_CorrectSource(
                [Range(1, 10)] int dummy)
            {
                using (var dataContext = new PartDataContext())
                {
                    var oio = Utilities.CreateFakePerson(true);
                    var pId = new PersonIdentifier()
                    {
                        UUID = Guid.NewGuid(), CprNumber = Utilities.RandomCprNumber()
                    };
                    var ret = CprBroker.Engine.Local.UpdateDatabase.MergePersonRegistration(pId, oio, out personRegistrationId);
                    Assert.True(ret);

                    var dbPerson = dataContext.PersonRegistrations.Where(pr => pr.UUID == pId.UUID).FirstOrDefault();
                    Assert.NotNull(dbPerson);

                    var tmpElement = System.Xml.Linq.XElement.Parse(oio.SourceObjectsXml);
                    Assert.AreEqual(tmpElement.ToString(), dbPerson.SourceObjects.ToString());
                }
            }
Esempio n. 23
0
        public override string[] LoadCprNumbers()
        {
            Utilities.UpdateConnectionString(this.BrokerConnectionString);

            if (string.IsNullOrEmpty(SourceFile))
            {
                using (var dataContext = new PartDataContext(this.BrokerConnectionString))
                {
                    return(dataContext.PersonRegistrations
                           .OrderBy(pr => pr.PersonRegistrationId)
                           .Where(pr => pr.SourceObjects != null)
                           .Select(pr => string.Format("{0},{1}", pr.UUID, pr.PersonRegistrationId))
                           .ToArray());
                }
            }
            else
            {
                return(System.IO.File.ReadAllLines(SourceFile).Where(l => !string.IsNullOrEmpty(l)).ToArray());
            }
        }
Esempio n. 24
0
        public Guid[] Search(CprBroker.Schemas.Part.SoegInputType1 searchCriteria)
        {
            Guid[] ret = null;
            using (var dataContext = new PartDataContext())
            {
                int firstResults = 0;
                int.TryParse(searchCriteria.FoersteResultatReference, out firstResults);

                int maxResults = 0;
                int.TryParse(searchCriteria.MaksimalAntalKvantitet, out maxResults);
                if (maxResults <= 0)
                {
                    maxResults = 1000;
                }

                var result = PersonRegistration.GetUuidsByCriteria(dataContext, searchCriteria.SoegObjekt, firstResults, maxResults);
                ret = result.ToArray();
            }
            // TODO: filter by effect date
            return(ret);
        }
Esempio n. 25
0
            public void UpdatePersonLists_NotMatching_NotFound([ValueSource("MunicipalityCodes")] string municipalityCode)
            {
                Guid uuid        = Guid.NewGuid();
                Guid personRegId = Guid.NewGuid();

                var pers            = Utils.CreatePerson(uuid);
                var dbReg           = Utils.CreatePersonRegistration(pers, municipalityCode, personRegId, uuid);
                var dataChangeEvent = Utils.CreateDataChangeEvent(dbReg);
                var subscription    = Utils.CreateCriteriaSubscription(municipalityCode + "222");

                using (var cprDataContext = new PartDataContext())
                {
                    cprDataContext.Persons.InsertOnSubmit(pers);
                    cprDataContext.PersonRegistrations.InsertOnSubmit(dbReg);
                    cprDataContext.SubmitChanges();
                }

                var sss = subscription.GetDataChangeEventMatches(new DataChangeEvent[] { dataChangeEvent }).ToArray();

                Assert.IsEmpty(sss);
            }
            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);
                }
            }
            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);
                }
            }
Esempio n. 28
0
        public int AddMatchingSubscriptionPersons(EventBrokerDataContext eventDataContext, int batchSize)
        {
            using (var partDataContext = new PartDataContext())
            {
                // Read the next (n) persons with the latest registration of each
                var persons = partDataContext.Persons
                              .Where(p => p.UUID.CompareTo(this.LastCheckedUUID.Value) > 0)
                              .OrderBy(p => p.UUID)
                              .Select(p => new
                {
                    UUID = p.UUID,
                    PersonRegistrationId = p.PersonRegistrations
                                           .Where(pr => pr.BrokerUpdateDate <= this.Created)
                                           .OrderByDescending(pr => pr.RegistrationDate)
                                           .ThenByDescending(pr => pr.BrokerUpdateDate)
                                           .Select(pr => pr.PersonRegistrationId as Guid?)
                                           .FirstOrDefault()
                })
                              .Take(batchSize)
                              .ToArray();

                // Search for matching criteria
                var personRegistrationIds = persons.Where(p => p.PersonRegistrationId.HasValue).Select(p => p.PersonRegistrationId.Value).ToArray();
                var soegObject            = Strings.Deserialize <SoegObjektType>(this.Criteria.ToString());
                var matchingPersons       = CprBroker.Data.Part.PersonRegistrationKey.GetByCriteria(partDataContext, soegObject, personRegistrationIds).ToArray();

                this.LastCheckedUUID = (persons.Count() == batchSize) ? persons.Last().UUID : null as Guid?;
                var subscriptionPersons = matchingPersons.Select(mp => new SubscriptionPerson()
                {
                    Created              = DateTime.Now,
                    PersonUuid           = mp.UUID,
                    Removed              = null,
                    SubscriptionPersonId = Guid.NewGuid()
                });
                this.SubscriptionPersons.AddRange(subscriptionPersons);
                return(subscriptionPersons.Count());
            }
        }
Esempio n. 29
0
        public override void ProcessPerson(string pnr)
        {
            using (var dataContext = new PartDataContext())
            {
                var pm  = dataContext.PersonMappings.Where(p => p.CprNumber == pnr).Single();
                var per = dataContext.Persons.Where(p => p.UUID == pm.UUID).SingleOrDefault();
                PersonRegistration[] regs = null;
                var actros = new List <ActorRef>();
                if (per != null)
                {
                    regs = per.PersonRegistrations.ToArray();
                    foreach (var reg in regs)
                    {
                        if (reg.SourceObjects != null)
                        {
                            throw new Exception("Source not null");
                        }

                        var oio = PersonRegistration.ToXmlType(reg);
                        if (oio.AttributListe != null || oio.RelationListe != null || oio.TilstandListe != null)
                        {
                            throw new Exception("Contents not empty");
                        }

                        actros.Add(reg.ActorRef);
                    }


                    // Now delete the records
                    dataContext.PersonRegistrations.DeleteAllOnSubmit(regs);
                    dataContext.ActorRefs.DeleteAllOnSubmit(actros);
                    dataContext.Persons.DeleteOnSubmit(per);
                    dataContext.PersonMappings.DeleteOnSubmit(pm);

                    dataContext.SubmitChanges();
                }
            }
        }
Esempio n. 30
0
            public void EnsurePersonExists_Existing_Saved(
                [Random(0, 99, 10)] int index)
            {
                using (var dataContext = new PartDataContext())
                {
                    var dbPerson = dataContext.Persons.Skip(index).First();

                    var uuid = dbPerson.UUID;
                    var pnr  = dbPerson.UserInterfaceKeyText;

                    var person = CprBroker.Engine.Local.UpdateDatabase.EnsurePersonExists(dataContext, new CprBroker.Schemas.PersonIdentifier()
                    {
                        CprNumber = pnr, UUID = uuid
                    });
                    Assert.NotNull(person);
                    Assert.AreEqual(uuid, person.UUID);
                    Assert.AreEqual(pnr, person.UserInterfaceKeyText);

                    Assert.AreEqual(0, dataContext.GetChangeSet().Inserts.Count);
                    Assert.AreEqual(0, dataContext.GetChangeSet().Updates.Count);
                    Assert.AreEqual(0, dataContext.GetChangeSet().Deletes.Count);
                }
            }