Removed Genealogical Data Communication files
This commit is contained in:
parent
a95639153e
commit
9686b93617
@ -131,22 +131,10 @@ public partial class DlibDotNet
|
||||
if (configuration.JLinks.Length > 0)
|
||||
{
|
||||
string a2PeopleSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration.PropertyConfiguration, nameof(A2_People), "{}");
|
||||
_JLinkResolvedDirectories.AddRange(Map.Models.Stateless.Methods.IMapLogic.GetJLinkDirectories(configuration.JLinks, configuration.PersonBirthdayFormat, configuration.PersonCharacters.ToArray(), a2PeopleSingletonDirectory, a2PeopleContentDirectory));
|
||||
_JLinkResolvedDirectories.AddRange(Map.Models.Stateless.Methods.IMapLogic.GetJLinkDirectories(configuration.GenealogicalDataCommunicationFile, configuration.JLinks, configuration.PersonBirthdayFormat, configuration.PersonCharacters.ToArray(), a2PeopleSingletonDirectory, a2PeopleContentDirectory));
|
||||
if (_JLinkResolvedDirectories.Count == 0)
|
||||
throw new Exception(nameof(Map.Models.Stateless.Methods.IMapLogic.GetJLinkDirectories));
|
||||
}
|
||||
GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections = IGenealogicalDataCommunication.GetIndividuals(configuration.GenealogicalDataCommunicationFile, requireNickName: true);
|
||||
if (!string.IsNullOrEmpty(configuration.GenealogicalDataCommunicationFile) && genealogicalDataCommunicationCollections.HeaderLines.Any() && genealogicalDataCommunicationCollections.Individuals.Any() && genealogicalDataCommunicationCollections.FamilyGroupLines.Any() && genealogicalDataCommunicationCollections.FooterLines.Any())
|
||||
{
|
||||
TimeSpan a2LastWriteTimeTimeSpan = new(ticks - new DirectoryInfo(a2PeopleContentDirectory).LastWriteTime.Ticks);
|
||||
if (a2LastWriteTimeTimeSpan.TotalDays > 1)
|
||||
{
|
||||
ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection = IGenealogicalDataCommunication.GetFamilyIndexToCollection(configuration.PersonBirthdayFormat, personContainers, genealogicalDataCommunicationCollections);
|
||||
if (familyIndexToCollection.Count != 0)
|
||||
IGenealogicalDataCommunication.MaybeWriteMarkDownFiles(configuration.MappingDefaultName, configuration.PersonBirthdayFormat, ticks, personContainers, genealogicalDataCommunicationCollections.Individuals, familyIndexToCollection, a2PeopleContentDirectory);
|
||||
Directory.SetLastWriteTime(a2PeopleContentDirectory, new(ticks));
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(
|
||||
@ -1273,8 +1261,6 @@ public partial class DlibDotNet
|
||||
int totalNotMapped = mapLogic.UpdateMappingFromPerson(distinctFilteredMappingCollection);
|
||||
string json = JsonSerializer.Serialize(distinctFilteredMappingCollection);
|
||||
File.WriteAllText(Path.Combine(eDistanceContentDirectory, $"{ticks}.json"), json);
|
||||
for (int i = 1; i < 5; i++)
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
foreach (string outputResolution in _Configuration.OutputResolutions)
|
||||
{
|
||||
if (_PropertyRootExistedBefore)
|
||||
|
@ -264,7 +264,7 @@ internal abstract class MapLogic
|
||||
if (personKeyFormattedToNewestPersonKeyFormatted.Count > 0 && newestPersonKeyFormatted is null)
|
||||
{
|
||||
timeSpan = new TimeSpan(DateTime.Now.Ticks - ticksDirectory.DirectoryTicks);
|
||||
if (timeSpan.TotalDays > 3)
|
||||
if (timeSpan.TotalDays > 7)
|
||||
throw new Exception($"{configuration.MappingDefaultName} are only allowed within x days!");
|
||||
}
|
||||
yearDirectories = Directory.GetDirectories(personKeyDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
@ -681,6 +681,8 @@ internal abstract class MapLogic
|
||||
DirectoryInfo directoryInfo;
|
||||
long? lastDirectoryTicks = null;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
for (int i = 1; i < 5; i++)
|
||||
_ = IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
string[] ticksDirectories = Directory.GetDirectories(eDistanceContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string ticksDirectory in ticksDirectories)
|
||||
{
|
||||
@ -1251,7 +1253,39 @@ internal abstract class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static List<(string, long)> GetJLinkDirectories(string[] jLinks, string personBirthdayFormat, char[] personCharacters, string a2PeopleSingletonDirectory, string a2PeopleContentDirectory)
|
||||
private static List<(string, long)> GetGenealogicalDataCommunicationDirectories(string genealogicalDataCommunicationFile, string[] jLinks, string personBirthdayFormat)
|
||||
{
|
||||
List<(string, long)> results = new();
|
||||
string directory;
|
||||
DateTime dateTime;
|
||||
string[] personKeyDirectories;
|
||||
string[] personDisplayDirectoryNames;
|
||||
string personKeyFormattedDirectoryName;
|
||||
string? genealogicalDataCommunicationDirectory = Path.GetDirectoryName(genealogicalDataCommunicationFile);
|
||||
foreach (string jLink in jLinks)
|
||||
{
|
||||
if (genealogicalDataCommunicationDirectory is null)
|
||||
continue;
|
||||
directory = Path.Combine(genealogicalDataCommunicationDirectory, jLink);
|
||||
if (!Directory.Exists(directory))
|
||||
continue;
|
||||
personDisplayDirectoryNames = Directory.GetDirectories(directory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string personDisplayDirectoryName in personDisplayDirectoryNames)
|
||||
{
|
||||
personKeyDirectories = Directory.GetDirectories(personDisplayDirectoryName, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string personKeyFormattedDirectory in personKeyDirectories)
|
||||
{
|
||||
personKeyFormattedDirectoryName = Path.GetFileName(personKeyFormattedDirectory);
|
||||
if (personKeyFormattedDirectoryName.Length != personBirthdayFormat.Length || !DateTime.TryParseExact(personKeyFormattedDirectoryName, personBirthdayFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
|
||||
continue;
|
||||
results.Add((directory, dateTime.Ticks));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static List<(string, long)> GetJLinkDirectories(string genealogicalDataCommunicationFile, string[] jLinks, string personBirthdayFormat, char[] personCharacters, string a2PeopleSingletonDirectory, string a2PeopleContentDirectory)
|
||||
{
|
||||
List<(string, long)> results;
|
||||
string[] files;
|
||||
@ -1260,38 +1294,42 @@ internal abstract class MapLogic
|
||||
string checkDirectory;
|
||||
WindowsShortcut windowsShortcut;
|
||||
List<string> resolvedDirectories = new();
|
||||
List<(string, string, string)> a2PeopleSingletonDirectories = new();
|
||||
foreach (string directory in Directory.GetDirectories(a2PeopleSingletonDirectory, "*", SearchOption.AllDirectories))
|
||||
a2PeopleSingletonDirectories.Add((directory, Path.GetFileName(directory), Path.GetFileName(directory).Split(personCharacters).First()));
|
||||
foreach (string directoryName in jLinks)
|
||||
results = GetGenealogicalDataCommunicationDirectories(genealogicalDataCommunicationFile, jLinks, personBirthdayFormat);
|
||||
if (results.Count == 0 || results.Count < jLinks.Length)
|
||||
{
|
||||
checkDirectory = Path.Combine(a2PeopleContentDirectory, directoryName);
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
continue;
|
||||
files = Directory.GetFiles(checkDirectory, "*.lnk", SearchOption.TopDirectoryOnly);
|
||||
totalFiles += files.Length;
|
||||
foreach (string file in files)
|
||||
List<(string, string, string)> a2PeopleSingletonDirectories = new();
|
||||
foreach (string directory in Directory.GetDirectories(a2PeopleSingletonDirectory, "*", SearchOption.AllDirectories))
|
||||
a2PeopleSingletonDirectories.Add((directory, Path.GetFileName(directory), Path.GetFileName(directory).Split(personCharacters).First()));
|
||||
foreach (string directoryName in jLinks)
|
||||
{
|
||||
windowsShortcut = WindowsShortcut.Load(file);
|
||||
if (windowsShortcut.Path is null)
|
||||
checkDirectory = Path.Combine(a2PeopleContentDirectory, directoryName);
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
continue;
|
||||
if (Directory.Exists(windowsShortcut.Path))
|
||||
resolvedDirectories.Add(windowsShortcut.Path);
|
||||
else
|
||||
files = Directory.GetFiles(checkDirectory, "*.lnk", SearchOption.TopDirectoryOnly);
|
||||
totalFiles += files.Length;
|
||||
foreach (string file in files)
|
||||
{
|
||||
foundPath = TryToFind(personCharacters, a2PeopleSingletonDirectory, a2PeopleSingletonDirectories, file, windowsShortcut.Path);
|
||||
if (string.IsNullOrEmpty(foundPath))
|
||||
windowsShortcut = WindowsShortcut.Load(file);
|
||||
if (windowsShortcut.Path is null)
|
||||
continue;
|
||||
resolvedDirectories.Add(foundPath);
|
||||
if (Directory.Exists(windowsShortcut.Path))
|
||||
resolvedDirectories.Add(windowsShortcut.Path);
|
||||
else
|
||||
{
|
||||
foundPath = TryToFind(personCharacters, a2PeopleSingletonDirectory, a2PeopleSingletonDirectories, file, windowsShortcut.Path);
|
||||
if (string.IsNullOrEmpty(foundPath))
|
||||
continue;
|
||||
resolvedDirectories.Add(foundPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (totalFiles == resolvedDirectories.Count)
|
||||
results = GetJLinkResolvedDirectories(personBirthdayFormat, resolvedDirectories);
|
||||
else
|
||||
{
|
||||
resolvedDirectories.Clear();
|
||||
results = new();
|
||||
if (totalFiles == resolvedDirectories.Count)
|
||||
results = GetJLinkResolvedDirectories(personBirthdayFormat, resolvedDirectories);
|
||||
else
|
||||
{
|
||||
resolvedDirectories.Clear();
|
||||
results = new();
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
@ -28,9 +28,9 @@ public interface IMapLogic
|
||||
static Dictionary<int, Dictionary<int, Shared.Models.Mapping>> GetIdToWholePercentagesToFace(Shared.Models.Mapping[] mappingCollection) =>
|
||||
MapLogic.GetIdToWholePercentagesToFace(mappingCollection);
|
||||
|
||||
List<(string, long)> TestStatic_GetJLinkDirectories(string[] jLinks, string personBirthdayFormat, char[] personCharacters, string a2PeopleSingletonDirectory, string a2PeopleContentDirectory) =>
|
||||
GetJLinkDirectories(jLinks, personBirthdayFormat, personCharacters, a2PeopleSingletonDirectory, a2PeopleContentDirectory);
|
||||
static List<(string, long)> GetJLinkDirectories(string[] jLinks, string personBirthdayFormat, char[] personCharacters, string a2PeopleSingletonDirectory, string a2PeopleContentDirectory) =>
|
||||
MapLogic.GetJLinkDirectories(jLinks, personBirthdayFormat, personCharacters, a2PeopleSingletonDirectory, a2PeopleContentDirectory);
|
||||
List<(string, long)> TestStatic_GetJLinkDirectories(string genealogicalDataCommunicationFile, string[] jLinks, string personBirthdayFormat, char[] personCharacters, string a2PeopleSingletonDirectory, string a2PeopleContentDirectory) =>
|
||||
GetJLinkDirectories(genealogicalDataCommunicationFile, jLinks, personBirthdayFormat, personCharacters, a2PeopleSingletonDirectory, a2PeopleContentDirectory);
|
||||
static List<(string, long)> GetJLinkDirectories(string genealogicalDataCommunicationFile, string[] jLinks, string personBirthdayFormat, char[] personCharacters, string a2PeopleSingletonDirectory, string a2PeopleContentDirectory) =>
|
||||
MapLogic.GetJLinkDirectories(genealogicalDataCommunicationFile, jLinks, personBirthdayFormat, personCharacters, a2PeopleSingletonDirectory, a2PeopleContentDirectory);
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public record GenealogicalDataCommunication(DateTime? Birth,
|
||||
DateTime? Changed,
|
||||
DateTime? Death,
|
||||
string? GivenName,
|
||||
string? Id,
|
||||
string? Name,
|
||||
string NickName,
|
||||
char Sex,
|
||||
string? Suffix,
|
||||
string? SurName,
|
||||
string? UId)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, GenealogicalDataCommunicationSourceGenerationContext.Default.GenealogicalDataCommunication);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(GenealogicalDataCommunication))]
|
||||
internal partial class GenealogicalDataCommunicationSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(GenealogicalDataCommunication[]))]
|
||||
internal partial class GenealogicalDataCommunicationSourceCollectionGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public record GenealogicalDataCommunicationCollections(string[] HeaderLines,
|
||||
ReadOnlyDictionary<string, string[]> Individuals,
|
||||
List<string[]> FamilyGroupLines,
|
||||
ReadOnlyDictionary<string, string> IdToNick,
|
||||
string[] FooterLines)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public record GenealogicalDataCommunicationLines(string? Id,
|
||||
string? UId,
|
||||
string? Name,
|
||||
string? GivenName,
|
||||
string? SurName,
|
||||
string? Suffix,
|
||||
string? NickName,
|
||||
string? Sex,
|
||||
List<string> Birth,
|
||||
List<string> Death,
|
||||
List<string> Changed)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public record GenealogicalDataCommunicationRelation(int FamilyIndex,
|
||||
string Relation,
|
||||
string Id,
|
||||
string NickName,
|
||||
long? PersonKey,
|
||||
string? FullName,
|
||||
string? LineTwo)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,520 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class GenealogicalDataCommunication
|
||||
{
|
||||
|
||||
// ...
|
||||
|
||||
private record Record(Models.PersonContainer PersonContainer,
|
||||
string PersonKeyFormatted,
|
||||
string File,
|
||||
string RelationPersonKeyFormatted,
|
||||
string MergeWithLineTwo,
|
||||
string? RelationFullName);
|
||||
|
||||
private static string[] GetHeaderLines(string startsWith, string[] sourceLines)
|
||||
{
|
||||
List<string> results = new();
|
||||
for (int i = 0; i < sourceLines.Length; i++)
|
||||
{
|
||||
if (sourceLines[i].StartsWith(startsWith))
|
||||
break;
|
||||
results.Add(sourceLines[i]);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
private static ReadOnlyDictionary<string, string[]> Convert(Dictionary<string, List<string>> keyValuePairs)
|
||||
{
|
||||
Dictionary<string, string[]> results = new();
|
||||
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
|
||||
results.Add(keyValuePair.Key, keyValuePair.Value.ToArray());
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static GenealogicalDataCommunicationCollections GetIndividuals(string genealogicalDataCommunicationFile, bool requireNickName)
|
||||
{
|
||||
GenealogicalDataCommunicationCollections result;
|
||||
ReadOnlyDictionary<string, string[]> results;
|
||||
string? nick;
|
||||
string[] segments;
|
||||
List<string> lines = new();
|
||||
const string startsWith = "0 @";
|
||||
List<string> footerLines = new();
|
||||
List<string[]> familyGroupLines = new();
|
||||
Dictionary<string, string> idToNick = new();
|
||||
Dictionary<string, List<string>> keyValuePairs = new();
|
||||
string[] sourceLines = string.IsNullOrEmpty(genealogicalDataCommunicationFile) || !File.Exists(genealogicalDataCommunicationFile) ? Array.Empty<string>() : File.ReadAllLines(genealogicalDataCommunicationFile);
|
||||
string[] headerLines = GetHeaderLines(startsWith, sourceLines);
|
||||
for (int i = headerLines.Length; i < sourceLines.Length; i++)
|
||||
{
|
||||
if (!sourceLines[i].StartsWith(startsWith))
|
||||
continue;
|
||||
nick = null;
|
||||
lines.Add(sourceLines[i]);
|
||||
if (sourceLines[i].EndsWith("@ SOUR") || sourceLines[i].EndsWith("@ SUBM") || sourceLines[i].EndsWith("@ OBJE") || sourceLines[i].EndsWith("@ REPO"))
|
||||
continue;
|
||||
else if (sourceLines[i].EndsWith("@ FAM"))
|
||||
{
|
||||
lines.Clear();
|
||||
for (int j = sourceLines.Length - 1; j >= i; j--)
|
||||
{
|
||||
lines.Add(sourceLines[j]);
|
||||
if (sourceLines[j].First() == '0')
|
||||
{
|
||||
if (!sourceLines[j].EndsWith("@ FAM"))
|
||||
footerLines.AddRange(lines);
|
||||
else
|
||||
{
|
||||
lines.Reverse();
|
||||
familyGroupLines.Add(lines.ToArray());
|
||||
}
|
||||
lines.Clear();
|
||||
}
|
||||
}
|
||||
familyGroupLines.Reverse();
|
||||
footerLines.Reverse();
|
||||
break;
|
||||
}
|
||||
else if (sourceLines[i].EndsWith("@ INDI"))
|
||||
{
|
||||
segments = sourceLines[i].Split('@');
|
||||
for (int j = i + 1; j < sourceLines.Length; j++)
|
||||
{
|
||||
if (sourceLines[j].StartsWith(startsWith))
|
||||
break;
|
||||
lines.Add(sourceLines[j]);
|
||||
if (!sourceLines[j].StartsWith("2 NICK "))
|
||||
continue;
|
||||
nick = sourceLines[j][7..];
|
||||
if (segments.Length == 3)
|
||||
idToNick.Add(segments[1], nick);
|
||||
}
|
||||
if (requireNickName && string.IsNullOrEmpty(nick))
|
||||
throw new Exception(string.Join(Environment.NewLine, lines));
|
||||
nick ??= Guid.NewGuid().ToString();
|
||||
keyValuePairs.Add(nick, new());
|
||||
if (!lines.Any())
|
||||
continue;
|
||||
keyValuePairs[nick].AddRange(lines);
|
||||
lines.Clear();
|
||||
}
|
||||
else
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
results = Convert(keyValuePairs);
|
||||
result = new(headerLines, results, familyGroupLines, new(idToNick), footerLines.ToArray());
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static List<string> GetMappedLines(string genealogicalDataCommunicationFile, bool requireNickName)
|
||||
{
|
||||
List<string> results = new();
|
||||
Models.PersonBirthday personBirthday = new(DateTime.Now);
|
||||
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
||||
GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections = GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
|
||||
results.AddRange(genealogicalDataCommunicationCollections.HeaderLines);
|
||||
foreach (KeyValuePair<string, string[]> keyValuePair in genealogicalDataCommunicationCollections.Individuals)
|
||||
{
|
||||
genealogicalDataCommunicationLines = GetGenealogicalDataCommunicationLines(personBirthday, keyValuePair.Value);
|
||||
if (!string.IsNullOrEmpty(genealogicalDataCommunicationLines.Id))
|
||||
results.Add(genealogicalDataCommunicationLines.Id);
|
||||
if (!string.IsNullOrEmpty(genealogicalDataCommunicationLines.UId))
|
||||
results.Add(genealogicalDataCommunicationLines.UId);
|
||||
if (!string.IsNullOrEmpty(genealogicalDataCommunicationLines.Name))
|
||||
results.Add(genealogicalDataCommunicationLines.Name);
|
||||
if (!string.IsNullOrEmpty(genealogicalDataCommunicationLines.GivenName))
|
||||
results.Add(genealogicalDataCommunicationLines.GivenName);
|
||||
if (!string.IsNullOrEmpty(genealogicalDataCommunicationLines.SurName))
|
||||
results.Add(genealogicalDataCommunicationLines.SurName);
|
||||
if (!string.IsNullOrEmpty(genealogicalDataCommunicationLines.NickName))
|
||||
results.Add(genealogicalDataCommunicationLines.NickName);
|
||||
if (!string.IsNullOrEmpty(genealogicalDataCommunicationLines.Sex))
|
||||
results.Add(genealogicalDataCommunicationLines.Sex);
|
||||
results.AddRange(genealogicalDataCommunicationLines.Birth);
|
||||
results.AddRange(genealogicalDataCommunicationLines.Death);
|
||||
results.AddRange(genealogicalDataCommunicationLines.Changed);
|
||||
}
|
||||
for (int i = 0; i < genealogicalDataCommunicationCollections.FamilyGroupLines.Count; i++)
|
||||
results.AddRange(genealogicalDataCommunicationCollections.FamilyGroupLines[i]);
|
||||
results.AddRange(genealogicalDataCommunicationCollections.FooterLines);
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static GenealogicalDataCommunicationLines GetGenealogicalDataCommunicationLines(Models.PersonBirthday personBirthday, string[] individualsLines)
|
||||
{
|
||||
GenealogicalDataCommunicationLines result;
|
||||
string? idLine = null;
|
||||
string? sexLine = null;
|
||||
string? uIdLine = null;
|
||||
string? nameLine = null;
|
||||
string? suffixLine = null;
|
||||
string? surNameLine = null;
|
||||
string? nickNameLine = null;
|
||||
string? givenNameLine = null;
|
||||
List<string> birthLines = new();
|
||||
List<string> deathLines = new();
|
||||
List<string> changedLines = new();
|
||||
for (int i = 0; i < individualsLines.Length; i++)
|
||||
{
|
||||
if (idLine is null && individualsLines[i].EndsWith("@ INDI"))
|
||||
idLine = individualsLines[i];
|
||||
else if (uIdLine is null && individualsLines[i].StartsWith("1 _UID"))
|
||||
uIdLine = individualsLines[i];
|
||||
else if (nameLine is null && individualsLines[i].StartsWith("1 NAME"))
|
||||
nameLine = individualsLines[i];
|
||||
else if (givenNameLine is null && individualsLines[i].StartsWith("2 GIVN"))
|
||||
givenNameLine = individualsLines[i];
|
||||
else if (surNameLine is null && individualsLines[i].StartsWith("2 SURN"))
|
||||
surNameLine = individualsLines[i];
|
||||
else if (suffixLine is null && individualsLines[i].StartsWith("2 NSFX"))
|
||||
suffixLine = individualsLines[i];
|
||||
else if (nickNameLine is null && individualsLines[i].StartsWith("2 NICK"))
|
||||
nickNameLine = individualsLines[i];
|
||||
else if (sexLine is null && individualsLines[i].StartsWith("1 SEX"))
|
||||
sexLine = individualsLines[i];
|
||||
else if (!birthLines.Any() && individualsLines[i] == "1 BIRT")
|
||||
{
|
||||
birthLines.Add(individualsLines[i]);
|
||||
if (individualsLines.Length > i + 1 && individualsLines[i + 1].StartsWith("2 DATE"))
|
||||
{
|
||||
i += 1;
|
||||
birthLines.Add(individualsLines[i]);
|
||||
}
|
||||
}
|
||||
else if (!deathLines.Any() && individualsLines[i].StartsWith("1 DEAT"))
|
||||
{
|
||||
deathLines.Add(individualsLines[i]);
|
||||
if (individualsLines.Length > i + 1 && individualsLines[i + 1].StartsWith("2 DATE"))
|
||||
{
|
||||
i += 1;
|
||||
deathLines.Add(individualsLines[i]);
|
||||
}
|
||||
}
|
||||
else if (!changedLines.Any() && individualsLines[i] == "1 CHAN")
|
||||
{
|
||||
changedLines.Add(individualsLines[i]);
|
||||
if (individualsLines.Length > i + 1 && individualsLines[i + 1].StartsWith("2 DATE"))
|
||||
{
|
||||
i += 1;
|
||||
changedLines.Add(individualsLines[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!birthLines.Any())
|
||||
{
|
||||
birthLines.Add("1 BIRT");
|
||||
birthLines.Add($"2 DATE {personBirthday.Value:dd MMM yyyy}");
|
||||
}
|
||||
result = new(idLine, uIdLine, nameLine, givenNameLine, surNameLine, suffixLine, nickNameLine, sexLine, birthLines, deathLines, changedLines);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static Models.GenealogicalDataCommunication GetGenealogicalDataCommunication(bool first, GenealogicalDataCommunicationLines genealogicalDataCommunicationLines)
|
||||
{
|
||||
Models.GenealogicalDataCommunication result;
|
||||
DateTime? birth;
|
||||
DateTime? death;
|
||||
DateTime? changed;
|
||||
string? uId = string.IsNullOrEmpty(genealogicalDataCommunicationLines.UId) || !genealogicalDataCommunicationLines.UId.Contains("1 _UID ") ? null : genealogicalDataCommunicationLines.UId.Split("1 _UID ")[1];
|
||||
char sex = string.IsNullOrEmpty(genealogicalDataCommunicationLines.Sex) || !genealogicalDataCommunicationLines.Sex.Contains("1 SEX ") ? 'U' : genealogicalDataCommunicationLines.Sex.Split("1 SEX ")[1].First();
|
||||
string? name = string.IsNullOrEmpty(genealogicalDataCommunicationLines.Name) || !genealogicalDataCommunicationLines.Name.Contains("1 NAME ") ? null : genealogicalDataCommunicationLines.Name.Split("1 NAME ")[1];
|
||||
string? suffix = string.IsNullOrEmpty(genealogicalDataCommunicationLines.Suffix) || !genealogicalDataCommunicationLines.Suffix.Contains("2 NSFX ") ? null : genealogicalDataCommunicationLines.Suffix.Split("2 NSFX ")[1];
|
||||
string? surName = string.IsNullOrEmpty(genealogicalDataCommunicationLines.SurName) || !genealogicalDataCommunicationLines.SurName.Contains("2 SURN ") ? null : genealogicalDataCommunicationLines.SurName.Split("2 SURN ")[1];
|
||||
string nickName = string.IsNullOrEmpty(genealogicalDataCommunicationLines.NickName) || !genealogicalDataCommunicationLines.NickName.Contains("2 NICK ") ? throw new NotSupportedException() : genealogicalDataCommunicationLines.NickName.Split("2 NICK ")[1];
|
||||
string? givenName = string.IsNullOrEmpty(genealogicalDataCommunicationLines.GivenName) || !genealogicalDataCommunicationLines.GivenName.Contains("2 GIVN ") ? null : genealogicalDataCommunicationLines.GivenName.Split("2 GIVN ")[1];
|
||||
string? id = string.IsNullOrEmpty(genealogicalDataCommunicationLines.Id) || !genealogicalDataCommunicationLines.Id.Contains("0 @I") || !genealogicalDataCommunicationLines.Id.Contains("@ INDI") ? null : genealogicalDataCommunicationLines.Id.Split('@')[1][1..];
|
||||
string[] birthLines = (from l in genealogicalDataCommunicationLines.Birth where l.Contains("2 DATE ") select l.Split("2 DATE ")[1]).ToArray();
|
||||
string[] deathLines = (from l in genealogicalDataCommunicationLines.Death where l.Contains("2 DATE ") select l.Split("2 DATE ")[1]).ToArray();
|
||||
string[] changedLines = (from l in genealogicalDataCommunicationLines.Changed where l.Contains("2 DATE ") select l.Split("2 DATE ")[1]).ToArray();
|
||||
if (!birthLines.Any() || !DateTime.TryParse(birthLines[0], out DateTime parseBirth))
|
||||
birth = null;
|
||||
else
|
||||
birth = parseBirth;
|
||||
if (!deathLines.Any() || !DateTime.TryParse(deathLines[0], out DateTime parseDeath))
|
||||
death = null;
|
||||
else
|
||||
death = parseDeath;
|
||||
if (!changedLines.Any() || !DateTime.TryParse(changedLines[0], out DateTime parseChanged))
|
||||
changed = null;
|
||||
else
|
||||
changed = parseChanged;
|
||||
if (birth is not null)
|
||||
{
|
||||
bool alive = death is null && !genealogicalDataCommunicationLines.Death.Any(l => l == "1 DEAT Y");
|
||||
(int age, _) = IAge.GetAge(DateTime.Now.Ticks, birth.Value.Ticks);
|
||||
int hours = IPersonBirthday.GetHour(alive, sex);
|
||||
if (!first)
|
||||
hours += 2;
|
||||
if (death == birth)
|
||||
death = death.Value.AddHours(hours);
|
||||
birth = birth.Value.AddHours(hours);
|
||||
if (age < 1)
|
||||
birth = null;
|
||||
if (birth is not null && death is null && (!alive || (age > 110 && !IPersonBirthday.IsCounterPersonBirthday(new(birth.Value)))))
|
||||
death = birth;
|
||||
}
|
||||
death ??= !genealogicalDataCommunicationLines.Death.Any(l => l == "1 DEAT Y") ? null : birth;
|
||||
result = new(birth,
|
||||
changed,
|
||||
death,
|
||||
givenName,
|
||||
id,
|
||||
name,
|
||||
nickName,
|
||||
sex,
|
||||
suffix,
|
||||
surName,
|
||||
uId);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<GenealogicalDataCommunicationRelation> GetRelations(string personBirthdayFormat, ReadOnlyCollection<Models.PersonContainer> personContainers, GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections)
|
||||
{
|
||||
List<GenealogicalDataCommunicationRelation> results = new();
|
||||
string? nick;
|
||||
long? personKey;
|
||||
string relation;
|
||||
string? fullName;
|
||||
string[] segments;
|
||||
string[] familyLines;
|
||||
Models.PersonBirthday? personBirthday;
|
||||
ReadOnlyDictionary<string, string> personKeyFormattedToPersonFullName = IPersonContainer.GetPersonKeyFormattedToPersonFullName(personBirthdayFormat, personContainers);
|
||||
for (int i = 0; i < genealogicalDataCommunicationCollections.FamilyGroupLines.Count; i++)
|
||||
{
|
||||
familyLines = genealogicalDataCommunicationCollections.FamilyGroupLines[i];
|
||||
for (int j = 0; j < familyLines.Length; j++)
|
||||
{
|
||||
segments = familyLines[j].Split('@');
|
||||
if (segments.First().Length < 3 || segments.Length != 3)
|
||||
continue;
|
||||
if (!genealogicalDataCommunicationCollections.IdToNick.TryGetValue(segments[1], out nick))
|
||||
continue;
|
||||
relation = segments.First()[2..].Trim();
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(personBirthdayFormat, nick);
|
||||
personKey = personBirthday?.Value.Ticks;
|
||||
fullName = personKeyFormattedToPersonFullName.GetValueOrDefault(nick);
|
||||
if (j + 1 >= familyLines.Length || familyLines[j + 1].Length < 3 || familyLines[j + 1][..3] != "2 _")
|
||||
results.Add(new(i, relation, segments[1], nick, personKey, fullName, null));
|
||||
else
|
||||
results.Add(new(i, relation, segments[1], nick, personKey, fullName, familyLines[j + 1][2..]));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> GetFamilyIndexToCollection(string personBirthdayFormat, ReadOnlyCollection<Models.PersonContainer> personContainers, GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections)
|
||||
{
|
||||
Dictionary<int, List<GenealogicalDataCommunicationRelation>> results = new();
|
||||
List<GenealogicalDataCommunicationRelation>? relations;
|
||||
List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations = GetRelations(personBirthdayFormat, personContainers, genealogicalDataCommunicationCollections);
|
||||
foreach (GenealogicalDataCommunicationRelation genealogicalDataCommunicationRelation in genealogicalDataCommunicationRelations)
|
||||
{
|
||||
if (!results.TryGetValue(genealogicalDataCommunicationRelation.FamilyIndex, out relations))
|
||||
{
|
||||
results.Add(genealogicalDataCommunicationRelation.FamilyIndex, new());
|
||||
if (!results.TryGetValue(genealogicalDataCommunicationRelation.FamilyIndex, out relations))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
relations.Add(genealogicalDataCommunicationRelation);
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static ReadOnlyDictionary<long, List<GenealogicalDataCommunicationRelation>> GetCollection(string personBirthdayFormat, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations)
|
||||
{
|
||||
Dictionary<long, List<GenealogicalDataCommunicationRelation>> results = new();
|
||||
long personKey;
|
||||
string personKeyFormatted;
|
||||
Models.PersonBirthday? personBirthday;
|
||||
List<GenealogicalDataCommunicationRelation>? collection;
|
||||
foreach (GenealogicalDataCommunicationRelation genealogicalDataCommunicationRelation in genealogicalDataCommunicationRelations)
|
||||
{
|
||||
personKeyFormatted = genealogicalDataCommunicationRelation.NickName;
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(personBirthdayFormat, personKeyFormatted);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
personKey = personBirthday.Value.Ticks;
|
||||
if (!results.TryGetValue(personKey, out collection))
|
||||
{
|
||||
results.Add(personKey, new());
|
||||
if (!results.TryGetValue(personKey, out collection))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
collection.Add(genealogicalDataCommunicationRelation);
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static ReadOnlyDictionary<long, List<GenealogicalDataCommunicationRelation>> GetCollection(string personBirthdayFormat, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection)
|
||||
{
|
||||
Dictionary<long, List<GenealogicalDataCommunicationRelation>> results = new();
|
||||
long personKey;
|
||||
string personKeyFormatted;
|
||||
Models.PersonBirthday? personBirthday;
|
||||
List<GenealogicalDataCommunicationRelation>? collection;
|
||||
foreach (KeyValuePair<int, List<GenealogicalDataCommunicationRelation>> keyValuePair in familyIndexToCollection)
|
||||
{
|
||||
foreach (GenealogicalDataCommunicationRelation genealogicalDataCommunicationRelation in keyValuePair.Value)
|
||||
{
|
||||
personKeyFormatted = genealogicalDataCommunicationRelation.NickName;
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(personBirthdayFormat, personKeyFormatted);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
personKey = personBirthday.Value.Ticks;
|
||||
if (!results.TryGetValue(personKey, out collection))
|
||||
{
|
||||
results.Add(personKey, new());
|
||||
if (!results.TryGetValue(personKey, out collection))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
collection.Add(genealogicalDataCommunicationRelation);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static string GetMergeWithLineTwo(GenealogicalDataCommunicationRelation genealogicalDataCommunicationRelation, GenealogicalDataCommunicationRelation relation)
|
||||
{
|
||||
string result;
|
||||
const char father = 'F';
|
||||
const char mother = 'M';
|
||||
string wife = IGenealogicalDataCommunication.Wife;
|
||||
string husband = IGenealogicalDataCommunication.Husband;
|
||||
if (string.IsNullOrEmpty(genealogicalDataCommunicationRelation.LineTwo))
|
||||
{
|
||||
if (relation.Relation == wife)
|
||||
result = nameof(mother);
|
||||
else if (relation.Relation == husband)
|
||||
result = nameof(father);
|
||||
else
|
||||
result = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder stringBuilder = new();
|
||||
if (genealogicalDataCommunicationRelation.LineTwo[1] == father)
|
||||
{
|
||||
if (relation.Relation == wife)
|
||||
_ = stringBuilder.Append(nameof(mother));
|
||||
else if (relation.Relation == husband)
|
||||
_ = stringBuilder.Append(genealogicalDataCommunicationRelation.LineTwo.Split(' ').Last()).Append(' ').Append(nameof(father));
|
||||
}
|
||||
else if (genealogicalDataCommunicationRelation.LineTwo[1] == mother)
|
||||
{
|
||||
if (relation.Relation == husband)
|
||||
_ = stringBuilder.Append(nameof(father));
|
||||
else if (relation.Relation == wife)
|
||||
_ = stringBuilder.Append(genealogicalDataCommunicationRelation.LineTwo.Split(' ').Last()).Append(' ').Append(nameof(mother));
|
||||
}
|
||||
result = stringBuilder.ToString();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void WriteAll(long ticks, string a2PeopleContentDirectory, List<string[]> frontMatterLinesCollections, string weekOfYear)
|
||||
{
|
||||
string json;
|
||||
string[] segments;
|
||||
string? directory;
|
||||
string frontMatterLastLine;
|
||||
DateTime dateTime = new(ticks);
|
||||
List<string> allFrontMatterLines = new();
|
||||
foreach (string[] frontMatterLines in frontMatterLinesCollections)
|
||||
{
|
||||
allFrontMatterLines.Add("{");
|
||||
frontMatterLastLine = frontMatterLines.Last();
|
||||
foreach (string frontMatterLine in frontMatterLines)
|
||||
{
|
||||
segments = frontMatterLine.Split(": ");
|
||||
if (segments.Length != 2)
|
||||
continue;
|
||||
if (frontMatterLine == frontMatterLastLine)
|
||||
allFrontMatterLines.Add($"\"{string.Join("\": ", segments)}");
|
||||
else
|
||||
allFrontMatterLines.Add($"\"{string.Join("\": ", segments)},");
|
||||
}
|
||||
allFrontMatterLines.Add("},");
|
||||
}
|
||||
directory = Path.Combine(a2PeopleContentDirectory, $"{dateTime.Year}-Markdown", $"{dateTime.Year}-Week-{weekOfYear}", ticks.ToString());
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
json = $"[{string.Join(Environment.NewLine, allFrontMatterLines.ToArray(), 0, allFrontMatterLines.Count - 1)}{allFrontMatterLines.Last()[..^1]}]";
|
||||
Models.GenealogicalDataCommunication[]? genealogicalDataCommunications = JsonSerializer.Deserialize(json, GenealogicalDataCommunicationSourceCollectionGenerationContext.Default.GenealogicalDataCommunicationArray);
|
||||
if (genealogicalDataCommunications is null)
|
||||
throw new NullReferenceException(nameof(genealogicalDataCommunications));
|
||||
json = JsonSerializer.Serialize(genealogicalDataCommunications, GenealogicalDataCommunicationSourceCollectionGenerationContext.Default.GenealogicalDataCommunicationArray);
|
||||
_ = IPath.WriteAllText(Path.Combine(directory, $"{ticks}.json"), json, updateDateWhenMatches: false, compareBeforeWrite: true);
|
||||
}
|
||||
|
||||
internal static void MaybeWriteMarkDownFiles(string mappingDefaultName, string personBirthdayFormat, long ticks, ReadOnlyCollection<Models.PersonContainer> personContainers, ReadOnlyDictionary<string, string[]> individuals, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection, string a2PeopleContentDirectory)
|
||||
{
|
||||
bool? male;
|
||||
bool? first;
|
||||
string fullName;
|
||||
string[]? lines;
|
||||
string[] matches;
|
||||
string? directory;
|
||||
bool isDefaultName;
|
||||
const int zero = 0;
|
||||
string personKeyFormatted;
|
||||
string lowerHyphenFullName;
|
||||
List<string> frontMatterLines;
|
||||
string pattern = "[^a-z0-9-]";
|
||||
DateTime dateTime = new(ticks);
|
||||
Calendar calendar = new CultureInfo("en-US").Calendar;
|
||||
List<(string? Id, string[] FrontMatterLines)> collection = new();
|
||||
Models.GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
GenealogicalDataCommunicationLines? genealogicalDataCommunicationLines;
|
||||
string weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
ReadOnlyDictionary<string, string> personKeyFormattedToPersonFullName = IPersonContainer.GetPersonKeyFormattedToPersonFullName(personBirthdayFormat, personContainers);
|
||||
foreach (Models.PersonContainer personContainer in personContainers.OrderByDescending(l => l.Key))
|
||||
{
|
||||
if (personContainer.Key is null || personContainer.Birthdays is null || personContainer.Person is null || personContainer.PersonDirectory is null || personContainer.Birthdays.Length == 0)
|
||||
continue;
|
||||
male = personContainer.PersonDirectory.Sex == 'U' ? null : personContainer.PersonDirectory.Sex == 'M' || (personContainer.PersonDirectory.Sex == 'F' ? false : throw new Exception());
|
||||
first = personContainer.PersonDirectory.First == 'U' ? null : personContainer.PersonDirectory.First == 'Y' || (personContainer.PersonDirectory.First == 'N' ? false : throw new Exception());
|
||||
if (first is null)
|
||||
continue;
|
||||
isDefaultName = IPerson.IsDefaultName(mappingDefaultName, personContainer.DisplayDirectoryName);
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthdayFormat, personContainer.Key.Value);
|
||||
matches = (from l in personContainer.DisplayDirectoryAllFiles where l.Contains(personKeyFormatted) select l).ToArray();
|
||||
if (!matches.Any())
|
||||
continue;
|
||||
directory = Path.GetDirectoryName(matches[zero]);
|
||||
if (directory is null)
|
||||
continue;
|
||||
if (!individuals.TryGetValue(personKeyFormatted, out lines))
|
||||
continue;
|
||||
genealogicalDataCommunicationLines = lines is null ? null : GetGenealogicalDataCommunicationLines(personContainer.Birthdays[zero], lines);
|
||||
if (genealogicalDataCommunicationLines is null)
|
||||
continue;
|
||||
genealogicalDataCommunication = GetGenealogicalDataCommunication(first.Value, genealogicalDataCommunicationLines);
|
||||
if (genealogicalDataCommunication.Sex != personContainer.PersonDirectory.Sex)
|
||||
continue;
|
||||
if (genealogicalDataCommunication.Birth is not null && !directory.EndsWith(genealogicalDataCommunication.Birth.Value.Hour.ToString()))
|
||||
continue;
|
||||
if (genealogicalDataCommunication.Death is null && personContainer.PersonDirectory.Status == 'D' || genealogicalDataCommunication.Death is not null && personContainer.PersonDirectory.Status == 'A')
|
||||
continue;
|
||||
fullName = PersonName.GetFullName(personContainer.Person.Name);
|
||||
lowerHyphenFullName = $"{Regex.Replace(fullName.ToLower(), pattern, "-")}";
|
||||
frontMatterLines = MarkDown.GetFrontMatterLines(ticks, fullName, lowerHyphenFullName, genealogicalDataCommunication);
|
||||
if (!frontMatterLines.Any())
|
||||
continue;
|
||||
collection.Add((genealogicalDataCommunication.Id, frontMatterLines.ToArray()));
|
||||
MarkDown.WriteFile(personKeyFormatted, ticks, a2PeopleContentDirectory, calendar, pattern, personKeyFormattedToPersonFullName, familyIndexToCollection, genealogicalDataCommunication, fullName, lowerHyphenFullName, frontMatterLines);
|
||||
}
|
||||
if (collection.Any())
|
||||
{
|
||||
List<string[]> frontMatterLinesCollections = (from l in collection orderby l.Id.Length, l.Id where l.Id is not null select l.FrontMatterLines).ToList();
|
||||
WriteAll(ticks, a2PeopleContentDirectory, frontMatterLinesCollections, weekOfYear);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
public interface IGenealogicalDataCommunication
|
||||
{
|
||||
|
||||
// ...
|
||||
|
||||
const string Wife = "WIFE";
|
||||
const string Child = "CHIL";
|
||||
const string Husband = "HUSB";
|
||||
|
||||
List<string> TestStatic_GetMappedLines(string genealogicalDataCommunicationFile, bool requireNickName) =>
|
||||
GetMappedLines(genealogicalDataCommunicationFile, requireNickName);
|
||||
static List<string> GetMappedLines(string genealogicalDataCommunicationFile, bool requireNickName) =>
|
||||
GenealogicalDataCommunication.GetMappedLines(genealogicalDataCommunicationFile, requireNickName);
|
||||
|
||||
GenealogicalDataCommunicationLines TestStatic_GetGenealogicalDataCommunicationLines(Models.PersonBirthday personBirthday, string[] individualsLines) =>
|
||||
GetGenealogicalDataCommunicationLines(individualsLines);
|
||||
static GenealogicalDataCommunicationLines GetGenealogicalDataCommunicationLines(string[] individualsLines) =>
|
||||
GenealogicalDataCommunication.GetGenealogicalDataCommunicationLines(new(DateTime.Now), individualsLines);
|
||||
|
||||
Models.GenealogicalDataCommunication TestStatic_GetGenealogicalDataCommunication(bool first, GenealogicalDataCommunicationLines genealogicalDataCommunicationLines) =>
|
||||
GetGenealogicalDataCommunication(first, genealogicalDataCommunicationLines);
|
||||
static Models.GenealogicalDataCommunication GetGenealogicalDataCommunication(bool first, GenealogicalDataCommunicationLines genealogicalDataCommunicationLines) =>
|
||||
GenealogicalDataCommunication.GetGenealogicalDataCommunication(first, genealogicalDataCommunicationLines);
|
||||
|
||||
GenealogicalDataCommunicationCollections TestStatic_GetIndividuals(string genealogicalDataCommunicationFile, bool requireNickName) =>
|
||||
GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
|
||||
static GenealogicalDataCommunicationCollections GetIndividuals(string genealogicalDataCommunicationFile, bool requireNickName) =>
|
||||
GenealogicalDataCommunication.GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
|
||||
|
||||
ReadOnlyDictionary<long, List<GenealogicalDataCommunicationRelation>> TestStatic_GetCollection(string personBirthdayFormat, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations) =>
|
||||
GetCollection(personBirthdayFormat, genealogicalDataCommunicationRelations);
|
||||
static ReadOnlyDictionary<long, List<GenealogicalDataCommunicationRelation>> GetCollection(string personBirthdayFormat, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations) =>
|
||||
GenealogicalDataCommunication.GetCollection(personBirthdayFormat, genealogicalDataCommunicationRelations);
|
||||
|
||||
ReadOnlyDictionary<long, List<GenealogicalDataCommunicationRelation>> TestStatic_GetCollection(string personBirthdayFormat, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection) =>
|
||||
GetCollection(personBirthdayFormat, familyIndexToCollection);
|
||||
static ReadOnlyDictionary<long, List<GenealogicalDataCommunicationRelation>> GetCollection(string personBirthdayFormat, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection) =>
|
||||
GenealogicalDataCommunication.GetCollection(personBirthdayFormat, familyIndexToCollection);
|
||||
|
||||
ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> TestStatic_GetFamilyIndexToCollection(string personBirthdayFormat, ReadOnlyCollection<Models.PersonContainer> personContainers, GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections) =>
|
||||
GetFamilyIndexToCollection(personBirthdayFormat, personContainers, genealogicalDataCommunicationCollections);
|
||||
static ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> GetFamilyIndexToCollection(string personBirthdayFormat, ReadOnlyCollection<Models.PersonContainer> personContainers, GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections) =>
|
||||
GenealogicalDataCommunication.GetFamilyIndexToCollection(personBirthdayFormat, personContainers, genealogicalDataCommunicationCollections);
|
||||
|
||||
string? TestStatic_GetMergeWithLineTwo(GenealogicalDataCommunicationRelation genealogicalDataCommunicationRelation, GenealogicalDataCommunicationRelation relation) =>
|
||||
GetMergeWithLineTwo(genealogicalDataCommunicationRelation, relation);
|
||||
static string? GetMergeWithLineTwo(GenealogicalDataCommunicationRelation genealogicalDataCommunicationRelation, GenealogicalDataCommunicationRelation relation) =>
|
||||
GenealogicalDataCommunication.GetMergeWithLineTwo(genealogicalDataCommunicationRelation, relation);
|
||||
|
||||
void TestStatic_MaybeWriteMarkDownFiles(string mappingDefaultName, string personBirthdayFormat, long ticks, ReadOnlyCollection<Models.PersonContainer> personContainers, ReadOnlyDictionary<string, string[]> individuals, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection, string a2PeopleContentDirectory) =>
|
||||
MaybeWriteMarkDownFiles(mappingDefaultName, personBirthdayFormat, ticks, personContainers, individuals, familyIndexToCollection, a2PeopleContentDirectory);
|
||||
static void MaybeWriteMarkDownFiles(string mappingDefaultName, string personBirthdayFormat, long ticks, ReadOnlyCollection<Models.PersonContainer> personContainers, ReadOnlyDictionary<string, string[]> individuals, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection, string a2PeopleContentDirectory) =>
|
||||
GenealogicalDataCommunication.MaybeWriteMarkDownFiles(mappingDefaultName, personBirthdayFormat, ticks, personContainers, individuals, familyIndexToCollection, a2PeopleContentDirectory);
|
||||
|
||||
}
|
@ -10,9 +10,4 @@ public interface IPersonName
|
||||
static string GetFullName(Models.PersonName personName) =>
|
||||
PersonName.GetFullName(personName);
|
||||
|
||||
Models.PersonName? TestStatic_GetPersonName(Models.GenealogicalDataCommunication genealogicalDataCommunication) =>
|
||||
GetPersonName(genealogicalDataCommunication);
|
||||
static Models.PersonName? GetPersonName(Models.GenealogicalDataCommunication genealogicalDataCommunication) =>
|
||||
PersonName.GetPersonName(genealogicalDataCommunication);
|
||||
|
||||
}
|
@ -1,155 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class MarkDown
|
||||
{
|
||||
|
||||
// ...
|
||||
|
||||
private static List<string> GetFrontMatterLines(string[] parsedLines)
|
||||
{
|
||||
List<string> results = new();
|
||||
string afterTrim;
|
||||
string[] segments;
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int i = 0; i < parsedLines.Length; i++)
|
||||
{
|
||||
afterTrim = parsedLines[i].Trim();
|
||||
if (string.IsNullOrEmpty(afterTrim) || afterTrim.First() is '{' or '}')
|
||||
continue;
|
||||
segments = afterTrim.Split(": ");
|
||||
if (segments.Length != 2)
|
||||
{
|
||||
if (results.Last()[^1] == '[')
|
||||
{
|
||||
_ = stringBuilder.Clear();
|
||||
_ = stringBuilder.Append(results.Last());
|
||||
results.RemoveAt(results.Count - 1);
|
||||
for (int j = i; j < parsedLines.Length; j++)
|
||||
{
|
||||
i = j;
|
||||
afterTrim = parsedLines[j].Trim();
|
||||
if (afterTrim == "],")
|
||||
_ = stringBuilder.Append(afterTrim[..^1]);
|
||||
else if (afterTrim[^1] == ',')
|
||||
_ = stringBuilder.Append(afterTrim).Append(' ');
|
||||
else
|
||||
_ = stringBuilder.Append(afterTrim);
|
||||
if (afterTrim is "]" or "],")
|
||||
{
|
||||
results.Add(stringBuilder.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
results.Clear();
|
||||
break;
|
||||
}
|
||||
if (afterTrim[^1] != ',')
|
||||
results.Add(afterTrim[1..].Replace("\": ", ": "));
|
||||
else
|
||||
results.Add(afterTrim[1..^1].Replace("\": ", ": "));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static List<string> GetFrontMatterLines(long ticks, string fullName, string lowerHyphenFullName, Models.GenealogicalDataCommunication genealogicalDataCommunication)
|
||||
{
|
||||
List<string> results;
|
||||
string[] parsedLines = genealogicalDataCommunication.ToString().Split(Environment.NewLine);
|
||||
results = GetFrontMatterLines(parsedLines);
|
||||
if (results.Any())
|
||||
{
|
||||
DateTime dateTime = new DateTime(ticks).ToUniversalTime();
|
||||
results.Insert(0, $"updated: \"{dateTime:yyyy-MM-ddTHH:mm:ss.fffZ}\"");
|
||||
results.Insert(0, $"created: \"{dateTime:yyyy-MM-ddTHH:mm:ss.fffZ}\"");
|
||||
results.Insert(0, $"title: \"{fullName}\"");
|
||||
results.Insert(0, "type: \"person\"");
|
||||
results.Add("draft: false");
|
||||
results.Add($"{nameof(lowerHyphenFullName)}: \"{lowerHyphenFullName}\"");
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static void WriteFile(string personKeyFormatted, long ticks, string a2PeopleContentDirectory, Calendar calendar, string pattern, ReadOnlyDictionary<string, string> personKeyFormattedToPersonFullName, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection, Models.GenealogicalDataCommunication genealogicalDataCommunication, string fullName, string lowerHyphenFullName, List<string> frontMatterLines)
|
||||
{
|
||||
string text;
|
||||
string decade;
|
||||
string? personFullName;
|
||||
bool hasRelation = false;
|
||||
string? mergeWithLineTwo;
|
||||
List<string> lines = new();
|
||||
StringBuilder link = new();
|
||||
const string person = "person";
|
||||
DateTime dateTime = new(ticks);
|
||||
List<GenealogicalDataCommunicationRelation>? genealogicalDataCommunicationRelations;
|
||||
lines.Add("---");
|
||||
lines.AddRange(frontMatterLines);
|
||||
lines.Add("---");
|
||||
lines.Add(string.Empty);
|
||||
lines.Add($"# {fullName}");
|
||||
lines.Add(string.Empty);
|
||||
foreach (KeyValuePair<int, List<GenealogicalDataCommunicationRelation>> keyValuePair in familyIndexToCollection)
|
||||
{
|
||||
foreach (GenealogicalDataCommunicationRelation genealogicalDataCommunicationRelation in keyValuePair.Value)
|
||||
{
|
||||
if (genealogicalDataCommunication?.NickName is null || genealogicalDataCommunication.NickName.Length < 4)
|
||||
continue;
|
||||
if (genealogicalDataCommunicationRelation.Relation != IGenealogicalDataCommunication.Child)
|
||||
continue;
|
||||
if (genealogicalDataCommunicationRelation.NickName != personKeyFormatted)
|
||||
continue;
|
||||
if (!familyIndexToCollection.TryGetValue(genealogicalDataCommunicationRelation.FamilyIndex, out genealogicalDataCommunicationRelations))
|
||||
continue;
|
||||
foreach (GenealogicalDataCommunicationRelation relation in genealogicalDataCommunicationRelations)
|
||||
{
|
||||
if (relation.FamilyIndex != genealogicalDataCommunicationRelation.FamilyIndex)
|
||||
continue;
|
||||
if (relation.Relation is IGenealogicalDataCommunication.Husband or IGenealogicalDataCommunication.Wife)
|
||||
{
|
||||
if (!hasRelation)
|
||||
{
|
||||
lines.Add("## Relations");
|
||||
lines.Add(string.Empty);
|
||||
hasRelation = true;
|
||||
}
|
||||
decade = relation.NickName[..3];
|
||||
_ = link.Clear();
|
||||
_ = link.Append("- [");
|
||||
if (!personKeyFormattedToPersonFullName.TryGetValue(relation.NickName, out personFullName))
|
||||
_ = link.Append(relation.NickName);
|
||||
else
|
||||
_ = link.Append(personFullName);
|
||||
if (genealogicalDataCommunication.NickName[..3] == decade)
|
||||
_ = link.Append("](");
|
||||
else
|
||||
_ = link.Append("](../").Append(decade).Append('/');
|
||||
if (personFullName is null)
|
||||
_ = link.Append(relation.NickName);
|
||||
else
|
||||
_ = link.Append(Regex.Replace(personFullName.ToLower(), pattern, "-").Replace("--", "-"));
|
||||
_ = link.Append(".md) ");
|
||||
mergeWithLineTwo = GenealogicalDataCommunication.GetMergeWithLineTwo(genealogicalDataCommunicationRelation, relation);
|
||||
lines.Add($"{link}{mergeWithLineTwo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasRelation)
|
||||
lines.Add(string.Empty);
|
||||
// text = string.Join(Environment.NewLine, lines);
|
||||
// _ = IPath.WriteAllText(Path.Combine(directory, $"{personKeyFormatted}.md"), text, updateDateWhenMatches: false, compareBeforeWrite: true);
|
||||
string weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string markdownOnlyDirectory = Path.Combine(a2PeopleContentDirectory, $"{dateTime.Year}-Markdown", $"{dateTime.Year}-Week-{weekOfYear}", ticks.ToString(), person, personKeyFormatted[..3]);
|
||||
if (!Directory.Exists(markdownOnlyDirectory))
|
||||
_ = Directory.CreateDirectory(markdownOnlyDirectory);
|
||||
text = string.Join(Environment.NewLine, lines);
|
||||
_ = IPath.WriteAllText(Path.Combine(markdownOnlyDirectory, $"{lowerHyphenFullName}.md"), text, updateDateWhenMatches: false, compareBeforeWrite: true);
|
||||
}
|
||||
|
||||
}
|
@ -78,16 +78,4 @@ internal abstract class PersonName
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
internal static Models.PersonName? GetPersonName(Models.GenealogicalDataCommunication genealogicalDataCommunication)
|
||||
{
|
||||
Models.PersonName? result;
|
||||
string[] surNameSegments = genealogicalDataCommunication.SurName is null ? Array.Empty<string>() : genealogicalDataCommunication.SurName.Split(' ');
|
||||
string[] givenNameSegments = genealogicalDataCommunication.GivenName is null ? Array.Empty<string>() : genealogicalDataCommunication.GivenName.Split(' ');
|
||||
if (!givenNameSegments.Any() || !surNameSegments.Any())
|
||||
result = null;
|
||||
else
|
||||
result = new(new(givenNameSegments[0]), new(givenNameSegments.Length == 1 ? string.Empty : givenNameSegments[1]), new(surNameSegments[^1]), new(string.Empty));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
|
@ -258,512 +258,6 @@ public partial class UnitTestHardCoded
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodAncestryGenealogicalDataCommunication()
|
||||
{
|
||||
string directory = "D:/1-Images-A/Images-dd514b88-Results/A2) People/dd514b88/([])";
|
||||
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||
{
|
||||
bool first = true;
|
||||
List<string> mappedLines;
|
||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
||||
GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections;
|
||||
List<(bool, string)> genealogicalDataCommunicationFiles = new()
|
||||
{
|
||||
// new(false, Path.Combine(directory, "Ancestry-Roberts/Roberts Family Tree.ged")),
|
||||
// new(false, Path.Combine(directory, "Ancestry-Phares/Phares Jr Family Tree.ged")),
|
||||
// new(true, Path.Combine(directory, "Code-638160708345114583/638160708345114583.ged")),
|
||||
// new(true, Path.Combine(directory, "Code-638160728606500015/638160728606500015.ged")),
|
||||
// new(true, Path.Combine(directory, "Code-638160738845419877/638160738845419877.ged")),
|
||||
new(true, Path.Combine(directory, "Code-638160743318283885/638160743318283885.ged")),
|
||||
// new(true, Path.Combine(directory, "Code-638245446208013055/638245446208013055.ged")),
|
||||
// new(false, Path.Combine(directory, "Ancestry-Porterfield/Porterfield Family Tree.ged")),
|
||||
// new(true, Path.Combine(directory, "Code-638160708345114583/638160708345114583-Export.ged")),
|
||||
// new(true, Path.Combine(directory, "Code-638160738845419877/638160738845419877-Export.ged")),
|
||||
// new(true, Path.Combine(directory, "Code-638160743318283885/638160743318283885-Export.ged")),
|
||||
// new(true, Path.Combine(directory, "Code-638245446208013055/638245446208013055-Export.ged")),
|
||||
};
|
||||
foreach ((bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
||||
{
|
||||
genealogicalDataCommunicationCollections = IGenealogicalDataCommunication.GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
|
||||
foreach (KeyValuePair<string, string[]> keyValuePair in genealogicalDataCommunicationCollections.Individuals)
|
||||
{
|
||||
genealogicalDataCommunicationLines = IGenealogicalDataCommunication.GetGenealogicalDataCommunicationLines(keyValuePair.Value);
|
||||
Assert.IsNotNull(genealogicalDataCommunicationLines.Name);
|
||||
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(first, genealogicalDataCommunicationLines);
|
||||
Assert.IsNotNull(genealogicalDataCommunication.Name);
|
||||
}
|
||||
mappedLines = IGenealogicalDataCommunication.GetMappedLines(genealogicalDataCommunicationFile, requireNickName);
|
||||
if (IPath.WriteAllText($"{genealogicalDataCommunicationFile}.cln", string.Join(Environment.NewLine, mappedLines), updateDateWhenMatches: false, compareBeforeWrite: true))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodAncestryGenealogicalDataCommunicationCleanToExport()
|
||||
{
|
||||
DateTime dateTime = DateTime.Now;
|
||||
string saveDirectory = "D:/1-Images-A/Images-dd514b88-Results/A2) People/dd514b88/([])";
|
||||
if (Directory.Exists(Path.GetPathRoot(saveDirectory)) && Directory.Exists(saveDirectory))
|
||||
{
|
||||
int age;
|
||||
long personKey;
|
||||
string ageGroup;
|
||||
string fileName;
|
||||
bool first = true;
|
||||
string? directory;
|
||||
PersonName? personName;
|
||||
string personKeyFormatted;
|
||||
// bool isDefaultName = false;
|
||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
||||
GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections;
|
||||
List<(bool, bool, string)> genealogicalDataCommunicationFiles = new()
|
||||
{
|
||||
// new(false, false, Path.Combine(saveDirectory, "Ancestry-Roberts/Roberts Family Tree.ged.cln")),
|
||||
// new(false, false, Path.Combine(saveDirectory, "Ancestry-Phares/Phares Jr Family Tree.ged.cln")),
|
||||
// new(true, true, Path.Combine(saveDirectory, "Code-638160708345114583/638160708345114583.ged.cln")),
|
||||
// new(true, true, Path.Combine(saveDirectory, "Code-638160728606500015/638160728606500015.ged.cln")),
|
||||
// new(true, true, Path.Combine(saveDirectory, "Code-638160738845419877/638160738845419877.ged.cln")),
|
||||
new(true, true, Path.Combine(saveDirectory, "Code-638160743318283885/638160743318283885.ged.cln")),
|
||||
// new(true, true, Path.Combine(saveDirectory, "Code-638245446208013055/638245446208013055.ged.cln")),
|
||||
// new(false, false, Path.Combine(saveDirectory, "Ancestry-Porterfield/Porterfield Family Tree.ged.cln")),
|
||||
// new(true, true, Path.Combine(saveDirectory, "Code-638160708345114583/638160708345114583-Export.ged.cln")),
|
||||
// new(true, true, Path.Combine(saveDirectory, "Code-638160738845419877/638160738845419877-Export.ged.cln")),
|
||||
// new(true, true, Path.Combine(saveDirectory, "Code-638160743318283885/638160743318283885-Export.ged.cln")),
|
||||
// new(true, true, Path.Combine(saveDirectory, "Code-638245446208013055/638245446208013055-Export.ged.cln")),
|
||||
};
|
||||
foreach ((bool verify, bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
||||
{
|
||||
fileName = Path.GetFileNameWithoutExtension(genealogicalDataCommunicationFile).Split(' ')[0];
|
||||
genealogicalDataCommunicationCollections = IGenealogicalDataCommunication.GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
|
||||
foreach (KeyValuePair<string, string[]> keyValuePair in genealogicalDataCommunicationCollections.Individuals)
|
||||
{
|
||||
genealogicalDataCommunicationLines = IGenealogicalDataCommunication.GetGenealogicalDataCommunicationLines(keyValuePair.Value);
|
||||
Assert.IsNotNull(genealogicalDataCommunicationLines.Name);
|
||||
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(first, genealogicalDataCommunicationLines);
|
||||
Assert.IsNotNull(genealogicalDataCommunication.Name);
|
||||
if (genealogicalDataCommunication.Birth is null)
|
||||
continue;
|
||||
personName = IPersonName.GetPersonName(genealogicalDataCommunication);
|
||||
if (personName is null)
|
||||
continue;
|
||||
personKey = genealogicalDataCommunication.Birth.Value.Ticks;
|
||||
(age, _) = IAge.GetAge(dateTime.Ticks, personKey);
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_PropertyConfiguration.PersonBirthdayFormat, personKey);
|
||||
if (age < 25)
|
||||
ageGroup = "1) Less-25";
|
||||
else if (age < 50)
|
||||
ageGroup = "2) Less-50";
|
||||
else if (age < 100)
|
||||
ageGroup = "3) Less-100";
|
||||
else if (age < 200)
|
||||
ageGroup = "4) Less-200";
|
||||
else
|
||||
ageGroup = "5) Else";
|
||||
directory = Path.Combine(saveDirectory, fileName, ageGroup, $"{personName.First.Value} {personName.Last.Value}^{age}", personKeyFormatted);
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
// IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, keyValuePair.Value, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
||||
}
|
||||
}
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
private static string[] GetFamily() => new string[] {
|
||||
"UBertha Scott (Barry Scott) 10/2/1900-8/19/1993",
|
||||
"MEarl Daniel Herman 1/5/1918-10/19/1962",
|
||||
"FGlendola Koch 8/10/1919-5/16/1910",
|
||||
"MLawrence Koch 5/14/1916-6/29/2003",
|
||||
"MEarl Herman Jr. (Sonny Herman) 6/24/1937-12/05/2007",
|
||||
"FBetty Herman 11/24/1941-11/25/2008",
|
||||
"FCindy Hoylman 12/4/1958",
|
||||
"MBill Hoylman 6/29/1959",
|
||||
"MJoshua Hoylman 7/17/1978",
|
||||
"FSasha Hoylman 1/21/1981",
|
||||
"FLyla Hoylman 1/30/2000",
|
||||
"MWilliam Hoylman 1/2/2006",
|
||||
"MJon Hoylman 8/17/2007",
|
||||
"FAmanda Westphal 3/14/1981",
|
||||
"MMatthew Westphal 06/09/1981",
|
||||
"MVincent Westphal 12/16/2009",
|
||||
"MJim Herman 6/8/1960",
|
||||
"MJames Parmenter 5/21/1973-7/15/1999",
|
||||
"MChristopher Parmenter 11/5/1976",
|
||||
"FAlexa Parmenter 10/07/2009",
|
||||
"MMathew Parmenter 03/21/2004",
|
||||
"MGreg Herman 4/12/1979",
|
||||
"MChad Herman 1/2/1983",
|
||||
"FPiper Marie 4/20/2002",
|
||||
"MDale Herman 8/28/1962",
|
||||
"FNancee Herman 3/25/1964",
|
||||
"FSara Herman 3/2/1992",
|
||||
"MNolan Herman 10/6/1995",
|
||||
"MNathan Herman 5/22/1997",
|
||||
"UNeven Herman 2/23/2000",
|
||||
"MRodney Herman 4/29/1964",
|
||||
"FTeresa Davies 08/17/1978",
|
||||
"FNicole Mangold 9/14/1988",
|
||||
"MTJ Mangold 1/3/1991",
|
||||
"FBrook Lynn 11/20/2010",
|
||||
"FTiffany Herman 3/25/1990",
|
||||
"MAndrew Herman 5/25/2007",
|
||||
"MCarson James 1/26/2012",
|
||||
"FPenny Mews 6/21/1966",
|
||||
"MThomas Arthur 2/22/1998",
|
||||
"MDanny Herman 10/6/1941",
|
||||
"MDan Herman 1/19/1963",
|
||||
"MDaniel Lee Herman 11/10/1983",
|
||||
"FDestini Marie Herman 4/21/1985",
|
||||
"MDavid Earl Jensen (Timmy Jensen) 3/10/1964",
|
||||
"MDarrin Hansen 6/1/1966",
|
||||
"FTasha Hansen 12/10/1983",
|
||||
"FCheri Lynch 1/19/1973",
|
||||
"FHannah Marie 10/5/1996",
|
||||
"FHolly Marie 1/25/1979",
|
||||
"FEarline Wheeler 7/18/1944",
|
||||
"MDewey Wheeler 9/3/1941",
|
||||
"MMark Wheeler 8/19/1962",
|
||||
"MMichael Shane Wheeler 1/31/1985",
|
||||
"FCadence Lynn Wheeler 9/16/2003",
|
||||
"FMacy Marie Wheeler 9/16/2003",
|
||||
"FKarmin Herman 9/25/1963",
|
||||
"MJon Herman 8/5/1959",
|
||||
"FChelsea Marie Herman 1/1/1989",
|
||||
"MMatthew Jon Herman 2/23/1992",
|
||||
"FBonnie Sherwood 10/12/1965",
|
||||
"MRandy Sherwood 7/9/1959",
|
||||
"MAustin James Sherwood 12/20/1994",
|
||||
"FStephanie Marie Sherwood 2/8/1999",
|
||||
"FCelia Harken 5/12/1950",
|
||||
"MLarry Harken 4/12/1949",
|
||||
"FCelena Vesely 5/11/1976",
|
||||
"MBen Vesely 9/5/1975",
|
||||
"MSammual Edward Vesely 5/7/2006",
|
||||
"MElijah John Vesely 1/25/2008",
|
||||
"MGlen Herman 5/5/1952",
|
||||
"FKathryn Melvina Holst 11/23/1920-03/08/2010",
|
||||
"FDonna Owens 4/8/1942",
|
||||
"MMike Owens 9/2/1935",
|
||||
"FAngie Georgie 4/24/1960",
|
||||
"MJohn Georgie 4/12/1965",
|
||||
"FSarah Etheridge Georgie 11/28/1980",
|
||||
"MHaiden Michael Kilpatrick 6/26/1998",
|
||||
"FEmmalea Kathryn Georgie 8/17/2003",
|
||||
"MJames Etheridge 8/25/1983",
|
||||
"UShawnessy Etheridge 11/9/1995",
|
||||
"FHaley Etheridge 5/7/1997",
|
||||
"MDenise Engbroten 8/17/1962",
|
||||
"FAshley Koffman 6/18/1982",
|
||||
"MEric Koffman 6/28/1982",
|
||||
"MEvan Koffman 7/21/1985",
|
||||
"FHeather Shook 8/3/1978",
|
||||
"MGage Shook 10/9/2000",
|
||||
"FGrace LeAnn Shook 3/14/2002",
|
||||
"FJanet Schwab 9/13/45-4/20/2007",
|
||||
"MAlan Schwab 7/31/1964",
|
||||
"MRandy Schwab 8/1/1967",
|
||||
"FMadison Lee Schwab 12/6/1997",
|
||||
"FMorgan Lynn Schwab 5/13/2000",
|
||||
"FKristen Fralich 12/14/1971",
|
||||
"MAaron Fralich 6/26/1966",
|
||||
"FAbigail Kristine Fralich 3/8/1998",
|
||||
"MDavid Dixon 11/6/1945",
|
||||
"FMary Dixon 4/1/1949",
|
||||
"MRon Dixon 9/22/1966",
|
||||
"MRyan Dixon 6/30/1988",
|
||||
"FMegan Dixon 4/30/1990",
|
||||
"UTatum Dixon 4/30/1990",
|
||||
"MJoshua David Dixon 10/5/1995",
|
||||
"FKelly Norman Dixon 7/5/1967",
|
||||
"FKaitlyn Dixon 10/16/2000",
|
||||
"FPeggy Swails 9/22/1968",
|
||||
"MJohn Swails 11/25/1968",
|
||||
"MMariah Swails 2/10/1991",
|
||||
"MJohnathan Drake 4/18/1994",
|
||||
"FDawson Swails 8/18/1998",
|
||||
"FMarisa Swails 9/7/1999",
|
||||
"MRaymond Schwab 7/20/1947",
|
||||
"FBonnie Schwab 1/15/1947",
|
||||
"MScott Schwab 3/27/1966",
|
||||
"FBonnie Schwab 1/15/1947",
|
||||
"MAustin Scott Schwab 7/13/1991",
|
||||
"MAndrew Paul Schwab 3/26/1995",
|
||||
"FAddyson Grace Schwab 8/27/1999",
|
||||
"MAaron Patrick Schwab 6/5/2001",
|
||||
"FDebra Sottos 3/29/1969",
|
||||
"MMike Sottos 8/4/1972-7/31/2006",
|
||||
"MLogan Ray Nolin 3/23/1991",
|
||||
"MSeth Michael Sottos 7/27/2000",
|
||||
"FGrace Adelia Lou 9/29/2001",
|
||||
"FClaire Marie Jeane 7/07/2003",
|
||||
"FEmma Rose Jacquelin 4/04/2005",
|
||||
"FRose Olivia Mae 1/6/2007",
|
||||
"FTeresa Justice 4/16/1971",
|
||||
"MKevin Justice 7/6/1967",
|
||||
"MNoah Gale Justice 9/17/1998",
|
||||
"MBenjamin Kevin Justice 1/18/2001",
|
||||
"MKenny Schwab 7/28/1948",
|
||||
"FBonnie Schwab 9/11/1947",
|
||||
"FDiane Schwab 6/10/1966",
|
||||
"FMary Anderegg 4/24/1970",
|
||||
"MScott Anderegg 10/4/1967",
|
||||
"FHanna Catherine Anderegg 1/31/2001",
|
||||
"FMadison Alyse Anderegg 9/20/2003",
|
||||
"FShelly Whittle 6/24/1972",
|
||||
"MBrant Whittle 3/5/1971",
|
||||
"FKendra Kay Whittle 8/31/1999",
|
||||
"MDrake Thomas Whittle 7/16/1991",
|
||||
"UKelesy Taylor Whittle 2/2/1995",
|
||||
"FRoberta Garrett 11/7/1951",
|
||||
"MCharley Garrett 6/2/1951",
|
||||
"MTravis Barker 6/9/1970",
|
||||
"FJulie Barker 3/1/1971",
|
||||
"FKayla Barker 3/31/1991",
|
||||
"UAlli Leighton Barker 3/10/1997",
|
||||
"MGarrett Ambrose Barker 4/11/2000",
|
||||
"MCharley Garrett Jr. 2/9/76-10/21/2000",
|
||||
"MBlake Mitchell Garrett 8/21/1994",
|
||||
"FMakenzie Faye Garrett 2/16/2000",
|
||||
"MRobert Dean Rush 12/11/1950-3/20/1976",
|
||||
"MDean Herman 12/25/1922-4/24/1908",
|
||||
"FThelma Herman 6/9/1926-10/25/1909",
|
||||
"FElizabeth Leach 8/12/1948",
|
||||
"MGary Leach 6/24/1945",
|
||||
"FStephen Herman 7/19/1951",
|
||||
"FDiane Herman 8/31/1957",
|
||||
"FMolly Elizabeth Herman 10/11/1983",
|
||||
"MThaddeus Benjamin Herman 3/9/1986",
|
||||
"MMaryam Safajoo Herman 2/7/1987",
|
||||
"FGeorgia Marie Herman 10/4/1988",
|
||||
"MTimothy Herman 2/22/1958",
|
||||
"MJon Herman 8/5/1959",
|
||||
"FKarmin Herman 9/25/1963",
|
||||
"FChelsea Marie Herman 1/1/1989",
|
||||
"MMatthew Jon Herman 2/23/1992",
|
||||
"MBen Herman 5/27/1962",
|
||||
"FSydney Herman 7/12/1992",
|
||||
"FHaley Anderson Carlisle 6/24/1989",
|
||||
"FJennifer Cedillo 12/31/1966",
|
||||
"MDave Cedillo 7/17/1966",
|
||||
"FLenore Pearson 3/2/1925",
|
||||
"MChester Pearson 2/7/1925",
|
||||
"FAmy Scofield 7/28/1950",
|
||||
"MRick Scofield 7/9/1954",
|
||||
"UTracey Eickstaedt 3/19/1971",
|
||||
"MTroy Eickstaedt 4/11/1970",
|
||||
"FHaley Morgan Eickstaedt 9/11/1994",
|
||||
"MDominique Dawn Eickstaedt 4/10/1998",
|
||||
"FAmber Dawn Scofield 10/9/1978",
|
||||
"MDalton Rickie Wenzel 8/25/2000",
|
||||
"MShane Scofield 6/19/1985", // Nope
|
||||
"FAshley Scofield 7/13/1984",
|
||||
"FKathy Pettus 1/28/1955",
|
||||
"MEd Pettus 11/5/1951",
|
||||
"MEddie Pettus 9/10/1982",
|
||||
"MMichael Pettus 8/15/1987",
|
||||
"FRuthMary Tibbetts 2/1/1929",
|
||||
"MJames Tibbetts 7/24/1922-10/15/1981",
|
||||
"MDave Tibbetts 11/12/1956",
|
||||
"FGale Tibbetts 11/26/1958", // https://www.facebook.com/gale.tibbetts.18/photos // https://scontent-lax3-2.xx.fbcdn.net/v/t1.6435-9/92647697_1914827555328335_6217595516130164736_n.jpg?_nc_cat=107&ccb=1-7&_nc_sid=8bfeb9&_nc_ohc=CGu6LkY9MisAX__EerY&_nc_ht=scontent-lax3-2.xx&oh=00_AfD-o-blr_-6HXChsCosOq_n-iqWvmPzh_vmOFVnax1ntA&oe=64530587
|
||||
"FJessica Ann Tibbetts 9/8/1990",
|
||||
"MJonathon Tibbetts 8/11/1994",
|
||||
"FErin Tibbetts 7/15/1998",
|
||||
"MElmer John Herman 1/6/1931-10/12/1977",
|
||||
"FNorma Herman 6/5/1933",
|
||||
"FLannie Bosveld 2/3/1954",
|
||||
"MTom Bosveld 10/7/1949",
|
||||
"MJeremy Bosveld 2/14/1973",
|
||||
"UAmbjour Hazen 10/16/1991",
|
||||
"UJordan Hazen 8/22/1991-12/23/2007",
|
||||
"FKira Hazen 9/02/1993",
|
||||
"MDevan Hazen 8/14/1999",
|
||||
"MEthan Hazen 8/14/1999",
|
||||
"FApril Hill 6/9/1980",
|
||||
"MRandall Hill 1/16/1978", // https://www.facebook.com/randall.directory.hill/about_contact_and_basic_info // https://www.facebook.com/photo.php?fbid=10154576010477639&set=pb.530957638.-2207520000.&type=3 // https://scontent-lax3-1.xx.fbcdn.net/v/t1.18169-9/16265790_10154576010477639_102119672782426718_n.jpg?_nc_cat=102&ccb=1-7&_nc_sid=174925&_nc_ohc=cWEECl9DMhoAX_qlUB-&_nc_ht=scontent-lax3-1.xx&oh=00_AfC4PZ-tytVowtRSu1AJtkxRkQb0_j0WSDk4MKquqs0img&oe=64531181
|
||||
"FBrenda Olson 8/27/1958", // https://www.facebook.com/barbara.olson.96/about_contact_and_basic_info
|
||||
"MChris Olson 11/13/1951",
|
||||
"FShilo Zeches 4/9/1980",
|
||||
"FAddison Zeches 9/14/2003",
|
||||
"FFrancis Zeches 6/2/2006",
|
||||
"FBarbara Olson 12/25/1981",
|
||||
"MAllan Olson 4/5/1977",
|
||||
"MJacob Olson 12/1/1906",
|
||||
"FJayden Olson 10/5/1909",
|
||||
"FRachael Zeches 8/28/1983",
|
||||
"MMarc Allan Zeches 6/9/2005",
|
||||
"FCynthia Bott (Charlie Bott) 4/7/1964",
|
||||
"FStephanie Martinez 3/13/1983",
|
||||
"FIsidro Martinez (David Martinez) 1/6/1980",
|
||||
"FNorma Herman 6/5/1933",
|
||||
"UNayeli Teresa Herman 10/6/2001",
|
||||
"FStephanie Herman Jr. 11/5/2003",
|
||||
"MDavid Herman 6/29/2006",
|
||||
"FKimberly Zoe 4/6/1984",
|
||||
"MRobert Zoe Jr. 10/17/2005",
|
||||
"MBlake Austin Zoe 3/20/2007",
|
||||
"FSara 10/8/1988",
|
||||
"FKeri Lee 3/30/1992",
|
||||
"FMarcia Lamprecht 1/28/1933",
|
||||
"MButch Darel Peirce 1/3/1936",
|
||||
"MNorman Lamprecht 3/29/1930-3/26/2002",
|
||||
"FJulie Arabzadeh 8/21/1950",
|
||||
"FJeana Arabzadeh 3/20/1978",
|
||||
"FJoyce Kamali 1/8/1952",
|
||||
"MEarl Rodriguez 7/27/1919",
|
||||
"FKai Kamali 9/6/1974",
|
||||
"FLauren Lamprecht 12/4/1956",
|
||||
"FLaura Lamprecht 5/22/1980",
|
||||
"FLeland Lamprecht 4/6/1983",
|
||||
"MNorman Herman 2/17/1935",
|
||||
"FJan Herman 7/20/1930",
|
||||
"FBonnie Glicco 9/19/1956",
|
||||
"MCalvin Glicco 1/6/1954",
|
||||
"FAnn Marie Glicco 4/25/1978",
|
||||
"FJessica Glicco 11/14/1981",
|
||||
"MThomas Glicco 10/11/2000",
|
||||
"MGabriel Glicco 1/4/2004",
|
||||
"FMackenzie Glicco 8/7/2007",
|
||||
"MMark Herman 9/9/1957",
|
||||
"MBrandt Moss 5/4/1996",
|
||||
"MChristopher Herman 7/25/1979",
|
||||
"FKari Herman 5/12/1982",
|
||||
"MMyles McKissack 9/16/2008",
|
||||
"MLogan McKissack 10/9/2011",
|
||||
"MChris Woolery 3/11/1988",
|
||||
"FAdalin Woolery 3/14/2011",
|
||||
"MGerald Billy 3/31/1937-8/29/1982",
|
||||
"FMary Ann Herman 6/2/1934",
|
||||
"MMike Herman 8/27/1955",
|
||||
"FCarolyn Hardin 1/4/1951",
|
||||
"MMark Herman 2/7/1957",
|
||||
"MKyle Herman 6/18/1989",
|
||||
"MEric Herman 4/16/1993",
|
||||
"MJoe Herman 1/14/1959",
|
||||
"FLisa Herman 4/26/1962-3/2/2011",
|
||||
"MBrett Herman 2/2/1989",
|
||||
"FJill Elisabeth Herman 8/18/1997",
|
||||
"MJeff Herman 4/14/1961",
|
||||
"MKeith Herman 12/20/1941",
|
||||
"FMary Ann Herman 5/10/1943",
|
||||
"FCarol Herman 3/1/1943-9/30/1990",
|
||||
"MBrian Herman 6/30/1965",
|
||||
"FStuart Herman 12/22/1987",
|
||||
"MTrevor Herman 1/10/1990",
|
||||
"MCletus Barry 1/12/1922-4/30/1999",
|
||||
"FAgnes Barry 10/20/1923",
|
||||
"FJanet Barry 7/22/1947",
|
||||
"MJack Herman 1/27/1905",
|
||||
"FHelen Herman 8/22/1908-4/13/1997",
|
||||
"FJoyce Waddell 05/13/1946",
|
||||
"MDewey Lynn Waddell 9/10/1970",
|
||||
"MJonathon G Waddell 9/27/1971",
|
||||
};
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodFamily()
|
||||
{
|
||||
DateTime dateTime = DateTime.Now;
|
||||
string saveDirectory = $"D:/1-Images-A/Images-dd514b88-Results/A2) People/dd514b88/([])/Norman-{dateTime.Ticks}";
|
||||
if (Directory.Exists(Path.GetPathRoot(saveDirectory)) && Directory.Exists(saveDirectory))
|
||||
{
|
||||
int age;
|
||||
string name;
|
||||
long personKey;
|
||||
DateTime? death;
|
||||
string ageGroup;
|
||||
string? directory;
|
||||
// bool first = true;
|
||||
string[] dateSegments;
|
||||
// bool verify = false;
|
||||
DateTime parseDateTime;
|
||||
PersonName? personName;
|
||||
string[] spaceSegments;
|
||||
string personKeyFormatted;
|
||||
// bool isDefaultName = false;
|
||||
PersonBirthday personBirthday;
|
||||
string[] family = GetFamily();
|
||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
foreach (string familyMember in family)
|
||||
{
|
||||
spaceSegments = familyMember[1..].Split(' ');
|
||||
dateSegments = spaceSegments[^1].Split('-');
|
||||
name = string.Join(' ', spaceSegments[..^1]);
|
||||
if (!DateTime.TryParse(dateSegments[0], out parseDateTime))
|
||||
continue;
|
||||
personName = IPerson.GetPersonName(name);
|
||||
if (personName is null)
|
||||
continue;
|
||||
personBirthday = new(parseDateTime);
|
||||
personKey = personBirthday.Value.Ticks;
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_PropertyConfiguration.PersonBirthdayFormat, personKey);
|
||||
(age, _) = IAge.GetAge(dateTime.Ticks, personKey);
|
||||
if (dateSegments.Length == 1)
|
||||
death = null;
|
||||
else
|
||||
{
|
||||
if (!DateTime.TryParse(dateSegments[0], out parseDateTime))
|
||||
continue;
|
||||
death = parseDateTime;
|
||||
}
|
||||
if (age < 25)
|
||||
ageGroup = "1) Less-25";
|
||||
else if (age < 50)
|
||||
ageGroup = "2) Less-50";
|
||||
else if (age < 100)
|
||||
ageGroup = "3) Less-100";
|
||||
else if (age < 200)
|
||||
ageGroup = "4) Less-200";
|
||||
else
|
||||
ageGroup = "5) Else";
|
||||
directory = Path.Combine(saveDirectory, "Norman", ageGroup, $"{personName.First.Value} {personName.Last.Value}^{age}", personKeyFormatted);
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
genealogicalDataCommunication = new(personBirthday.Value,
|
||||
null,
|
||||
death,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"",
|
||||
'U',
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
// IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, null, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
||||
}
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[Ignore]
|
||||
[TestMethod]
|
||||
public void TestMethodGroup()
|
||||
{
|
||||
// const int Number = 0;
|
||||
// const int Partial = 1;
|
||||
// const int Approximate = 5;
|
||||
// const int Exact = 9;
|
||||
// //
|
||||
// const int Alive = 0;
|
||||
// const int Dead = 5;
|
||||
// //
|
||||
// const int Unknown = 0;
|
||||
// const int Male = 5;
|
||||
// const int Female = 9;
|
||||
// foreach (var item in new string[] { "Number", "Partial", "Approximate", "Exact" })
|
||||
foreach (string status in new string[] { "Alive", "Dead" })
|
||||
{
|
||||
foreach (string sex in new string[] { "Unknown", "Male", "Female" })
|
||||
_ = Directory.CreateDirectory($"D:/{status}-{sex}");
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodRename()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user