SaveShortcutsForOutputResolutions

This commit is contained in:
2023-01-02 20:22:27 -07:00
parent d0cd52807d
commit 92288c9381
7 changed files with 252 additions and 143 deletions

View File

@ -1,5 +1,6 @@
using Humanizer;
using ShellProgressBar;
using System.Collections.ObjectModel;
using System.Text.Json;
using View_by_Distance.Shared.Models;
using View_by_Distance.Shared.Models.Stateless.Methods;
@ -10,10 +11,10 @@ namespace View_by_Distance.Map.Models;
public class MapLogic : Shared.Models.Methods.IMapLogic
{
protected readonly Dictionary<int, List<int>> _SkipCollection;
protected readonly List<PersonContainer> _NotMappedPersonContainers;
protected readonly Dictionary<long, PersonContainer> _PersonKeyToPersonContainer;
protected readonly Dictionary<int, Dictionary<int, PersonContainer[]>> _IdThenNormalizedRectangleToPersonContainers;
protected readonly ReadOnlyDictionary<int, List<int>> _SkipCollection;
protected readonly ReadOnlyDictionary<long, PersonContainer> _PersonKeyToPersonContainer;
protected readonly ReadOnlyDictionary<int, Dictionary<int, PersonContainer[]>> _IdThenNormalizedRectangleToPersonContainers;
public Dictionary<int, int[]> KeyValuePairs => throw new NotImplementedException();
public Dictionary<int, int[]> IndicesFromNew => throw new NotImplementedException();
@ -87,11 +88,11 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
if (collection is null)
throw new NullReferenceException(nameof(collection));
}
_SkipCollection = skipCollection;
_PersonKeyToPersonContainer = personKeyToPersonContainer;
_SkipCollection = new(skipCollection);
_PersonKeyToPersonContainer = new(personKeyToPersonContainer);
_EDistanceContentTicksDirectory = eDistanceContentTicksDirectory;
_IdThenNormalizedRectangleToPersonContainers = idThenNormalizedRectangleToPersonContainers;
_NotMappedPersonContainers = notMappedPersonContainers.OrderByDescending(l => l.Key).ToList();
_IdThenNormalizedRectangleToPersonContainers = new(idThenNormalizedRectangleToPersonContainers);
}
public override string ToString()
@ -131,36 +132,13 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
}
}
private static Dictionary<int, List<long>> GetIdToPersonKeys(Dictionary<long, List<int>> keyValuePairs)
public Dictionary<long, List<int>> GetPersonKeyToIds()
{
Dictionary<int, List<long>> results = new();
List<long>? collection;
foreach (KeyValuePair<long, List<int>> keyValuePair in keyValuePairs)
{
foreach (int id in keyValuePair.Value)
{
if (!results.TryGetValue(id, out collection))
{
results.Add(id, new());
if (!results.TryGetValue(id, out collection))
throw new Exception();
}
if (collection.Contains(keyValuePair.Key))
continue;
collection.Add(keyValuePair.Key);
}
}
return results;
}
public Dictionary<int, List<long>> GetIdToPeronKeys()
{
Dictionary<int, List<long>> results;
long key;
Dictionary<long, List<int>> results = new();
long personKey;
const int zero = 0;
List<int>? collection;
PersonBirthday personBirthday;
Dictionary<long, List<int>> keyValuePairs = new();
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> idToCollection in _IdThenNormalizedRectangleToPersonContainers)
{
foreach (KeyValuePair<int, PersonContainer[]> normalizedRectangleToPersonContainers in idToCollection.Value)
@ -172,11 +150,11 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
personBirthday = personContainer.Birthdays[zero];
if (IPersonBirthday.IsCounterPersonBirthday(personBirthday))
continue;
key = personBirthday.Value.Ticks;
if (!keyValuePairs.TryGetValue(key, out collection))
personKey = personBirthday.Value.Ticks;
if (!results.TryGetValue(personKey, out collection))
{
keyValuePairs.Add(key, new());
if (!keyValuePairs.TryGetValue(key, out collection))
results.Add(personKey, new());
if (!results.TryGetValue(personKey, out collection))
throw new Exception();
}
if (collection.Contains(idToCollection.Key))
@ -185,7 +163,6 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
}
}
}
results = GetIdToPersonKeys(keyValuePairs);
return results;
}
@ -236,36 +213,6 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
return result;
}
public Dictionary<long, int> GetPersonKeyToCount(Mapping[] mappingCollection)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
Dictionary<long, int> results = new();
long personKey;
const int zero = 0;
PersonBirthday personBirthday;
PersonContainer[]? personContainers;
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
foreach (Mapping mapping in mappingCollection)
{
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out normalizedRectangleToPersonContainers))
continue;
if (!normalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromLocation.NormalizedRectangle, out personContainers))
continue;
foreach (PersonContainer personContainer in personContainers)
{
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
continue;
personBirthday = personContainer.Birthdays[zero];
personKey = personBirthday.Value.Ticks;
if (!results.ContainsKey(personKey))
results.Add(personKey, 0);
results[personKey] += 1;
}
}
return results;
}
public void SaveContainers(int totalNotMapped, int? updated, List<SaveContainer> saveContainers)
{
if (_Configuration is null)
@ -472,12 +419,13 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
return result;
}
private List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, Dictionary<long, int> personKeyToCount, int? useFiltersCounter, bool saveMapped, bool sortingContainersAny)
private List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, Dictionary<long, List<int>> personKeyToIds, int? useFiltersCounter, bool saveMapped, bool sortingContainersAny)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
List<SaveContainer> results = new();
string by;
List<int>? ids;
long personKey;
bool isByMapping;
bool isBySorting;
@ -546,9 +494,9 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName, "lnk");
else
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName[..1], "lnk");
if (isByMapping && personKeyToCount.TryGetValue(personKey, out int count))
if (isByMapping && personKeyToIds.TryGetValue(personKey, out ids))
{
saveContainer = new(Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName, $"{count} Face(s)"));
saveContainer = new(Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName, $"{ids.Count} Face(s)"));
results.Add(saveContainer);
}
}
@ -604,12 +552,12 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
throw new NullReferenceException(nameof(_Configuration));
List<SaveContainer> results;
bool saveMapped = false;
Dictionary<long, int> personKeyToCount = new();
results = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToCount, useFiltersCounter, saveMapped, sortingContainersAny);
Dictionary<long, List<int>> personKeyToIds = new();
results = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToIds, useFiltersCounter, saveMapped, sortingContainersAny);
return results;
}
public void SaveMapped(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, Dictionary<long, int> personKeyToCount, int totalNotMapped)
public void SaveMapped(string dFacesContentDirectory, string d2FacePartsContentDirectory, Dictionary<long, List<int>> personKeyToIds, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, int totalNotMapped)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
@ -617,7 +565,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
bool saveMapped = true;
int? useFiltersCounter = null;
string mappingDirectory = Path.Combine(_EDistanceContentTicksDirectory, nameof(Shared.Models.Stateless.IMapLogic.Mapping));
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToCount, useFiltersCounter, saveMapped, sortingContainersAny: true);
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToIds, useFiltersCounter, saveMapped, sortingContainersAny: true);
SaveContainers(totalNotMapped, updated, saveContainers);
if (!string.IsNullOrEmpty(_EDistanceContentTicksDirectory) && Directory.Exists(mappingDirectory))
Stateless.MapLogic.SaveMappingShortcuts(mappingDirectory);
@ -952,7 +900,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
return new(personKeyFormatted, personBirthday);
}
private List<string> GetPersonKeyFormattedCollection(string[] jLinks, string a2PeopleContentDirectory, PersonContainer[] personContainers, Dictionary<long, int> personKeyToCount)
private List<string> GetPersonKeyFormattedCollection(string[] jLinks, string a2PeopleContentDirectory, PersonContainer[] personContainers, Dictionary<long, List<int>> personKeyToIds)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
@ -991,10 +939,10 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
(personKeyFormatted, personBirthday) = GetPersonBirthday(windowsShortcut.Path);
if (personBirthday is null)
throw new NotSupportedException(fileNameWithoutExtension);
if (!personKeyToCount.ContainsKey(personBirthday.Value.Ticks))
if (!personKeyToIds.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)")));
collection.Add(new(personBirthday.Value.Ticks, Path.Combine(checkDirectory, personKeyFormatted, fileNameWithoutExtension, $"{personKeyToIds[personBirthday.Value.Ticks].Count} Face(s)")));
foreach ((long personKey, string displayDirectoryName) in collection)
{
matches = (from l in personContainers where l.Key == personKey && l.ApproximateYears.HasValue select l).ToArray();
@ -1012,7 +960,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
return results;
}
private (int, FileHolder, int, string, string, string, string)[] GetCollectionForSaveFilteredOriginalImagesFromJLinks(string[] jLinks, string a2PeopleContentDirectory, PersonContainer[] personContainers, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount)
private (int, FileHolder, int, string, string, string, string)[] GetCollectionForSaveFilteredOriginalImagesFromJLinks(string[] jLinks, string a2PeopleContentDirectory, PersonContainer[] personContainers, Mapping[] mappingCollection, Dictionary<long, List<int>> personKeyToIds)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
@ -1023,7 +971,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
string personDirectory;
string personKeyFormatted;
bool usePersonKeyAndDeterministicHashCodeKey = false;
List<string> personKeyFormattedCollection = GetPersonKeyFormattedCollection(jLinks, a2PeopleContentDirectory, personContainers, personKeyToCount);
List<string> personKeyFormattedCollection = GetPersonKeyFormattedCollection(jLinks, a2PeopleContentDirectory, personContainers, personKeyToIds);
List<(int Id, FileHolder ImageFileHolder, int ApproximateYears, string PersonKeyFormatted, string CheckFile, string Directory, string PersonDirectory)> collection = new();
foreach (Mapping mapping in mappingCollection)
{
@ -1112,7 +1060,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
}
}
public void SaveFilteredOriginalImagesFromJLinks(string[] jLinks, PersonContainer[] personContainers, string a2PeopleContentDirectory, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount, int totalNotMapped)
public void SaveFilteredOriginalImagesFromJLinks(string[] jLinks, PersonContainer[] personContainers, string a2PeopleContentDirectory, Dictionary<long, List<int>> personKeyToIds, Mapping[] mappingCollection, int totalNotMapped)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
@ -1120,7 +1068,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
List<int> distinctCollection = new();
List<SaveContainer> saveContainers = new();
BeforeSaveFilteredOriginalImagesFromJLinks(jLinks, a2PeopleContentDirectory);
(int, FileHolder, int, string, string, string, string)[] collection = GetCollectionForSaveFilteredOriginalImagesFromJLinks(jLinks, a2PeopleContentDirectory, personContainers, mappingCollection, personKeyToCount);
(int, FileHolder, int, string, string, string, string)[] collection = GetCollectionForSaveFilteredOriginalImagesFromJLinks(jLinks, a2PeopleContentDirectory, personContainers, mappingCollection, personKeyToIds);
foreach ((int id, FileHolder imageFileHolder, int approximateYears, string personKeyFormatted, string directory, string personDirectory, string checkFile) in collection)
{
if (distinctCollection.Contains(id))
@ -1134,7 +1082,64 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
SaveContainers(totalNotMapped, null, saveContainers);
}
private (List<(string, DateTime[])>, List<(string, string, string, string)>) GetCollectionForSaveShortcutsForOutputResolutions(List<Item> filteredItems, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount)
public void SaveShortcutsForOutputResolutions(string a2PeopleContentDirectory, Dictionary<long, List<int>> personKeyToIds, Mapping[] mappingCollection, int totalNotMapped)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
long personKey;
string fileName;
string directory;
string hiddenFile;
string personDirectory;
List<long>? personKeys;
string personKeyFormatted;
WindowsShortcut windowsShortcut;
List<SaveShortcutsForOutputResolutions> collection = new();
Dictionary<int, List<long>> idToPersonKeys = Stateless.Methods.IMapLogic.GetIdToPersonKeys(personKeyToIds);
foreach (Mapping mapping in mappingCollection)
{
if (mapping.MappingFromItem.ImageFileHolder.DirectoryName is null || mapping.MappingFromPerson is null)
continue;
if (!idToPersonKeys.TryGetValue(mapping.MappingFromItem.Id, out personKeys))
continue;
personKey = mapping.MappingFromPerson.PersonBirthday.Value.Ticks;
if (!personKeys.Contains(mapping.MappingFromPerson.PersonBirthday.Value.Ticks))
continue;
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, mapping.MappingFromPerson.PersonBirthday);
directory = Path.Combine(a2PeopleContentDirectory, $"{_PropertyConfiguration.ResultAllInOne}Shortcuts", personKeyFormatted);
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName[..1], Path.GetFileName(mapping.MappingFromItem.ImageFileHolder.DirectoryName));
fileName = Path.Combine(personDirectory, $"{mapping.MappingFromItem.ResizedFileHolder.Name}.lnk");
collection.Add(new(mapping.MappingFromItem.ResizedFileHolder.FullName, personDirectory, mapping.MappingFromItem.MinimumDateTime, fileName, mapping.MappingFromLocation.DeterministicHashCodeKey));
}
string[] directories = (from l in collection select l.Directory).Distinct().ToArray();
foreach (string d in directories)
{
if (string.IsNullOrEmpty(d))
continue;
if (!Directory.Exists(d))
_ = Directory.CreateDirectory(d);
}
foreach (SaveShortcutsForOutputResolutions s in collection)
{
hiddenFile = $"{s.FileName}.lvs";
File.WriteAllLines(hiddenFile, new string[] { s.FullName, s.Description });
File.SetAttributes(hiddenFile, FileAttributes.Hidden);
File.SetLastWriteTime(hiddenFile, s.DateTime);
if (File.Exists(s.FileName))
continue;
try
{
windowsShortcut = new() { Path = s.FullName, Description = s.Description };
windowsShortcut.Save(s.FileName);
windowsShortcut.Dispose();
File.SetLastWriteTime(s.FileName, s.DateTime);
}
catch (Exception)
{ }
}
}
private (List<(string, DateTime[])>, List<SaveShortcutsForOutputResolutions>) GetCollectionForSaveShortcutsForOutputResolutions(Dictionary<long, List<int>> personKeyToIds, List<Item> filteredItems, Mapping[] mappingCollection)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
@ -1145,7 +1150,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
string personDirectory;
string personKeyFormatted;
List<string> distinct = new();
List<(string, string, string, string)> collection = new();
List<SaveShortcutsForOutputResolutions> collection = new();
List<(string, DateTime[])> directoriesAndDateTimes = new();
foreach (Item item in filteredItems)
{
@ -1158,12 +1163,12 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
directoryName = Path.GetDirectoryName(face.Mapping.MappingFromItem.RelativePath);
if (directoryName is null)
throw new NotSupportedException();
if (item.ResizedFileHolder?.DirectoryName is null || !item.ResizedFileHolder.Exists)
if (item.ResizedFileHolder?.DirectoryName is null || !item.ResizedFileHolder.Exists || item.ImageFileHolder.LastWriteTime is null)
continue;
directory = Path.Combine(item.ResizedFileHolder.DirectoryName, $"{_PropertyConfiguration.ResultAllInOne}Shortcuts", _PropertyConfiguration.ResultAllInOne);
personDirectory = Path.Combine(directory, "No Faces");
fileName = Path.Combine(personDirectory, $"{item.ResizedFileHolder.Name}.lnk");
collection.Add(new(item.ResizedFileHolder.FullName, personDirectory, fileName, face.Mapping.MappingFromItem.Id.ToString()));
collection.Add(new(item.ResizedFileHolder.FullName, personDirectory, item.ImageFileHolder.LastWriteTime.Value, fileName, face.Mapping.MappingFromItem.Id.ToString()));
if (face.Mapping.MappingFromItem.ContainerDateTimes.Any() && !distinct.Contains(item.ResizedFileHolder.DirectoryName))
{
distinct.Add(item.ResizedFileHolder.DirectoryName);
@ -1188,7 +1193,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
directory = Path.Combine(mapping.MappingFromItem.ResizedFileHolder.DirectoryName, $"{_PropertyConfiguration.ResultAllInOne}Shortcuts", _PropertyConfiguration.ResultAllInOne);
personDirectory = Path.Combine(directory, "Unknown");
fileName = Path.Combine(personDirectory, $"{mapping.MappingFromItem.ResizedFileHolder.Name}.lnk");
collection.Add(new(mapping.MappingFromItem.ResizedFileHolder.FullName, personDirectory, fileName, mapping.MappingFromLocation.DeterministicHashCodeKey));
collection.Add(new(mapping.MappingFromItem.ResizedFileHolder.FullName, personDirectory, mapping.MappingFromItem.MinimumDateTime, fileName, mapping.MappingFromLocation.DeterministicHashCodeKey));
}
else
{
@ -1204,25 +1209,25 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
directoriesAndDateTimes.Add(new(mapping.MappingFromItem.ResizedFileHolder.DirectoryName, mapping.MappingFromItem.ContainerDateTimes));
}
directory = Path.Combine(mapping.MappingFromItem.ResizedFileHolder.DirectoryName, $"{_PropertyConfiguration.ResultAllInOne}Shortcuts", personKeyFormatted);
if (!personKeyToCount.ContainsKey(personKey))
if (!personKeyToIds.ContainsKey(personKey))
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName);
else
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName, $"{personKeyToCount[personKey]} Face(s)");
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName, $"{personKeyToIds[personKey].Count} Face(s)");
fileName = Path.Combine(directory, $"{mapping.MappingFromItem.ResizedFileHolder.Name}.lnk");
collection.Add(new(mapping.MappingFromItem.ResizedFileHolder.FullName, personDirectory, fileName, mapping.MappingFromLocation.DeterministicHashCodeKey));
collection.Add(new(mapping.MappingFromItem.ResizedFileHolder.FullName, personDirectory, mapping.MappingFromItem.MinimumDateTime, fileName, mapping.MappingFromLocation.DeterministicHashCodeKey));
}
}
return new(directoriesAndDateTimes, collection);
}
public void SaveShortcutsForOutputResolutions(List<Item> filteredItems, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount)
public void SaveShortcutsForOutputResolutions(Dictionary<long, List<int>> personKeyToIds, List<Item> filteredItems, Mapping[] mappingCollection)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
WindowsShortcut windowsShortcut;
List<(string, DateTime[])> directoriesAndDateTimes;
List<(string, string Directory, string, string)> collection;
(directoriesAndDateTimes, collection) = GetCollectionForSaveShortcutsForOutputResolutions(filteredItems, mappingCollection, personKeyToCount);
List<SaveShortcutsForOutputResolutions> collection;
(directoriesAndDateTimes, collection) = GetCollectionForSaveShortcutsForOutputResolutions(personKeyToIds, filteredItems, mappingCollection);
string[] directories = (from l in collection select l.Directory).Distinct().ToArray();
foreach (string directory in directories)
{
@ -1231,14 +1236,14 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
}
foreach ((string fullName, string directory, string fileName, string description) in collection)
foreach (SaveShortcutsForOutputResolutions saveShortcutsForOutputResolutions in collection)
{
if (File.Exists(fileName))
if (File.Exists(saveShortcutsForOutputResolutions.FileName))
continue;
try
{
windowsShortcut = new() { Path = fullName, Description = description };
windowsShortcut.Save(fileName);
windowsShortcut = new() { Path = saveShortcutsForOutputResolutions.FullName, Description = saveShortcutsForOutputResolutions.Description };
windowsShortcut.Save(saveShortcutsForOutputResolutions.FileName);
windowsShortcut.Dispose();
}
catch (Exception)

View File

@ -680,4 +680,26 @@ internal abstract class MapLogic
return results;
}
internal static Dictionary<int, List<long>> GetIdToPersonKeys(Dictionary<long, List<int>> personKeyToIds)
{
Dictionary<int, List<long>> results = new();
List<long>? collection;
foreach (KeyValuePair<long, List<int>> keyValuePair in personKeyToIds)
{
foreach (int id in keyValuePair.Value)
{
if (!results.TryGetValue(id, out collection))
{
results.Add(id, new());
if (!results.TryGetValue(id, out collection))
throw new Exception();
}
if (collection.Contains(keyValuePair.Key))
continue;
collection.Add(keyValuePair.Key);
}
}
return results;
}
}

View File

@ -1,7 +1,12 @@
namespace View_by_Distance.Map.Models.Stateless.Methods;
public interface IMapLogic
{ // ...
{
Dictionary<int, List<long>> TestStatic_GetIdToPersonKeys(Dictionary<long, List<int>> personKeyToIds) =>
GetIdToPersonKeys(personKeyToIds);
static Dictionary<int, List<long>> GetIdToPersonKeys(Dictionary<long, List<int>> personKeyToIds) =>
MapLogic.GetIdToPersonKeys(personKeyToIds);
List<(long, string)> TestStatic_GetDisplayDirectoryAllFiles(Shared.Models.PersonContainer[] personContainers) =>
GetDisplayDirectoryAllFiles(personContainers);