diff --git a/Instance/DlibDotNet.cs b/Instance/DlibDotNet.cs index 49f7f61..93bf17a 100644 --- a/Instance/DlibDotNet.cs +++ b/Instance/DlibDotNet.cs @@ -1065,7 +1065,7 @@ public partial class DlibDotNet "1 GEDC", "2 VERS 5.5.1", "2 FORM LINEAGE-LINKED", - "1 SUBM @1980-01-17_00@", + "1 SUBM @1980-01-17_05@", "2 NAME Mike Phares Jr", "1 SUBN", }; diff --git a/Shared/Models/Stateless/Methods/Person.cs b/Shared/Models/Stateless/Methods/Person.cs index cbce056..8c891e3 100644 --- a/Shared/Models/Stateless/Methods/Person.cs +++ b/Shared/Models/Stateless/Methods/Person.cs @@ -23,31 +23,26 @@ internal abstract class Person string? directory = Path.GetDirectoryName(matches[0]); if (directory is null) throw new Exception(); - List pGedLines = new(); + string? sexLine; + string? deathLine = null; string nameLine = $"1 NAME {name.First.Value} /{name.Last.Value}/"; - pGedLines.Add($"0 @I{personKeyFormatted}@ INDI"); - pGedLines.Add(nameLine); - if (!string.IsNullOrEmpty(name.First.Value)) - pGedLines.Add($"2 GIVN {name.First.Value}"); - if (!string.IsNullOrEmpty(name.Last.Value)) - pGedLines.Add($"2 SURN {name.Last.Value}"); - if (!string.IsNullOrEmpty(name.Alias.Value)) + if (personKeyFormatted[^2..] is "23" or "21" or "19" or "17" or "15") { - pGedLines.Add($"2 NICK {name.Alias.Value}"); - if (name.Alias.Value.Contains(" Jr")) - pGedLines.Add("2 NSFX Jr"); - else if (name.Alias.Value.Contains(" Sr")) - pGedLines.Add("2 NSFX Sr"); + sexLine = "1 SEX M"; + deathLine = "1 DEAT Y"; } - if (personKeyFormatted[^2..] == "23") - pGedLines.Add("1 SEX F"); - else if (personKeyFormatted[^2..] == "22") - pGedLines.Add("1 SEX M"); - else if (personKeyFormatted[^2..] == "21") - pGedLines.Add("1 SEX U"); + else if (personKeyFormatted[^2..] is "22" or "20" or "18" or "16" or "14") + { + sexLine = "1 SEX F"; + deathLine = "1 DEAT Y"; + } + else if (personKeyFormatted[^2..] is "13" or "11" or "09" or "07" or "05") + sexLine = "1 SEX M"; + else if (personKeyFormatted[^2..] is "12" or "10" or "08" or "06" or "04") + sexLine = "1 SEX F"; else { - string? sexLine = null; + sexLine = null; // string[] sourceLines = File.ReadAllLines("D:/1) Images A/Images-9b89679-Results/A2) People/9b89679/([])/FamilyEcho/638157228251558818-RootsMagic-Export.ged"); string[] sourceLines = File.ReadAllLines("D:/1) Images A/Images-9b89679-Results/A2) People/9b89679/([])/638157314010628679.ged"); for (int i = 0; i < sourceLines.Length; i++) @@ -60,37 +55,57 @@ internal abstract class Person if (sourceLines[j].StartsWith("0 @I")) break; if (sourceLines[j].StartsWith("1 SEX ")) - { sexLine = sourceLines[j]; - break; - } + else if (sourceLines[j].StartsWith("1 DEAT ")) + deathLine = sourceLines[j]; } - if (sexLine is not null) - break; } if (sexLine is null) - pGedLines.Add("1 SEX U"); + sexLine = "1 SEX U"; else { - pGedLines.Add($"1 SEX {sexLine[6]}"); - string sex = sexLine[6] is 'F' ? "23" : sexLine[6] is 'M' ? "22" : sexLine[6] is 'U' ? "21" : throw new NotImplementedException(); + string sex; + if (deathLine is null or not "1 DEAT Y") + sex = sexLine[6] is 'M' ? "05" : sexLine[6] is 'F' ? "04" : sexLine[6] is 'U' ? "02" : throw new NotImplementedException(); + else + sex = sexLine[6] is 'M' ? "15" : sexLine[6] is 'F' ? "14" : sexLine[6] is 'U' ? "03" : throw new NotImplementedException(); if (directory.EndsWith("00")) directory = string.Concat(directory[..^2], sex); else if (directory.EndsWith("01")) directory = string.Concat(directory[..^2], sex); - else if (directory.EndsWith("04")) // Cameran - directory = string.Concat(directory[..^2], sex); - else if (directory.EndsWith("05")) // Daisy - directory = string.Concat(directory[..^2], sex); - else if (directory.EndsWith("18")) // Meghan - directory = string.Concat(directory[..^2], sex); - else if (directory.EndsWith("20")) // Joey - directory = string.Concat(directory[..^2], sex); + // else if (directory.EndsWith("04")) // Cameran + // directory = string.Concat(directory[..^2], sex); + // else if (directory.EndsWith("05")) // Daisy + // directory = string.Concat(directory[..^2], sex); + // else if (directory.EndsWith("18")) // Meghan + // directory = string.Concat(directory[..^2], sex); + // else if (directory.EndsWith("20")) // Joey + // directory = string.Concat(directory[..^2], sex); else throw new NotImplementedException(); personKeyFormatted = $"{personKeyFormatted[..^2]}{sex}"; } } + List pGedLines = new() + { + $"0 @I{personKeyFormatted}@ INDI", + nameLine + }; + if (!string.IsNullOrEmpty(name.First.Value)) + pGedLines.Add($"2 GIVN {name.First.Value}"); + if (!string.IsNullOrEmpty(name.Last.Value)) + pGedLines.Add($"2 SURN {name.Last.Value}"); + if (!string.IsNullOrEmpty(name.Alias.Value)) + { + pGedLines.Add($"2 NICK {name.Alias.Value}"); + if (name.Alias.Value.Contains(" Jr")) + pGedLines.Add("2 NSFX Jr"); + else if (name.Alias.Value.Contains(" Sr")) + pGedLines.Add("2 NSFX Sr"); + } + pGedLines.Add(sexLine); + if (!string.IsNullOrEmpty(deathLine)) + pGedLines.Add(deathLine); if (!IPersonBirthday.IsCounterPersonBirthday(personBirthday)) { pGedLines.Add("1 BIRT");