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 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); }