net7.0
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputType>library</OutputType>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PackageId>Phares.View.by.Distance.Map</PackageId>
|
||||
@ -34,14 +34,12 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.13.14" />
|
||||
<PackageReference Include="MetadataExtractor" Version="2.7.1" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.1.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.0" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="MetadataExtractor" Version="2.7.2" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.1.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -246,24 +246,55 @@ public class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
private static string? GetFacesDirectory(string dFacesContentDirectory, MappingFromItem mappingFromItem)
|
||||
{
|
||||
string? result;
|
||||
string? directoryName = Path.GetDirectoryName(mappingFromItem.RelativePath);
|
||||
if (directoryName is null)
|
||||
result = null;
|
||||
else
|
||||
result = Path.Combine($"{dFacesContentDirectory}{directoryName}", mappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string? GetFacePartsDirectory(string d2FacePartsContentDirectory, MappingFromItem mappingFromItem)
|
||||
{
|
||||
string? result;
|
||||
string? directoryName = Path.GetDirectoryName(mappingFromItem.RelativePath);
|
||||
if (directoryName is null)
|
||||
result = null;
|
||||
else
|
||||
result = Path.Combine($"{d2FacePartsContentDirectory}{directoryName}", mappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
return result;
|
||||
}
|
||||
|
||||
private SaveContainer? GetMatchSaveContainer(string dFacesContentDirectory, string d2FacePartsContentDirectory, string directory, Mapping mapping)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
SaveContainer? result;
|
||||
string shortcutFile = string.Empty;
|
||||
string? directoryName = Path.GetDirectoryName(mapping.MappingFromItem.RelativePath);
|
||||
string facesDirectory = Path.Combine($"{dFacesContentDirectory}{directoryName}", mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
FileHolder faceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesFileNameExtension}"));
|
||||
if (directoryName is null || !faceFileHolder.Exists)
|
||||
string? facesDirectory = GetFacesDirectory(dFacesContentDirectory, mapping.MappingFromItem);
|
||||
if (facesDirectory is null)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
string facePartsDirectory = Path.Combine($"{d2FacePartsContentDirectory}{directoryName}", mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
string checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
FileHolder hiddenFaceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesHiddenFileNameExtension}"));
|
||||
FileHolder facePartsFileHolder = new(Path.Combine(facePartsDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacePartsFileNameExtension}"));
|
||||
result = new(checkFile, directory, faceFileHolder, hiddenFaceFileHolder, facePartsFileHolder, mapping.MappingFromItem.ResizedFileHolder, shortcutFile);
|
||||
FileHolder faceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesFileNameExtension}"));
|
||||
if (!faceFileHolder.Exists)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
string? facePartsDirectory = GetFacePartsDirectory(d2FacePartsContentDirectory, mapping.MappingFromItem);
|
||||
if (facePartsDirectory is null)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
string checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
FileHolder hiddenFaceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesHiddenFileNameExtension}"));
|
||||
FileHolder facePartsFileHolder = new(Path.Combine(facePartsDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacePartsFileNameExtension}"));
|
||||
result = new(checkFile, directory, faceFileHolder, hiddenFaceFileHolder, facePartsFileHolder, mapping.MappingFromItem.ResizedFileHolder, shortcutFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -339,12 +370,12 @@ public class MapLogic
|
||||
string checkFile;
|
||||
string directory;
|
||||
string shortcutFile;
|
||||
string facesDirectory;
|
||||
string? directoryName;
|
||||
string personDirectory;
|
||||
string? facesDirectory;
|
||||
FileHolder faceFileHolder;
|
||||
string facePartsDirectory;
|
||||
string personKeyFormatted;
|
||||
string? facePartsDirectory;
|
||||
SaveContainer? saveContainer;
|
||||
FileHolder facePartsFileHolder;
|
||||
FileHolder hiddenFaceFileHolder;
|
||||
@ -380,15 +411,17 @@ public class MapLogic
|
||||
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName, "lnk");
|
||||
else
|
||||
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName[..1], "lnk");
|
||||
if (isByMapping && personKeyToCount.ContainsKey(personKey))
|
||||
if (isByMapping && personKeyToCount.TryGetValue(personKey, out int count))
|
||||
{
|
||||
saveContainer = new(Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName, $"{personKeyToCount[personKey]} Face(s)"));
|
||||
saveContainer = new(Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName, $"{count} Face(s)"));
|
||||
results.Add(saveContainer);
|
||||
}
|
||||
}
|
||||
saveContainer = new(personDirectory);
|
||||
results.Add(saveContainer);
|
||||
facesDirectory = Path.Combine($"{dFacesContentDirectory}{directoryName}", mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
facesDirectory = GetFacesDirectory(dFacesContentDirectory, mapping.MappingFromItem);
|
||||
if (facesDirectory is null)
|
||||
continue;
|
||||
faceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesFileNameExtension}"));
|
||||
if (!faceFileHolder.Exists)
|
||||
continue;
|
||||
@ -399,7 +432,9 @@ public class MapLogic
|
||||
}
|
||||
else
|
||||
{
|
||||
facePartsDirectory = Path.Combine($"{d2FacePartsContentDirectory}{directoryName}", mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
facePartsDirectory = GetFacePartsDirectory(d2FacePartsContentDirectory, mapping.MappingFromItem);
|
||||
if (facePartsDirectory is null)
|
||||
continue;
|
||||
checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{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}"));
|
||||
@ -633,9 +668,9 @@ public class MapLogic
|
||||
string faceFileName;
|
||||
string shortcutFile;
|
||||
string? directoryName;
|
||||
string facesDirectory;
|
||||
string mappingSegmentB;
|
||||
string personDirectory;
|
||||
string? facesDirectory;
|
||||
string personKeyFormatted;
|
||||
string personDisplayFileName;
|
||||
PersonBirthday personBirthday;
|
||||
@ -653,6 +688,8 @@ public class MapLogic
|
||||
personBirthday = keyValuePair.Value.Birthdays[zero];
|
||||
foreach (string personDisplayDirectoryAllFile in keyValuePair.Value.DisplayDirectoryAllFiles)
|
||||
{
|
||||
if (personDisplayDirectoryAllFile.Contains("-2318605"))
|
||||
continue;
|
||||
if (!personDisplayDirectoryAllFile.EndsWith(_Configuration.FacesFileNameExtension))
|
||||
continue;
|
||||
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(_Configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
@ -678,7 +715,9 @@ public class MapLogic
|
||||
if (string.IsNullOrEmpty(directoryName))
|
||||
throw new NotSupportedException();
|
||||
shortcutFile = Path.Combine(personDisplayDirectory, $"{personDisplayFileName}.lnk");
|
||||
facesDirectory = Path.Combine($"{dFacesContentDirectory}{directoryName}", mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
facesDirectory = GetFacesDirectory(dFacesContentDirectory, mapping.MappingFromItem); // Path.Combine($"{dFacesContentDirectory}{directoryName}", mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
if (facesDirectory is null)
|
||||
continue;
|
||||
faceFileName = $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesFileNameExtension}";
|
||||
checkFile = Path.Combine(directory, fileInfo.Name);
|
||||
if (!_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(id.Value, out normalizedPixelPercentageToPeronContainerCollection) || !normalizedPixelPercentageToPeronContainerCollection.ContainsKey(normalizedPixelPercentage.Value))
|
||||
@ -762,6 +801,8 @@ public class MapLogic
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
if (_MapLogicSupport is null)
|
||||
throw new NullReferenceException(nameof(_MapLogicSupport));
|
||||
List<(string, PersonContainer)> results = new();
|
||||
string[] files;
|
||||
const int zero = 0;
|
||||
@ -788,8 +829,12 @@ public class MapLogic
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
|
||||
if (windowsShortcut.Path is null)
|
||||
continue;
|
||||
if (!Directory.Exists(windowsShortcut.Path) && files.Length != checkDirectories.Length)
|
||||
throw new NotSupportedException(fileNameWithoutExtension);
|
||||
if (!Directory.Exists(windowsShortcut.Path))
|
||||
{
|
||||
if (files.Length != checkDirectories.Length)
|
||||
throw new NotSupportedException(fileNameWithoutExtension);
|
||||
continue;
|
||||
}
|
||||
(personKeyFormatted, personBirthday) = GetPersonBirthday(windowsShortcut.Path);
|
||||
if (personBirthday is not null)
|
||||
{
|
||||
@ -819,9 +864,10 @@ public class MapLogic
|
||||
{
|
||||
matches = (from l in personContainers where l.Key == personKey && l.ApproximateYears.HasValue select l).ToArray();
|
||||
if (!matches.Any())
|
||||
throw new NotSupportedException(fileNameWithoutExtension);
|
||||
continue;
|
||||
if (!Directory.Exists(displayDirectoryName))
|
||||
_ = Directory.CreateDirectory(displayDirectoryName);
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personKey);
|
||||
results.Add(new(personKeyFormatted, matches[zero]));
|
||||
}
|
||||
}
|
||||
@ -995,8 +1041,8 @@ public class MapLogic
|
||||
Mapping mapping;
|
||||
string checkFile;
|
||||
string directory;
|
||||
string facesDirectory;
|
||||
string? directoryName;
|
||||
string? facesDirectory;
|
||||
FileHolder faceFileHolder;
|
||||
List<int>? normalizedPixelPercentages;
|
||||
string by = nameof(IMapLogic.CopyNotMappedFaces);
|
||||
@ -1013,7 +1059,9 @@ public class MapLogic
|
||||
if (normalizedPixelPercentages is not null && normalizedPixelPercentages.Contains(mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||
continue;
|
||||
directoryName = Path.GetDirectoryName(mapping.MappingFromItem.RelativePath);
|
||||
facesDirectory = Path.Combine($"{dFacesContentDirectory}{directoryName}", mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
facesDirectory = GetFacesDirectory(dFacesContentDirectory, mapping.MappingFromItem); // Path.Combine($"{dFacesContentDirectory}{directoryName}", mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
if (facesDirectory is null)
|
||||
continue;
|
||||
faceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesFileNameExtension}"));
|
||||
if (directoryName is null || !faceFileHolder.Exists)
|
||||
continue;
|
||||
|
@ -208,7 +208,10 @@ internal abstract class MapLogic
|
||||
ticksDirectories = Array.Empty<string>();
|
||||
else
|
||||
{
|
||||
_ = IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
if (!Directory.Exists(eDistanceContentDirectory))
|
||||
_ = Directory.CreateDirectory(eDistanceContentDirectory);
|
||||
else
|
||||
_ = IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
ticksDirectories = Directory.GetDirectories(eDistanceContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
}
|
||||
string message = $") {ticksDirectories.Length:000} collect from and clean ticks Director(ies) - A - {totalSeconds} total second(s)";
|
||||
@ -556,22 +559,28 @@ internal abstract class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
private static string? GetDisplayDirectoryName(Dictionary<long, PersonContainer> personKeyToPersonContainer, long key)
|
||||
{
|
||||
string? result = null;
|
||||
if (personKeyToPersonContainer.TryGetValue(key, out PersonContainer? personContainer))
|
||||
{
|
||||
result = personContainer.DisplayDirectoryName;
|
||||
if (string.IsNullOrEmpty(result))
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void SetPersonKeyToPersonContainer(Configuration configuration, List<PersonContainer> personContainers, long[] personKeyCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer)
|
||||
{
|
||||
string personDisplayDirectoryName;
|
||||
string? displayDirectoryName;
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
if (personContainer.Key is null || !personKeyCollection.Contains(personContainer.Key.Value))
|
||||
continue;
|
||||
if (personKeyToPersonContainer.ContainsKey(personContainer.Key.Value))
|
||||
{
|
||||
personDisplayDirectoryName = personKeyToPersonContainer[personContainer.Key.Value].DisplayDirectoryName;
|
||||
if (string.IsNullOrEmpty(personDisplayDirectoryName))
|
||||
throw new NotSupportedException();
|
||||
if (personDisplayDirectoryName == personContainer.DisplayDirectoryName || (personDisplayDirectoryName[0] == personContainer.DisplayDirectoryName[0] && (personDisplayDirectoryName.Length == 1 || personContainer.DisplayDirectoryName.Length == 1)))
|
||||
continue;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
displayDirectoryName = GetDisplayDirectoryName(personKeyToPersonContainer, personContainer.Key.Value);
|
||||
if (displayDirectoryName is not null && (displayDirectoryName == personContainer.DisplayDirectoryName || (displayDirectoryName[0] == personContainer.DisplayDirectoryName[0] && (displayDirectoryName.Length == 1 || personContainer.DisplayDirectoryName.Length == 1))))
|
||||
continue;
|
||||
personKeyToPersonContainer.Add(personContainer.Key.Value, personContainer);
|
||||
}
|
||||
if (personKeyCollection.Any())
|
||||
@ -579,7 +588,7 @@ internal abstract class MapLogic
|
||||
int? approximateYears = null;
|
||||
PersonBirthday? personBirthday;
|
||||
PersonContainer? personContainer;
|
||||
string displayDirectoryName = configuration.MappingDefaultName;
|
||||
displayDirectoryName = configuration.MappingDefaultName;
|
||||
foreach (long personKey in personKeyCollection)
|
||||
{
|
||||
if (personKeyToPersonContainer.ContainsKey(personKey))
|
||||
|
Reference in New Issue
Block a user