|
|
|
@ -8,7 +8,7 @@ namespace View_by_Distance.Map.Models.Stateless;
|
|
|
|
|
internal abstract class MapLogic
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private static List<PersonContainer> AddToPersonKeysThenGetNonSpecificPeopleCollection(Property.Models.Configuration propertyConfiguration, Configuration configuration, List<long> personKeys)
|
|
|
|
|
private static List<PersonContainer> AddToPersonKeysThenGetNonSpecificPeopleCollection(Configuration configuration, List<long> personKeys)
|
|
|
|
|
{
|
|
|
|
|
List<PersonContainer> results = new();
|
|
|
|
|
Person person;
|
|
|
|
@ -26,14 +26,14 @@ internal abstract class MapLogic
|
|
|
|
|
continue;
|
|
|
|
|
personKeys.Add(personKey);
|
|
|
|
|
personBirthday = IPersonBirthday.GetPersonBirthday(personKey);
|
|
|
|
|
person = IPerson.GetPerson(propertyConfiguration.ResultAllInOne, personKey, personBirthday);
|
|
|
|
|
personContainer = new(approximateYears, person, new PersonBirthday[] { personBirthday }, personDisplayDirectoryAllFiles, propertyConfiguration.ResultAllInOne, personKey);
|
|
|
|
|
person = IPerson.GetPerson(configuration.MappingDefaultName, personKey, personBirthday);
|
|
|
|
|
personContainer = new(approximateYears, person, new PersonBirthday[] { personBirthday }, personDisplayDirectoryAllFiles, configuration.MappingDefaultName, personKey);
|
|
|
|
|
results.Add(personContainer);
|
|
|
|
|
}
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SetPersonCollections(Configuration configuration, string resizeFilenameExtension, List<PersonContainer> personContainers, List<long> personKeys, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, Dictionary<int, List<int>> skipCollection)
|
|
|
|
|
private static void SetPersonCollections(Configuration configuration, string resizeFilenameExtension, List<PersonContainer> personContainers, List<long> personKeys, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<string> personKeyFormattedCollection, Dictionary<int, List<int>> skipCollection)
|
|
|
|
|
{
|
|
|
|
|
int? id;
|
|
|
|
|
long personKey;
|
|
|
|
@ -60,22 +60,22 @@ internal abstract class MapLogic
|
|
|
|
|
personKey = personBirthday.Value.Ticks;
|
|
|
|
|
personKeys.Add(personKey);
|
|
|
|
|
}
|
|
|
|
|
if (personContainer.PersonBirthdays.Length > 1)
|
|
|
|
|
foreach (PersonBirthday personBirthday in personContainer.PersonBirthdays)
|
|
|
|
|
{
|
|
|
|
|
foreach (PersonBirthday personBirthday in personContainer.PersonBirthdays)
|
|
|
|
|
{
|
|
|
|
|
personKeyFormatted = IPersonBirthday.GetFormatted(configuration.PersonBirthdayFormat, personBirthday);
|
|
|
|
|
newestPersonKeyFormatted = IPersonBirthday.GetFormatted(configuration.PersonBirthdayFormat, personContainer.PersonKey.Value);
|
|
|
|
|
if (!personKeyFormattedToNewestPersonKeyFormatted.ContainsKey(personKeyFormatted))
|
|
|
|
|
personKeyFormattedToNewestPersonKeyFormatted.Add(personKeyFormatted, newestPersonKeyFormatted);
|
|
|
|
|
}
|
|
|
|
|
personKeyFormatted = IPersonBirthday.GetFormatted(configuration.PersonBirthdayFormat, personBirthday);
|
|
|
|
|
personKeyFormattedCollection.Add(personKeyFormatted);
|
|
|
|
|
if (personContainer.PersonBirthdays.Length < 1)
|
|
|
|
|
continue;
|
|
|
|
|
newestPersonKeyFormatted = IPersonBirthday.GetFormatted(configuration.PersonBirthdayFormat, personContainer.PersonKey.Value);
|
|
|
|
|
if (!personKeyFormattedToNewestPersonKeyFormatted.ContainsKey(personKeyFormatted))
|
|
|
|
|
personKeyFormattedToNewestPersonKeyFormatted.Add(personKeyFormatted, newestPersonKeyFormatted);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static List<(string, char, string, int?, int?, List<Face>?)> DeleteEmptyDirectoriesAndGetCollection(Configuration configuration, long ticks, string eDistanceContentDirectory, Dictionary<int, List<Face>> keyValuePairs)
|
|
|
|
|
internal static List<(string, string[], string, int?, int?, List<Face>?)> DeleteEmptyDirectoriesAndGetCollection(Configuration configuration, long ticks, string eDistanceContentDirectory, List<string> personKeyFormattedCollection, Dictionary<int, List<Face>> keyValuePairs)
|
|
|
|
|
{
|
|
|
|
|
List<(string, char, string, int?, int?, List<Face>?)> results = new();
|
|
|
|
|
List<(string, string[], string, int?, int?, List<Face>?)> results = new();
|
|
|
|
|
int? id;
|
|
|
|
|
bool check;
|
|
|
|
|
string[] files;
|
|
|
|
@ -92,6 +92,7 @@ internal abstract class MapLogic
|
|
|
|
|
string[] personNameDirectories;
|
|
|
|
|
string[] personNameLinkDirectories;
|
|
|
|
|
string? personFirstInitialDirectory;
|
|
|
|
|
string[] personDisplayDirectoryNames;
|
|
|
|
|
bool keyValuePairsAny = keyValuePairs.Any();
|
|
|
|
|
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
|
|
|
|
string[] ticksDirectories = Directory.GetDirectories(eDistanceContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
|
|
|
@ -129,12 +130,18 @@ internal abstract class MapLogic
|
|
|
|
|
File.Delete(file);
|
|
|
|
|
foreach (string personNameDirectory in personNameDirectories)
|
|
|
|
|
{
|
|
|
|
|
personFirstInitial = Path.GetFileName(personNameDirectory)[..1];
|
|
|
|
|
if (personFirstInitial is null)
|
|
|
|
|
personDisplayDirectoryNames = IPath.GetDirectoryNames(personNameDirectory);
|
|
|
|
|
if (!personDisplayDirectoryNames.Any())
|
|
|
|
|
continue;
|
|
|
|
|
personFirstInitialDirectory = Path.Combine(yearDirectory, personFirstInitial.ToString());
|
|
|
|
|
if (personNameDirectory != personFirstInitialDirectory)
|
|
|
|
|
Directory.Move(personNameDirectory, personFirstInitialDirectory);
|
|
|
|
|
if (personDisplayDirectoryNames[^1].Length == 1 || personDisplayDirectoryNames[^1] == configuration.MappingDefaultName || !personKeyFormattedCollection.Contains(personKeyFormatted))
|
|
|
|
|
personFirstInitialDirectory = personNameDirectory;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
personFirstInitial = personDisplayDirectoryNames[^1][..1];
|
|
|
|
|
personFirstInitialDirectory = Path.Combine(yearDirectory, personFirstInitial.ToString());
|
|
|
|
|
if (personNameDirectory != personFirstInitialDirectory)
|
|
|
|
|
Directory.Move(personNameDirectory, personFirstInitialDirectory);
|
|
|
|
|
}
|
|
|
|
|
files = Directory.GetFiles(personFirstInitialDirectory, "*", SearchOption.TopDirectoryOnly);
|
|
|
|
|
if (personKeyFormatted == nameof(Models.MapLogic.ForceSingleImage) && files.Any())
|
|
|
|
|
throw new Exception($"Move personKey directories up one from {nameof(Models.MapLogic.ForceSingleImage)} and delete {nameof(Models.MapLogic.ForceSingleImage)} directory!");
|
|
|
|
@ -168,7 +175,7 @@ internal abstract class MapLogic
|
|
|
|
|
checks.Add(normalizedPixelPercentage.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
results.Add(new(personKeyFormatted, personFirstInitial[0], file, id, normalizedPixelPercentage, faces));
|
|
|
|
|
results.Add(new(personKeyFormatted, personDisplayDirectoryNames, file, id, normalizedPixelPercentage, faces));
|
|
|
|
|
}
|
|
|
|
|
personNameLinkDirectories = Directory.GetDirectories(personFirstInitialDirectory, "*", SearchOption.TopDirectoryOnly);
|
|
|
|
|
foreach (string personNameLinkDirectory in personNameLinkDirectories)
|
|
|
|
@ -207,7 +214,7 @@ internal abstract class MapLogic
|
|
|
|
|
return results.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SetKeyValuePairs(Configuration configuration, long ticks, List<PersonContainer> personContainers, List<Face> distinctFilteredFaces, List<(string, int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges)
|
|
|
|
|
private static void SetKeyValuePairs(Configuration configuration, long ticks, List<PersonContainer> personContainers, List<Face> distinctFilteredFaces, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges)
|
|
|
|
|
{
|
|
|
|
|
string check;
|
|
|
|
|
string rightPadded;
|
|
|
|
@ -228,32 +235,46 @@ internal abstract class MapLogic
|
|
|
|
|
if (!personKeyFormattedToPersonContainer.ContainsKey(newestPersonKeyFormatted))
|
|
|
|
|
personKeyFormattedToPersonContainer.Add(newestPersonKeyFormatted, personContainer);
|
|
|
|
|
}
|
|
|
|
|
foreach ((string personKeyFormatted, int id, int normalizedPixelPercentage) in personKeyFormattedIdThenNormalizedPixelPercentageCollection)
|
|
|
|
|
if (personKeyFormattedIdThenNormalizedPixelPercentageCollection.Any())
|
|
|
|
|
{
|
|
|
|
|
personBirthday = IPersonBirthday.GetPersonBirthday(configuration.PersonBirthdayFormat, personKeyFormatted);
|
|
|
|
|
if (personBirthday is null)
|
|
|
|
|
continue;
|
|
|
|
|
if (!idThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
|
|
|
|
check = normalizedPixelPercentage.ToString();
|
|
|
|
|
if (check.Length == configuration.LocationDigits)
|
|
|
|
|
string personDisplayDirectory;
|
|
|
|
|
PersonContainer personContainer;
|
|
|
|
|
string personDisplayDirectoryName;
|
|
|
|
|
Dictionary<string, (string[], PersonContainer)> personDisplayDirectoryTo = new();
|
|
|
|
|
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, int id, int normalizedPixelPercentage) in personKeyFormattedIdThenNormalizedPixelPercentageCollection)
|
|
|
|
|
{
|
|
|
|
|
if (!idThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
|
|
|
|
personBirthday = IPersonBirthday.GetPersonBirthday(configuration.PersonBirthdayFormat, personKeyFormatted);
|
|
|
|
|
if (personBirthday is null)
|
|
|
|
|
continue;
|
|
|
|
|
personDisplayDirectoryName = personDisplayDirectoryNames[^1];
|
|
|
|
|
personDisplayDirectory = Path.Combine(personDisplayDirectoryNames);
|
|
|
|
|
if (!personKeyFormattedToPersonContainer.ContainsKey(personKeyFormatted))
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rightPadded = ILocation.GetRightPadded(configuration.LocationDigits, check);
|
|
|
|
|
normalizedPixelPercentageInDecimalForm = int.Parse(rightPadded);
|
|
|
|
|
if (!idThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentageInDecimalForm))
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentageInDecimalForm, new());
|
|
|
|
|
if (!personKeyFormattedToPersonContainer.ContainsKey(personKeyFormatted))
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
|
|
|
{
|
|
|
|
|
personContainer = new(personBirthday, personDisplayDirectoryName);
|
|
|
|
|
personKeyFormattedToPersonContainer.Add(personKeyFormatted, personContainer);
|
|
|
|
|
}
|
|
|
|
|
if (personDisplayDirectoryName.Length != 1 && personDisplayDirectoryName != configuration.MappingDefaultName && !personDisplayDirectoryTo.ContainsKey(personDisplayDirectory))
|
|
|
|
|
personDisplayDirectoryTo.Add(personDisplayDirectory, new(personDisplayDirectoryNames, personKeyFormattedToPersonContainer[personKeyFormatted]));
|
|
|
|
|
if (!idThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
|
|
|
|
check = normalizedPixelPercentage.ToString();
|
|
|
|
|
if (check.Length == configuration.LocationDigits)
|
|
|
|
|
{
|
|
|
|
|
if (!idThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rightPadded = ILocation.GetRightPadded(configuration.LocationDigits, check);
|
|
|
|
|
normalizedPixelPercentageInDecimalForm = int.Parse(rightPadded);
|
|
|
|
|
if (!idThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentageInDecimalForm))
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentageInDecimalForm, new());
|
|
|
|
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (KeyValuePair<string, (string[], PersonContainer)> keyValuePair in personDisplayDirectoryTo)
|
|
|
|
|
possiblyNewPersonDisplayDirectoryNamesAndPersonContainer.Add(keyValuePair.Value);
|
|
|
|
|
}
|
|
|
|
|
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in idThenNormalizedPixelPercentageToPersonContainerCollection)
|
|
|
|
|
{
|
|
|
|
@ -265,31 +286,37 @@ internal abstract class MapLogic
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
SetPersonTicks(ticks, distinctFilteredFaces, personKeyToRanges, idThenNormalizedPixelPercentageToPersonContainers);
|
|
|
|
|
foreach ((string personKeyFormatted, int id, int normalizedPixelPercentage) in incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection)
|
|
|
|
|
if (incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection.Any())
|
|
|
|
|
{
|
|
|
|
|
personBirthday = IPersonBirthday.GetPersonBirthday(configuration.PersonBirthdayFormat, personKeyFormatted);
|
|
|
|
|
if (personBirthday is null)
|
|
|
|
|
continue;
|
|
|
|
|
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
|
|
|
|
check = normalizedPixelPercentage.ToString();
|
|
|
|
|
if (check.Length == configuration.LocationDigits)
|
|
|
|
|
PersonContainer personContainer;
|
|
|
|
|
foreach ((string personKeyFormatted, int id, int normalizedPixelPercentage) in incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection)
|
|
|
|
|
{
|
|
|
|
|
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
|
|
|
|
personBirthday = IPersonBirthday.GetPersonBirthday(configuration.PersonBirthdayFormat, personKeyFormatted);
|
|
|
|
|
if (personBirthday is null)
|
|
|
|
|
continue;
|
|
|
|
|
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
|
|
|
|
check = normalizedPixelPercentage.ToString();
|
|
|
|
|
if (!personKeyFormattedToPersonContainer.ContainsKey(personKeyFormatted))
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rightPadded = ILocation.GetRightPadded(configuration.LocationDigits, check);
|
|
|
|
|
normalizedPixelPercentageInDecimalForm = int.Parse(rightPadded);
|
|
|
|
|
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentageInDecimalForm))
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentageInDecimalForm, new());
|
|
|
|
|
if (!personKeyFormattedToPersonContainer.ContainsKey(personKeyFormatted))
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
|
|
|
{
|
|
|
|
|
personContainer = new(personBirthday, configuration.MappingDefaultName);
|
|
|
|
|
personKeyFormattedToPersonContainer.Add(personKeyFormatted, personContainer);
|
|
|
|
|
}
|
|
|
|
|
if (check.Length == configuration.LocationDigits)
|
|
|
|
|
{
|
|
|
|
|
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rightPadded = ILocation.GetRightPadded(configuration.LocationDigits, check);
|
|
|
|
|
normalizedPixelPercentageInDecimalForm = int.Parse(rightPadded);
|
|
|
|
|
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentageInDecimalForm))
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentageInDecimalForm, new());
|
|
|
|
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection)
|
|
|
|
@ -399,17 +426,18 @@ internal abstract class MapLogic
|
|
|
|
|
{ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int SetCollectionsAndGetUnableToMatchCount(Configuration configuration, long ticks, string eDistanceContentDirectory, Shared.Models.Methods.IFaceDistance? distance, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, char, string, int?, int?, List<Face>?)> collection)
|
|
|
|
|
private static int SetCollectionsAndGetUnableToMatchCount(Configuration configuration, long ticks, string eDistanceContentDirectory, Shared.Models.Methods.IFaceDistance? distance, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, string[], string, int?, int?, List<Face>?)> collection)
|
|
|
|
|
{
|
|
|
|
|
int result = 0;
|
|
|
|
|
string? checkFile;
|
|
|
|
|
List<Face> checkFaces = new();
|
|
|
|
|
string newestPersonKeyFormatted;
|
|
|
|
|
string personDisplayDirectoryName;
|
|
|
|
|
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
|
|
|
|
string message = $") {collection.Count:000} join from ticks Director(ies) - B - {totalSeconds} total second(s)";
|
|
|
|
|
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
|
|
|
|
using ProgressBar progressBar = new(collection.Count, message, options);
|
|
|
|
|
foreach ((string personKeyFormatted, char personFirstInitial, string file, int? id, int? normalizedPixelPercentage, List<Face>? faces) in collection)
|
|
|
|
|
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, string file, int? id, int? normalizedPixelPercentage, List<Face>? faces) in collection)
|
|
|
|
|
{
|
|
|
|
|
progressBar.Tick();
|
|
|
|
|
if (id is null || normalizedPixelPercentage is null)
|
|
|
|
@ -464,8 +492,9 @@ internal abstract class MapLogic
|
|
|
|
|
newestPersonKeyFormatted = personKeyFormatted;
|
|
|
|
|
else
|
|
|
|
|
newestPersonKeyFormatted = personKeyFormattedToNewestPersonKeyFormatted[personKeyFormatted];
|
|
|
|
|
if (personFirstInitial != '!')
|
|
|
|
|
personKeyFormattedIdThenNormalizedPixelPercentageCollection.Add(new(newestPersonKeyFormatted, id.Value, normalizedPixelPercentage.Value));
|
|
|
|
|
personDisplayDirectoryName = personDisplayDirectoryNames[^1];
|
|
|
|
|
if (!string.IsNullOrEmpty(personDisplayDirectoryName) && personDisplayDirectoryName[0] != '!')
|
|
|
|
|
personKeyFormattedIdThenNormalizedPixelPercentageCollection.Add(new(newestPersonKeyFormatted, personDisplayDirectoryNames, id.Value, normalizedPixelPercentage.Value));
|
|
|
|
|
else
|
|
|
|
|
incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection.Add(new(newestPersonKeyFormatted, id.Value, normalizedPixelPercentage.Value));
|
|
|
|
|
}
|
|
|
|
@ -548,26 +577,24 @@ internal abstract class MapLogic
|
|
|
|
|
SetPersonKeysRanges(ticks, personTicks, personKeyToRanges);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<long> GetNotMappedPersonKeys(Property.Models.Configuration propertyConfiguration, List<PersonContainer> personContainers, long[] personKeyCollection)
|
|
|
|
|
private static List<PersonContainer> GetNotMappedPersonContainers(Configuration configuration, List<PersonContainer> personContainers, long[] personKeyCollection)
|
|
|
|
|
{
|
|
|
|
|
List<long> results = new();
|
|
|
|
|
List<long> notMappedAndNotNamedPersonKeys = new();
|
|
|
|
|
List<long> notMappedAndWithNamedPersonKeys = new();
|
|
|
|
|
List<PersonContainer> results = new();
|
|
|
|
|
List<PersonContainer> notMappedAndNotNamedPersonKeys = new();
|
|
|
|
|
List<PersonContainer> notMappedAndWithNamedPersonKeys = new();
|
|
|
|
|
foreach (PersonContainer personContainer in personContainers)
|
|
|
|
|
{
|
|
|
|
|
if (personContainer.Person is null || personContainer.PersonKey is null || personContainer.PersonBirthdays is null || !personContainer.PersonBirthdays.Any())
|
|
|
|
|
continue;
|
|
|
|
|
if (personKeyCollection.Contains(personContainer.PersonKey.Value))
|
|
|
|
|
continue;
|
|
|
|
|
else if (string.IsNullOrEmpty(personContainer.PersonDisplayDirectoryName) || personContainer.PersonDisplayDirectoryName == propertyConfiguration.ResultAllInOne)
|
|
|
|
|
notMappedAndNotNamedPersonKeys.Add(personContainer.PersonKey.Value);
|
|
|
|
|
else if (string.IsNullOrEmpty(personContainer.PersonDisplayDirectoryName) || personContainer.PersonDisplayDirectoryName == configuration.MappingDefaultName)
|
|
|
|
|
notMappedAndNotNamedPersonKeys.Add(personContainer);
|
|
|
|
|
else
|
|
|
|
|
notMappedAndWithNamedPersonKeys.Add(personContainer.PersonKey.Value);
|
|
|
|
|
notMappedAndWithNamedPersonKeys.Add(personContainer);
|
|
|
|
|
}
|
|
|
|
|
notMappedAndNotNamedPersonKeys.Sort();
|
|
|
|
|
notMappedAndWithNamedPersonKeys.Sort();
|
|
|
|
|
results.AddRange(notMappedAndNotNamedPersonKeys);
|
|
|
|
|
results.AddRange(notMappedAndWithNamedPersonKeys);
|
|
|
|
|
results.AddRange(from l in notMappedAndNotNamedPersonKeys orderby l.PersonKey is not null, l.PersonKey select l);
|
|
|
|
|
results.AddRange(from l in notMappedAndWithNamedPersonKeys orderby l.PersonKey is not null, l.PersonKey select l);
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -586,15 +613,19 @@ internal abstract class MapLogic
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SetPersonKeyToPersonContainer(Property.Models.Configuration propertyConfiguration, List<PersonContainer> personContainers, long[] personKeyCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer)
|
|
|
|
|
private static void SetPersonKeyToPersonContainer(Configuration configuration, List<PersonContainer> personContainers, long[] personKeyCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer)
|
|
|
|
|
{
|
|
|
|
|
string personDisplayDirectoryName;
|
|
|
|
|
foreach (PersonContainer personContainer in personContainers)
|
|
|
|
|
{
|
|
|
|
|
if (personContainer.PersonKey is null || !personKeyCollection.Contains(personContainer.PersonKey.Value))
|
|
|
|
|
continue;
|
|
|
|
|
if (personKeyToPersonContainer.ContainsKey(personContainer.PersonKey.Value))
|
|
|
|
|
{
|
|
|
|
|
if (personKeyToPersonContainer[personContainer.PersonKey.Value].PersonDisplayDirectoryName == personContainer.PersonDisplayDirectoryName)
|
|
|
|
|
personDisplayDirectoryName = personKeyToPersonContainer[personContainer.PersonKey.Value].PersonDisplayDirectoryName;
|
|
|
|
|
if (string.IsNullOrEmpty(personDisplayDirectoryName))
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
if (personDisplayDirectoryName == personContainer.PersonDisplayDirectoryName || (personDisplayDirectoryName[0] == personContainer.PersonDisplayDirectoryName[0] && (personDisplayDirectoryName.Length == 1 || personContainer.PersonDisplayDirectoryName.Length == 1)))
|
|
|
|
|
continue;
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
@ -605,7 +636,7 @@ internal abstract class MapLogic
|
|
|
|
|
int? approximateYears = null;
|
|
|
|
|
PersonBirthday? personBirthday;
|
|
|
|
|
PersonContainer personContainer;
|
|
|
|
|
string displayDirectoryName = propertyConfiguration.ResultAllInOne;
|
|
|
|
|
string displayDirectoryName = configuration.MappingDefaultName;
|
|
|
|
|
foreach (long personKey in personKeyCollection)
|
|
|
|
|
{
|
|
|
|
|
if (personKeyToPersonContainer.ContainsKey(personKey))
|
|
|
|
@ -617,19 +648,21 @@ internal abstract class MapLogic
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static void Set(Property.Models.Configuration propertyConfiguration, Configuration? configuration, string resizeFilenameExtension, long ticks, List<PersonContainer> personContainers, string eDistanceContentDirectory, List<Face> distinctFilteredFaces, Shared.Models.Methods.IFaceDistance? distance, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, List<long> notMappedPersonKeys, Dictionary<int, List<int>> skipCollection, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers)
|
|
|
|
|
internal static void Set(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, Configuration? configuration, string resizeFilenameExtension, long ticks, List<PersonContainer> personContainers, string eDistanceContentDirectory, List<Face> distinctFilteredFaces, Shared.Models.Methods.IFaceDistance faceDistance, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, List<PersonContainer> notMappedPersonContainers, Dictionary<int, List<int>> skipCollection, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers)
|
|
|
|
|
{
|
|
|
|
|
if (configuration is null)
|
|
|
|
|
throw new NullReferenceException(nameof(configuration));
|
|
|
|
|
List<long> personKeys = new();
|
|
|
|
|
List<long?> nullablePersonKeyCollection = new();
|
|
|
|
|
List<string> personKeyFormattedCollection = new();
|
|
|
|
|
Dictionary<int, List<Face>> keyValuePairs = new();
|
|
|
|
|
Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted = new();
|
|
|
|
|
List<(string, int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection = new();
|
|
|
|
|
List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer = new();
|
|
|
|
|
List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection = new();
|
|
|
|
|
List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection = new();
|
|
|
|
|
Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers = new();
|
|
|
|
|
SetPersonCollections(configuration, resizeFilenameExtension, personContainers, personKeys, personKeyFormattedToNewestPersonKeyFormatted, skipCollection);
|
|
|
|
|
personContainers.AddRange(AddToPersonKeysThenGetNonSpecificPeopleCollection(propertyConfiguration, configuration, personKeys));
|
|
|
|
|
SetPersonCollections(configuration, resizeFilenameExtension, personContainers, personKeys, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedCollection, skipCollection);
|
|
|
|
|
personContainers.AddRange(AddToPersonKeysThenGetNonSpecificPeopleCollection(configuration, personKeys));
|
|
|
|
|
foreach (Face face in distinctFilteredFaces)
|
|
|
|
|
{
|
|
|
|
|
if (face.FaceEncoding is null || face.Location?.NormalizedPixelPercentage is null)
|
|
|
|
@ -640,9 +673,9 @@ internal abstract class MapLogic
|
|
|
|
|
keyValuePairs.Add(face.Mapping.MappingFromItem.Id, new());
|
|
|
|
|
keyValuePairs[face.Mapping.MappingFromItem.Id].Add(face);
|
|
|
|
|
}
|
|
|
|
|
List<(string, char, string, int?, int?, List<Face>?)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, ticks, eDistanceContentDirectory, keyValuePairs);
|
|
|
|
|
int unableToMatchCount = SetCollectionsAndGetUnableToMatchCount(configuration, ticks, eDistanceContentDirectory, distance, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenNormalizedPixelPercentageCollection, incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, collection);
|
|
|
|
|
SetKeyValuePairs(configuration, ticks, personContainers, distinctFilteredFaces, personKeyFormattedIdThenNormalizedPixelPercentageCollection, incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, personKeyToPersonContainer, idThenNormalizedPixelPercentageToPersonContainers, incorrectIdThenNormalizedPixelPercentageToPersonContainers, personKeyToRanges);
|
|
|
|
|
List<(string, string[], string, int?, int?, List<Face>?)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, ticks, eDistanceContentDirectory, personKeyFormattedCollection, keyValuePairs);
|
|
|
|
|
int unableToMatchCount = SetCollectionsAndGetUnableToMatchCount(configuration, ticks, eDistanceContentDirectory, faceDistance, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenNormalizedPixelPercentageCollection, incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, collection);
|
|
|
|
|
SetKeyValuePairs(configuration, ticks, personContainers, distinctFilteredFaces, personKeyFormattedIdThenNormalizedPixelPercentageCollection, incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, personKeyToPersonContainer, idThenNormalizedPixelPercentageToPersonContainers, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, incorrectIdThenNormalizedPixelPercentageToPersonContainers, personKeyToRanges);
|
|
|
|
|
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
|
|
|
|
string message = $") {collection.Count:000} message from ticks Director(ies) - C - {unableToMatchCount} Unable To Match Count / {collection.Count} Collection - {totalSeconds} total second(s)";
|
|
|
|
|
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
|
|
|
@ -656,9 +689,11 @@ internal abstract class MapLogic
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
long[] personKeyCollection = (from l in nullablePersonKeyCollection where l is not null select l.Value).Distinct().ToArray();
|
|
|
|
|
notMappedPersonKeys.AddRange(GetNotMappedPersonKeys(propertyConfiguration, personContainers, personKeyCollection));
|
|
|
|
|
SetPersonKeyToPersonContainer(propertyConfiguration, personContainers, personKeyCollection, personKeyToPersonContainer);
|
|
|
|
|
SetPersonKeyToPersonContainer(configuration, personContainers, personKeyCollection, personKeyToPersonContainer);
|
|
|
|
|
notMappedPersonContainers.AddRange(GetNotMappedPersonContainers(configuration, personContainers, personKeyCollection));
|
|
|
|
|
AppendToSkipCollection(skipCollection, idThenNormalizedPixelPercentageToPersonContainers, incorrectIdThenNormalizedPixelPercentageToPersonContainers);
|
|
|
|
|
if (possiblyNewPersonDisplayDirectoryNamesAndPersonContainer.Any())
|
|
|
|
|
faceDistance.SavePossiblyNewPersonContainers(propertyConfiguration, configuration.PersonBirthdayFormat, resizeFilenameExtension, personKeyToPersonContainer, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|