Sorting without ... improvements
This commit is contained in:
@ -2,7 +2,6 @@ using Humanizer;
|
||||
using ShellProgressBar;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Map.Models.Stateless;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
using WindowsShortcutFactory;
|
||||
@ -15,7 +14,7 @@ public class MapLogic
|
||||
protected readonly Dictionary<int, List<int>> _SkipCollection;
|
||||
protected readonly List<PersonContainer> _NotMappedPersonContainers;
|
||||
protected readonly Dictionary<long, PersonContainer> _PersonKeyToPersonContainer;
|
||||
protected readonly Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> _PersonKeyToRanges;
|
||||
protected Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)>? _PersonKeyToRanges;
|
||||
protected readonly Dictionary<int, Dictionary<int, PersonContainer[]>> _IdThenNormalizedRectangleToPersonContainers;
|
||||
|
||||
public Dictionary<int, int[]> KeyValuePairs => throw new NotImplementedException();
|
||||
@ -29,7 +28,7 @@ public class MapLogic
|
||||
private readonly Shared.Models.Methods.IMapLogicSupport? _MapLogicSupport;
|
||||
private readonly Shared.Models.Properties.IPropertyConfiguration _PropertyConfiguration;
|
||||
|
||||
public MapLogic(int maxDegreeOfParallelism, Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, Configuration? configuration, long ticks, PersonContainer[] personContainers, string a2PeopleSingletonDirectory, string eDistanceContentDirectory, Mapping[] mappingCollection, Shared.Models.Methods.IMapLogicSupport? mapLogicSupport)
|
||||
public MapLogic(int maxDegreeOfParallelism, Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, Configuration? configuration, long ticks, PersonContainer[] personContainers, string a2PeopleSingletonDirectory, string eDistanceContentDirectory, Shared.Models.Methods.IMapLogicSupport? mapLogicSupport)
|
||||
{
|
||||
_Ticks = ticks;
|
||||
_Configuration = configuration;
|
||||
@ -50,7 +49,6 @@ public class MapLogic
|
||||
List<PersonContainer> notMappedPersonContainers = new();
|
||||
Dictionary<long, PersonContainer> personKeyToPersonContainer = new();
|
||||
string? rootDirectoryParent = Path.GetDirectoryName(propertyConfiguration.RootDirectory);
|
||||
Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges = new();
|
||||
string eDistanceContentTicksDirectory = Path.Combine(eDistanceContentDirectory, $"({ticks})");
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers = new();
|
||||
for (int i = 1; i < 5; i++)
|
||||
@ -71,10 +69,8 @@ public class MapLogic
|
||||
personContainerCollection,
|
||||
a2PeopleSingletonDirectory,
|
||||
eDistanceContentDirectory,
|
||||
mappingCollection,
|
||||
mapLogicSupport,
|
||||
personKeyToPersonContainer,
|
||||
personKeyToRanges,
|
||||
notMappedPersonContainers,
|
||||
skipCollection,
|
||||
idThenNormalizedRectangleToPersonContainers);
|
||||
@ -94,17 +90,12 @@ public class MapLogic
|
||||
throw new NullReferenceException(nameof(collection));
|
||||
}
|
||||
_SkipCollection = skipCollection;
|
||||
_PersonKeyToRanges = personKeyToRanges;
|
||||
_NotMappedPersonContainers = notMappedPersonContainers;
|
||||
_PersonKeyToPersonContainer = personKeyToPersonContainer;
|
||||
_EDistanceContentTicksDirectory = eDistanceContentTicksDirectory;
|
||||
_IdThenNormalizedRectangleToPersonContainers = idThenNormalizedRectangleToPersonContainers;
|
||||
_NotMappedPersonContainers = notMappedPersonContainers.OrderByDescending(l => l.Key).ToList();
|
||||
}
|
||||
|
||||
public MapLogic(int maxDegreeOfParallelism, Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, Configuration? configuration, long ticks, PersonContainer[] personContainers, string a2PeopleSingletonDirectory, string eDistanceContentDirectory) :
|
||||
this(maxDegreeOfParallelism, propertyConfiguration, configuration, ticks, personContainers, a2PeopleSingletonDirectory, eDistanceContentDirectory, Array.Empty<Mapping>(), null)
|
||||
{ }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
@ -119,7 +110,6 @@ public class MapLogic
|
||||
long personKey;
|
||||
const int zero = 0;
|
||||
string mappingSegmentB;
|
||||
int by = IMapLogic.Mapping;
|
||||
PersonBirthday personBirthday;
|
||||
PersonContainer[]? collection;
|
||||
List<PersonContainer> personContainers = new();
|
||||
@ -147,7 +137,7 @@ public class MapLogic
|
||||
personKeyToCount.Add(personKey, 0);
|
||||
personKeyToCount[personKey] += 1;
|
||||
mappingSegmentB = Stateless.MapLogic.GetMappingSegmentB(_Ticks, personBirthday, personContainer.ApproximateYears, mapping.MappingFromItem);
|
||||
mapping.UpdateMappingFromPerson(personContainer.ApproximateYears, by, personContainer.DisplayDirectoryName, personBirthday, mappingSegmentB);
|
||||
mapping.UpdateMappingFromPerson(personContainer.ApproximateYears, personContainer.DisplayDirectoryName, personBirthday, mappingSegmentB);
|
||||
}
|
||||
}
|
||||
return new(personKeyToCount, result);
|
||||
@ -309,23 +299,23 @@ public class MapLogic
|
||||
{
|
||||
isByMapping = false;
|
||||
isBySorting = false;
|
||||
by = $"{nameof(IMapLogic.Mapping)}Null";
|
||||
by = $"{nameof(Shared.Models.Stateless.IMapLogic.Mapping)}Null";
|
||||
}
|
||||
else
|
||||
{
|
||||
isByMapping = mapping.By == IMapLogic.Mapping;
|
||||
isBySorting = mapping.By == IMapLogic.Sorting;
|
||||
isByMapping = mapping.By == Shared.Models.Stateless.IMapLogic.Mapping;
|
||||
isBySorting = mapping.By == Shared.Models.Stateless.IMapLogic.Sorting;
|
||||
if (isBySorting && mapping.MappingFromPerson is null)
|
||||
by = $"{nameof(IMapLogic.Sorting)} Without Person";
|
||||
by = $"{nameof(Shared.Models.Stateless.IMapLogic.Sorting)} Without Person";
|
||||
else if (isBySorting && useFiltersCounter.HasValue)
|
||||
by = $"{nameof(IMapLogic.Sorting)} Modified Filters - {useFiltersCounter.Value}";
|
||||
by = $"{nameof(Shared.Models.Stateless.IMapLogic.Sorting)} Modified Filters - {useFiltersCounter.Value}";
|
||||
else
|
||||
{
|
||||
by = mapping.By.Value switch
|
||||
{
|
||||
IMapLogic.Mapping => nameof(IMapLogic.Mapping),
|
||||
IMapLogic.Sorting => nameof(IMapLogic.Sorting),
|
||||
IMapLogic.ForceSingleImage => forceSingleImageHumanized,
|
||||
Shared.Models.Stateless.IMapLogic.Mapping => nameof(Shared.Models.Stateless.IMapLogic.Mapping),
|
||||
Shared.Models.Stateless.IMapLogic.Sorting => nameof(Shared.Models.Stateless.IMapLogic.Sorting),
|
||||
Shared.Models.Stateless.IMapLogic.ForceSingleImage => forceSingleImageHumanized,
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
}
|
||||
@ -344,7 +334,7 @@ public class MapLogic
|
||||
PersonBirthday personBirthday;
|
||||
PersonContainer personContainer;
|
||||
result = Path.Combine(_EDistanceContentTicksDirectory, by, sortingContainer.Sorting.Id.ToString(), sortingContainer.Sorting.NormalizedRectangle.ToString());
|
||||
for (int i = 0; i < _NotMappedPersonContainers.Count; i++)
|
||||
for (int i = _NotMappedPersonContainers.Count - 1; i > 0; i--)
|
||||
{
|
||||
personContainer = _NotMappedPersonContainers[i];
|
||||
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
@ -376,12 +366,13 @@ public class MapLogic
|
||||
string? facesDirectory;
|
||||
FileHolder faceFileHolder;
|
||||
string personKeyFormatted;
|
||||
List<int> distinct = new();
|
||||
string? facePartsDirectory;
|
||||
SaveContainer? saveContainer;
|
||||
FileHolder facePartsFileHolder;
|
||||
FileHolder hiddenFaceFileHolder;
|
||||
Dictionary<int, Mapping>? normalizedRectangleToMapping;
|
||||
string forceSingleImageHumanized = nameof(IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
||||
string forceSingleImageHumanized = nameof(Shared.Models.Stateless.IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
directoryName = Path.GetDirectoryName(mapping.MappingFromItem.RelativePath);
|
||||
@ -396,8 +387,14 @@ public class MapLogic
|
||||
continue;
|
||||
if (mapping.SortingContainer is null)
|
||||
continue;
|
||||
if (distinct.Contains(mapping.MappingFromItem.Id))
|
||||
continue;
|
||||
if (distinct.Contains(mapping.SortingContainer.Sorting.Id))
|
||||
continue;
|
||||
directory = GetDirectory(by, mapping.MappingFromItem, mapping.SortingContainer);
|
||||
personDirectory = Path.Combine(directory, _Configuration.MappingDefaultName);
|
||||
personDirectory = Path.Combine(directory, $"Z]{DateTime.Now.Ticks}");
|
||||
distinct.Add(mapping.MappingFromItem.Id);
|
||||
distinct.Add(mapping.SortingContainer.Sorting.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -441,10 +438,10 @@ public class MapLogic
|
||||
facePartsDirectory = GetFacePartsDirectory(d2FacePartsContentDirectory, mapping.MappingFromItem);
|
||||
if (facePartsDirectory is null)
|
||||
continue;
|
||||
if (!isBySorting || mapping.MappingFromPerson is not null)
|
||||
checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
else
|
||||
checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}-Source{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
// if (!isBySorting || mapping.MappingFromPerson is not null)
|
||||
checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
// else
|
||||
// checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}-Source{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
shortcutFile = Path.Combine(personDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}.lnk");
|
||||
hiddenFaceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesHiddenFileNameExtension}"));
|
||||
facePartsFileHolder = new(Path.Combine(facePartsDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacePartsFileNameExtension}"));
|
||||
@ -488,7 +485,7 @@ public class MapLogic
|
||||
bool saveMapped = true;
|
||||
bool saveNullPerson = false;
|
||||
int? useFiltersCounter = null;
|
||||
string mappingDirectory = Path.Combine(_EDistanceContentTicksDirectory, nameof(IMapLogic.Mapping));
|
||||
string mappingDirectory = Path.Combine(_EDistanceContentTicksDirectory, nameof(Shared.Models.Stateless.IMapLogic.Mapping));
|
||||
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToCount, useFiltersCounter, saveNullPerson, saveMapped);
|
||||
SaveContainers(totalNotMapped, updated, saveContainers);
|
||||
if (!string.IsNullOrEmpty(_EDistanceContentTicksDirectory) && Directory.Exists(mappingDirectory))
|
||||
@ -497,6 +494,8 @@ public class MapLogic
|
||||
|
||||
private List<(long, long, long, long)> GetPersonKeysRangesCollection(PersonContainer[] personContainers)
|
||||
{
|
||||
if (_PersonKeyToRanges is null)
|
||||
throw new NullReferenceException(nameof(_PersonKeyToRanges));
|
||||
List<(long, long, long, long)> results = new();
|
||||
(long, long, long, long) singleton;
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
@ -576,7 +575,7 @@ public class MapLogic
|
||||
if (sorting.Id == faceDistanceEncoding.Id)
|
||||
{
|
||||
if (sorting.NormalizedRectangle == faceDistanceEncoding.NormalizedRectangle.Value)
|
||||
throw new NotSupportedException();
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
results.Add(sorting);
|
||||
@ -599,12 +598,11 @@ public class MapLogic
|
||||
string mappingSegmentB;
|
||||
string personKeyFormatted;
|
||||
PersonBirthday personBirthday;
|
||||
const int by = IMapLogic.Sorting;
|
||||
PersonContainer[] personContainers;
|
||||
PersonContainer[]? personContainers;
|
||||
Dictionary<string, int> keyToCount = new();
|
||||
Dictionary<string, string> keyToSegmentC = new();
|
||||
List<int> normalizedRectangleCollectionForA;
|
||||
List<int> normalizedRectangleCollectionForB;
|
||||
Dictionary<string, string> keyToSegmentC = new();
|
||||
Dictionary<int, List<int>> idToNormalizedRectangleCollectionForA = new();
|
||||
Dictionary<int, List<int>> idToNormalizedRectangleCollectionForB = new();
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
@ -623,22 +621,13 @@ public class MapLogic
|
||||
if (!idToNormalizedRectangleCollectionForB.ContainsKey(sortingContainer.Mapping.MappingFromItem.Id))
|
||||
idToNormalizedRectangleCollectionForB.Add(sortingContainer.Mapping.MappingFromItem.Id, new());
|
||||
normalizedRectangleCollectionForB = idToNormalizedRectangleCollectionForB[sortingContainer.Mapping.MappingFromItem.Id];
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(sortingContainer.Sorting.Id, out normalizedRectangleToPersonContainers))
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(sortingContainer.Sorting.Id, out normalizedRectangleToPersonContainers) || !normalizedRectangleToPersonContainers.TryGetValue(sortingContainer.Sorting.NormalizedRectangle, out personContainers))
|
||||
{
|
||||
if (!saveNullPerson)
|
||||
continue;
|
||||
personContainers = Array.Empty<PersonContainer>();
|
||||
if (normalizedRectangleCollectionForA.Contains(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
key = string.Concat(sortingContainer.Mapping.MappingFromItem.Id, '\t', sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle);
|
||||
if (!keyToCount.ContainsKey(key))
|
||||
keyToCount.Add(key, 0);
|
||||
if (!keyToSegmentC.ContainsKey(key))
|
||||
keyToSegmentC.Add(key, string.Empty);
|
||||
keyToCount[key]++;
|
||||
if (keyToCount[key] > _Configuration.SortingMaximumPerKey)
|
||||
continue;
|
||||
sortingContainer.Mapping.UpdateMappingFromUnknownPerson(by, sortingContainer);
|
||||
sortingContainer.Mapping.UpdateMappingFromUnknownPerson(sortingContainer);
|
||||
normalizedRectangleCollectionForA.Add(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle);
|
||||
result += 1;
|
||||
}
|
||||
@ -646,10 +635,6 @@ public class MapLogic
|
||||
{
|
||||
if (normalizedRectangleCollectionForB.Contains(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
if (!normalizedRectangleToPersonContainers.ContainsKey(sortingContainer.Sorting.NormalizedRectangle))
|
||||
personContainers = Array.Empty<PersonContainer>();
|
||||
else
|
||||
personContainers = normalizedRectangleToPersonContainers[sortingContainer.Sorting.NormalizedRectangle];
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
@ -670,7 +655,7 @@ public class MapLogic
|
||||
keyToCount[key] = 0;
|
||||
keyToSegmentC[key] = sortingContainer.Sorting.DistancePermyriad.ToString();
|
||||
}
|
||||
sortingContainer.Mapping.UpdateMappingFromPerson(personContainer.ApproximateYears, by, personContainer.DisplayDirectoryName, personBirthday, mappingSegmentB, keyToSegmentC[key], sortingContainer);
|
||||
sortingContainer.Mapping.UpdateMappingFromPerson(personContainer.ApproximateYears, personContainer.DisplayDirectoryName, personBirthday, mappingSegmentB, keyToSegmentC[key], sortingContainer);
|
||||
normalizedRectangleCollectionForB.Add(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle);
|
||||
result += 1;
|
||||
break;
|
||||
@ -703,10 +688,10 @@ public class MapLogic
|
||||
string? personDisplayDirectory;
|
||||
int? normalizedRectangle;
|
||||
WindowsShortcut windowsShortcut;
|
||||
string by = nameof(IMapLogic.ManualCopy);
|
||||
Dictionary<int, Mapping>? normalizedRectangleToMapping;
|
||||
string by = nameof(Shared.Models.Stateless.IMapLogic.ManualCopy);
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPeronContainerCollection;
|
||||
string successfull = $"_ {nameof(IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Successfull";
|
||||
string successfull = $"_ {nameof(Shared.Models.Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Successfull";
|
||||
foreach (KeyValuePair<long, PersonContainer> keyValuePair in _PersonKeyToPersonContainer)
|
||||
{
|
||||
if (keyValuePair.Value.Key is null || keyValuePair.Value.Birthdays is null || !keyValuePair.Value.Birthdays.Any())
|
||||
@ -718,7 +703,7 @@ public class MapLogic
|
||||
continue;
|
||||
if (!personDisplayDirectoryAllFile.EndsWith(_Configuration.FacesFileNameExtension))
|
||||
continue;
|
||||
(id, normalizedRectangle, _) = IMapping.GetConverted(_Configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
(id, normalizedRectangle) = IMapping.GetConverted(_Configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
continue;
|
||||
fileInfo = new(personDisplayDirectoryAllFile);
|
||||
@ -790,7 +775,7 @@ public class MapLogic
|
||||
SaveContainer saveContainer;
|
||||
PersonBirthday personBirthday;
|
||||
List<SaveContainer> saveContainers = new();
|
||||
const string facePopulatedKey = nameof(IMapLogic.Sorting);
|
||||
const string facePopulatedKey = nameof(Shared.Models.Stateless.IMapLogic.Sorting);
|
||||
foreach (PersonContainer personContainer in _NotMappedPersonContainers)
|
||||
{
|
||||
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
@ -804,13 +789,12 @@ public class MapLogic
|
||||
SaveContainers(totalNotMapped, updated, saveContainers);
|
||||
}
|
||||
|
||||
private (string, PersonBirthday?) GetPersonBirthday(string windowsShortcutPath)
|
||||
private (string, PersonBirthday?) GetPersonBirthday(string[] directoryNames)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
PersonBirthday? personBirthday = null;
|
||||
string personKeyFormatted = string.Empty;
|
||||
string[] directoryNames = IPath.GetDirectoryNames(windowsShortcutPath);
|
||||
foreach (string directoryName in directoryNames)
|
||||
{
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(_Configuration.PersonBirthdayFormat, directoryName);
|
||||
@ -823,6 +807,26 @@ public class MapLogic
|
||||
return new(personKeyFormatted, personBirthday);
|
||||
}
|
||||
|
||||
private (string, PersonBirthday?) GetPersonBirthday(string windowsShortcutPath)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
string[] directoryNames = IPath.GetDirectoryNames(windowsShortcutPath);
|
||||
(string personKeyFormatted, PersonBirthday? personBirthday) = GetPersonBirthday(directoryNames);
|
||||
if (personBirthday is null)
|
||||
{
|
||||
string[] directories = Directory.GetDirectories(windowsShortcutPath, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
directoryNames = IPath.GetDirectoryNames(directory);
|
||||
(personKeyFormatted, personBirthday) = GetPersonBirthday(directoryNames);
|
||||
if (personBirthday is not null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new(personKeyFormatted, personBirthday);
|
||||
}
|
||||
|
||||
private List<string> GetPersonKeyFormattedCollection(string[] jLinks, string a2PeopleSingletonDirectory, PersonContainer[] personContainers, Dictionary<long, int> personKeyToCount)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
@ -831,7 +835,6 @@ public class MapLogic
|
||||
throw new NullReferenceException(nameof(_MapLogicSupport));
|
||||
List<string> results = new();
|
||||
string[] files;
|
||||
string[] directories;
|
||||
string checkDirectory;
|
||||
string[] checkDirectories;
|
||||
string personKeyFormatted;
|
||||
@ -861,30 +864,12 @@ public class MapLogic
|
||||
continue;
|
||||
}
|
||||
(personKeyFormatted, personBirthday) = GetPersonBirthday(windowsShortcut.Path);
|
||||
if (personBirthday is not null)
|
||||
{
|
||||
if (!personKeyToCount.ContainsKey(personBirthday.Value.Ticks))
|
||||
collection.Add(new(personBirthday.Value.Ticks, Path.Combine(checkDirectory, personKeyFormatted, fileNameWithoutExtension)));
|
||||
else
|
||||
collection.Add(new(personBirthday.Value.Ticks, Path.Combine(checkDirectory, personKeyFormatted, fileNameWithoutExtension, $"{personKeyToCount[personBirthday.Value.Ticks]} Face(s)")));
|
||||
}
|
||||
else
|
||||
{
|
||||
directories = Directory.GetDirectories(windowsShortcut.Path, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
personKeyFormatted = Path.GetFileName(directory);
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(_Configuration.PersonBirthdayFormat, personKeyFormatted);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
if (!personKeyToCount.ContainsKey(personBirthday.Value.Ticks))
|
||||
collection.Add(new(personBirthday.Value.Ticks, Path.Combine(checkDirectory, personKeyFormatted, fileNameWithoutExtension)));
|
||||
else
|
||||
collection.Add(new(personBirthday.Value.Ticks, Path.Combine(checkDirectory, personKeyFormatted, fileNameWithoutExtension, $"{personKeyToCount[personBirthday.Value.Ticks]} Face(s)")));
|
||||
}
|
||||
}
|
||||
if (!collection.Any())
|
||||
if (personBirthday is null)
|
||||
throw new NotSupportedException(fileNameWithoutExtension);
|
||||
if (!personKeyToCount.ContainsKey(personBirthday.Value.Ticks))
|
||||
collection.Add(new(personBirthday.Value.Ticks, Path.Combine(checkDirectory, personKeyFormatted, fileNameWithoutExtension)));
|
||||
else
|
||||
collection.Add(new(personBirthday.Value.Ticks, Path.Combine(checkDirectory, personKeyFormatted, fileNameWithoutExtension, $"{personKeyToCount[personBirthday.Value.Ticks]} Face(s)")));
|
||||
foreach ((long personKey, string displayDirectoryName) in collection)
|
||||
{
|
||||
matches = (from l in personContainers where l.Key == personKey && l.ApproximateYears.HasValue select l).ToArray();
|
||||
@ -902,7 +887,7 @@ public class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
private (int, FileHolder, int, string, string, string, string)[] GetCollectionForSaveResizedImagesByPersonKeyFormatted(string[] jLinks, string a2PeopleSingletonDirectory, PersonContainer[] personContainers, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount)
|
||||
private (int, FileHolder, int, string, string, string, string)[] GetCollectionForSaveFilteredOriginalImagesFromJLinks(string[] jLinks, string a2PeopleSingletonDirectory, PersonContainer[] personContainers, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -914,13 +899,13 @@ public class MapLogic
|
||||
string personKeyFormatted;
|
||||
bool usePersonKeyAndDeterministicHashCodeKey = false;
|
||||
List<string> personKeyFormattedCollection = GetPersonKeyFormattedCollection(jLinks, a2PeopleSingletonDirectory, personContainers, personKeyToCount);
|
||||
List<(int Id, FileHolder ResizedFileHolder, int ApproximateYears, string PersonKeyFormatted, string CheckFile, string Directory, string PersonDirectory)> collection = new();
|
||||
List<(int Id, FileHolder ImageFileHolder, int ApproximateYears, string PersonKeyFormatted, string CheckFile, string Directory, string PersonDirectory)> collection = new();
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
directoryName = Path.GetDirectoryName(mapping.MappingFromItem.RelativePath);
|
||||
if (directoryName is null)
|
||||
throw new NotSupportedException();
|
||||
if (mapping.By is null or IMapLogic.Sorting)
|
||||
if (mapping.By is null or Shared.Models.Stateless.IMapLogic.Sorting)
|
||||
continue;
|
||||
if (mapping.MappingFromPerson?.ApproximateYears is null)
|
||||
continue;
|
||||
@ -945,28 +930,28 @@ public class MapLogic
|
||||
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName);
|
||||
checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
}
|
||||
collection.Add(new(mapping.MappingFromItem.Id, mapping.MappingFromItem.ResizedFileHolder, mapping.MappingFromPerson.ApproximateYears.Value, personKeyFormatted, directory, personDirectory, checkFile));
|
||||
collection.Add(new(mapping.MappingFromItem.Id, mapping.MappingFromItem.ImageFileHolder, mapping.MappingFromPerson.ApproximateYears.Value, personKeyFormatted, directory, personDirectory, checkFile));
|
||||
}
|
||||
results = (from l in collection orderby l.ApproximateYears descending, l.PersonKeyFormatted descending select l).ToArray();
|
||||
return results;
|
||||
}
|
||||
|
||||
public void SaveResizedImagesByPersonKeyFormatted(string[] jLinks, string a2PeopleSingletonDirectory, PersonContainer[] personContainers, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount, int totalNotMapped)
|
||||
public void SaveFilteredOriginalImagesFromJLinks(string[] jLinks, string a2PeopleSingletonDirectory, PersonContainer[] personContainers, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount, int totalNotMapped)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
SaveContainer? saveContainer;
|
||||
List<int> distinctCollection = new();
|
||||
List<SaveContainer> saveContainers = new();
|
||||
(int, FileHolder, int, string, string, string, string)[] collection = GetCollectionForSaveResizedImagesByPersonKeyFormatted(jLinks, a2PeopleSingletonDirectory, personContainers, mappingCollection, personKeyToCount);
|
||||
foreach ((int id, FileHolder resizedFileHolder, int approximateYears, string personKeyFormatted, string directory, string personDirectory, string checkFile) in collection)
|
||||
(int, FileHolder, int, string, string, string, string)[] collection = GetCollectionForSaveFilteredOriginalImagesFromJLinks(jLinks, a2PeopleSingletonDirectory, personContainers, mappingCollection, personKeyToCount);
|
||||
foreach ((int id, FileHolder imageFileHolder, int approximateYears, string personKeyFormatted, string directory, string personDirectory, string checkFile) in collection)
|
||||
{
|
||||
if (distinctCollection.Contains(id))
|
||||
continue;
|
||||
distinctCollection.Add(id);
|
||||
saveContainer = new(personDirectory);
|
||||
saveContainers.Add(saveContainer);
|
||||
saveContainer = new(resizedFileHolder, checkFile, directory);
|
||||
saveContainer = new(imageFileHolder, checkFile, directory);
|
||||
saveContainers.Add(saveContainer);
|
||||
}
|
||||
SaveContainers(totalNotMapped, null, saveContainers);
|
||||
@ -1013,7 +998,7 @@ public class MapLogic
|
||||
{
|
||||
if (mapping.MappingFromItem.ResizedFileHolder.DirectoryName is null || !mapping.MappingFromItem.ResizedFileHolder.Exists)
|
||||
continue;
|
||||
if (mapping.By is null or IMapLogic.Sorting || mapping.MappingFromPerson?.ApproximateYears is null)
|
||||
if (mapping.By is null or Shared.Models.Stateless.IMapLogic.Sorting || mapping.MappingFromPerson?.ApproximateYears is null)
|
||||
continue;
|
||||
if (string.IsNullOrEmpty(mapping.MappingFromPerson.SegmentB))
|
||||
throw new NotSupportedException();
|
||||
@ -1028,7 +1013,7 @@ public class MapLogic
|
||||
throw new NotSupportedException();
|
||||
if (mapping.MappingFromItem.ResizedFileHolder.DirectoryName is null || !mapping.MappingFromItem.ResizedFileHolder.Exists)
|
||||
continue;
|
||||
if (mapping.By is null or IMapLogic.Sorting || mapping.MappingFromPerson?.ApproximateYears is null)
|
||||
if (mapping.By is null or Shared.Models.Stateless.IMapLogic.Sorting || mapping.MappingFromPerson?.ApproximateYears is null)
|
||||
{
|
||||
if (mapping.MappingFromItem.ContainerDateTimes.Any() && !distinct.Contains(mapping.MappingFromItem.ResizedFileHolder.DirectoryName))
|
||||
{
|
||||
@ -1115,7 +1100,7 @@ public class MapLogic
|
||||
string? facesDirectory;
|
||||
FileHolder faceFileHolder;
|
||||
List<int>? normalizedRectangles;
|
||||
string by = nameof(IMapLogic.CopyNotMappedFaces);
|
||||
string by = nameof(Shared.Models.Stateless.IMapLogic.CopyNotMappedFaces);
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
foreach (KeyValuePair<int, Dictionary<int, Mapping>> keyValuePair in idToNormalizedRectangleToMapping)
|
||||
{
|
||||
@ -1409,4 +1394,11 @@ public class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public void UpdatedPersonKeyToRanges(Configuration configuration, long ticks, Mapping[] mappingCollection)
|
||||
{
|
||||
Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges = new();
|
||||
Stateless.MapLogic.SetPersonTicks(configuration, ticks, mappingCollection, personKeyToRanges, _IdThenNormalizedRectangleToPersonContainers);
|
||||
_PersonKeyToRanges = personKeyToRanges;
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
namespace View_by_Distance.Map.Models.Stateless;
|
||||
|
||||
public interface IMapLogic
|
||||
{ // ...
|
||||
|
||||
const int CopyNotMappedFaces = 5;
|
||||
const int ForceSingleImage = 3;
|
||||
const int ManualCopy = 4;
|
||||
const int Mapping = 1;
|
||||
const int Sigma = 3;
|
||||
const int Sorting = 2;
|
||||
|
||||
}
|
@ -9,7 +9,7 @@ namespace View_by_Distance.Map.Models.Stateless;
|
||||
internal abstract class MapLogic
|
||||
{
|
||||
|
||||
private static List<PersonContainer> AddToPersonKeysThenGetNonSpecificPeopleCollection(Configuration configuration, List<long> personKeys)
|
||||
private static List<PersonContainer> GetNonSpecificPeopleCollection(Configuration configuration, long ticks, List<long> personKeys)
|
||||
{
|
||||
List<PersonContainer> results = new();
|
||||
Person person;
|
||||
@ -19,13 +19,14 @@ internal abstract class MapLogic
|
||||
PersonContainer personContainer;
|
||||
string[] personDisplayDirectoryAllFiles = Array.Empty<string>();
|
||||
DateTime incrementDate = new(configuration.PersonBirthdayFirstYear, 1, 1);
|
||||
for (int i = 0; i < 500; i++)
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
personKey = incrementDate.Ticks;
|
||||
incrementDate = incrementDate.AddDays(1);
|
||||
if (incrementDate.Ticks > ticks)
|
||||
break;
|
||||
if (personKeys.Contains(personKey))
|
||||
continue;
|
||||
personKeys.Add(personKey);
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(personKey);
|
||||
person = IPerson.GetPerson(configuration.MappingDefaultName, personKey, personBirthday);
|
||||
personContainer = new(approximateYears, person, new PersonBirthday[] { personBirthday }, personDisplayDirectoryAllFiles, configuration.MappingDefaultName, personKey, partialKeyFormatted: null);
|
||||
@ -47,7 +48,7 @@ internal abstract class MapLogic
|
||||
{
|
||||
if (!personDisplayDirectoryAllFile.EndsWith(configuration.FacesFileNameExtension))
|
||||
continue;
|
||||
(id, normalizedRectangle, _) = IMapping.GetConverted(configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
(id, normalizedRectangle) = IMapping.GetConverted(configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
continue;
|
||||
if (!skipCollection.ContainsKey(id.Value))
|
||||
@ -91,8 +92,8 @@ internal abstract class MapLogic
|
||||
string[] personNameLinkDirectories;
|
||||
string? personFirstInitialDirectory;
|
||||
string[] personDisplayDirectoryNames;
|
||||
string manualCopyHumanized = nameof(IMapLogic.ManualCopy).Humanize(LetterCasing.Title);
|
||||
string forceSingleImageHumanized = nameof(IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
||||
string manualCopyHumanized = nameof(Shared.Models.Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title);
|
||||
string forceSingleImageHumanized = nameof(Shared.Models.Stateless.IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
using ProgressBar progressBar = new(ticksDirectories.Length, message, options);
|
||||
foreach (string ticksDirectory in ticksDirectories)
|
||||
@ -128,8 +129,8 @@ internal abstract class MapLogic
|
||||
if (!personDisplayDirectoryNames.Any())
|
||||
continue;
|
||||
files = Directory.GetFiles(personNameDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
if (personKeyFormatted == nameof(IMapLogic.Sorting) && files.Any())
|
||||
throw new Exception($"Move personKey directories up one from {nameof(IMapLogic.Sorting)} and delete {nameof(IMapLogic.Sorting)} directory!");
|
||||
if (personKeyFormatted == nameof(Shared.Models.Stateless.IMapLogic.Sorting) && files.Any())
|
||||
throw new Exception($"Move personKey directories up one from {nameof(Shared.Models.Stateless.IMapLogic.Sorting)} and delete {nameof(Shared.Models.Stateless.IMapLogic.Sorting)} directory!");
|
||||
if (personKeyFormatted == manualCopyHumanized && files.Any())
|
||||
throw new Exception($"Move personKey directories up one from {manualCopyHumanized} and delete {manualCopyHumanized} directory!");
|
||||
if (personKeyFormatted == forceSingleImageHumanized && files.Any())
|
||||
@ -159,7 +160,7 @@ internal abstract class MapLogic
|
||||
{
|
||||
if (file.EndsWith(".lnk") || file.EndsWith(".json"))
|
||||
continue;
|
||||
(id, normalizedRectangle, _) = IMapping.GetConverted(configuration.FacesFileNameExtension, file);
|
||||
(id, normalizedRectangle) = IMapping.GetConverted(configuration.FacesFileNameExtension, file);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
continue;
|
||||
results.Add(new(personKeyFormatted, personDisplayDirectoryNames, file));
|
||||
@ -188,26 +189,9 @@ internal abstract class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public static Dictionary<int, List<(string, int)>> GetIdToCollection(Configuration configuration, List<(string, string[], string)> collection)
|
||||
internal static List<(string, string[], string)> DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, long ticks, string? a2PeopleContentDirectory, string? eDistanceContentDirectory, PersonContainer[] personContainers)
|
||||
{
|
||||
Dictionary<int, List<(string, int)>> results = new();
|
||||
int? id;
|
||||
int? normalizedRectangle;
|
||||
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, string mappedFaceFile) in collection)
|
||||
{
|
||||
(id, normalizedRectangle, _) = IMapping.GetConverted(configuration.FacesFileNameExtension, mappedFaceFile);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
continue;
|
||||
if (!results.ContainsKey(id.Value))
|
||||
results.Add(id.Value, new());
|
||||
results[id.Value].Add(new(mappedFaceFile, normalizedRectangle.Value));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static Dictionary<int, List<(string, int)>> DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, long ticks, string? a2PeopleContentDirectory, string? eDistanceContentDirectory, PersonContainer[] personContainers)
|
||||
{
|
||||
Dictionary<int, List<(string, int)>> results;
|
||||
List<(string, string[], string)> results;
|
||||
string personKeyFormatted;
|
||||
List<string> personKeyFormattedCollection = new();
|
||||
List<(long? PersonKey, string Line)> lines = new();
|
||||
@ -242,8 +226,7 @@ internal abstract class MapLogic
|
||||
}
|
||||
if (!string.IsNullOrEmpty(a2PeopleContentDirectory))
|
||||
File.WriteAllLines(Path.Combine(a2PeopleContentDirectory, "People - C.tsv"), from l in lines select l.Line);
|
||||
List<(string, string[], string)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, personKeyFormattedCollection, ticksDirectories, message);
|
||||
results = GetIdToCollection(configuration, collection);
|
||||
results = DeleteEmptyDirectoriesAndGetCollection(configuration, personKeyFormattedCollection, ticksDirectories, message);
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -260,7 +243,7 @@ internal abstract class MapLogic
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
private static void SetKeyValuePairs(Configuration configuration, long ticks, List<PersonContainer> personContainers, Mapping[] mappingCollection, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedRectangleToPersonContainers, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges)
|
||||
private static void SetKeyValuePairs(Configuration configuration, List<PersonContainer> personContainers, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
PersonBirthday? personBirthday;
|
||||
PersonContainer[] distinctPersonContainers;
|
||||
@ -308,7 +291,6 @@ internal abstract class MapLogic
|
||||
idThenNormalizedRectangleToPersonContainers[keyValuePair.Key].Add(innerKeyValuePair.Key, distinctPersonContainers);
|
||||
}
|
||||
};
|
||||
SetPersonTicks(configuration, ticks, mappingCollection, personKeyToRanges, idThenNormalizedRectangleToPersonContainers);
|
||||
if (incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection.Any())
|
||||
{
|
||||
PersonContainer personContainer;
|
||||
@ -366,18 +348,15 @@ internal abstract class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
private static (int, int) SetCollectionsAndGetUnableToMatchCount(Configuration configuration, long ticks, Dictionary<int, List<Mapping>> idToMappingCollection, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, List<(string, string[], string)> collection)
|
||||
private static (int, int) SetCollectionsAndGetUnableToConvertCount(Configuration configuration, long ticks, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, List<(string, string[], string)> collection)
|
||||
{
|
||||
int result = 0;
|
||||
int? id;
|
||||
int? normalizedRectangle;
|
||||
string newestPersonKeyFormatted;
|
||||
List<Mapping>? mappingCollection;
|
||||
string personDisplayDirectoryName;
|
||||
List<int> normalizedRectangles;
|
||||
List<Mapping> checkMappingCollection = new();
|
||||
string newestPersonKeyFormatted;
|
||||
string personDisplayDirectoryName;
|
||||
List<string> duplicateMappedFaceFiles = new();
|
||||
bool idToMappingCollectionAny = idToMappingCollection.Any();
|
||||
Dictionary<int, List<int>> idToNormalizedRectangles = new();
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
string message = $") {collection.Count:000} join from ticks Director(ies) - C - {totalSeconds} total second(s)";
|
||||
@ -386,7 +365,7 @@ internal abstract class MapLogic
|
||||
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, string mappedFaceFile) in collection)
|
||||
{
|
||||
progressBar.Tick();
|
||||
(id, normalizedRectangle, mappingCollection) = IMapping.GetConverted(configuration.FacesFileNameExtension, idToMappingCollectionAny, idToMappingCollection, mappedFaceFile);
|
||||
(id, normalizedRectangle) = IMapping.GetConverted(configuration.FacesFileNameExtension, mappedFaceFile);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
{
|
||||
result++;
|
||||
@ -395,31 +374,6 @@ internal abstract class MapLogic
|
||||
if (!idToNormalizedRectangles.ContainsKey(id.Value))
|
||||
idToNormalizedRectangles.Add(id.Value, new());
|
||||
normalizedRectangles = idToNormalizedRectangles[id.Value];
|
||||
checkMappingCollection.Clear();
|
||||
if (mappingCollection is not null)
|
||||
{
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
if (normalizedRectangle.Value != mapping.MappingFromLocation.NormalizedRectangle)
|
||||
continue;
|
||||
if (normalizedRectangles.Contains(mapping.MappingFromLocation.NormalizedRectangle))
|
||||
{
|
||||
duplicateMappedFaceFiles.Add(mappedFaceFile);
|
||||
continue;
|
||||
}
|
||||
checkMappingCollection.Add(mapping);
|
||||
}
|
||||
if (!checkMappingCollection.Any())
|
||||
{
|
||||
result++;
|
||||
continue;
|
||||
}
|
||||
if (checkMappingCollection.Count != 1)
|
||||
{
|
||||
result++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
normalizedRectangles.Add(normalizedRectangle.Value);
|
||||
idToNormalizedRectangles[id.Value].Add(normalizedRectangle.Value);
|
||||
if (!personKeyFormattedToNewestPersonKeyFormatted.ContainsKey(personKeyFormatted))
|
||||
@ -495,8 +449,8 @@ internal abstract class MapLogic
|
||||
else
|
||||
average = (sumCollection.Sum() / collection.Length) + minimum;
|
||||
standardDeviation = GetStandardDeviation(collection, average);
|
||||
ucl = (long)(average + (standardDeviation * IMapLogic.Sigma));
|
||||
lcl = (long)(average - (standardDeviation * IMapLogic.Sigma));
|
||||
ucl = (long)(average + (standardDeviation * Shared.Models.Stateless.IMapLogic.Sigma));
|
||||
lcl = (long)(average - (standardDeviation * Shared.Models.Stateless.IMapLogic.Sigma));
|
||||
if (lcl < 0)
|
||||
lcl = 0;
|
||||
if (ucl > 0)
|
||||
@ -506,7 +460,7 @@ internal abstract class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetPersonTicks(Configuration configuration, long ticks, Mapping[] mappingCollection, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers)
|
||||
internal static void SetPersonTicks(Configuration configuration, long ticks, Mapping[] mappingCollection, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
PersonContainer[]? personContainers;
|
||||
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||
@ -534,7 +488,7 @@ internal abstract class MapLogic
|
||||
SetPersonKeysRanges(configuration, ticks, personKeyToMinimumDateTimeTicks, personKeyToRanges);
|
||||
}
|
||||
|
||||
private static List<PersonContainer> GetNotMappedPersonContainers(Configuration configuration, List<PersonContainer> personContainers, long[] personKeyCollection)
|
||||
private static List<PersonContainer> GetNotMappedPersonContainers(Configuration configuration, List<PersonContainer> personContainers, List<long> personKeys, long[] personKeyCollection)
|
||||
{
|
||||
List<PersonContainer> results = new();
|
||||
List<PersonContainer> notMappedAndNotNamedPersonKeys = new();
|
||||
@ -543,15 +497,17 @@ internal abstract class MapLogic
|
||||
{
|
||||
if (personContainer.Person is null || personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
continue;
|
||||
if (personKeys.Contains(personContainer.Key.Value))
|
||||
continue;
|
||||
if (personKeyCollection.Contains(personContainer.Key.Value))
|
||||
continue;
|
||||
else if (string.IsNullOrEmpty(personContainer.DisplayDirectoryName) || personContainer.DisplayDirectoryName == configuration.MappingDefaultName)
|
||||
if (string.IsNullOrEmpty(personContainer.DisplayDirectoryName) || personContainer.DisplayDirectoryName == configuration.MappingDefaultName)
|
||||
notMappedAndNotNamedPersonKeys.Add(personContainer);
|
||||
else
|
||||
notMappedAndWithNamedPersonKeys.Add(personContainer);
|
||||
}
|
||||
results.AddRange(from l in notMappedAndNotNamedPersonKeys orderby l.Key is not null, l.Key select l);
|
||||
results.AddRange(from l in notMappedAndWithNamedPersonKeys orderby l.Key is not null, l.Key select l);
|
||||
results.AddRange(notMappedAndNotNamedPersonKeys);
|
||||
// results.AddRange(notMappedAndWithNamedPersonKeys);
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -612,7 +568,7 @@ internal abstract class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
internal static void Set(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, Configuration? configuration, long ticks, List<PersonContainer> personContainers, string? a2PeopleContentDirectory, string eDistanceContentDirectory, Mapping[] mappingCollection, Shared.Models.Methods.IMapLogicSupport mapLogicSupport, 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[]>> idThenNormalizedRectangleToPersonContainers)
|
||||
internal static void Set(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, Configuration? configuration, long ticks, List<PersonContainer> personContainers, string? a2PeopleContentDirectory, string eDistanceContentDirectory, Shared.Models.Methods.IMapLogicSupport mapLogicSupport, Dictionary<long, PersonContainer> personKeyToPersonContainer, List<PersonContainer> notMappedPersonContainers, Dictionary<int, List<int>> skipCollection, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
if (configuration is null)
|
||||
throw new NullReferenceException(nameof(configuration));
|
||||
@ -621,26 +577,19 @@ internal abstract class MapLogic
|
||||
List<long> personKeys = new();
|
||||
List<long?> nullablePersonKeyCollection = new();
|
||||
List<string> personKeyFormattedCollection = new();
|
||||
Dictionary<int, List<Mapping>> idToMappingCollection = new();
|
||||
Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted = new();
|
||||
List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer = new();
|
||||
List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection = new();
|
||||
List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection = new();
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedRectangleToPersonContainers = new();
|
||||
SetPersonCollections(configuration, personContainers, personKeys, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedCollection, skipCollection);
|
||||
personContainers.AddRange(AddToPersonKeysThenGetNonSpecificPeopleCollection(configuration, personKeys));
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
if (!idToMappingCollection.ContainsKey(mapping.MappingFromItem.Id))
|
||||
idToMappingCollection.Add(mapping.MappingFromItem.Id, new());
|
||||
idToMappingCollection[mapping.MappingFromItem.Id].Add(mapping);
|
||||
}
|
||||
personContainers.AddRange(GetNonSpecificPeopleCollection(configuration, ticks, personKeys));
|
||||
totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
string[] ticksDirectories = Directory.GetDirectories(eDistanceContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
message = $") {ticksDirectories.Length:000} compile from and clean ticks Director(ies) - B - {totalSeconds} total second(s)";
|
||||
List<(string, string[], string)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, personKeyFormattedCollection, ticksDirectories, message);
|
||||
(int unableToMatchCount, int duplicateCount) = SetCollectionsAndGetUnableToMatchCount(configuration, ticks, idToMappingCollection, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenNormalizedRectangleCollection, incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, collection);
|
||||
SetKeyValuePairs(configuration, ticks, personContainers, mappingCollection, personKeyFormattedIdThenNormalizedRectangleCollection, incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, personKeyToPersonContainer, idThenNormalizedRectangleToPersonContainers, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, incorrectIdThenNormalizedRectangleToPersonContainers, personKeyToRanges);
|
||||
(int unableToMatchCount, int duplicateCount) = SetCollectionsAndGetUnableToConvertCount(configuration, ticks, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenNormalizedRectangleCollection, incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, collection);
|
||||
SetKeyValuePairs(configuration, personContainers, personKeyFormattedIdThenNormalizedRectangleCollection, incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, personKeyToPersonContainer, idThenNormalizedRectangleToPersonContainers, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, incorrectIdThenNormalizedRectangleToPersonContainers);
|
||||
totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
message = $") {collection.Count:000} message from ticks Director(ies) - D - {duplicateCount} Duplicate Count {unableToMatchCount} Unable To Match Count / {collection.Count} Collection - {totalSeconds} total second(s)";
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
@ -655,7 +604,7 @@ internal abstract class MapLogic
|
||||
}
|
||||
long[] personKeyCollection = (from l in nullablePersonKeyCollection where l is not null select l.Value).Distinct().ToArray();
|
||||
SetPersonKeyToPersonContainer(configuration, personContainers, personKeyCollection, personKeyToPersonContainer);
|
||||
notMappedPersonContainers.AddRange(GetNotMappedPersonContainers(configuration, personContainers, personKeyCollection));
|
||||
notMappedPersonContainers.AddRange(GetNotMappedPersonContainers(configuration, personContainers, personKeys, personKeyCollection));
|
||||
AppendToSkipCollection(skipCollection, idThenNormalizedRectangleToPersonContainers, incorrectIdThenNormalizedRectangleToPersonContainers);
|
||||
if (possiblyNewPersonDisplayDirectoryNamesAndPersonContainer.Any())
|
||||
mapLogicSupport.SavePossiblyNewPersonContainers(propertyConfiguration, configuration.PersonBirthdayFormat, configuration.FacesFileNameExtension, a2PeopleContentDirectory, personKeyToPersonContainer, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer);
|
||||
|
@ -3,9 +3,9 @@ namespace View_by_Distance.Map.Models.Stateless.Methods;
|
||||
public interface IMapLogic
|
||||
{ // ...
|
||||
|
||||
Dictionary<int, List<(string, int)>> TestStatic_DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, long ticks, string? a2PeopleContentDirectory, string? eDistanceContentDirectory, Shared.Models.PersonContainer[] personContainers) =>
|
||||
List<(string, string[], string)> TestStatic_DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, long ticks, string? a2PeopleContentDirectory, string? eDistanceContentDirectory, Shared.Models.PersonContainer[] personContainers) =>
|
||||
DeleteEmptyDirectoriesAndGetMappedFaceFiles(configuration, ticks, a2PeopleContentDirectory, eDistanceContentDirectory, personContainers);
|
||||
static Dictionary<int, List<(string, int)>> DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, long ticks, string? a2PeopleContentDirectory, string? eDistanceContentDirectory, Shared.Models.PersonContainer[] personContainers) =>
|
||||
static List<(string, string[], string)> DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, long ticks, string? a2PeopleContentDirectory, string? eDistanceContentDirectory, Shared.Models.PersonContainer[] personContainers) =>
|
||||
MapLogic.DeleteEmptyDirectoriesAndGetMappedFaceFiles(configuration, ticks, a2PeopleContentDirectory, eDistanceContentDirectory, personContainers);
|
||||
|
||||
}
|
Reference in New Issue
Block a user