Ticks
This commit is contained in:
@ -2,6 +2,7 @@ using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
using WindowsShortcutFactory;
|
||||
|
||||
namespace View_by_Distance.Map.Models;
|
||||
@ -10,16 +11,16 @@ public class MapLogic
|
||||
{
|
||||
|
||||
protected readonly List<double> _SkipCollection;
|
||||
protected readonly List<string> _NotMappedPersonKeys;
|
||||
protected readonly List<long> _NotMappedPersonKeys;
|
||||
protected readonly List<(int, string[])> _AllCollection;
|
||||
protected readonly Dictionary<int, int[]> _KeyValuePairs;
|
||||
protected readonly Dictionary<int, int[]> _IndicesFromNew;
|
||||
protected readonly string _DeterministicHashCodeContentDirectory;
|
||||
protected readonly Dictionary<int, string[]> _SixCharacterNamedFaceInfo;
|
||||
protected readonly Dictionary<double, string[]> _DeterministicHashCodeKeyValuePairs;
|
||||
protected readonly Dictionary<int, string[]> _DeterministicHashCodeUnknownFaceKeyValuePairs;
|
||||
protected readonly Dictionary<double, string[]> _IncorrectDeterministicHashCodeKeyValuePairs;
|
||||
protected readonly Dictionary<string, (string DisplayDirectoryName, int? ApproximateYears, string Key, PersonBirthday[] PersonBirthdays)> _PeopleKeyValuePairs;
|
||||
protected readonly Dictionary<double, PersonBirthday[]> _DeterministicHashCodeKeyValuePairs;
|
||||
protected readonly Dictionary<int, PersonBirthday[]> _DeterministicHashCodeUnknownFaceKeyValuePairs;
|
||||
protected readonly Dictionary<double, PersonBirthday[]> _IncorrectDeterministicHashCodeKeyValuePairs;
|
||||
protected readonly Dictionary<long, (string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long Ticks)> _PeopleKeyValuePairs;
|
||||
|
||||
public Dictionary<int, int[]> KeyValuePairs => _KeyValuePairs;
|
||||
public Dictionary<int, int[]> IndicesFromNew => _IndicesFromNew;
|
||||
@ -40,7 +41,7 @@ public class MapLogic
|
||||
_ResizeFilenameExtension = resizeFilenameExtension;
|
||||
_FacePartsFilenameExtension = facePartsFilenameExtension;
|
||||
_FacesHiddenFilenameExtension = facesHiddenFilenameExtension;
|
||||
Dictionary<int, string[]>? deterministicHashCodeUnknownFaceKeyValuePairs;
|
||||
Dictionary<int, PersonBirthday[]>? deterministicHashCodeUnknownFaceKeyValuePairs;
|
||||
if (configuration.VerifyToSeason is null || !configuration.VerifyToSeason.Any())
|
||||
throw new Exception();
|
||||
string json;
|
||||
@ -48,15 +49,15 @@ public class MapLogic
|
||||
string fullPath;
|
||||
List<double> skipCollection = new();
|
||||
Dictionary<int, int[]>? keyValuePairs;
|
||||
List<string> notMappedPersonKeys = new();
|
||||
List<long> notMappedPersonKeys = new();
|
||||
List<KeyValuePair<int, int[]>>? collection;
|
||||
string deterministicHashCodeContentDirectory;
|
||||
Dictionary<int, int[]> indicesFromNew = new();
|
||||
Dictionary<int, string[]>? sixCharacterNamedFaceInfo;
|
||||
Dictionary<double, string[]> deterministicHashCodeKeyValuePairs = new();
|
||||
Dictionary<double, string[]> incorrectDeterministicHashCodeKeyValuePairs = new();
|
||||
Dictionary<double, PersonBirthday[]> deterministicHashCodeKeyValuePairs = new();
|
||||
string? rootDirectoryParent = Path.GetDirectoryName(configuration.RootDirectory);
|
||||
Dictionary<string, (string, int?, string, PersonBirthday[])> peopleKeyValuePairs = new();
|
||||
Dictionary<long, (string, int?, PersonBirthday[], long)> peopleKeyValuePairs = new();
|
||||
Dictionary<double, PersonBirthday[]> incorrectDeterministicHashCodeKeyValuePairs = new();
|
||||
if (string.IsNullOrEmpty(rootDirectoryParent))
|
||||
throw new NullReferenceException(nameof(rootDirectoryParent));
|
||||
string deterministicHashCodeRootDirectory = Path.Combine(rootDirectoryParent, "DeterministicHashCode");
|
||||
@ -66,13 +67,12 @@ public class MapLogic
|
||||
else
|
||||
{
|
||||
json = File.ReadAllText(files[0]);
|
||||
deterministicHashCodeUnknownFaceKeyValuePairs = JsonSerializer.Deserialize<Dictionary<int, string[]>>(json);
|
||||
if (deterministicHashCodeUnknownFaceKeyValuePairs is null)
|
||||
throw new NullReferenceException(nameof(deterministicHashCodeUnknownFaceKeyValuePairs));
|
||||
deterministicHashCodeUnknownFaceKeyValuePairs = Get(json);
|
||||
}
|
||||
if (!Directory.Exists(deterministicHashCodeRootDirectory))
|
||||
_ = Directory.CreateDirectory(deterministicHashCodeRootDirectory);
|
||||
deterministicHashCodeContentDirectory = Stateless.ByDeterministicHashCode.SetByRef(_ResizeFilenameExtension, people, skipCollection, peopleKeyValuePairs, notMappedPersonKeys, deterministicHashCodeUnknownFaceKeyValuePairs, deterministicHashCodeKeyValuePairs, incorrectDeterministicHashCodeKeyValuePairs, deterministicHashCodeRootDirectory);
|
||||
deterministicHashCodeContentDirectory = Path.Combine(deterministicHashCodeRootDirectory, "()");
|
||||
Stateless.ByDeterministicHashCode.SetByRef(_ResizeFilenameExtension, people, skipCollection, peopleKeyValuePairs, notMappedPersonKeys, deterministicHashCodeUnknownFaceKeyValuePairs, deterministicHashCodeKeyValuePairs, incorrectDeterministicHashCodeKeyValuePairs, deterministicHashCodeRootDirectory, deterministicHashCodeContentDirectory);
|
||||
if (!deterministicHashCodeUnknownFaceKeyValuePairs.Any())
|
||||
sixCharacterNamedFaceInfo = new();
|
||||
else
|
||||
@ -134,22 +134,47 @@ public class MapLogic
|
||||
|
||||
public bool Skip(double deterministicHashCodeKey) => _SkipCollection.Contains(deterministicHashCodeKey);
|
||||
|
||||
public void SaveShortcuts(string[] juliePhares, string dResultsFullGroupDirectory, long ticks, List<Item> items)
|
||||
private static Dictionary<int, PersonBirthday[]> Get(string json)
|
||||
{
|
||||
Dictionary<int, PersonBirthday[]> results = new();
|
||||
PersonBirthday? personBirthday;
|
||||
List<PersonBirthday> personBirthdays;
|
||||
Dictionary<int, string[]>? keyValuePairs = JsonSerializer.Deserialize<Dictionary<int, string[]>>(json);
|
||||
if (keyValuePairs is null)
|
||||
throw new NullReferenceException(nameof(keyValuePairs));
|
||||
foreach (KeyValuePair<int, string[]> keyValuePair in keyValuePairs)
|
||||
{
|
||||
personBirthdays = new();
|
||||
foreach (string personKey in keyValuePair.Value)
|
||||
{
|
||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(personKey);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
}
|
||||
if (!personBirthdays.Any())
|
||||
continue;
|
||||
results.Add(keyValuePair.Key, personBirthdays.ToArray());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void SaveShortcuts(string[] juliePhares, string dFacesContentDirectory, List<Item> items)
|
||||
{
|
||||
string fileName;
|
||||
string fullName;
|
||||
string personKey;
|
||||
DateTime? minimumDateTime;
|
||||
PersonBirthday personBirthday;
|
||||
WindowsShortcut windowsShortcut;
|
||||
(string DisplayDirectoryName, int? ApproximateYears, string Key, PersonBirthday[] _) person;
|
||||
string dFacesContentDirectory = Path.Combine(dResultsFullGroupDirectory, $"({ticks})");
|
||||
List<(Item, (string, Face?, (string, string, string, string))[])> collections = GetCollection(items, dFacesContentDirectory);
|
||||
foreach ((Item item, (string personKey, Face? _, (string, string, string, string))[] collection) in collections)
|
||||
(string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] _, long Ticks) person;
|
||||
List<(Item, (long?, Face?, (string, string, string, string))[])> collections = GetCollection(items, dFacesContentDirectory);
|
||||
foreach ((Item item, (long? ticks, Face? _, (string, string, string, string))[] collection) in collections)
|
||||
{
|
||||
if (collection.Length != 1)
|
||||
continue;
|
||||
foreach ((string personKey, Face? _, (string directory, string copyDirectory, string copyFileName, string shortcutFileName)) in collection)
|
||||
foreach ((long? ticks, Face? _, (string directory, string copyDirectory, string copyFileName, string shortcutFileName)) in collection)
|
||||
{
|
||||
if (string.IsNullOrEmpty(personKey))
|
||||
if (ticks is null)
|
||||
continue;
|
||||
if (item.Property?.Id is null || item.ImageFileHolder is null || item.ResizedFileHolder is null)
|
||||
continue;
|
||||
@ -159,13 +184,17 @@ public class MapLogic
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
if (!string.IsNullOrEmpty(personKey) && _PeopleKeyValuePairs.ContainsKey(personKey))
|
||||
if (ticks is not null && _PeopleKeyValuePairs.ContainsKey(ticks.Value))
|
||||
{
|
||||
person = _PeopleKeyValuePairs[personKey];
|
||||
person = _PeopleKeyValuePairs[ticks.Value];
|
||||
fullName = string.Concat(person.DisplayDirectoryName, ".txt");
|
||||
File.WriteAllText(Path.Combine(directory, fullName), string.Empty);
|
||||
}
|
||||
}
|
||||
if (ticks is null)
|
||||
continue;
|
||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(ticks.Value);
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
||||
if (juliePhares.Contains(personKey) && !string.IsNullOrEmpty(copyDirectory))
|
||||
{
|
||||
if (!Directory.Exists(copyDirectory))
|
||||
@ -192,8 +221,8 @@ public class MapLogic
|
||||
if (!string.IsNullOrEmpty(_DeterministicHashCodeContentDirectory))
|
||||
{
|
||||
Dictionary<int, List<Face>> keyValuePairs = new();
|
||||
List<(string PersonKey, double IdAndNormalizedPixelPercentage)> deterministicHashCodeCollection = new();
|
||||
List<(string PersonKey, double IdAndNormalizedPixelPercentage)> incorrectDeterministicHashCodeCollection = new();
|
||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> deterministicHashCodeCollection = new();
|
||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> incorrectDeterministicHashCodeCollection = new();
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
foreach (Item item in container.Items)
|
||||
@ -283,14 +312,14 @@ public class MapLogic
|
||||
|
||||
public void AddToMapping(List<Item> items)
|
||||
{
|
||||
long ticks;
|
||||
Mapping mapping;
|
||||
string personKey;
|
||||
int? approximateYears;
|
||||
string displayDirectoryName;
|
||||
PersonBirthday? personBirthday;
|
||||
PersonBirthday personBirthday;
|
||||
double deterministicHashCodeKey;
|
||||
List<string> personKeys = new();
|
||||
(string DisplayDirectoryName, int? ApproximateYears, string Key, PersonBirthday[] PersonBirthdays) person;
|
||||
List<PersonBirthday> personBirthdays = new();
|
||||
(string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long Ticks) person;
|
||||
foreach (Item item in items)
|
||||
{
|
||||
if (item.ImageFileHolder is null)
|
||||
@ -299,45 +328,41 @@ public class MapLogic
|
||||
continue;
|
||||
foreach (Face face in item.Faces)
|
||||
{
|
||||
personKeys.Clear();
|
||||
personBirthdays.Clear();
|
||||
if (face.FaceEncoding is null || face.Location?.NormalizedPixelPercentage is null)
|
||||
continue;
|
||||
deterministicHashCodeKey = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(item, face);
|
||||
if (!_DeterministicHashCodeKeyValuePairs.ContainsKey(deterministicHashCodeKey))
|
||||
continue;
|
||||
personKeys.AddRange(_DeterministicHashCodeKeyValuePairs[deterministicHashCodeKey]);
|
||||
for (int i = 0; i < personKeys.Count; i++)
|
||||
personBirthdays.AddRange(_DeterministicHashCodeKeyValuePairs[deterministicHashCodeKey]);
|
||||
for (int i = 0; i < personBirthdays.Count; i++)
|
||||
{
|
||||
if (!_PeopleKeyValuePairs.ContainsKey(personKeys[i]))
|
||||
ticks = personBirthdays[i].Value.Ticks;
|
||||
if (!_PeopleKeyValuePairs.ContainsKey(ticks))
|
||||
continue;
|
||||
person = _PeopleKeyValuePairs[personKeys[i]];
|
||||
person = _PeopleKeyValuePairs[ticks];
|
||||
personBirthday = person.PersonBirthdays[0];
|
||||
approximateYears = person.ApproximateYears;
|
||||
displayDirectoryName = person.DisplayDirectoryName;
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
mapping = new(approximateYears, displayDirectoryName, face.Location.NormalizedPixelPercentage, personBirthday, personKey);
|
||||
mapping = new(approximateYears, displayDirectoryName, face.Location.NormalizedPixelPercentage, personBirthday);
|
||||
item.Mapping.Add(mapping);
|
||||
}
|
||||
}
|
||||
if (Shared.Models.Stateless.IMapping.UseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping && !personKeys.Any())
|
||||
if (IMapping.UseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping && !personBirthdays.Any())
|
||||
{
|
||||
if (!_DeterministicHashCodeUnknownFaceKeyValuePairs.ContainsKey(item.Property.Id.Value))
|
||||
continue;
|
||||
personKeys.AddRange(_DeterministicHashCodeUnknownFaceKeyValuePairs[item.Property.Id.Value]);
|
||||
for (int i = 0; i < personKeys.Count; i++)
|
||||
personBirthdays.AddRange(_DeterministicHashCodeUnknownFaceKeyValuePairs[item.Property.Id.Value]);
|
||||
for (int i = 0; i < personBirthdays.Count; i++)
|
||||
{
|
||||
if (!_PeopleKeyValuePairs.ContainsKey(personKeys[i]))
|
||||
ticks = personBirthdays[i].Value.Ticks;
|
||||
if (!_PeopleKeyValuePairs.ContainsKey(ticks))
|
||||
continue;
|
||||
person = _PeopleKeyValuePairs[personKeys[i]];
|
||||
person = _PeopleKeyValuePairs[ticks];
|
||||
personBirthday = person.PersonBirthdays[0];
|
||||
approximateYears = person.ApproximateYears;
|
||||
displayDirectoryName = person.DisplayDirectoryName;
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
mapping = new(approximateYears, displayDirectoryName, personBirthday, personKey);
|
||||
mapping = new(approximateYears, displayDirectoryName, personBirthday);
|
||||
item.Mapping.Add(mapping);
|
||||
}
|
||||
}
|
||||
@ -398,11 +423,15 @@ public class MapLogic
|
||||
public void SaveNotMappedPersonKeys(string zPropertyHolderContentDirectory)
|
||||
{
|
||||
string directory;
|
||||
string personKey;
|
||||
SaveContainer saveContainer;
|
||||
PersonBirthday personBirthday;
|
||||
List<SaveContainer> saveContainers = new();
|
||||
const string facePopulatedKey = nameof(Closest);
|
||||
foreach (string personKey in _NotMappedPersonKeys)
|
||||
foreach (long ticks in _NotMappedPersonKeys)
|
||||
{
|
||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(ticks);
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}NotMapped", personKey, Property.Models.Stateless.IResult.AllInOne);
|
||||
saveContainer = new(directory);
|
||||
saveContainers.Add(saveContainer);
|
||||
@ -410,13 +439,13 @@ public class MapLogic
|
||||
SaveContainers(saveContainers);
|
||||
}
|
||||
|
||||
public List<(Item, (string, Face?, (string, string, string, string))[])> GetCollection(List<Item> items, string dFacesContentDirectory)
|
||||
public List<(Item, (long?, Face?, (string, string, string, string))[])> GetCollection(List<Item> items, string dFacesContentDirectory)
|
||||
{
|
||||
List<(Item, (string, Face?, (string, string, string, string))[])> results = new();
|
||||
List<(Item, (long?, Face?, (string, string, string, string))[])> results = new();
|
||||
int years;
|
||||
Face face;
|
||||
Item item;
|
||||
string[] keys;
|
||||
long? ticks;
|
||||
string directory;
|
||||
string personKey;
|
||||
bool? isWrongYear;
|
||||
@ -430,10 +459,11 @@ public class MapLogic
|
||||
string subDirectoryName;
|
||||
List<int> indices = new();
|
||||
DateTime? minimumDateTime;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
List<Face> faceCollection;
|
||||
PersonBirthday? personBirthday;
|
||||
List<(string, Face?, (string, string, string, string))> collection;
|
||||
PersonBirthday personBirthday;
|
||||
PersonBirthday[] personBirthdays;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
List<(long?, Face?, (string, string, string, string))> collection;
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
indices.Clear();
|
||||
@ -451,13 +481,13 @@ public class MapLogic
|
||||
if (!_DeterministicHashCodeUnknownFaceKeyValuePairs.ContainsKey(item.Property.Id.Value))
|
||||
{
|
||||
faceCollection = new();
|
||||
personKey = string.Empty;
|
||||
ticks = null;
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Unnamed{relativePath[2..]}");
|
||||
}
|
||||
else
|
||||
{
|
||||
faceCollection = item.Faces;
|
||||
keys = _DeterministicHashCodeUnknownFaceKeyValuePairs[item.Property.Id.Value];
|
||||
personBirthdays = _DeterministicHashCodeUnknownFaceKeyValuePairs[item.Property.Id.Value];
|
||||
minimumDateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
|
||||
if (minimumDateTime is null)
|
||||
continue;
|
||||
@ -466,26 +496,24 @@ public class MapLogic
|
||||
subDirectoryName = $"{isWrongYearFlag}{minimumDateTime.Value:yyyy}";
|
||||
if (!faceCollection.Any())
|
||||
{
|
||||
personKey = string.Empty;
|
||||
ticks = null;
|
||||
directory = Path.Combine(dFacesContentDirectory, $"None{relativePath[2..]}", subDirectoryName);
|
||||
}
|
||||
else if (keys.Length != 1)
|
||||
else if (personBirthdays.Length != 1)
|
||||
{
|
||||
personKey = string.Empty;
|
||||
ticks = null;
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Not Supported{relativePath[2..]}", subDirectoryName);
|
||||
}
|
||||
else if (faceCollection.Count != 1)
|
||||
{
|
||||
personKey = string.Empty;
|
||||
ticks = null;
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Many{relativePath[2..]}", subDirectoryName);
|
||||
}
|
||||
else
|
||||
{
|
||||
indices.Add(zero);
|
||||
personKey = keys[zero];
|
||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(personKey);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
personBirthday = personBirthdays[zero];
|
||||
ticks = personBirthday.Value.Ticks;
|
||||
timeSpan = Shared.Models.Stateless.Methods.IPersonBirthday.GetTimeSpan(minimumDateTime.Value, isWrongYear, personBirthday);
|
||||
if (timeSpan.HasValue)
|
||||
{
|
||||
@ -498,6 +526,7 @@ public class MapLogic
|
||||
}
|
||||
}
|
||||
face = faceCollection[zero];
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
||||
directory = Path.Combine(dFacesContentDirectory, "Shortcuts", personKey, subDirectoryName);
|
||||
if (face.FaceEncoding is not null && face.Location?.NormalizedPixelPercentage is not null)
|
||||
copyDirectory = Path.Combine(dFacesContentDirectory, "Images", personKey, subDirectoryName);
|
||||
@ -507,12 +536,12 @@ public class MapLogic
|
||||
}
|
||||
}
|
||||
shortcutFileName = Path.Combine(directory, $"{item.Property.Id.Value}.lnk");
|
||||
if (string.IsNullOrEmpty(personKey) || !indices.Any())
|
||||
collection.Add(new(personKey, null, (directory, copyDirectory, copyFileName, shortcutFileName)));
|
||||
if (ticks is null || !indices.Any())
|
||||
collection.Add(new(ticks, null, (directory, copyDirectory, copyFileName, shortcutFileName)));
|
||||
else
|
||||
{
|
||||
foreach (int index in indices)
|
||||
collection.Add(new(personKey, faceCollection[index], (directory, copyDirectory, copyFileName, shortcutFileName)));
|
||||
collection.Add(new(ticks, faceCollection[index], (directory, copyDirectory, copyFileName, shortcutFileName)));
|
||||
}
|
||||
results.Add(new(item, collection.ToArray()));
|
||||
}
|
||||
@ -521,20 +550,27 @@ public class MapLogic
|
||||
|
||||
public void AddToClosest(int maxDegreeOfParallelism, string argZero, Container[] containers)
|
||||
{
|
||||
long ticks;
|
||||
string key;
|
||||
string dateKey;
|
||||
Closest closest;
|
||||
string personKey;
|
||||
const int zero = 0;
|
||||
DateTime minimumDateTime;
|
||||
Closest[] closestCollection;
|
||||
PersonBirthday personBirthday;
|
||||
double deterministicHashCodeKey;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
Dictionary<string, int> keyValuePairs = new();
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
if (!_NotMappedPersonKeys.Any())
|
||||
break;
|
||||
if (!container.Items.Any())
|
||||
continue;
|
||||
if (!container.SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
ticks = _NotMappedPersonKeys[zero];
|
||||
foreach (Item item in container.Items)
|
||||
{
|
||||
if (item.ImageFileHolder is null || item.Property is null)
|
||||
@ -545,20 +581,22 @@ public class MapLogic
|
||||
continue;
|
||||
deterministicHashCodeKey = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(item, face);
|
||||
if (_DeterministicHashCodeKeyValuePairs.ContainsKey(deterministicHashCodeKey))
|
||||
continue;
|
||||
continue;
|
||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(ticks);
|
||||
minimumDateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
|
||||
closestCollection = Shared.Models.Stateless.Methods.IClosest.GetCollection(face, minimumDateTime, face.FaceDistances);
|
||||
closestCollection = Shared.Models.Stateless.Methods.IClosest.GetCollection(personBirthday, face, minimumDateTime, face.FaceDistances);
|
||||
face.FaceDistances.Clear();
|
||||
for (int j = 0; j < closestCollection.Length; j++)
|
||||
{
|
||||
closest = closestCollection[j];
|
||||
if (_IncorrectDeterministicHashCodeKeyValuePairs.ContainsKey(deterministicHashCodeKey) && _IncorrectDeterministicHashCodeKeyValuePairs[deterministicHashCodeKey].Contains(closest.Mapping.PersonKey))
|
||||
if (_IncorrectDeterministicHashCodeKeyValuePairs.ContainsKey(deterministicHashCodeKey) && _IncorrectDeterministicHashCodeKeyValuePairs[deterministicHashCodeKey].Contains(personBirthday))
|
||||
continue;
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(closest.Mapping.PersonBirthday);
|
||||
dateKey = Stateless.MapLogic.GetDateKey(dateTime, closest.Mapping, closest.MinimumDateTime, closest.IsWrongYear);
|
||||
key = string.Concat(closest.Mapping.PersonKey, dateKey);
|
||||
key = string.Concat(personKey, dateKey);
|
||||
if (!keyValuePairs.ContainsKey(key))
|
||||
keyValuePairs.Add(key, 0);
|
||||
else if (keyValuePairs[key] > Shared.Models.Stateless.IClosest.MaximumPer)
|
||||
else if (keyValuePairs[key] > IClosest.MaximumPer)
|
||||
continue;
|
||||
keyValuePairs[key] += 1;
|
||||
item.Closest.Add(closest);
|
||||
@ -576,6 +614,7 @@ public class MapLogic
|
||||
string json;
|
||||
string dateKey;
|
||||
Mapping? match;
|
||||
string personKey;
|
||||
string checkFile;
|
||||
string directory;
|
||||
bool? isWrongYear;
|
||||
@ -631,13 +670,14 @@ public class MapLogic
|
||||
minimumDateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
|
||||
(isWrongYear, _) = item.Property.IsWrongYear(item.ImageFileHolder.FullName, minimumDateTime);
|
||||
dateKey = Stateless.MapLogic.GetDateKey(dateTime, match, minimumDateTime, isWrongYear);
|
||||
key = string.Concat(match.PersonKey, dateKey);
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(match.PersonBirthday);
|
||||
key = string.Concat(personKey, dateKey);
|
||||
if (match.Filtered is null)
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}Null", match.PersonKey, dateKey);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}Null", personKey, dateKey);
|
||||
else if (!match.Filtered.Value)
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}Okay", match.PersonKey, dateKey);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}Okay", personKey, dateKey);
|
||||
else
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}OutOfControl", match.PersonKey, dateKey);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}OutOfControl", personKey, dateKey);
|
||||
personDirectory = Path.Combine(directory, match.DisplayDirectoryName[..1], "lnk");
|
||||
saveContainer = new(personDirectory);
|
||||
results.Add(saveContainer);
|
||||
@ -654,7 +694,7 @@ public class MapLogic
|
||||
shortcutFile = Path.Combine(personDirectory, $"{deterministicHashCodeKey}{item.ImageFileHolder.ExtensionLowered}.lnk");
|
||||
saveContainer = new(checkFile, directory, faceFileHolder, hiddenFaceFileHolder, string.Empty, facePartsFileHolder, item.ResizedFileHolder, shortcutFile);
|
||||
results.Add(saveContainer);
|
||||
if (!string.IsNullOrEmpty(checkFile) && Shared.Models.Stateless.IMapping.SaveFaceEncoding)
|
||||
if (!string.IsNullOrEmpty(checkFile) && IMapping.SaveFaceEncoding)
|
||||
{
|
||||
checkFile = Path.Combine(directory, $"{deterministicHashCodeKey}{item.ImageFileHolder.ExtensionLowered}.json");
|
||||
json = JsonSerializer.Serialize(face.FaceEncoding);
|
||||
@ -666,7 +706,7 @@ public class MapLogic
|
||||
results.Add(saveContainer);
|
||||
used.Add(face.Location.NormalizedPixelPercentage.Value);
|
||||
}
|
||||
if (deterministicHashCodeKeyValuePairsAny && Shared.Models.Stateless.IMapping.UseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping)
|
||||
if (deterministicHashCodeKeyValuePairsAny && IMapping.UseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping)
|
||||
{
|
||||
foreach (Face face in item.Faces)
|
||||
{
|
||||
@ -692,15 +732,16 @@ public class MapLogic
|
||||
continue;
|
||||
throw new Exception();
|
||||
}
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(match.PersonBirthday);
|
||||
minimumDateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
|
||||
(isWrongYear, _) = item.Property.IsWrongYear(item.ImageFileHolder.FullName, minimumDateTime);
|
||||
dateKey = Stateless.MapLogic.GetDateKey(dateTime, match, minimumDateTime, isWrongYear);
|
||||
if (match.Filtered is null)
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}WithButNull", match.PersonKey, dateKey);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}WithButNull", personKey, dateKey);
|
||||
else if (!match.Filtered.Value)
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}WithAndOkay", match.PersonKey, dateKey);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}WithAndOkay", personKey, dateKey);
|
||||
else
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}WithButOutOfControl", match.PersonKey, dateKey);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, $"{facePopulatedKey}WithButOutOfControl", personKey, dateKey);
|
||||
personDirectory = Path.Combine(directory, match.DisplayDirectoryName[..1], "lnk");
|
||||
saveContainer = new(personDirectory);
|
||||
results.Add(saveContainer);
|
||||
@ -717,7 +758,7 @@ public class MapLogic
|
||||
shortcutFile = Path.Combine(personDirectory, $"{deterministicHashCodeKey}{item.ImageFileHolder.ExtensionLowered}.lnk");
|
||||
saveContainer = new(checkFile, directory, faceFileHolder, hiddenFaceFileHolder, string.Empty, facePartsFileHolder, item.ResizedFileHolder, shortcutFile);
|
||||
results.Add(saveContainer);
|
||||
if (!string.IsNullOrEmpty(checkFile) && Shared.Models.Stateless.IMapping.SaveFaceEncoding)
|
||||
if (!string.IsNullOrEmpty(checkFile) && IMapping.SaveFaceEncoding)
|
||||
{
|
||||
checkFile = Path.Combine(directory, $"{deterministicHashCodeKey}{item.ImageFileHolder.ExtensionLowered}.json");
|
||||
json = JsonSerializer.Serialize(face.FaceEncoding);
|
||||
@ -742,6 +783,7 @@ public class MapLogic
|
||||
string dateKey;
|
||||
string checkFile;
|
||||
string directory;
|
||||
string personKey;
|
||||
string shortcutFile;
|
||||
string? directoryName;
|
||||
string facesDirectory;
|
||||
@ -791,8 +833,9 @@ public class MapLogic
|
||||
continue;
|
||||
throw new Exception();
|
||||
}
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(match.Mapping.PersonBirthday);
|
||||
dateKey = Stateless.MapLogic.GetDateKey(dateTime, match.Mapping, match.MinimumDateTime, match.IsWrongYear);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, facePopulatedKey, match.Mapping.PersonKey, dateKey);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, facePopulatedKey, personKey, dateKey);
|
||||
personDirectory = Path.Combine(directory, match.Mapping.DisplayDirectoryName[..1], "lnk");
|
||||
saveContainer = new(personDirectory);
|
||||
results.Add(saveContainer);
|
||||
@ -818,8 +861,9 @@ public class MapLogic
|
||||
{
|
||||
if (used.Contains(closest.NormalizedPixelPercentage))
|
||||
continue;
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(closest.Mapping.PersonBirthday);
|
||||
dateKey = Stateless.MapLogic.GetDateKey(dateTime, closest.Mapping, closest.MinimumDateTime, closest.IsWrongYear);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, facePopulatedKey, closest.Mapping.PersonKey, dateKey);
|
||||
directory = Path.Combine(zPropertyHolderContentDirectory, facePopulatedKey, personKey, dateKey);
|
||||
personDirectory = Path.Combine(directory, closest.Mapping.DisplayDirectoryName, "lnk");
|
||||
saveContainer = new(personDirectory);
|
||||
results.Add(saveContainer);
|
||||
@ -858,4 +902,45 @@ public class MapLogic
|
||||
SaveContainers(saveContainers);
|
||||
}
|
||||
|
||||
public void SetSingleImage(string[] ignoreRelativePaths, string argZero, Container[] containers)
|
||||
{
|
||||
Mapping mapping;
|
||||
long? ticks = null;
|
||||
const int zero = 0;
|
||||
int? approximateYears = null;
|
||||
PersonBirthday personBirthday;
|
||||
const string displayDirectoryName = Property.Models.Stateless.IResult.AllInOne;
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
if (!_NotMappedPersonKeys.Any())
|
||||
break;
|
||||
if (!container.Items.Any())
|
||||
continue;
|
||||
if (!container.SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
if (ignoreRelativePaths.Contains(Path.GetFileName(container.SourceDirectory)))
|
||||
continue;
|
||||
foreach (Item item in container.Items)
|
||||
{
|
||||
if (item.ImageFileHolder is null || item.Property?.Id is null)
|
||||
continue;
|
||||
foreach (Face face in item.Faces)
|
||||
{
|
||||
if (face.FaceEncoding is null || face.Location?.NormalizedPixelPercentage is null)
|
||||
continue;
|
||||
ticks = _NotMappedPersonKeys[zero];
|
||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(ticks.Value);
|
||||
mapping = new(approximateYears, displayDirectoryName, face.Location.NormalizedPixelPercentage, personBirthday);
|
||||
item.Mapping.Add(mapping);
|
||||
if (ticks is not null)
|
||||
break;
|
||||
}
|
||||
if (ticks is not null)
|
||||
break;
|
||||
}
|
||||
if (ticks is not null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user