Instance UserSecretsId and BlurHash for 1376 x 768
This commit is contained in:
parent
085dee358c
commit
1712de2952
@ -11,7 +11,7 @@ public class C2_BlurHasher : IBlurHasher
|
|||||||
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
||||||
|
|
||||||
public C2_BlurHasher(string resultAllInOne, string? resultsFullGroupDirectory) =>
|
public C2_BlurHasher(string resultAllInOne, string? resultsFullGroupDirectory) =>
|
||||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory);
|
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory, new string[] { "{}", "()" }, maxValue: 102);
|
||||||
|
|
||||||
string IBlurHasher.Encode(FileHolder fileHolder)
|
string IBlurHasher.Encode(FileHolder fileHolder)
|
||||||
{
|
{
|
||||||
@ -26,32 +26,44 @@ public class C2_BlurHasher : IBlurHasher
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string? IBlurHasher.GetFile(FileHolder fileHolder)
|
||||||
|
{
|
||||||
|
string? result;
|
||||||
|
string directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(fileHolder.Name, length: 2);
|
||||||
|
result = !int.TryParse(directory, out int directoryIndex) ? null : Path.Combine(_JsonGroups["{}"][directoryIndex], $"{fileHolder.Name}.csv");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
string IBlurHasher.EncodeAndSave(FileHolder fileHolder)
|
string IBlurHasher.EncodeAndSave(FileHolder fileHolder)
|
||||||
{
|
{
|
||||||
string file;
|
string? file;
|
||||||
string result;
|
string result;
|
||||||
int actualByte;
|
int actualByte;
|
||||||
char directory;
|
|
||||||
int directoryIndex;
|
|
||||||
string extension = ".png";
|
string extension = ".png";
|
||||||
|
IBlurHasher blurHasher = this;
|
||||||
|
file = blurHasher.GetFile(fileHolder);
|
||||||
|
if (file is null)
|
||||||
|
throw new NullReferenceException(nameof(file));
|
||||||
#pragma warning disable CA1416
|
#pragma warning disable CA1416
|
||||||
Image image = Image.FromFile(fileHolder.FullName);
|
Image image = Image.FromFile(fileHolder.FullName);
|
||||||
(int componentsX, int componentsY, int outputWidth, int outputHeight) = image.Width < image.Height ? (4, 3, 300, 190) : (3, 4, 300, 190);
|
int outputWidth = (int)(image.Width * .25);
|
||||||
|
int outputHeight = (int)(image.Height * .25);
|
||||||
|
(int componentsX, int componentsY) = image.Width < image.Height ? (4, 3) : (3, 4);
|
||||||
ReadOnlySpan<char> blurHash = System.Drawing.BlurHash.BlurHasher.Encode(image, componentsX, componentsY);
|
ReadOnlySpan<char> blurHash = System.Drawing.BlurHash.BlurHasher.Encode(image, componentsX, componentsY);
|
||||||
using Image actualImage = System.Drawing.BlurHash.BlurHasher.Decode(blurHash, outputWidth, outputHeight);
|
using Image actualImage = System.Drawing.BlurHash.BlurHasher.Decode(blurHash, outputWidth, outputHeight);
|
||||||
result = blurHash.ToString();
|
result = blurHash.ToString();
|
||||||
byte[] blurHashBytes = Encoding.UTF8.GetBytes(result);
|
byte[] blurHashBytes = Encoding.UTF8.GetBytes(result);
|
||||||
string joined = string.Join(string.Empty, blurHashBytes.Select(l => l.ToString("000")));
|
string joined = string.Join(string.Empty, blurHashBytes.Select(l => l.ToString("000")));
|
||||||
string fileNameWithoutExtension = $"{componentsX}x{componentsY}-{outputWidth}x{outputHeight}-{joined}";
|
string fileNameWithoutExtension = $"{componentsX}x{componentsY}-{outputWidth}x{outputHeight}-{joined}";
|
||||||
directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(fileHolder.Name);
|
|
||||||
directoryIndex = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(directory);
|
|
||||||
file = Path.Combine(_JsonGroups["{}"][directoryIndex], $"{fileHolder.Name}.csv");
|
|
||||||
string contents = string.Concat(result, Environment.NewLine, fileNameWithoutExtension, Environment.NewLine, extension);
|
string contents = string.Concat(result, Environment.NewLine, fileNameWithoutExtension, Environment.NewLine, extension);
|
||||||
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(file, contents, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(file, contents, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(joined);
|
string directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(joined, length: 2);
|
||||||
directoryIndex = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(directory);
|
if (int.TryParse(directory, out int directoryIndex))
|
||||||
|
{
|
||||||
file = Path.Combine(_JsonGroups["()"][directoryIndex], $"{fileNameWithoutExtension}{extension}");
|
file = Path.Combine(_JsonGroups["()"][directoryIndex], $"{fileNameWithoutExtension}{extension}");
|
||||||
if (!File.Exists(file))
|
if (!File.Exists(file))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
using FileStream fileStream = new(file, FileMode.CreateNew);
|
using FileStream fileStream = new(file, FileMode.CreateNew);
|
||||||
actualImage.Save(fileStream, System.Drawing.Imaging.ImageFormat.Png);
|
actualImage.Save(fileStream, System.Drawing.Imaging.ImageFormat.Png);
|
||||||
@ -60,6 +72,9 @@ public class C2_BlurHasher : IBlurHasher
|
|||||||
while (actualByte > -1)
|
while (actualByte > -1)
|
||||||
actualByte = fileStream.ReadByte();
|
actualByte = fileStream.ReadByte();
|
||||||
}
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
image.Dispose();
|
image.Dispose();
|
||||||
#pragma warning restore CA1416
|
#pragma warning restore CA1416
|
||||||
result = blurHash.ToString();
|
result = blurHash.ToString();
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
using CliWrap;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using ShellProgressBar;
|
using ShellProgressBar;
|
||||||
using System.Text.Json;
|
|
||||||
using View_by_Distance.Copy.Distinct.Models;
|
using View_by_Distance.Copy.Distinct.Models;
|
||||||
using View_by_Distance.Shared.Models;
|
using View_by_Distance.Shared.Models;
|
||||||
using View_by_Distance.Shared.Models.Methods;
|
using View_by_Distance.Shared.Models.Methods;
|
||||||
@ -18,6 +16,7 @@ public class CopyDistinct
|
|||||||
private readonly Configuration _Configuration;
|
private readonly Configuration _Configuration;
|
||||||
private readonly IsEnvironment _IsEnvironment;
|
private readonly IsEnvironment _IsEnvironment;
|
||||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||||
|
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
||||||
private readonly Property.Models.Configuration _PropertyConfiguration;
|
private readonly Property.Models.Configuration _PropertyConfiguration;
|
||||||
|
|
||||||
public CopyDistinct(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
public CopyDistinct(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||||
@ -26,43 +25,24 @@ public class CopyDistinct
|
|||||||
{ }
|
{ }
|
||||||
if (console is null)
|
if (console is null)
|
||||||
{ }
|
{ }
|
||||||
bool any = false;
|
|
||||||
_AppSettings = appSettings;
|
_AppSettings = appSettings;
|
||||||
_IsEnvironment = isEnvironment;
|
_IsEnvironment = isEnvironment;
|
||||||
_WorkingDirectory = workingDirectory;
|
_WorkingDirectory = workingDirectory;
|
||||||
_ConfigurationRoot = configurationRoot;
|
_ConfigurationRoot = configurationRoot;
|
||||||
|
string[] directories = new string[] { "()" };
|
||||||
ILogger? log = Log.ForContext<CopyDistinct>();
|
ILogger? log = Log.ForContext<CopyDistinct>();
|
||||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||||
|
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration.ResultAllInOne, appSettings.MoveTo, directories, appSettings.MaxValue);
|
||||||
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||||
_PropertyConfiguration = propertyConfiguration;
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
_Configuration = configuration;
|
_Configuration = configuration;
|
||||||
propertyConfiguration.Update();
|
propertyConfiguration.Update();
|
||||||
string? comparePathRoot = Path.GetDirectoryName(appSettings.ComparePathsFile);
|
|
||||||
if (comparePathRoot is null || comparePathRoot == propertyConfiguration.RootDirectory)
|
|
||||||
throw new Exception("Nested isn't allowed!");
|
|
||||||
log.Information(propertyConfiguration.RootDirectory);
|
log.Information(propertyConfiguration.RootDirectory);
|
||||||
Verify();
|
Verify();
|
||||||
string json = File.ReadAllText(appSettings.ComparePathsFile);
|
List<string> lines = CopyDistinctFilesInDirectories(log);
|
||||||
MatchNginx[]? matchNginxCollection = JsonSerializer.Deserialize<MatchNginx[]>(json);
|
|
||||||
if (matchNginxCollection is null)
|
|
||||||
throw new NullReferenceException(nameof(matchNginxCollection));
|
|
||||||
if (matchNginxCollection.Any())
|
|
||||||
{
|
|
||||||
bool deleted;
|
|
||||||
for (int i = 1; i < 5; i++)
|
|
||||||
{
|
|
||||||
deleted = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(matchNginxCollection.First().ConvertedPath);
|
|
||||||
if (deleted && !any)
|
|
||||||
any = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!any)
|
|
||||||
{
|
|
||||||
List<string> lines = CopyDistinctFilesInDirectories(log, matchNginxCollection);
|
|
||||||
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
||||||
if (comparePathRoot != Path.GetPathRoot(matchNginxCollection[0].ConvertedPath))
|
if (lines.Any())
|
||||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(comparePathRoot);
|
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(propertyConfiguration.RootDirectory);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Verify()
|
private void Verify()
|
||||||
@ -81,181 +61,55 @@ public class CopyDistinct
|
|||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<(FileHolder, string)> GetToDoCollection(ProgressBar progressBar, string[] files)
|
private static (List<string>, List<string>) Get(List<string[]> filesCollection)
|
||||||
|
{
|
||||||
|
List<string> results = new();
|
||||||
|
string? directory;
|
||||||
|
List<string> directories = new();
|
||||||
|
foreach (string[] files in filesCollection)
|
||||||
|
{
|
||||||
|
if (!files.Any())
|
||||||
|
continue;
|
||||||
|
directory = Path.GetDirectoryName(files.First());
|
||||||
|
if (directory is null)
|
||||||
|
continue;
|
||||||
|
if (!directories.Contains(directory))
|
||||||
|
directories.Add(directory);
|
||||||
|
results.AddRange(files);
|
||||||
|
}
|
||||||
|
return (directories, results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<(FileHolder, string)> GetToDoCollection(ProgressBar progressBar, List<string> files)
|
||||||
{
|
{
|
||||||
List<(FileHolder, string)> results = new();
|
List<(FileHolder, string)> results = new();
|
||||||
int? id;
|
string directory;
|
||||||
string fileName;
|
|
||||||
string? message;
|
|
||||||
string checkFile;
|
string checkFile;
|
||||||
string? directory;
|
int directoryIndex;
|
||||||
TimeSpan timeSpan;
|
|
||||||
DateTime? dateTime;
|
|
||||||
DateTime?[] dateTimes;
|
|
||||||
FileHolder fileHolder;
|
FileHolder fileHolder;
|
||||||
string[]? ffmpegFiles;
|
|
||||||
bool isIgnoreExtension;
|
bool isIgnoreExtension;
|
||||||
string checkFileExtension;
|
|
||||||
DateTime? minimumDateTime;
|
|
||||||
const string jpg = ".jpg";
|
|
||||||
const string jpeg = ".jpeg";
|
|
||||||
List<string> distinct = new();
|
List<string> distinct = new();
|
||||||
bool isValidImageFormatExtension;
|
bool isValidImageFormatExtension;
|
||||||
bool nameWithoutExtensionIsIdFormat;
|
bool nameWithoutExtensionIsIdFormat;
|
||||||
IReadOnlyList<MetadataExtractor.Directory> directories;
|
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
progressBar.Tick();
|
progressBar.Tick();
|
||||||
fileHolder = new(file);
|
fileHolder = new(file);
|
||||||
if (file.EndsWith(".rename"))
|
|
||||||
{
|
|
||||||
directory = Path.GetDirectoryName(file);
|
|
||||||
if (string.IsNullOrEmpty(directory))
|
|
||||||
continue;
|
|
||||||
checkFile = Path.Combine(directory, $"rename_{Path.GetFileName(file[..^7])}");
|
|
||||||
if (File.Exists(checkFile))
|
|
||||||
continue;
|
|
||||||
if (distinct.Contains(checkFile))
|
|
||||||
continue;
|
|
||||||
distinct.Add(checkFile);
|
|
||||||
results.Add(new(fileHolder, checkFile));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (file.EndsWith(".jpg.del"))
|
|
||||||
{
|
|
||||||
checkFile = file[..^4];
|
|
||||||
if (File.Exists(checkFile))
|
|
||||||
continue;
|
|
||||||
if (distinct.Contains(checkFile))
|
|
||||||
continue;
|
|
||||||
distinct.Add(checkFile);
|
|
||||||
results.Add(new(fileHolder, checkFile));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (fileHolder.ExtensionLowered == ".id" || fileHolder.ExtensionLowered == ".lsv" || fileHolder.DirectoryName is null)
|
if (fileHolder.ExtensionLowered == ".id" || fileHolder.ExtensionLowered == ".lsv" || fileHolder.DirectoryName is null)
|
||||||
continue;
|
continue;
|
||||||
if (files.Contains($"{fileHolder.FullName}.id"))
|
if (files.Contains($"{fileHolder.FullName}.id"))
|
||||||
continue;
|
continue;
|
||||||
nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(fileHolder);
|
|
||||||
if (nameWithoutExtensionIsIdFormat)
|
|
||||||
continue;
|
|
||||||
isValidImageFormatExtension = _PropertyConfiguration.ValidImageFormatExtensions.Contains(fileHolder.ExtensionLowered);
|
|
||||||
isIgnoreExtension = isValidImageFormatExtension && _PropertyConfiguration.IgnoreExtensions.Contains(fileHolder.ExtensionLowered);
|
|
||||||
if (!isIgnoreExtension && isValidImageFormatExtension)
|
|
||||||
ffmpegFiles = null;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{ directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(file); }
|
|
||||||
catch (Exception) { continue; }
|
|
||||||
CommandTask<CommandResult> result = Cli.Wrap("ffmpeg.exe")
|
|
||||||
// .WithArguments(new[] { "-ss", "00:00:00", "-t", "00:00:00", "-i", file, "-qscale:v", "2", "-r", "0.01", $"{fileHolder.Name}-%4d.jpg" })
|
|
||||||
.WithArguments(new[] { "-i", file, "-vframes", "1", $"{fileHolder.Name}-%4d.jpg" })
|
|
||||||
.WithWorkingDirectory(fileHolder.DirectoryName)
|
|
||||||
.ExecuteAsync();
|
|
||||||
result.Task.Wait();
|
|
||||||
ffmpegFiles = Directory.GetFiles(fileHolder.DirectoryName, $"{fileHolder.Name}-*.jpg", SearchOption.TopDirectoryOnly);
|
|
||||||
if (!ffmpegFiles.Any())
|
|
||||||
continue;
|
|
||||||
fileHolder = new(ffmpegFiles.First());
|
|
||||||
if (!fileHolder.Name.EndsWith("-0001.jpg"))
|
|
||||||
throw new Exception();
|
|
||||||
isValidImageFormatExtension = _PropertyConfiguration.ValidImageFormatExtensions.Contains(fileHolder.ExtensionLowered);
|
isValidImageFormatExtension = _PropertyConfiguration.ValidImageFormatExtensions.Contains(fileHolder.ExtensionLowered);
|
||||||
isIgnoreExtension = isValidImageFormatExtension && _PropertyConfiguration.IgnoreExtensions.Contains(fileHolder.ExtensionLowered);
|
isIgnoreExtension = isValidImageFormatExtension && _PropertyConfiguration.IgnoreExtensions.Contains(fileHolder.ExtensionLowered);
|
||||||
if (isIgnoreExtension || !isValidImageFormatExtension)
|
if (isIgnoreExtension || !isValidImageFormatExtension)
|
||||||
continue;
|
continue;
|
||||||
if (fileHolder.DirectoryName is null)
|
nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(fileHolder);
|
||||||
|
if (nameWithoutExtensionIsIdFormat)
|
||||||
continue;
|
continue;
|
||||||
}
|
directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(fileHolder.NameWithoutExtension, 2);
|
||||||
if (!isIgnoreExtension && isValidImageFormatExtension)
|
if (!int.TryParse(directory, out directoryIndex))
|
||||||
{
|
|
||||||
if (fileHolder.ExtensionLowered == jpeg)
|
|
||||||
{
|
|
||||||
if (File.Exists($"{fileHolder.FullName}.id"))
|
|
||||||
{
|
|
||||||
checkFile = Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension}{jpg}.id");
|
|
||||||
if (File.Exists(checkFile))
|
|
||||||
continue;
|
continue;
|
||||||
if (distinct.Contains(checkFile))
|
checkFile = Path.Combine(_JsonGroups["()"][directoryIndex], fileHolder.Name);
|
||||||
continue;
|
|
||||||
distinct.Add(checkFile);
|
|
||||||
results.Add(new(new($"{fileHolder.FullName}.id"), checkFile));
|
|
||||||
}
|
|
||||||
checkFile = Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension}{jpg}");
|
|
||||||
if (File.Exists(checkFile))
|
|
||||||
continue;
|
|
||||||
if (distinct.Contains(checkFile))
|
|
||||||
continue;
|
|
||||||
distinct.Add(checkFile);
|
|
||||||
results.Add(new(fileHolder, checkFile));
|
|
||||||
if (File.Exists(checkFile))
|
|
||||||
continue;
|
|
||||||
File.Move(fileHolder.FullName, checkFile);
|
|
||||||
fileHolder = new(checkFile);
|
|
||||||
if (fileHolder.DirectoryName is null)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(dateTimes, id, message) = Shared.Models.Stateless.Methods.IProperty.Get(fileHolder, isIgnoreExtension, isValidImageFormatExtension);
|
|
||||||
minimumDateTime = dateTimes.Min();
|
|
||||||
if (minimumDateTime is null || !isIgnoreExtension && isValidImageFormatExtension)
|
|
||||||
{
|
|
||||||
dateTime = Shared.Models.Stateless.Methods.IProperty.GetDateTimeFromName(fileHolder);
|
|
||||||
if (dateTime is null || minimumDateTime is null)
|
|
||||||
timeSpan = new TimeSpan(0);
|
|
||||||
else
|
|
||||||
timeSpan = new(Math.Abs(minimumDateTime.Value.Ticks - dateTime.Value.Ticks));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fileName = Path.GetFileName(fileHolder.DirectoryName);
|
|
||||||
if (fileName.Length < 4 || !int.TryParse(fileName[..4], out int year))
|
|
||||||
year = minimumDateTime.Value.Year;
|
|
||||||
if (_PropertyConfiguration.IgnoreExtensions.Contains(fileHolder.ExtensionLowered))
|
|
||||||
continue;
|
|
||||||
try
|
|
||||||
{ directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(file); }
|
|
||||||
catch (Exception) { continue; }
|
|
||||||
dateTime = Metadata.Models.Stateless.Methods.IMetadata.GetMinimumDateTime(dateTimes, year, directories);
|
|
||||||
timeSpan = new TimeSpan(int.MaxValue);
|
|
||||||
}
|
|
||||||
if (dateTime is not null && string.IsNullOrEmpty(_AppSettings.CopyTo))
|
|
||||||
{
|
|
||||||
checkFileExtension = fileHolder.ExtensionLowered == jpeg ? jpg : fileHolder.ExtensionLowered;
|
|
||||||
checkFile = Path.Combine(fileHolder.DirectoryName, $"{dateTime.Value:yyyy-MM-dd}.{dateTime.Value.Ticks}.{fileHolder.Length}{checkFileExtension}");
|
|
||||||
if (checkFile == fileHolder.FullName)
|
|
||||||
continue;
|
|
||||||
if (distinct.Contains(checkFile))
|
|
||||||
continue;
|
|
||||||
distinct.Add(checkFile);
|
|
||||||
results.Add(new(fileHolder, checkFile));
|
|
||||||
if (ffmpegFiles is not null)
|
|
||||||
{
|
|
||||||
foreach (string ffmpegFile in ffmpegFiles)
|
|
||||||
File.Delete(ffmpegFile);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (id is null)
|
|
||||||
continue;
|
|
||||||
if (ffmpegFiles is not null)
|
|
||||||
{
|
|
||||||
foreach (string ffmpegFile in ffmpegFiles)
|
|
||||||
File.Delete(ffmpegFile);
|
|
||||||
fileHolder = new(file);
|
|
||||||
if (fileHolder.DirectoryName is null)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
checkFileExtension = fileHolder.ExtensionLowered == jpeg ? jpg : fileHolder.ExtensionLowered;
|
|
||||||
checkFile = Path.Combine(fileHolder.DirectoryName, $"{id.Value}{checkFileExtension}");
|
|
||||||
if (checkFile == fileHolder.FullName)
|
|
||||||
continue;
|
|
||||||
if (File.Exists(checkFile))
|
|
||||||
{
|
|
||||||
checkFile = string.Concat(checkFile, ".del");
|
|
||||||
if (File.Exists(checkFile))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (distinct.Contains(checkFile))
|
if (distinct.Contains(checkFile))
|
||||||
continue;
|
continue;
|
||||||
distinct.Add(checkFile);
|
distinct.Add(checkFile);
|
||||||
@ -264,97 +118,11 @@ public class CopyDistinct
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<string> GetAllFiles(MatchNginx[] matchNginxCollection)
|
private static List<string> Move(ILogger log, List<(FileHolder, string)> toDoCollection)
|
||||||
{
|
|
||||||
List<string> allFiles = new();
|
|
||||||
string[] files;
|
|
||||||
string directoryName;
|
|
||||||
ReadOnlySpan<char> span;
|
|
||||||
foreach (MatchNginx matchNginx in matchNginxCollection)
|
|
||||||
{
|
|
||||||
if (matchNginx.ConvertedPath.Length < 6)
|
|
||||||
continue;
|
|
||||||
directoryName = Path.GetFileName(matchNginx.ConvertedPath);
|
|
||||||
if (matchNginx.ConvertedPath.Contains("!---"))
|
|
||||||
span = "0";
|
|
||||||
else
|
|
||||||
span = matchNginx.ConvertedPath.AsSpan(matchNginx.ConvertedPath.Length - 5, 3);
|
|
||||||
if (directoryName.Length == 1 && int.TryParse(span, out int age))
|
|
||||||
continue;
|
|
||||||
if (File.Exists(matchNginx.ConvertedPath))
|
|
||||||
continue;
|
|
||||||
if (!Directory.Exists(matchNginx.ConvertedPath))
|
|
||||||
continue;
|
|
||||||
files = Directory.GetFiles(matchNginx.ConvertedPath, "*", SearchOption.AllDirectories);
|
|
||||||
if (files.All(l => l.EndsWith(".id")))
|
|
||||||
{
|
|
||||||
foreach (string file in files)
|
|
||||||
File.Delete(file);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
allFiles.AddRange(files);
|
|
||||||
}
|
|
||||||
return allFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CreateDirectories(List<string> directories)
|
|
||||||
{
|
|
||||||
foreach (string directory in directories)
|
|
||||||
{
|
|
||||||
if (Directory.Exists(directory))
|
|
||||||
continue;
|
|
||||||
_ = Directory.CreateDirectory(directory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string> CopyInstead(ILogger log, List<(FileHolder, string)> verifiedToDoCollection)
|
|
||||||
{
|
|
||||||
List<string> results = new();
|
|
||||||
string copyTo;
|
|
||||||
string? directory;
|
|
||||||
ConsoleKey? consoleKey = null;
|
|
||||||
List<string> distinctDirectories = new();
|
|
||||||
List<(FileHolder, string)> copyCollection = new();
|
|
||||||
foreach ((FileHolder fileHolder, string to) in verifiedToDoCollection)
|
|
||||||
{
|
|
||||||
copyTo = $"{_AppSettings.CopyTo}{to[1..]}";
|
|
||||||
directory = Path.GetDirectoryName(copyTo);
|
|
||||||
if (directory is null)
|
|
||||||
continue;
|
|
||||||
copyCollection.Add(new(fileHolder, copyTo));
|
|
||||||
if (distinctDirectories.Contains(directory))
|
|
||||||
continue;
|
|
||||||
distinctDirectories.Add(directory);
|
|
||||||
}
|
|
||||||
CreateDirectories(distinctDirectories);
|
|
||||||
log.Information($"Ready to Copy {verifiedToDoCollection.Count} file(s)?");
|
|
||||||
for (int y = 0; y < int.MaxValue; y++)
|
|
||||||
{
|
|
||||||
log.Information("Press \"Y\" key to copy file(s), \"N\" key to log file(s) or close console to not copy files");
|
|
||||||
consoleKey = System.Console.ReadKey().Key;
|
|
||||||
if (consoleKey is ConsoleKey.Y or ConsoleKey.N)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
log.Information(". . .");
|
|
||||||
if (consoleKey is null || consoleKey.Value != ConsoleKey.Y)
|
|
||||||
log.Information("Nothing Copied!");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach ((FileHolder fileHolder, string to) in verifiedToDoCollection)
|
|
||||||
{
|
|
||||||
results.Add(fileHolder.NameWithoutExtension);
|
|
||||||
File.Copy(fileHolder.FullName, to);
|
|
||||||
}
|
|
||||||
log.Information("Done Copying");
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<string> Move(ILogger log, List<(FileHolder, string)> verifiedToDoCollection)
|
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
List<string> results = new();
|
||||||
ConsoleKey? consoleKey = null;
|
ConsoleKey? consoleKey = null;
|
||||||
log.Information($"Ready to Move {verifiedToDoCollection.Count} file(s)?");
|
log.Information($"Ready to Move {toDoCollection.Count} file(s)?");
|
||||||
for (int y = 0; y < int.MaxValue; y++)
|
for (int y = 0; y < int.MaxValue; y++)
|
||||||
{
|
{
|
||||||
log.Information("Press \"Y\" key to move file(s), \"N\" key to log file(s) or close console to not move files");
|
log.Information("Press \"Y\" key to move file(s), \"N\" key to log file(s) or close console to not move files");
|
||||||
@ -367,69 +135,31 @@ public class CopyDistinct
|
|||||||
log.Information("Nothing moved!");
|
log.Information("Nothing moved!");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach ((FileHolder fileHolder, string to) in verifiedToDoCollection)
|
foreach ((FileHolder fileHolder, string to) in toDoCollection)
|
||||||
{
|
{
|
||||||
results.Add(fileHolder.NameWithoutExtension);
|
results.Add(fileHolder.NameWithoutExtension);
|
||||||
try
|
try
|
||||||
{ File.Move(fileHolder.FullName, to); }
|
{ File.Copy(fileHolder.FullName, to); }
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
log.Information("Done Moving");
|
log.Information("Done Moving");
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
// {
|
|
||||||
// "_App": "Copy-Distinct",
|
private List<string> CopyDistinctFilesInDirectories(ILogger log)
|
||||||
// "_UserSecretsId": "d862524f-2b48-4f47-b4c3-5a8615814ec2",
|
|
||||||
// "ComparePathsFile": "C:/Users/lphar/AppData/Local/PharesApps/Drag-Drop-Explorer/2023_24/638220924947919275.json",
|
|
||||||
// "CopyTo": "",
|
|
||||||
// "MaxDegreeOfParallelism": 6,
|
|
||||||
// "Windows": {
|
|
||||||
// "Configuration": {
|
|
||||||
// "RootDirectory": "C:/",
|
|
||||||
// "VerifyToSeason": []
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
private List<string> CopyDistinctFilesInDirectories(ILogger log, MatchNginx[] matchNginxCollection)
|
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
List<string> results = new();
|
||||||
string[] files;
|
const string fileSearchFilter = "*";
|
||||||
string message;
|
string message = nameof(CopyDistinct);
|
||||||
List<string> allFiles;
|
const string directorySearchFilter = "*";
|
||||||
ProgressBar progressBar;
|
List<string[]> filesCollection = Shared.Models.Stateless.Methods.IDirectory.GetFilesCollection(_PropertyConfiguration.RootDirectory, directorySearchFilter, fileSearchFilter);
|
||||||
List<(FileHolder, string)> toDoCollection;
|
(_, List<string> allFiles) = Get(filesCollection);
|
||||||
allFiles = GetAllFiles(matchNginxCollection);
|
|
||||||
List<(FileHolder, string)> verifiedToDoCollection;
|
|
||||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||||
for (int i = 1; i < 3; i++)
|
ProgressBar progressBar = new(allFiles.Count, message, options);
|
||||||
{
|
List<(FileHolder, string)> toDoCollection = GetToDoCollection(progressBar, allFiles);
|
||||||
if (!allFiles.Any())
|
|
||||||
continue;
|
|
||||||
message = $"{i}) Renaming files";
|
|
||||||
files = i == 2 ? allFiles.ToArray() : (from l in allFiles where l.Contains("Rename", StringComparison.OrdinalIgnoreCase) select l).ToArray();
|
|
||||||
progressBar = new(files.Length, message, options);
|
|
||||||
if (!files.Any())
|
|
||||||
continue;
|
|
||||||
toDoCollection = GetToDoCollection(progressBar, files);
|
|
||||||
verifiedToDoCollection = new();
|
|
||||||
foreach ((FileHolder fileHolder, string to) in toDoCollection)
|
|
||||||
{
|
|
||||||
if (File.Exists(to))
|
|
||||||
continue;
|
|
||||||
verifiedToDoCollection.Add(new(fileHolder, to));
|
|
||||||
if (string.IsNullOrEmpty(_AppSettings.CopyTo))
|
|
||||||
File.WriteAllText($"{to}.id", $"{to}{Environment.NewLine}{fileHolder.FullName}");
|
|
||||||
}
|
|
||||||
if (!verifiedToDoCollection.Any())
|
|
||||||
continue;
|
|
||||||
if (string.IsNullOrEmpty(_AppSettings.CopyTo))
|
|
||||||
results.AddRange(Move(log, toDoCollection));
|
results.AddRange(Move(log, toDoCollection));
|
||||||
else
|
|
||||||
results.AddRange(CopyInstead(log, toDoCollection));
|
|
||||||
allFiles = GetAllFiles(matchNginxCollection);
|
|
||||||
progressBar.Dispose();
|
progressBar.Dispose();
|
||||||
}
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
<SupportedPlatform Include="browser" />
|
<SupportedPlatform Include="browser" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CliWrap" Version="3.6.3" />
|
|
||||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
||||||
|
@ -7,22 +7,22 @@ public class AppSettings
|
|||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
public string Company { init; get; }
|
||||||
public string ComparePathsFile { init; get; }
|
|
||||||
public string CopyTo { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
public int MaxDegreeOfParallelism { init; get; }
|
||||||
|
public int MaxValue { init; get; }
|
||||||
|
public string MoveTo { init; get; }
|
||||||
public string WorkingDirectoryName { init; get; }
|
public string WorkingDirectoryName { init; get; }
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public AppSettings(string company,
|
public AppSettings(string company,
|
||||||
string comparePathsFile,
|
|
||||||
string copyTo,
|
|
||||||
int maxDegreeOfParallelism,
|
int maxDegreeOfParallelism,
|
||||||
|
int maxValue,
|
||||||
|
string moveTo,
|
||||||
string workingDirectoryName)
|
string workingDirectoryName)
|
||||||
{
|
{
|
||||||
Company = company;
|
Company = company;
|
||||||
ComparePathsFile = comparePathsFile;
|
|
||||||
CopyTo = copyTo;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||||
|
MaxValue = maxValue;
|
||||||
|
MoveTo = moveTo;
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
WorkingDirectoryName = workingDirectoryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ public class AppSettings
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
public string Company { get; set; }
|
public string Company { get; set; }
|
||||||
public string ComparePathsFile { get; set; }
|
|
||||||
public string CopyTo { get; set; }
|
|
||||||
public int? MaxDegreeOfParallelism { get; set; }
|
public int? MaxDegreeOfParallelism { get; set; }
|
||||||
|
public int? MaxValue { get; set; }
|
||||||
|
public string MoveTo { get; set; }
|
||||||
public string WorkingDirectoryName { get; set; }
|
public string WorkingDirectoryName { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
@ -27,11 +27,13 @@ public class AppSettings
|
|||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
if (appSettings?.MaxDegreeOfParallelism is null)
|
if (appSettings?.MaxDegreeOfParallelism is null)
|
||||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||||
|
if (appSettings?.MaxValue is null)
|
||||||
|
throw new NullReferenceException(nameof(appSettings.MaxValue));
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.Company,
|
appSettings.Company,
|
||||||
appSettings.ComparePathsFile,
|
|
||||||
appSettings.CopyTo,
|
|
||||||
appSettings.MaxDegreeOfParallelism.Value,
|
appSettings.MaxDegreeOfParallelism.Value,
|
||||||
|
appSettings.MaxValue.Value,
|
||||||
|
appSettings.MoveTo,
|
||||||
appSettings.WorkingDirectoryName
|
appSettings.WorkingDirectoryName
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ComparePathsFile": "",
|
"ComparePathsFile": "",
|
||||||
"Company": "Mike Phares",
|
"Company": "Mike Phares",
|
||||||
"CopyTo": "",
|
|
||||||
"Linux": {},
|
"Linux": {},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
@ -12,6 +11,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"MaxDegreeOfParallelism": 6,
|
"MaxDegreeOfParallelism": 6,
|
||||||
|
"MaxValue": 12,
|
||||||
|
"MoveTo": "",
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
"Serilog.Sinks.Console",
|
"Serilog.Sinks.Console",
|
||||||
|
@ -349,6 +349,28 @@ public partial class DlibDotNet
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogItemPropertyIsNull(Item item)
|
||||||
|
{
|
||||||
|
if (_Log is null)
|
||||||
|
throw new NullReferenceException(nameof(_Log));
|
||||||
|
if (!item.SourceDirectoryFileHolder.Exists)
|
||||||
|
_Log.Information(string.Concat("NoJson <", item.ImageFileHolder.FullName, '>'));
|
||||||
|
else if (item.FileSizeChanged.HasValue && item.FileSizeChanged.Value)
|
||||||
|
_Log.Information(string.Concat("FileSizeChanged <", item.ImageFileHolder.FullName, '>'));
|
||||||
|
else if (item.LastWriteTimeChanged.HasValue && item.LastWriteTimeChanged.Value)
|
||||||
|
_Log.Information(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
|
||||||
|
else if (item.Moved.HasValue && item.Moved.Value)
|
||||||
|
_Log.Information(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LogNameWithoutExtensionIsIdFormatBut(Item item)
|
||||||
|
{
|
||||||
|
if (_Log is null)
|
||||||
|
throw new NullReferenceException(nameof(_Log));
|
||||||
|
_Log.Information($"Name without extension is Id format but doesn't match id <{item.ImageFileHolder.FullName}>");
|
||||||
|
File.Move(item.ImageFileHolder.FullName, $"{item.ImageFileHolder.FullName}.rename");
|
||||||
|
}
|
||||||
|
|
||||||
private void FullParallelForWork(A_Property propertyLogic,
|
private void FullParallelForWork(A_Property propertyLogic,
|
||||||
B_Metadata metadata,
|
B_Metadata metadata,
|
||||||
ReadOnlyDictionary<int, List<LocationContainer<MetadataExtractor.Directory>>> idToLocationContainers,
|
ReadOnlyDictionary<int, List<LocationContainer<MetadataExtractor.Directory>>> idToLocationContainers,
|
||||||
@ -366,8 +388,6 @@ public partial class DlibDotNet
|
|||||||
bool? isIgnoreRelativePath,
|
bool? isIgnoreRelativePath,
|
||||||
string facePartsCollectionDirectory)
|
string facePartsCollectionDirectory)
|
||||||
{
|
{
|
||||||
if (_Log is null)
|
|
||||||
throw new NullReferenceException(nameof(_Log));
|
|
||||||
List<Shared.Models.Face> faces;
|
List<Shared.Models.Face> faces;
|
||||||
long ticks = DateTime.Now.Ticks;
|
long ticks = DateTime.Now.Ticks;
|
||||||
DateTime dateTime = DateTime.Now;
|
DateTime dateTime = DateTime.Now;
|
||||||
@ -376,56 +396,10 @@ public partial class DlibDotNet
|
|||||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||||
List<KeyValuePair<string, string>> metadataCollection;
|
List<KeyValuePair<string, string>> metadataCollection;
|
||||||
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(item);
|
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(item);
|
||||||
if (item.Property is not null && item.Property.Id is not null && resizedFileHolder.Exists && item.Property.Width is not null && item.Property.Height is not null)
|
if (item.Property is null || item.Property.Id is null || item.Any())
|
||||||
{
|
|
||||||
_ = _BlurHasher?.EncodeAndSave(resizedFileHolder);
|
|
||||||
// if (item.Property.Width.Value < -255 && item.Property.Height.Value < -255)
|
|
||||||
// {
|
|
||||||
// MemoryStream memoryStream = _ThumbHasher.GetMemoryStream(Array.Empty<byte>(), item.Property.Width.Value, item.Property.Height.Value);
|
|
||||||
// string thumbHashJson = JsonSerializer.Serialize(Array.Empty<byte>())[1..^1];
|
|
||||||
// if (!Regex.Matches(thumbHashJson, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]").Any())
|
|
||||||
// fileName = Path.Combine(c2HasherSingletonDirectory, $"{thumbHashJson}.png");
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // string thumbHash = BitConverter.ToString(Array.Empty<byte>()).Replace("-", string.Empty);
|
|
||||||
// // fileName = Path.Combine(c2HasherContentDirectory, $"{thumbHash}.png");
|
|
||||||
// fileName = Path.Combine(c2HasherContentDirectory, $"{resizedFileHolder.NameWithoutExtension}.png");
|
|
||||||
// }
|
|
||||||
// if (!File.Exists(fileName))
|
|
||||||
// {
|
|
||||||
// using FileStream fileStream = new(fileName, FileMode.CreateNew);
|
|
||||||
// memoryStream.WriteTo(fileStream);
|
|
||||||
// memoryStream.Dispose();
|
|
||||||
// if (resizedFileHolder.LastWriteTime is not null)
|
|
||||||
// File.SetLastWriteTime(fileName, resizedFileHolder.LastWriteTime.Value);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
if (item.Property is not null && item.Property.Id is not null && !item.Any())
|
|
||||||
{
|
|
||||||
property = item.Property;
|
|
||||||
if (item.SourceDirectoryFileHolder.LastWriteTime is not null)
|
|
||||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value));
|
|
||||||
else
|
|
||||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime));
|
|
||||||
bool nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(item.ImageFileHolder);
|
|
||||||
if (nameWithoutExtensionIsIdFormat && item.ImageFileHolder.NameWithoutExtension != item.Property.Id.ToString())
|
|
||||||
{
|
|
||||||
_Log.Information($"Name without extension is Id format but doesn't match id <{item.ImageFileHolder.FullName}>");
|
|
||||||
File.Move(item.ImageFileHolder.FullName, $"{item.ImageFileHolder.FullName}.rename");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
LogItemPropertyIsNull(item);
|
||||||
int? propertyHashCode = item.Property?.GetHashCode();
|
int? propertyHashCode = item.Property?.GetHashCode();
|
||||||
if (!item.SourceDirectoryFileHolder.Exists)
|
|
||||||
_Log.Information(string.Concat("NoJson <", item.ImageFileHolder.FullName, '>'));
|
|
||||||
else if (item.FileSizeChanged.HasValue && item.FileSizeChanged.Value)
|
|
||||||
_Log.Information(string.Concat("FileSizeChanged <", item.ImageFileHolder.FullName, '>'));
|
|
||||||
else if (item.LastWriteTimeChanged.HasValue && item.LastWriteTimeChanged.Value)
|
|
||||||
_Log.Information(string.Concat("LastWriteTimeChanged <", item.ImageFileHolder.FullName, '>'));
|
|
||||||
else if (item.Moved.HasValue && item.Moved.Value)
|
|
||||||
_Log.Information(string.Concat("Moved <", item.ImageFileHolder.FullName, '>'));
|
|
||||||
property = propertyLogic.GetProperty(item, subFileTuples, parseExceptions);
|
property = propertyLogic.GetProperty(item, subFileTuples, parseExceptions);
|
||||||
item.Update(property);
|
item.Update(property);
|
||||||
if (propertyHashCode is null)
|
if (propertyHashCode is null)
|
||||||
@ -439,6 +413,23 @@ public partial class DlibDotNet
|
|||||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
|
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
property = item.Property;
|
||||||
|
if (item.SourceDirectoryFileHolder.LastWriteTime is not null)
|
||||||
|
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value));
|
||||||
|
else
|
||||||
|
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime));
|
||||||
|
bool nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(item.ImageFileHolder);
|
||||||
|
if (nameWithoutExtensionIsIdFormat && item.ImageFileHolder.NameWithoutExtension != item.Property.Id.ToString())
|
||||||
|
LogNameWithoutExtensionIsIdFormatBut(item);
|
||||||
|
if (_BlurHasher is not null && resizedFileHolder.Exists && item.Property.Width is not null && item.Property.Width.Value > 4 && _Configuration.SaveBlurHashForOutputResolutions.Contains(outputResolution))
|
||||||
|
{
|
||||||
|
string? file = _BlurHasher.GetFile(resizedFileHolder);
|
||||||
|
if (file is not null && !File.Exists(file))
|
||||||
|
_ = _BlurHasher.EncodeAndSave(resizedFileHolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (property is null || item.Property is null)
|
if (property is null || item.Property is null)
|
||||||
throw new NullReferenceException(nameof(property));
|
throw new NullReferenceException(nameof(property));
|
||||||
item.SetResizedFileHolder(_Resize.FileNameExtension, resizedFileHolder);
|
item.SetResizedFileHolder(_Resize.FileNameExtension, resizedFileHolder);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<LangVersion>10.0</LangVersion>
|
<LangVersion>10.0</LangVersion>
|
||||||
@ -6,6 +6,7 @@
|
|||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<UserSecretsId>2999dda1-5329-4d9f-9d68-cccfabe0e47f</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageId>Phares.View.by.Distance.Instance</PackageId>
|
<PackageId>Phares.View.by.Distance.Instance</PackageId>
|
||||||
|
@ -68,7 +68,8 @@ public class Configuration
|
|||||||
[Display(Name = "Face Area Permille Tolerance"), Required] public float[] RangeFaceAreaTolerance { get; set; }
|
[Display(Name = "Face Area Permille Tolerance"), Required] public float[] RangeFaceAreaTolerance { get; set; }
|
||||||
[Display(Name = "Location Minimum Confidence"), Required] public float[] RangeFaceConfidence { get; set; }
|
[Display(Name = "Location Minimum Confidence"), Required] public float[] RangeFaceConfidence { get; set; }
|
||||||
[Display(Name = "Reverse"), Required] public bool? Reverse { get; set; }
|
[Display(Name = "Reverse"), Required] public bool? Reverse { get; set; }
|
||||||
[Display(Name = "Save Face Distances"), Required] public string[] SaveFaceDistancesForOutputResolutions { get; set; }
|
[Display(Name = "Save Blur Hash For Output Resolutions"), Required] public string[] SaveBlurHashForOutputResolutions { get; set; }
|
||||||
|
[Display(Name = "Save Face Distances For Output Resolutions"), Required] public string[] SaveFaceDistancesForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Save Face Landmark For Output Resolutions"), Required] public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
|
[Display(Name = "Save Face Landmark For Output Resolutions"), Required] public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Save Full Year Of Random Files"), Required] public bool? SaveFullYearOfRandomFiles { get; set; }
|
[Display(Name = "Save Full Year Of Random Files"), Required] public bool? SaveFullYearOfRandomFiles { get; set; }
|
||||||
[Display(Name = "Save Mapped"), Required] public string[] SaveMappedForOutputResolutions { get; set; }
|
[Display(Name = "Save Mapped"), Required] public string[] SaveMappedForOutputResolutions { get; set; }
|
||||||
@ -201,6 +202,7 @@ public class Configuration
|
|||||||
throw new NullReferenceException(nameof(configuration.RangeDistanceTolerance));
|
throw new NullReferenceException(nameof(configuration.RangeDistanceTolerance));
|
||||||
if (configuration.Reverse is null)
|
if (configuration.Reverse is null)
|
||||||
throw new NullReferenceException(nameof(configuration.Reverse));
|
throw new NullReferenceException(nameof(configuration.Reverse));
|
||||||
|
configuration.SaveBlurHashForOutputResolutions ??= Array.Empty<string>();
|
||||||
configuration.SaveFaceDistancesForOutputResolutions ??= Array.Empty<string>();
|
configuration.SaveFaceDistancesForOutputResolutions ??= Array.Empty<string>();
|
||||||
configuration.SaveFaceLandmarkForOutputResolutions ??= Array.Empty<string>();
|
configuration.SaveFaceLandmarkForOutputResolutions ??= Array.Empty<string>();
|
||||||
if (configuration.SaveFullYearOfRandomFiles is null)
|
if (configuration.SaveFullYearOfRandomFiles is null)
|
||||||
@ -288,6 +290,7 @@ public class Configuration
|
|||||||
configuration.RangeFaceAreaTolerance,
|
configuration.RangeFaceAreaTolerance,
|
||||||
configuration.RangeFaceConfidence,
|
configuration.RangeFaceConfidence,
|
||||||
configuration.Reverse.Value,
|
configuration.Reverse.Value,
|
||||||
|
configuration.SaveBlurHashForOutputResolutions,
|
||||||
configuration.SaveFaceDistancesForOutputResolutions,
|
configuration.SaveFaceDistancesForOutputResolutions,
|
||||||
configuration.SaveFaceLandmarkForOutputResolutions,
|
configuration.SaveFaceLandmarkForOutputResolutions,
|
||||||
configuration.SaveFilteredOriginalImagesFromJLinksForOutputResolutions,
|
configuration.SaveFilteredOriginalImagesFromJLinksForOutputResolutions,
|
||||||
|
@ -64,6 +64,7 @@ public class Configuration
|
|||||||
public float[] RangeFaceAreaTolerance { init; get; }
|
public float[] RangeFaceAreaTolerance { init; get; }
|
||||||
public float[] RangeFaceConfidence { init; get; }
|
public float[] RangeFaceConfidence { init; get; }
|
||||||
public bool Reverse { init; get; }
|
public bool Reverse { init; get; }
|
||||||
|
public string[] SaveBlurHashForOutputResolutions { init; get; }
|
||||||
public string[] SaveFaceDistancesForOutputResolutions { init; get; }
|
public string[] SaveFaceDistancesForOutputResolutions { init; get; }
|
||||||
public string[] SaveFaceLandmarkForOutputResolutions { init; get; }
|
public string[] SaveFaceLandmarkForOutputResolutions { init; get; }
|
||||||
public string[] SaveFilteredOriginalImagesFromJLinksForOutputResolutions { init; get; }
|
public string[] SaveFilteredOriginalImagesFromJLinksForOutputResolutions { init; get; }
|
||||||
@ -141,6 +142,7 @@ public class Configuration
|
|||||||
float[] rangeFaceAreaPermyriadTolerance,
|
float[] rangeFaceAreaPermyriadTolerance,
|
||||||
float[] rangeFaceConfidence,
|
float[] rangeFaceConfidence,
|
||||||
bool reverse,
|
bool reverse,
|
||||||
|
string[] saveBlurHashForOutputResolutions,
|
||||||
string[] saveFaceDistancesForOutputResolutions,
|
string[] saveFaceDistancesForOutputResolutions,
|
||||||
string[] saveFaceLandmarkForOutputResolutions,
|
string[] saveFaceLandmarkForOutputResolutions,
|
||||||
string[] saveFilteredOriginalImagesFromJLinksForOutputResolutions,
|
string[] saveFilteredOriginalImagesFromJLinksForOutputResolutions,
|
||||||
@ -217,6 +219,7 @@ public class Configuration
|
|||||||
RangeFaceAreaTolerance = rangeFaceAreaPermyriadTolerance;
|
RangeFaceAreaTolerance = rangeFaceAreaPermyriadTolerance;
|
||||||
RangeFaceConfidence = rangeFaceConfidence;
|
RangeFaceConfidence = rangeFaceConfidence;
|
||||||
Reverse = reverse;
|
Reverse = reverse;
|
||||||
|
SaveBlurHashForOutputResolutions = saveBlurHashForOutputResolutions;
|
||||||
SaveFaceDistancesForOutputResolutions = saveFaceDistancesForOutputResolutions;
|
SaveFaceDistancesForOutputResolutions = saveFaceDistancesForOutputResolutions;
|
||||||
SaveFaceLandmarkForOutputResolutions = saveFaceLandmarkForOutputResolutions;
|
SaveFaceLandmarkForOutputResolutions = saveFaceLandmarkForOutputResolutions;
|
||||||
SaveFilteredOriginalImagesFromJLinksForOutputResolutions = saveFilteredOriginalImagesFromJLinksForOutputResolutions;
|
SaveFilteredOriginalImagesFromJLinksForOutputResolutions = saveFilteredOriginalImagesFromJLinksForOutputResolutions;
|
||||||
|
@ -4,114 +4,7 @@
|
|||||||
"Log4netProvider": "Debug"
|
"Log4netProvider": "Debug"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"MaxDegreeOfParallelism": 6,
|
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"MinimumLevel": "Debug"
|
"MinimumLevel": "Debug"
|
||||||
},
|
|
||||||
"Windows": {
|
|
||||||
"Configuration": {
|
|
||||||
"DateGroup": "1e85c0ba",
|
|
||||||
"DeletePossibleDuplicates": true,
|
|
||||||
"DistanceRenameToMatch": true,
|
|
||||||
"DistanceMoveUnableToMatch": true,
|
|
||||||
"xFaceDistanceHiddenImageFactor": 2,
|
|
||||||
"FaceDistanceHiddenImageFactor": 3,
|
|
||||||
"FocusDirectory": "",
|
|
||||||
"xFocusDirectory": "/Hawaii 2022",
|
|
||||||
"FocusModel": "",
|
|
||||||
"xFocusModel": "NIKON D3400",
|
|
||||||
"LookForAbandoned": false,
|
|
||||||
"xGenealogicalDataCommunicationFile": "",
|
|
||||||
"GenealogicalDataCommunicationFile": "D:/5) Other Small/RootsMagic/Code-638160743318283885/638160743318283885-Export.ged.cln",
|
|
||||||
"PersonCharactersCopyCount": 0,
|
|
||||||
"xPersonCharactersCopyCount": 5,
|
|
||||||
"xRootDirectory": "D:/Tmp/phares/Pictures",
|
|
||||||
"xxRootDirectory": "D:/Tmp/Phares/Compare/Corrupt",
|
|
||||||
"xxxRootDirectory": "D:/2) Images B/Not-Copy-Copy-1e85c0ba",
|
|
||||||
"RootDirectory": "D:/1) Images A/Images-1e85c0ba",
|
|
||||||
"xxxxxRootDirectory": "D:/1) Images A/Images-1e85c0ba/Facebook/2023.2 Facebook",
|
|
||||||
"SaveIndividually": false,
|
|
||||||
"xSaveIndividually": true,
|
|
||||||
"SaveSortingWithoutPerson": true,
|
|
||||||
"SkipOlderThanDays": null,
|
|
||||||
"xSkipOlderThanDays": 2200,
|
|
||||||
"CopyFacesAndSaveFaceLandmarkForOutputResolutions": [],
|
|
||||||
"xJLinks": [
|
|
||||||
"Julie"
|
|
||||||
],
|
|
||||||
"JLinks": [
|
|
||||||
"Mike Phares Jr"
|
|
||||||
],
|
|
||||||
"LoadOrCreateThenSaveDistanceResultsForOutputResolutions": [
|
|
||||||
"Original"
|
|
||||||
],
|
|
||||||
"LoadOrCreateThenSaveImageFacesResultsForOutputResolutions": [
|
|
||||||
"Original"
|
|
||||||
],
|
|
||||||
"OutputResolutions": [
|
|
||||||
"Original"
|
|
||||||
],
|
|
||||||
"PropertyContentCollectionFiles": [],
|
|
||||||
"RangeDaysDeltaTolerance": [
|
|
||||||
0,
|
|
||||||
7000,
|
|
||||||
7300
|
|
||||||
],
|
|
||||||
"RangeDistanceTolerance": [
|
|
||||||
0,
|
|
||||||
0.6,
|
|
||||||
1.8
|
|
||||||
],
|
|
||||||
"RangeFaceAreaTolerance": [
|
|
||||||
0,
|
|
||||||
0.0001,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"RangeFaceConfidence": [
|
|
||||||
0,
|
|
||||||
0.8,
|
|
||||||
2.4
|
|
||||||
],
|
|
||||||
"SaveFaceDistancesForOutputResolutions": [
|
|
||||||
"Original"
|
|
||||||
],
|
|
||||||
"SaveFaceLandmarkForOutputResolutions": [],
|
|
||||||
"SaveFilteredOriginalImagesFromJLinksForOutputResolutions": [],
|
|
||||||
"SaveMappedForOutputResolutions": [],
|
|
||||||
"SaveRandomForOutputResolutions": [],
|
|
||||||
"SaveShortcutsForOutputResolutions": [],
|
|
||||||
"SkipNotSkipDirectories": [],
|
|
||||||
"xSkipNotSkipDirectories": [
|
|
||||||
"/!/_ Images-To-Do",
|
|
||||||
"/!/_ Test",
|
|
||||||
"/!/Disney",
|
|
||||||
"/!/Chelsea's Friends",
|
|
||||||
"/!/Jason's Friends",
|
|
||||||
"/!/Johnny's Friends",
|
|
||||||
"/!/Julie's Friends",
|
|
||||||
"/!/Kristy's Family",
|
|
||||||
"/!/Kristy's Friends",
|
|
||||||
"/!/Logan Friends",
|
|
||||||
"/!/Mackenzie Friends",
|
|
||||||
"/!/Mike's Family",
|
|
||||||
"/!/Mike's Friends",
|
|
||||||
"/!/Statue",
|
|
||||||
"/!/Tracy's Friend",
|
|
||||||
"/!/Wax"
|
|
||||||
],
|
|
||||||
"IgnoreRelativePaths": [
|
|
||||||
"zzz Phares Slides ####"
|
|
||||||
],
|
|
||||||
"MixedYearRelativePaths": [
|
|
||||||
"Edited",
|
|
||||||
"Phares Slides",
|
|
||||||
"Rex Memorial",
|
|
||||||
"Scanned Grandma's Quilt",
|
|
||||||
"Scanned Pictures Of Kids",
|
|
||||||
"Scanned Prints",
|
|
||||||
"Slide in Name Order Originals (622)",
|
|
||||||
"Slides Pictures"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class B_Metadata
|
|||||||
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
|
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
|
||||||
_ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
|
_ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
|
||||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(configuration.ResultAllInOne, bResultsFullGroupDirectory);
|
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(configuration.ResultAllInOne, bResultsFullGroupDirectory, new string[] { "{}" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
@ -1,22 +1,10 @@
|
|||||||
{
|
{
|
||||||
"Linux": {
|
|
||||||
"Configuration": {
|
|
||||||
"VerifyToSeason": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Log4netProvider": "Debug"
|
"Log4netProvider": "Debug"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"MaxDegreeOfParallelism": 6,
|
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"MinimumLevel": "Debug"
|
"MinimumLevel": "Debug"
|
||||||
},
|
|
||||||
"Windows": {
|
|
||||||
"Configuration": {
|
|
||||||
"RootDirectory": "C:/",
|
|
||||||
"VerifyToSeason": []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,7 +39,7 @@ public class A_Property
|
|||||||
_AngleBracketCollection = new List<string>();
|
_AngleBracketCollection = new List<string>();
|
||||||
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(configuration.ResultAllInOne, aResultsFullGroupDirectory);
|
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(configuration.ResultAllInOne, aResultsFullGroupDirectory, new string[] { "{}" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
@ -502,9 +502,9 @@ public class Rename
|
|||||||
if (!verifiedToDoCollection.Any())
|
if (!verifiedToDoCollection.Any())
|
||||||
continue;
|
continue;
|
||||||
if (string.IsNullOrEmpty(_AppSettings.CopyTo))
|
if (string.IsNullOrEmpty(_AppSettings.CopyTo))
|
||||||
results.AddRange(Move(log, toDoCollection));
|
results.AddRange(Move(log, verifiedToDoCollection));
|
||||||
else
|
else
|
||||||
results.AddRange(CopyInstead(log, toDoCollection));
|
results.AddRange(CopyInstead(log, verifiedToDoCollection));
|
||||||
allFiles = GetAllFiles(matchNginxCollection);
|
allFiles = GetAllFiles(matchNginxCollection);
|
||||||
progressBar.Dispose();
|
progressBar.Dispose();
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,5 @@
|
|||||||
},
|
},
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"MinimumLevel": "Debug"
|
"MinimumLevel": "Debug"
|
||||||
},
|
|
||||||
"Windows": {
|
|
||||||
"Configuration": {
|
|
||||||
"RootDirectory": "C:/",
|
|
||||||
"VerifyToSeason": []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ public interface IBlurHasher
|
|||||||
{
|
{
|
||||||
|
|
||||||
string Encode(FileHolder fileHolder);
|
string Encode(FileHolder fileHolder);
|
||||||
|
string? GetFile(FileHolder fileHolder);
|
||||||
string EncodeAndSave(FileHolder fileHolder);
|
string EncodeAndSave(FileHolder fileHolder);
|
||||||
|
|
||||||
}
|
}
|
@ -5,11 +5,18 @@ public interface IDirectory
|
|||||||
|
|
||||||
char TestStatic_GetDirectory(string fileName) =>
|
char TestStatic_GetDirectory(string fileName) =>
|
||||||
GetDirectory(fileName);
|
GetDirectory(fileName);
|
||||||
static char GetDirectory(string fileName) => fileName.Split('-').Length > 2 ? '-' : fileName.Split('.')[0][^1];
|
static char GetDirectory(string fileName) =>
|
||||||
|
fileName.Split('-').Length > 2 ? '-' : fileName.Split('.')[0][^1];
|
||||||
|
|
||||||
|
string TestStatic_GetDirectory(string fileName, int length) =>
|
||||||
|
GetDirectory(fileName, length);
|
||||||
|
static string GetDirectory(string fileName, int length) =>
|
||||||
|
fileName.Length < length ? new('-', length) : fileName.Split('.')[0][^length..];
|
||||||
|
|
||||||
int TestStatic_GetDirectory(char directory) =>
|
int TestStatic_GetDirectory(char directory) =>
|
||||||
GetDirectory(directory);
|
GetDirectory(directory);
|
||||||
static int GetDirectory(char directory) => directory == '-' ? 10 : int.TryParse(directory.ToString(), out int value) ? value : 11;
|
static int GetDirectory(char directory) =>
|
||||||
|
directory == '-' ? 10 : int.TryParse(directory.ToString(), out int value) ? value : 11;
|
||||||
|
|
||||||
List<string[]> TestStatic_GetFilesCollection(string directory, string directorySearchFilter, string fileSearchFilter) =>
|
List<string[]> TestStatic_GetFilesCollection(string directory, string directorySearchFilter, string fileSearchFilter) =>
|
||||||
GetFilesCollection(directory, directorySearchFilter, fileSearchFilter);
|
GetFilesCollection(directory, directorySearchFilter, fileSearchFilter);
|
||||||
|
@ -59,9 +59,9 @@ public interface IPath
|
|||||||
static string GetDirectory(string sourceDirectory, int level, string directoryName) =>
|
static string GetDirectory(string sourceDirectory, int level, string directoryName) =>
|
||||||
XPath.GetDirectory(sourceDirectory, level, directoryName);
|
XPath.GetDirectory(sourceDirectory, level, directoryName);
|
||||||
|
|
||||||
Dictionary<string, string[]> TestStatic_GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory) =>
|
Dictionary<string, string[]> TestStatic_GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12) =>
|
||||||
GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory);
|
GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory, directories, maxValue);
|
||||||
static Dictionary<string, string[]> GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory) =>
|
static Dictionary<string, string[]> GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12) =>
|
||||||
XPath.GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory);
|
XPath.GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory, directories, maxValue);
|
||||||
|
|
||||||
}
|
}
|
@ -257,30 +257,37 @@ internal abstract class XPath
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Dictionary<string, string[]> GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory)
|
internal static Dictionary<string, string[]> GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12)
|
||||||
{
|
{
|
||||||
Dictionary<string, string[]> results = new();
|
Dictionary<string, string[]> results = new();
|
||||||
string checkDirectory;
|
string checkDirectory;
|
||||||
|
int minusOne = maxValue - 1;
|
||||||
|
int minusTwo = maxValue - 2;
|
||||||
|
int minusThree = maxValue - 3;
|
||||||
List<string> collection = new();
|
List<string> collection = new();
|
||||||
foreach (string key in new string[] { "{}", "()" })
|
int length = minusThree.ToString().Length;
|
||||||
|
if (directories is not null)
|
||||||
|
{
|
||||||
|
foreach (string key in directories)
|
||||||
{
|
{
|
||||||
if (resultsFullGroupDirectory is null)
|
if (resultsFullGroupDirectory is null)
|
||||||
continue;
|
continue;
|
||||||
collection.Clear();
|
collection.Clear();
|
||||||
for (int i = 0; i < 12; i++)
|
for (int i = 0; i < maxValue; i++)
|
||||||
{
|
{
|
||||||
if (i == 10)
|
if (i == minusTwo)
|
||||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, "-");
|
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, new('-', length));
|
||||||
else if (i == 11)
|
else if (i == minusOne)
|
||||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, "_");
|
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, new('_', length));
|
||||||
else
|
else
|
||||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, i.ToString());
|
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, i.ToString().PadLeft(length, '0'));
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
collection.Add(checkDirectory);
|
collection.Add(checkDirectory);
|
||||||
}
|
}
|
||||||
results.Add(key, collection.ToArray());
|
results.Add(key, collection.ToArray());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user