|
|
|
@ -25,11 +25,14 @@ public partial class DlibDotNet
|
|
|
|
|
private readonly C_Resize _Resize;
|
|
|
|
|
private readonly F_Random _Random;
|
|
|
|
|
private readonly IConsole _Console;
|
|
|
|
|
private readonly string? _GEDCOMFile;
|
|
|
|
|
private readonly E_Distance _Distance;
|
|
|
|
|
private readonly Serilog.ILogger? _Log;
|
|
|
|
|
private readonly D2_FaceParts _FaceParts;
|
|
|
|
|
private readonly AppSettings _AppSettings;
|
|
|
|
|
private readonly List<string> _Exceptions;
|
|
|
|
|
private readonly string[]? _GEDCOMFooterLines;
|
|
|
|
|
private readonly string[]? _GEDCOMHeaderLines;
|
|
|
|
|
private readonly IsEnvironment _IsEnvironment;
|
|
|
|
|
private readonly bool _PropertyRootExistedBefore;
|
|
|
|
|
private readonly PersonContainer[] _PersonContainers;
|
|
|
|
@ -101,7 +104,12 @@ public partial class DlibDotNet
|
|
|
|
|
_MapConfiguration = Get(configuration, _Faces.FileNameExtension, _Faces.HiddenFileNameExtension, _FaceParts.FileNameExtension);
|
|
|
|
|
_Distance = new(configuration.DistanceMoveUnableToMatch, configuration.DistanceRenameToMatch, _Configuration.FaceConfidencePercent, configuration.RangeFaceConfidence);
|
|
|
|
|
if (_PropertyRootExistedBefore || !_ArgZeroIsConfigurationRootDirectory)
|
|
|
|
|
{
|
|
|
|
|
_GEDCOMFile = null;
|
|
|
|
|
_GEDCOMFooterLines = null;
|
|
|
|
|
_GEDCOMHeaderLines = null;
|
|
|
|
|
_PersonContainers = Array.Empty<PersonContainer>();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
|
|
|
@ -115,8 +123,10 @@ public partial class DlibDotNet
|
|
|
|
|
if (rootResultsDirectory is null)
|
|
|
|
|
throw new Exception();
|
|
|
|
|
Storage storage = new(rootDirectory, rootResultsDirectory, peopleRootDirectory);
|
|
|
|
|
_GEDCOMFile = Path.GetFullPath(string.Concat(peopleRootDirectory, configuration.GEDCOMFile));
|
|
|
|
|
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(Path.Combine(peopleRootDirectory, "{}"));
|
|
|
|
|
_PersonContainers = Shared.Models.Stateless.Methods.IPersonContainer.GetPersonContainers(storage, configuration.PersonBirthdayFormat, configuration.PersonCharacters.ToArray(), _Faces.FileNameExtension);
|
|
|
|
|
(_GEDCOMHeaderLines, Dictionary<string, List<string>> individuals, _GEDCOMFooterLines) = Shared.Models.Stateless.Methods.IPerson.GetIndividuals(_GEDCOMFile);
|
|
|
|
|
_PersonContainers = Shared.Models.Stateless.Methods.IPersonContainer.GetPersonContainers(storage, configuration.PersonBirthdayFormat, configuration.PersonCharacters.ToArray(), _Faces.FileNameExtension, individuals);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(
|
|
|
|
@ -182,7 +192,7 @@ public partial class DlibDotNet
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Verify(Models.Configuration configuration)
|
|
|
|
|
private static void Verify(Models.Configuration configuration)
|
|
|
|
|
{
|
|
|
|
|
if (!configuration.OutputResolutions.Any() || string.IsNullOrEmpty(configuration.OutputResolutions[0]) || !configuration.ValidResolutions.Contains(configuration.OutputResolutions[0]))
|
|
|
|
|
throw new NullReferenceException($"{nameof(configuration.OutputResolutions)} must be fileNameToCollection valid outputResolution!");
|
|
|
|
@ -1044,66 +1054,6 @@ public partial class DlibDotNet
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CreateTree(PersonContainer[] personContainers, long ticks, string a2PeopleContentDirectory, Dictionary<long, List<int>> personKeyToIds)
|
|
|
|
|
{
|
|
|
|
|
string by;
|
|
|
|
|
string[] matches;
|
|
|
|
|
const int zero = 0;
|
|
|
|
|
string[] pGedFiles;
|
|
|
|
|
string[] pGedLines;
|
|
|
|
|
string personKeyFormatted;
|
|
|
|
|
List<long> distinct = new();
|
|
|
|
|
PersonBirthday personBirthday;
|
|
|
|
|
string rootDirectory = Path.Combine(a2PeopleContentDirectory, $"{ticks}-Tree");
|
|
|
|
|
List<string> lines = new()
|
|
|
|
|
{
|
|
|
|
|
"0 HEAD",
|
|
|
|
|
"1 SOUR DlibDotNet",
|
|
|
|
|
$"1 FILE {ticks}",
|
|
|
|
|
$"1 DATE {new DateTime(ticks):dd MMM yyyy}",
|
|
|
|
|
"1 DEST ANSTFILE",
|
|
|
|
|
"1 GEDC",
|
|
|
|
|
"2 VERS 5.5.1",
|
|
|
|
|
"2 FORM LINEAGE-LINKED",
|
|
|
|
|
"1 SUBM @1980-01-17_05@",
|
|
|
|
|
"2 NAME Mike Phares Jr",
|
|
|
|
|
"1 SUBN",
|
|
|
|
|
};
|
|
|
|
|
foreach (PersonContainer personContainer in personContainers)
|
|
|
|
|
{
|
|
|
|
|
if (personContainer.Key is null || personContainer.Birthdays is null || personContainer.Person is null || !personContainer.Birthdays.Any())
|
|
|
|
|
continue;
|
|
|
|
|
if (personContainer.DisplayDirectoryName == _Configuration.MappingDefaultName || personContainer.Person.Name.Alias.Value == "Z")
|
|
|
|
|
continue;
|
|
|
|
|
if (distinct.Contains(personContainer.Key.Value))
|
|
|
|
|
continue;
|
|
|
|
|
distinct.Add(personContainer.Key.Value);
|
|
|
|
|
if (!personKeyToIds.ContainsKey(personContainer.Key.Value))
|
|
|
|
|
continue;
|
|
|
|
|
personBirthday = personContainer.Birthdays[zero];
|
|
|
|
|
personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personBirthday);
|
|
|
|
|
by = Shared.Models.Stateless.Methods.IPersonBirthday.IsCounterPersonBirthday(personBirthday) ? _Configuration.PropertyConfiguration.ResultAllInOne : "People";
|
|
|
|
|
matches = (from l in personContainer.DisplayDirectoryAllFiles where !string.IsNullOrEmpty(personKeyFormatted) && l.Contains(personKeyFormatted) select l).ToArray();
|
|
|
|
|
if (!matches.Any())
|
|
|
|
|
continue;
|
|
|
|
|
pGedFiles = (from l in matches where l.EndsWith(".pged") select l).ToArray();
|
|
|
|
|
if (!pGedFiles.Any())
|
|
|
|
|
continue;
|
|
|
|
|
pGedLines = File.ReadAllLines(pGedFiles[0]);
|
|
|
|
|
lines.AddRange(pGedLines);
|
|
|
|
|
// segments = personContainer.DisplayDirectoryName.Split(_Configuration.PersonCharacters.ToArray());
|
|
|
|
|
// if (segments.Length < 2)
|
|
|
|
|
// directory = Path.Combine(rootDirectory, $"000 {personKeyFormatted} {personContainer.DisplayDirectoryName}");
|
|
|
|
|
// else
|
|
|
|
|
// directory = Path.Combine(rootDirectory, $"{segments[1].PadLeft(3, '0')} {personKeyFormatted} {personContainer.DisplayDirectoryName}");
|
|
|
|
|
// if (Directory.Exists(directory))
|
|
|
|
|
// continue;
|
|
|
|
|
// _ = Directory.CreateDirectory(directory);
|
|
|
|
|
}
|
|
|
|
|
lines.Add("0 TRLR");
|
|
|
|
|
File.WriteAllLines(Path.Combine(a2PeopleContentDirectory, $"{ticks}.ged"), lines);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Search(long ticks, string argZero, string propertyRoot)
|
|
|
|
|
{
|
|
|
|
|
int t;
|
|
|
|
@ -1162,8 +1112,8 @@ public partial class DlibDotNet
|
|
|
|
|
containers = Shared.Models.Stateless.Methods.IContainer.SortContainers(_Configuration.PropertyConfiguration, _Configuration.IgnoreRelativePaths, _ArgZeroIsConfigurationRootDirectory, argZero, containers);
|
|
|
|
|
MapLogic mapLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _MapConfiguration, _PersonContainers, ticks, a2PeopleSingletonDirectory, eDistanceContentDirectory);
|
|
|
|
|
personKeyToIds = mapLogic.GetPersonKeyToIds();
|
|
|
|
|
if (a2PeopleContentDirectory is not null)
|
|
|
|
|
CreateTree(_PersonContainers, ticks, a2PeopleContentDirectory, personKeyToIds);
|
|
|
|
|
if (!string.IsNullOrEmpty(_GEDCOMFile) && !string.IsNullOrEmpty(a2PeopleContentDirectory) && _GEDCOMHeaderLines is not null && _GEDCOMFooterLines is not null)
|
|
|
|
|
Shared.Models.Stateless.Methods.IPerson.CreateTree(_Configuration.MappingDefaultName, _Configuration.PersonBirthdayFormat, _Configuration.PropertyConfiguration.ResultAllInOne, _PersonContainers, _GEDCOMHeaderLines, _GEDCOMFooterLines, ticks, a2PeopleContentDirectory, personKeyToIds);
|
|
|
|
|
fileNameToCollection = !Directory.Exists(fPhotoPrismSingletonDirectory) ? fileNameToCollection = new() : F_PhotoPrism.GetFileNameToCollection(fPhotoPrismSingletonDirectory);
|
|
|
|
|
Dictionary<int, List<LocationContainer<MetadataExtractor.Directory>>> idToLocationContainers = GetDictionary(ticks, a2PeopleContentDirectory, eDistanceContentDirectory);
|
|
|
|
|
FullDoWork(argZero, propertyRoot, ticks, aResultsFullGroupDirectory, bResultsFullGroupDirectory, t, containers, propertyLogic, metadata, eDistanceContentDirectory, fileNameToCollection, idToLocationContainers, mapLogic);
|
|
|
|
|