public IndividualClass DecodeIndividual(HttpPerson person) { if (person != null) { IndividualClass individual = new IndividualClass(); PersonalNameClass name = new PersonalNameClass(); if (person.id != null) { individual.SetXrefName(person.id.Substring(8)); // skip "profile-" } if (person.first_name != null) { name.SetName(PersonalNameClass.PartialNameType.GivenName, person.first_name); } if (person.last_name != null) { name.SetName(PersonalNameClass.PartialNameType.Surname, person.last_name); } if (person.former_name != null) { name.SetName(PersonalNameClass.PartialNameType.BirthSurname, person.former_name); } name.SanityCheck(); individual.SetPersonalName(name); if (person.gender != null) { switch (person.gender) { case "male": individual.SetSex(IndividualClass.IndividualSexType.Male); break; case "female": individual.SetSex(IndividualClass.IndividualSexType.Female); break; } } if (person.birth_date != null) { FamilyDateTimeClass birthDate = new FamilyDateTimeClass( person.birth_date.gedcom); individual.AddEvent(new IndividualEventClass(IndividualEventClass.EventType.Birth, birthDate)); } if (person.death_date != null) { FamilyDateTimeClass deathDate = new FamilyDateTimeClass( person.death_date.gedcom); individual.AddEvent(new IndividualEventClass(IndividualEventClass.EventType.Death, deathDate)); } return(individual); } return(null); }
void DecodeEvent(ref IndividualClass person, ParsePersonState evType, string eventString) { switch (evType) { case ParsePersonState.Birth: { person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Birth, false)); } break; case ParsePersonState.Baptism: { person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Baptism, false)); } break; case ParsePersonState.Death: { person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Death, false)); } break; case ParsePersonState.Burial: { person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Burial, false)); } break; case ParsePersonState.Occupation: { person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Occupation, true)); } break; /*case ParsePersonState.Fosterchild: * { * IndividualEventClass occupation = new IndividualEventClass(IndividualEventClass.EventType.Adoption); * occupation.AddNote(eventString); * trace.TraceInformation("fosterchild " + eventString + " => " + occupation); * person.AddEvent(occupation); * } * break;*/ case ParsePersonState.Move: { person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Immigration, true)); } break; case ParsePersonState.Source: { SourceDescriptionClass source = new SourceDescriptionClass(eventString); trace.TraceInformation("source " + eventString + " => " + source); person.AddSource(source); } break; case ParsePersonState.Lived: { person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Residence, true)); } break; case ParsePersonState.Changed: { person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.RecordUpdate, true)); } break; case ParsePersonState.ChildFamily: { string familyId = ""; foreach (char ch in eventString) { if ((ch >= '0') && (ch <= '9') || (ch == ':')) { familyId += ch; } } string familyXref = xrefMapLists.GetMapper(XrefType.Family).GetXRef(familyId, false); person.AddRelation(new FamilyXrefClass(familyXref), IndividualClass.RelationType.Child); trace.TraceInformation("child in " + familyId + "=" + familyXref); FamilyClass family = familyTree.GetFamily(familyXref); if (family == null) { family = new FamilyClass(); family.SetXrefName(familyXref); } family.AddRelation(new IndividualXrefClass(person.GetXrefName()), FamilyClass.RelationType.Child); familyTree.AddFamily(family); } break; case ParsePersonState.SpouseFamily: { string familyId = ""; foreach (char ch in eventString) { if ((ch >= '0') && (ch <= '9') || (ch == ':')) { familyId += ch; } } string familyXref = xrefMapLists.GetMapper(XrefType.Family).GetXRef(familyId, false); person.AddRelation(new FamilyXrefClass(familyXref), IndividualClass.RelationType.Spouse); trace.TraceInformation("spouse in " + familyId + "=" + familyXref); FamilyClass family = familyTree.GetFamily(familyXref); if (family == null) { family = new FamilyClass(); family.SetXrefName(familyXref); } family.AddRelation(new IndividualXrefClass(person.GetXrefName()), FamilyClass.RelationType.Parent); familyTree.AddFamily(family); } break; } }