CreateTree
This commit is contained in:
@ -13,11 +13,11 @@ public interface IPerson
|
||||
Models.Person TestStatic_GetPerson(char[] personCharacters, string personDisplayDirectoryName, long personKey, Models.PersonBirthday personBirthday) =>
|
||||
GetPerson(personCharacters, personDisplayDirectoryName, personKey, personBirthday);
|
||||
static Models.Person GetPerson(char[] personCharacters, string personDisplayDirectoryName, long personKey, Models.PersonBirthday personBirthday) =>
|
||||
Person.GetPerson(personKey, personBirthday, personDisplayDirectoryName.Split(personCharacters));
|
||||
Person.GetPerson(Array.Empty<string>(), null, personKey, personBirthday, personDisplayDirectoryName.Split(personCharacters));
|
||||
|
||||
Models.Person TestStatic_GetPerson(long personKey, string[] segments) =>
|
||||
GetPerson(personKey, segments);
|
||||
static Models.Person GetPerson(long personKey, string[] segments) =>
|
||||
Person.GetPerson(personKey, IPersonBirthday.GetPersonBirthday(personKey), segments);
|
||||
Models.Person TestStatic_GetPerson(string[] personDisplayDirectoryAllFiles, string personKeyFormatted, long personKey, string[] segments) =>
|
||||
GetPerson(personDisplayDirectoryAllFiles, personKeyFormatted, personKey, segments);
|
||||
static Models.Person GetPerson(string[] personDisplayDirectoryAllFiles, string personKeyFormatted, long personKey, string[] segments) =>
|
||||
Person.GetPerson(personDisplayDirectoryAllFiles, personKeyFormatted, personKey, IPersonBirthday.GetPersonBirthday(personKey), segments);
|
||||
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
using System.Text;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class Person
|
||||
@ -15,7 +17,42 @@ internal abstract class Person
|
||||
return new(personBirthday, personKeyFormatted);
|
||||
}
|
||||
|
||||
internal static Models.Person GetPerson(long personKey, Models.PersonBirthday personBirthday, string[] segments)
|
||||
private static void WriteGedFile(string? personKeyFormatted, Models.PersonBirthday personBirthday, Models.PersonName name, string[] matches)
|
||||
{
|
||||
string[] pGedFiles = (from l in matches where l.EndsWith(".pged") select l).ToArray();
|
||||
if (!pGedFiles.Any())
|
||||
{
|
||||
StringBuilder stringBuilder = new();
|
||||
_ = stringBuilder.Append("0 @I").Append(personKeyFormatted).AppendLine("@ INDI");
|
||||
_ = stringBuilder.Append("1 NAME ").Append(name.First.Value).Append(" /").Append(name.Last.Value).AppendLine("/");
|
||||
if (!string.IsNullOrEmpty(name.First.Value))
|
||||
_ = stringBuilder.Append("2 GIVN ").AppendLine(name.First.Value);
|
||||
if (!string.IsNullOrEmpty(name.Last.Value))
|
||||
_ = stringBuilder.Append("2 SURN ").AppendLine(name.Last.Value);
|
||||
if (!string.IsNullOrEmpty(name.Alias.Value))
|
||||
{
|
||||
_ = stringBuilder.Append("2 NICK ").AppendLine(name.Alias.Value);
|
||||
if (name.Alias.Value.Contains(" Jr"))
|
||||
_ = stringBuilder.Append("2 NSFX ").AppendLine("Jr");
|
||||
else if (name.Alias.Value.Contains(" Sr"))
|
||||
_ = stringBuilder.Append("2 NSFX ").AppendLine("Sr");
|
||||
}
|
||||
_ = stringBuilder.AppendLine("1 SEX U");
|
||||
if (!IPersonBirthday.IsCounterPersonBirthday(personBirthday))
|
||||
{
|
||||
_ = stringBuilder.AppendLine("1 BIRT");
|
||||
_ = stringBuilder.Append("2 DATE ").AppendLine(personBirthday.Value.ToString("dd MMM yyyy"));
|
||||
}
|
||||
string? directory = Path.GetDirectoryName(matches[0]);
|
||||
if (directory is null)
|
||||
throw new Exception();
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
File.WriteAllText(Path.Combine(directory, $"{personKeyFormatted}.pged"), stringBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
internal static Models.Person GetPerson(string[] personDisplayDirectoryAllFiles, string? personKeyFormatted, long personKey, Models.PersonBirthday personBirthday, string[] segments)
|
||||
{
|
||||
Models.Person result;
|
||||
const int zero = 0;
|
||||
@ -26,6 +63,9 @@ internal abstract class Person
|
||||
List<Models.PersonComment> comments = new();
|
||||
List<Models.PersonAddress> addresses = new();
|
||||
Models.PersonName name = PersonName.Create(segments[zero]);
|
||||
string[] matches = (from l in personDisplayDirectoryAllFiles where !string.IsNullOrEmpty(personKeyFormatted) && l.Contains(personKeyFormatted) select l).ToArray();
|
||||
if (matches.Any())
|
||||
WriteGedFile(personKeyFormatted, personBirthday, name, matches);
|
||||
result = new(id, personBirthday, name, comments, urls, numbers, emails, addresses);
|
||||
return result;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ internal abstract class PersonBirthday
|
||||
internal static bool IsCounterPersonBirthday(Models.PersonBirthday personBirthday)
|
||||
{
|
||||
bool result;
|
||||
if (personBirthday.Value.Year < 1826)
|
||||
if (personBirthday.Value.Year < 1809)
|
||||
result = true;
|
||||
else
|
||||
result = false;
|
||||
|
@ -15,7 +15,7 @@ internal abstract class PersonContainer
|
||||
if (personDisplayDirectoryAllFile.EndsWith(".lnk"))
|
||||
continue;
|
||||
(id, normalizedRectangle) = IMapping.GetConverted(facesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
if (id is not null && normalizedRectangle is not null && !personDisplayDirectoryAllFile.EndsWith(".json"))
|
||||
if (id is not null && normalizedRectangle is not null)
|
||||
continue;
|
||||
checkDirectory = Path.GetDirectoryName(personDisplayDirectoryAllFile);
|
||||
if (string.IsNullOrEmpty(checkDirectory))
|
||||
@ -55,7 +55,7 @@ internal abstract class PersonContainer
|
||||
continue;
|
||||
personKey = orderedPersonBirthdays[zero].Value.Ticks;
|
||||
}
|
||||
person = IPerson.GetPerson(personKey, segments);
|
||||
person = IPerson.GetPerson(personDisplayDirectoryAllFiles, personKeyFormatted, personKey, segments);
|
||||
personContainer = new(approximateYears, @char, person, orderedPersonBirthdays, personDisplayDirectoryAllFiles, personDisplayDirectoryName, personKey);
|
||||
results.Add(new(personKey, personContainer));
|
||||
}
|
||||
|
Reference in New Issue
Block a user