private static void WriteOneNote(StreamWriter file, NoteRecord noteRecord) { //file.WriteLine("0 @{0}@ NOTE", noteRecord.Ident); var tag = string.Format("@{0}@ NOTE", noteRecord.Ident); WriteCommon.writeExtended(file, 0, tag, noteRecord.Text); WriteCommon.writeRecordTrailer(file, noteRecord, 1); }
private static void writeLink(StreamWriter file, IndiLink indiLink) { // TODO extra text var str = indiLink.Type == IndiLink.FAMS_TYPE ? "FAMS" : "FAMC"; WriteCommon.writeXrefIfNotEmpty(file, str, indiLink.Xref, 1); WriteCommon.writeIfNotEmpty(file, "PEDI", indiLink.Pedi, 2); WriteCommon.writeIfNotEmpty(file, "STAT", indiLink.Stat, 2); WriteCommon.writeSubNotes(file, indiLink, 2); }
private static void WriteOneRepo(StreamWriter file, Repository repository) { file.WriteLine("0 @{0}@ REPO", repository.Ident); // TODO a missing name is an error... WriteCommon.writeIfNotEmpty(file, "NAME", repository.Name, 1); WriteCommon.writeAddr(file, repository.Addr, 1); WriteCommon.writeRecordTrailer(file, repository, 1); }
internal static void writeEvents(StreamWriter file, List <IndiEvent> events, int level) { foreach (var indiEvent in events) { writeEventCommon(file, indiEvent, level); if (!string.IsNullOrWhiteSpace(indiEvent.Famc)) { // INDI.BIRT, INDI.CHR, INDI.ADOP WriteCommon.writeXrefIfNotEmpty(file, "FAMC", indiEvent.Famc, level + 1); WriteCommon.writeIfNotEmpty(file, "ADOP", indiEvent.FamcAdop, level + 2); } } }
private static void WriteOneObje(StreamWriter file, MediaRecord mediaRecord) { file.WriteLine("0 @{0}@ OBJE", mediaRecord.Ident); // TODO were 5.5 OBJE records converted to 5.5.1 ? kinda - don't have a REFN (error?) foreach (var mediaFile in mediaRecord.Files) { file.WriteLine("1 FILE {0}", mediaFile.FileRefn); WriteCommon.writeIfNotEmpty(file, "TITL", mediaFile.Title, 2); file.WriteLine("2 FORM {0}", mediaFile.Form); WriteCommon.writeIfNotEmpty(file, "TYPE", mediaFile.Type, 3); } WriteCommon.writeRecordTrailer(file, mediaRecord, 1); // TODO other lines /unknowns : don't have access to original text }
private static void WriteOneFam(StreamWriter file, FamRecord famRecord) { file.WriteLine("0 @{0}@ FAM", famRecord.Ident); WriteCommon.writeIfNotEmpty(file, "RESN", famRecord.Restriction, 1); // TODO multiple HUSB/WIFE? if (famRecord.Dads.Count > 0) { file.WriteLine("1 HUSB @{0}@", famRecord.Dads[0]); } if (famRecord.Moms.Count > 0) { file.WriteLine("1 WIFE @{0}@", famRecord.Moms[0]); } foreach (var child in famRecord.Childs) { file.WriteLine("1 CHIL @{0}@", child.Xref); if (!string.IsNullOrEmpty(child.FatherRelation)) { file.WriteLine("2 _FREL {0}", child.FatherRelation); } if (!string.IsNullOrEmpty(child.MotherRelation)) { file.WriteLine("2 _MREL {0}", child.MotherRelation); } } if (famRecord.ChildCount > 0) { file.WriteLine("1 NCHI {0}", famRecord.ChildCount); } WriteEvent.writeEvents(file, famRecord.FamEvents, 1); // TODO LDS Spouse Sealing // TODO why are INDI and FAM submitters treated different? foreach (var submitter in famRecord.FamSubm) { file.WriteLine("1 SUBM @{0}@", submitter); } WriteCommon.writeRecordTrailer(file, famRecord, 1); }
private static void WriteOneSour(StreamWriter file, SourceRecord sourceRecord) { file.WriteLine("0 @{0}@ SOUR", sourceRecord.Ident); if (sourceRecord.Data != null && sourceRecord.Data.Events.Count > 0) { file.WriteLine("1 DATA"); WriteCommon.writeIfNotEmpty(file, "AGNC", sourceRecord.Data.Agency, 2); foreach (var sourEvent in sourceRecord.Data.Events) { file.WriteLine("2 EVEN {0}", sourEvent.Text); WriteCommon.writeIfNotEmpty(file, "DATE", sourEvent.Date, 3); WriteCommon.writeIfNotEmpty(file, "PLAC", sourEvent.Place, 3); } } WriteCommon.writeExtIfNotEmpty(file, "AUTH", sourceRecord.Author, 1); WriteCommon.writeExtIfNotEmpty(file, "TITL", sourceRecord.Title, 1); WriteCommon.writeExtIfNotEmpty(file, "ABBR", sourceRecord.Abbreviation, 1); WriteCommon.writeExtIfNotEmpty(file, "PUBL", sourceRecord.Publication, 1); WriteCommon.writeExtIfNotEmpty(file, "TEXT", sourceRecord.Text, 1); // TODO have 5.5 repository citations been converted to 5.5.1? E.g. SOUR.REPO.MEDI? foreach (var repoCit in sourceRecord.Cits) { if (string.IsNullOrWhiteSpace(repoCit.Xref)) { file.WriteLine("1 REPO"); } else { file.WriteLine("1 REPO @{0}@", repoCit.Xref); } foreach (var callNum in repoCit.CallNums) { file.WriteLine("2 CALN {0}", callNum.Number); WriteCommon.writeIfNotEmpty(file, "MEDI", callNum.Media, 3); } WriteCommon.writeSubNotes(file, repoCit, 2); } WriteCommon.writeRecordTrailer(file, sourceRecord, 1); }
internal static void writeEventCommon(StreamWriter file, EventCommon data, int level) { WriteCommon.writeExtended(file, level, data.Tag, data.Descriptor); WriteCommon.writeIfNotEmpty(file, "TYPE", data.Type, level + 1); WriteCommon.writeIfNotEmpty(file, "DATE", data.Date, level + 1); WriteCommon.writeIfNotEmpty(file, "PLAC", data.Place, level + 1); // TODO place structure WriteCommon.writeIfNotEmpty(file, "AGNC", data.Agency, level + 1); WriteCommon.writeIfNotEmpty(file, "RELI", data.Religion, level + 1); WriteCommon.writeIfNotEmpty(file, "CAUS", data.Cause, level + 1); WriteCommon.writeIfNotEmpty(file, "RESN", data.Restriction, level + 1); WriteCommon.writeSubNotes(file, data, level + 1); WriteCommon.writeSourCit(file, data, level + 1); WriteCommon.writeObjeLink(file, data, level + 1); }
private static void WriteHead(StreamWriter file, HeadRecord rec) { // TODO SUBM info // TODO file notes // TODO destination path? // TODO date/time file.WriteLine("0 HEAD"); file.WriteLine("1 GEDC"); file.WriteLine("2 VERS 5.5.1"); file.WriteLine("2 FORM LINEAGE-LINKED"); file.WriteLine("1 CHAR UTF-8"); file.WriteLine("1 SOUR SharpGEDWriter"); // TODO not registered file.WriteLine("2 VERS V0.2-Alpha"); WriteCommon.writeSubNotes(file, rec); file.WriteLine("1 SUBM @S0@"); file.WriteLine("0 @S0@ SUBM"); }
// TODO more closely match PAF order? - specifically _UID // INDI records are written to be as close to PAF order as possible private static void WriteOneIndi(StreamWriter file, IndiRecord indiRecord) { file.WriteLine("0 @{0}@ INDI", indiRecord.Ident); WriteCommon.writeIfNotEmpty(file, "RESN", indiRecord.Restriction, 1); foreach (var nameRec in indiRecord.Names) { writeName(file, nameRec); // this convolution below due to: // 1 NAME Joe /Blow/ Jr. // vs // 1 NAME Joe // 2 GIVN Joe // 2 SURN Blow // TODO nice to output parts in specific order despite how they came in bool didGivn = false; bool didSurn = false; bool didNSFX = false; foreach (var tuple in nameRec.Parts) { file.WriteLine("2 {0} {1}", tuple.Item1, tuple.Item2); if (tuple.Item1 == "SURN") { didSurn = true; } if (tuple.Item1 == "GIVN") { didGivn = true; } if (tuple.Item1 == "NSFX") { didNSFX = true; } } if (!didGivn && !string.IsNullOrEmpty(nameRec.Names)) { file.WriteLine("2 GIVN {0}", nameRec.Names); } if (!didSurn && !string.IsNullOrEmpty(nameRec.Surname)) { file.WriteLine("2 SURN {0}", nameRec.Surname); } if (!didNSFX && !string.IsNullOrEmpty(nameRec.Suffix)) { file.WriteLine("2 NSFX {0}", nameRec.Suffix); } // TODO other name pieces WriteCommon.writeSubNotes(file, nameRec, 2); WriteCommon.writeSourCit(file, nameRec, 2); } // TODO want to init sex to 'U' but don't want to output it if not initialized as such if (string.IsNullOrEmpty(indiRecord.FullSex) && indiRecord.Sex != '\0' && indiRecord.Sex != 'U') { WriteCommon.writeIfNotEmpty(file, "SEX", indiRecord.Sex.ToString(), 1); } else { WriteCommon.writeIfNotEmpty(file, "SEX", indiRecord.FullSex, 1); } WriteEvent.writeEvents(file, indiRecord.Events, 1); WriteEvent.writeEvents(file, indiRecord.Attribs, 1); // Insure FAMS/FAMC output in consistent order if (indiRecord.Links != null) { foreach (var indiLink in indiRecord.Links.Where(indiLink => indiLink.Type == IndiLink.FAMS_TYPE)) { writeLink(file, indiLink); } foreach (var indiLink in indiRecord.Links.Where(indiLink => indiLink.Type == IndiLink.FAMC_TYPE)) { writeLink(file, indiLink); } } // TODO LDS events foreach (var aliasLink in indiRecord.AliasLinks) { WriteCommon.writeXrefIfNotEmpty(file, "ALIA", aliasLink, 1); } foreach (var assoRec in indiRecord.Assocs) { WriteCommon.writeXrefIfNotEmpty(file, "ASSO", assoRec.Ident, 1); WriteCommon.writeIfNotEmpty(file, "RELA", assoRec.Relation, 2); WriteCommon.writeSubNotes(file, assoRec, 2); WriteCommon.writeSourCit(file, assoRec, 2); } // Different from FAM because there are different types foreach (var submitter in indiRecord.Submitters) { string tag = ""; switch (submitter.SubmitterType) { case Submitter.SubmitType.SUBM: tag = "SUBM"; break; case Submitter.SubmitType.ANCI: tag = "ANCI"; break; case Submitter.SubmitType.DESI: tag = "DESI"; break; } file.WriteLine("1 {0} @{1}@", tag, submitter.Xref); } WriteCommon.writeRecordTrailer(file, indiRecord, 1); }