PersonCharactersCopyCount
This commit is contained in:
@ -859,7 +859,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyAtLeastOneMappedFiles(char personCharactersToCopyTo, string dFacesContentDirectory, string a2PeopleSingletonDirectory, Mapping[] mappingCollection)
|
||||
public void CopyAtLeastOneMappedFiles(string dFacesContentDirectory, string a2PeopleSingletonDirectory, Mapping[] mappingCollection)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -897,13 +897,13 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
continue;
|
||||
if (!_PersonKeyToPersonContainer.TryGetValue(personKey, out personContainer))
|
||||
continue;
|
||||
if (personContainer.Char is null || personContainer.Char != personCharactersToCopyTo)
|
||||
if (personContainer.Char is null || !_Configuration.PersonCharacters.Contains(personContainer.Char.Value))
|
||||
continue;
|
||||
if (personContainer.DisplayDirectoryAllFiles.Any(l => l.EndsWith(faceFileName)))
|
||||
continue;
|
||||
if (!File.Exists(faceFile))
|
||||
continue;
|
||||
directory = Path.Combine(a2PeopleSingletonDirectory, personCharactersToCopyTo.ToString(), personContainer.DisplayDirectoryName);
|
||||
directory = Path.Combine(a2PeopleSingletonDirectory, personContainer.Char.Value.ToString(), personContainer.DisplayDirectoryName);
|
||||
if (!Directory.Exists(directory))
|
||||
continue;
|
||||
fileName = Path.Combine(directory, faceFileName);
|
||||
@ -952,7 +952,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return new(personKeyFormatted, personBirthday);
|
||||
}
|
||||
|
||||
private List<string> GetPersonKeyFormattedCollection(string[] jLinks, string a2PeopleSingletonDirectory, PersonContainer[] personContainers, Dictionary<long, int> personKeyToCount)
|
||||
private List<string> GetPersonKeyFormattedCollection(string[] jLinks, string a2PeopleContentDirectory, PersonContainer[] personContainers, Dictionary<long, int> personKeyToCount)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -970,7 +970,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
List<(long, string)> collection = new();
|
||||
foreach (string directoryName in jLinks)
|
||||
{
|
||||
checkDirectory = Path.Combine(a2PeopleSingletonDirectory, directoryName);
|
||||
checkDirectory = Path.Combine(a2PeopleContentDirectory, directoryName);
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
continue;
|
||||
checkDirectories = Directory.GetDirectories(checkDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
@ -1012,7 +1012,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
private (int, FileHolder, int, string, string, string, string)[] GetCollectionForSaveFilteredOriginalImagesFromJLinks(string[] jLinks, string a2PeopleSingletonDirectory, 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, int> personKeyToCount)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -1023,7 +1023,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
string personDirectory;
|
||||
string personKeyFormatted;
|
||||
bool usePersonKeyAndDeterministicHashCodeKey = false;
|
||||
List<string> personKeyFormattedCollection = GetPersonKeyFormattedCollection(jLinks, a2PeopleSingletonDirectory, personContainers, personKeyToCount);
|
||||
List<string> personKeyFormattedCollection = GetPersonKeyFormattedCollection(jLinks, a2PeopleContentDirectory, personContainers, personKeyToCount);
|
||||
List<(int Id, FileHolder ImageFileHolder, int ApproximateYears, string PersonKeyFormatted, string CheckFile, string Directory, string PersonDirectory)> collection = new();
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
@ -1061,14 +1061,66 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public void SaveFilteredOriginalImagesFromJLinks(string[] jLinks, PersonContainer[] personContainers, string a2PeopleSingletonDirectory, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount, int totalNotMapped)
|
||||
private static bool TryToFind(string a2PeopleSingletonDirectory, string file, string path)
|
||||
{
|
||||
bool result = false;
|
||||
string? pathName = Path.GetFileName(path);
|
||||
string? group = Path.GetDirectoryName(path);
|
||||
string? groupName = Path.GetFileName(group);
|
||||
if (pathName is not null && group is not null && groupName is not null)
|
||||
{
|
||||
WindowsShortcut windowsShortcut;
|
||||
string checkDirectory = Path.Combine(a2PeopleSingletonDirectory, groupName, pathName);
|
||||
if (Directory.Exists(checkDirectory))
|
||||
{
|
||||
try
|
||||
{
|
||||
windowsShortcut = new() { Path = checkDirectory };
|
||||
windowsShortcut.Save(file);
|
||||
windowsShortcut.Dispose();
|
||||
result = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void BeforeSaveFilteredOriginalImagesFromJLinks(string[] jLinks, string a2PeopleContentDirectory)
|
||||
{
|
||||
string[] files;
|
||||
string checkDirectory;
|
||||
WindowsShortcut windowsShortcut;
|
||||
foreach (string directoryName in jLinks)
|
||||
{
|
||||
checkDirectory = Path.Combine(a2PeopleContentDirectory, directoryName);
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
continue;
|
||||
files = Directory.GetFiles(checkDirectory, "*.lnk", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
windowsShortcut = WindowsShortcut.Load(file);
|
||||
if (windowsShortcut.Path is null)
|
||||
continue;
|
||||
if (!Directory.Exists(windowsShortcut.Path))
|
||||
{
|
||||
if (!TryToFind(a2PeopleContentDirectory, file, windowsShortcut.Path))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveFilteredOriginalImagesFromJLinks(string[] jLinks, PersonContainer[] personContainers, string a2PeopleContentDirectory, 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 = GetCollectionForSaveFilteredOriginalImagesFromJLinks(jLinks, a2PeopleSingletonDirectory, personContainers, mappingCollection, personKeyToCount);
|
||||
BeforeSaveFilteredOriginalImagesFromJLinks(jLinks, a2PeopleContentDirectory);
|
||||
(int, FileHolder, int, string, string, string, string)[] collection = GetCollectionForSaveFilteredOriginalImagesFromJLinks(jLinks, a2PeopleContentDirectory, personContainers, mappingCollection, personKeyToCount);
|
||||
foreach ((int id, FileHolder imageFileHolder, int approximateYears, string personKeyFormatted, string directory, string personDirectory, string checkFile) in collection)
|
||||
{
|
||||
if (distinctCollection.Contains(id))
|
||||
|
Reference in New Issue
Block a user