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); }
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); }
public void ToVirkningType_Correct_CorrectFraTidspunkt( [Values(1, 3, 5)] int yearOffset) { DateTime date = DateTime.Today.AddYears(yearOffset); var virkning = new TilstandVirkningType() { FraTidspunkt = TidspunktType.Create(date) }; var result = virkning.ToVirkningType(); Assert.AreEqual(date, result.FraTidspunkt.ToDateTime()); }
public virtual TidspunktType ToTidspunktType() { return(TidspunktType.Create( Converters.GetMaxDate( Converters.ToDateTime(this.BirthRegistrationDate, this.BirthRegistrationDateUncertainty), Converters.ToDateTime(this.CprChurchTimestamp), Converters.ToDateTime(this.CprPersonTimestamp), Converters.ToDateTime(this.PNRMarkingDate, this.PNRMarkingDateUncertainty), Converters.ToDateTime(this.MunicipalityArrivalDate, MunicipalityArrivalDateUncertainty) ) )); }
public static TilstandVirkningType ToTilstandVirkningType(Effect db) { if (db != null) { return(new TilstandVirkningType() { AktoerRef = ActorRef.ToXmlType(db.ActorRef), CommentText = db.CommentText, FraTidspunkt = TidspunktType.Create(db.FromDate), }); } return(null); }
private static PersonRegistration[] MatchPersonRegistration(PersonIdentifier personIdentifier, RegistreringType1 oioRegistration, PartDataContext dataContext, out bool dataChanged) { //TODO: Modify this method to allow searching for registrations that have a fake date of Today, these should be matched by content rather than registration date dataChanged = false; // Match db registrations by UUID, ActorId and registration date var existingInDb = ( from dbReg in dataContext.PersonRegistrations where dbReg.UUID == personIdentifier.UUID && dbReg.RegistrationDate == TidspunktType.ToDateTime(oioRegistration.Tidspunkt) && ( ( oioRegistration.AktoerRef == null && dbReg.ActorRef == null ) || ( oioRegistration.AktoerRef != null && dbReg.ActorRef != null && oioRegistration.AktoerRef.Item == dbReg.ActorRef.Value && (int)oioRegistration.AktoerRef.ItemElementName == dbReg.ActorRef.Type ) ) select dbReg ).ToArray(); var ret = new List <PersonRegistration>(existingInDb.Length); // Perform a content match if key match is found foreach (var dbReg in existingInDb) { if (dbReg.Equals(oioRegistration)) { // Exact content match ret.Add(dbReg); } else { // Content match due to bug fix if (UpdateRules.MatchRule.ApplyRules(dbReg, oioRegistration)) { dataChanged = true; ret.Add(dbReg); } } } return(ret.ToArray()); }
internal VirkningType GetVirkning(DateTime timestamp) { TidspunktType beginTime = new TidspunktType(); beginTime.Item = timestamp.Date + new TimeSpan(0, 0, 0); VirkningType virkning = new VirkningType(); virkning.AktoerRef = GetOrganisationReference(); virkning.AktoerTypeKode = AktoerTypeKodeType.Organisation; virkning.AktoerTypeKodeSpecified = true; virkning.FraTidspunkt = beginTime; return(virkning); }
public RegistreringType1 ToRegisteringType1(Func <string, Guid> cpr2uuidConverter, DPRDataContext dataContext) { RegistreringType1 ret = new RegistreringType1() { AttributListe = ToAttributListeType(), TilstandListe = ToTilstandListeType(), RelationListe = ToRelationListeType(cpr2uuidConverter, dataContext), AktoerRef = Constants.Actor, CommentText = Constants.CommentText, LivscyklusKode = LivscyklusKodeType.Rettet, Tidspunkt = TidspunktType.Create(this.RegistrationDate), Virkning = null }; ret.CalculateVirkning(); return(ret); }
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), "", ""); } } }
public EgenskabType ToEgenskabType() { var ret = new EgenskabType() { BirthDate = this.PersonTotal.ToBirthdate().Value, // Birth registration authority //TODO: Is this assignment correct? FoedselsregistreringMyndighedNavn = PersonTotal.BirthPlaceOfRegistration, // Place of birth // Shall this be null? Is it birthplace or name at birth - I think it should be null FoedestedNavn = PersonTotal.BirthplaceText, PersonGenderCode = Utilities.PersonGenderCodeTypeFromChar(PersonTotal.Sex), NavnStruktur = PersonName != null?PersonName.ToNavnStrukturType() : null, AndreAdresser = Address != null?Address.ToForeignAddressFromSupplementary() : null, //No contact channels implemented KontaktKanal = null, //Next of kin (nearest relative). Not implemented NaermestePaaroerende = null, //TODO: Fill this object Virkning = VirkningType.Create(Utilities.GetMaxDate(PersonTotal.DateOfBirth, PersonTotal.StatusDate), null) }; if (PersonName != null) { ret.Virkning = VirkningType.Compose( ret.Virkning, VirkningType.Create(Utilities.DateFromDecimal(PersonName.NameStartDate), null), VirkningType.Create(Utilities.DateFromDecimal(PersonName.AddressingNameDate), null) ); } // TODO: More effect date fields here ret.Virkning.FraTidspunkt = TidspunktType.Create(Utilities.GetMaxDate(PersonTotal.DateOfBirth)); return(ret); }
public RegistreringType1 ToRegistreringType1(Func <string, Guid> cpr2uuidFunc) { var addressResponse = new WS_AS78205.EnglishAS78205Response(AS78205Response); var detailsResponse = new WS_AS78207.EnglishAS78207Response(AS78207Response); var ret = new RegistreringType1() { AttributListe = detailsResponse.ToAttributListeType(addressResponse), TilstandListe = detailsResponse.ToTilstandListeType(), RelationListe = ToRelationListeType(detailsResponse, cpr2uuidFunc), AktoerRef = Constants.Actor, CommentText = Constants.CommentText, LivscyklusKode = LivscyklusKodeType.Rettet, Tidspunkt = TidspunktType.Create(detailsResponse.GetRegistrationDate()), Virkning = null, SourceObjectsXml = Strings.SerializeObject(this) }; ret.CalculateVirkning(); return(ret); }
public TidspunktType ToTidspunktType() { // TODO: Is this the correct registration date regarding the case of online TCP queries? return(TidspunktType.Create(this.RegistrationDate)); }
public RegisterOplysningType ToRegisterOplysningType(WS_AS78205.EnglishAS78205Response addressResponse) { var ret = new RegisterOplysningType() { Item = null, Virkning = VirkningType.Create(null, null) }; // TODO: Always return CprBorgerType !!!! if (string.Equals(NationalityCode, Constants.DanishNationalityCode)) { ret.Item = new CprBorgerType() { PersonCivilRegistrationIdentifier = PNR, PersonNationalityCode = Schemas.Part.CountryIdentificationCodeType.Create(CprBroker.Schemas.Part._CountryIdentificationSchemeType.imk, NationalityCode), FolkeregisterAdresse = addressResponse.ToAdresseType(), // Research protection ForskerBeskyttelseIndikator = Protection.Equals(Constants.ResearchProtection), // Name and address protection NavneAdresseBeskyttelseIndikator = Protection.Equals(Constants.AddressProtection), // Church membership // TODO: Shall this be ChurchRelationship = 'F'? FolkekirkeMedlemIndikator = ChurchRelationship.Length > 0, // No address note AdresseNoteTekst = null, //PNR validity status // TODO: Shall this be set as other providers, false if status is 30,50,60 ? PersonNummerGyldighedStatusIndikator = int.Parse(ReturnCode) < 10, // TODO: Check if this is correct TelefonNummerBeskyttelseIndikator = Protection.Equals(Constants.AddressProtection), }; ret.Virkning.FraTidspunkt = TidspunktType.Create(Utilities.GetMaxDate(AddressDate, RelocationDate, ImmigrationDate)); } else if (!string.IsNullOrEmpty(NationalityCode)) { // TODO: Validate all data in this structure ret.Item = new UdenlandskBorgerType() { // Birth country.Not in KMD FoedselslandKode = null, // TODO: What is that? PersonIdentifikator = "", // Languages. Not implemented here SprogKode = new CprBroker.Schemas.Part.CountryIdentificationCodeType[0], // Citizenships PersonNationalityCode = new CprBroker.Schemas.Part.CountryIdentificationCodeType[] { CprBroker.Schemas.Part.CountryIdentificationCodeType.Create(CprBroker.Schemas.Part._CountryIdentificationSchemeType.imk, NationalityCode) }, PersonCivilRegistrationReplacementIdentifier = PNR, }; ret.Virkning.FraTidspunkt = TidspunktType.Create(Utilities.GetMaxDate(ImmigrationDate, AbroadDate)); } else { // TODO: Validate all data in this structure ret.Item = new UkendtBorgerType() { PersonCivilRegistrationReplacementIdentifier = PNR, }; ret.Virkning.FraTidspunkt = TidspunktType.Create(Utilities.GetMaxDate(AbroadDate, AddressDate, DisempowermentDate, ImmigrationDate, PaternityDate, RelocationDate, StatusDate)); } return(ret); }