diff --git a/Drag-Drop-Search/Models/Binder/Configuration.cs b/Drag-Drop-Search/Models/Binder/Configuration.cs index 82e97d9..752653a 100644 --- a/Drag-Drop-Search/Models/Binder/Configuration.cs +++ b/Drag-Drop-Search/Models/Binder/Configuration.cs @@ -22,8 +22,6 @@ public class Configuration [Display(Name = "Julie Phares Copy Birthdays"), Required] public string[] JLinks { get; set; } [Display(Name = "Load Or Create Then Save Distance Results"), Required] public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; } [Display(Name = "Load Or Create Then Save Image Faces Results"), Required] public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; } - [Display(Name = "Load Or Create Then Save Index"), Required] public bool? LoadOrCreateThenSaveIndex { get; set; } - [Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; } [Display(Name = "Mixed Year Relative Paths"), Required] public string[] MixedYearRelativePaths { get; set; } [Display(Name = "Model Directory"), Required] public string ModelDirectory { get; set; } [Display(Name = "Model Name"), Required] public string ModelName { get; set; } @@ -86,8 +84,6 @@ public class Configuration throw new NullReferenceException(nameof(configuration.IgnoreRelativePaths)); configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ??= Array.Empty(); configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions ??= Array.Empty(); - if (configuration.LoadOrCreateThenSaveIndex is null) - throw new NullReferenceException(nameof(configuration.LoadOrCreateThenSaveIndex)); if (configuration.MixedYearRelativePaths is null) throw new NullReferenceException(nameof(configuration.MixedYearRelativePaths)); if (configuration.NumberOfJitters is null) @@ -144,8 +140,6 @@ public class Configuration configuration.JLinks, configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions, configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions, - configuration.LoadOrCreateThenSaveIndex.Value, - configuration.MappedMaxIndex, configuration.MixedYearRelativePaths, configuration.ModelDirectory, configuration.ModelName, diff --git a/Drag-Drop-Search/Models/Configuration.cs b/Drag-Drop-Search/Models/Configuration.cs index 01480b2..6fdd0b3 100644 --- a/Drag-Drop-Search/Models/Configuration.cs +++ b/Drag-Drop-Search/Models/Configuration.cs @@ -21,8 +21,6 @@ public class Configuration public string[] JLinks { init; get; } public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { init; get; } public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { init; get; } - public bool LoadOrCreateThenSaveIndex { init; get; } - public int? MappedMaxIndex { init; get; } public string[] MixedYearRelativePaths { init; get; } public string ModelDirectory { init; get; } public string ModelName { init; get; } @@ -65,8 +63,6 @@ public class Configuration string[] jLinks, string[] loadOrCreateThenSaveDistanceResultsForOutputResolutions, string[] loadOrCreateThenSaveImageFacesResultsForOutputResolutions, - bool loadOrCreateThenSaveIndex, - int? mappedMaxIndex, string[] mixedYearRelativePaths, string modelDirectory, string modelName, @@ -108,8 +104,6 @@ public class Configuration JLinks = jLinks; LoadOrCreateThenSaveDistanceResultsForOutputResolutions = loadOrCreateThenSaveDistanceResultsForOutputResolutions; LoadOrCreateThenSaveImageFacesResultsForOutputResolutions = loadOrCreateThenSaveImageFacesResultsForOutputResolutions; - LoadOrCreateThenSaveIndex = loadOrCreateThenSaveIndex; - MappedMaxIndex = mappedMaxIndex; MixedYearRelativePaths = mixedYearRelativePaths; ModelDirectory = modelDirectory; ModelName = modelName; diff --git a/Instance/DlibDotNet.cs b/Instance/DlibDotNet.cs index 1203662..1b46bdd 100644 --- a/Instance/DlibDotNet.cs +++ b/Instance/DlibDotNet.cs @@ -22,10 +22,8 @@ public partial class DlibDotNet { private readonly D_Face _Faces; - private readonly G_Index _Index; private readonly C_Resize _Resize; private readonly F_Random _Random; - private readonly E3_Rename _Rename; private readonly IConsole _Console; private readonly E_Distance _Distance; private readonly Serilog.ILogger? _Log; @@ -62,9 +60,7 @@ public partial class DlibDotNet Verify(configuration); VerifyExtra(args, propertyConfiguration, configuration); _Configuration = configuration; - _Index = new(configuration); _Random = new(configuration); - _Rename = new(configuration); if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions)); string propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(propertyConfiguration, nameof(A_Property), create: false); @@ -121,12 +117,6 @@ public partial class DlibDotNet Storage storage = new(rootDirectory, rootResultsDirectory, peopleRootDirectory); _PersonContainers = Shared.Models.Stateless.Methods.IPersonContainer.GetPersonContainers(storage, configuration.PersonBirthdayFormat, configuration.PersonCharacters.ToArray(), _Faces.FileNameExtension); } - if (!isSilent && configuration.TestDistanceResults) - { - E2_Navigate e2Navigate = new(console, configuration, argZero); - e2Navigate.Navigate(propertyConfiguration, configuration.OutputResolutions[0]); - _Log.Information(propertyConfiguration.RootDirectory); - } { (ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple( configuration.OutputExtension, @@ -144,16 +134,6 @@ public partial class DlibDotNet Search(ticks, argZero, propertyRoot); if (!_PropertyRootExistedBefore && !_IsEnvironment.Development && _Exceptions.Count == 0 && _ArgZeroIsConfigurationRootDirectory) { - List directoryCollections = _Rename.GetDirectoryRenameCollections( - propertyConfiguration, - relativePath: string.Empty, - newDirectoryName: string.Empty, - jsonFiles4InfoAny: false); - foreach (string[] directoryCollection in directoryCollections) - { - _Log.Information(string.Concat("Cleaning <", directoryCollection[0], ">")); - _ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(directoryCollection[0]); - } string d2FacePartsRootDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(propertyConfiguration, nameof(D2_FaceParts)); _Log.Information(string.Concat("Cleaning <", d2FacePartsRootDirectory, ">")); _ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(d2FacePartsRootDirectory); @@ -225,8 +205,6 @@ public partial class DlibDotNet throw new NullReferenceException(nameof(configuration.PredictorModelName)); if (string.IsNullOrEmpty(configuration.ModelDirectory) || !Directory.Exists(configuration.ModelDirectory)) throw new NullReferenceException(nameof(configuration.ModelDirectory)); - if (configuration.MappedMaxIndex.HasValue && configuration.LoadOrCreateThenSaveIndex && !_IsEnvironment.DebuggerWasAttachedDuringConstructor) - throw new NullReferenceException(nameof(configuration.MappedMaxIndex)); } private void VerifyExtra(List args, Property.Models.Configuration propertyConfiguration, Models.Configuration configuration) @@ -1116,11 +1094,6 @@ public partial class DlibDotNet _Random.Random(_Configuration.PropertyConfiguration, outputResolution, personKeyToIds, mappingCollection); if (_IsEnvironment.Development) continue; - G2_Identify identify = new(_Configuration); - List identifiedCollection = identify.GetIdentifiedCollection(_IsEnvironment, _Configuration.PropertyConfiguration, _Faces.FileNameExtension); - identify.WriteAllText(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0], identifiedCollection); - if (_Configuration.LoadOrCreateThenSaveIndex) - _Index.SetIndex(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0]); if (!_IsEnvironment.Development) { _ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(Path.Combine(aResultsFullGroupDirectory, "{}")); @@ -1132,6 +1105,4 @@ public partial class DlibDotNet } } - internal void RenameQueue() => _Rename.RenameQueue(_Configuration.PropertyConfiguration); - } \ No newline at end of file diff --git a/Instance/Models/Binder/Configuration.cs b/Instance/Models/Binder/Configuration.cs index 437fa31..012db03 100644 --- a/Instance/Models/Binder/Configuration.cs +++ b/Instance/Models/Binder/Configuration.cs @@ -30,10 +30,8 @@ public class Configuration [Display(Name = "Julie Phares Copy Birthdays"), Required] public string[] JLinks { get; set; } [Display(Name = "Load Or Create Then Save Distance Results"), Required] public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; } [Display(Name = "Load Or Create Then Save Image Faces Results"), Required] public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; } - [Display(Name = "Load Or Create Then Save Index"), Required] public bool? LoadOrCreateThenSaveIndex { get; set; } [Display(Name = "Location Digits"), Required] public int? LocationDigits { get; set; } [Display(Name = "Location Factor"), Required] public int? LocationFactor { get; set; } - [Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; } [Display(Name = "Mapping Default Name"), Required] public string MappingDefaultName { get; set; } [Display(Name = "Mapping Use Deterministic Hash Code Unknown Face Key Value Pairs for Add to Mapping"), Required] public bool? MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { get; set; } [Display(Name = "Mapping Use Deterministic Hash Code Unknown Face Key Value Pairs for Save Mapping"), Required] public bool? MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping { get; set; } @@ -130,8 +128,6 @@ public class Configuration throw new NullReferenceException(nameof(configuration.IgnoreRelativePaths)); configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ??= Array.Empty(); configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions ??= Array.Empty(); - if (configuration.LoadOrCreateThenSaveIndex is null) - throw new NullReferenceException(nameof(configuration.LoadOrCreateThenSaveIndex)); if (configuration.LocationDigits is null) throw new NullReferenceException(nameof(configuration.LocationDigits)); if (configuration.LocationFactor is null) @@ -235,10 +231,8 @@ public class Configuration configuration.JLinks, configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions, configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions, - configuration.LoadOrCreateThenSaveIndex.Value, configuration.LocationDigits.Value, configuration.LocationFactor.Value, - configuration.MappedMaxIndex, configuration.MappingDefaultName, configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping.Value, configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping.Value, diff --git a/Instance/Models/Configuration.cs b/Instance/Models/Configuration.cs index 5d46b26..001dbd7 100644 --- a/Instance/Models/Configuration.cs +++ b/Instance/Models/Configuration.cs @@ -29,10 +29,8 @@ public class Configuration public string[] JLinks { init; get; } public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { init; get; } public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { init; get; } - public bool LoadOrCreateThenSaveIndex { init; get; } public int LocationDigits { init; get; } public int LocationFactor { init; get; } - public int? MappedMaxIndex { init; get; } public string MappingDefaultName { init; get; } public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { init; get; } public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping { init; get; } @@ -99,10 +97,8 @@ public class Configuration string[] jLinks, string[] loadOrCreateThenSaveDistanceResultsForOutputResolutions, string[] loadOrCreateThenSaveImageFacesResultsForOutputResolutions, - bool loadOrCreateThenSaveIndex, int locationDigits, int locationFactor, - int? mappedMaxIndex, string mappingDefaultName, bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping, bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping, @@ -168,10 +164,8 @@ public class Configuration JLinks = jLinks; LoadOrCreateThenSaveDistanceResultsForOutputResolutions = loadOrCreateThenSaveDistanceResultsForOutputResolutions; LoadOrCreateThenSaveImageFacesResultsForOutputResolutions = loadOrCreateThenSaveImageFacesResultsForOutputResolutions; - LoadOrCreateThenSaveIndex = loadOrCreateThenSaveIndex; LocationDigits = locationDigits; LocationFactor = locationFactor; - MappedMaxIndex = mappedMaxIndex; MappingDefaultName = mappingDefaultName; MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping; MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping; diff --git a/Instance/Models/_E2_Navigate.cs b/Instance/Models/_E2_Navigate.cs deleted file mode 100644 index 614ca2b..0000000 --- a/Instance/Models/_E2_Navigate.cs +++ /dev/null @@ -1,232 +0,0 @@ -using System.Text.Json; -using View_by_Distance.Distance.Models; -using View_by_Distance.Face.Models; -using View_by_Distance.Instance.Models.Stateless; -using View_by_Distance.Metadata.Models; -using View_by_Distance.Resize.Models; -using View_by_Distance.Shared.Models; -using View_by_Distance.Shared.Models.Methods; - -namespace View_by_Distance.Instance.Models; - -/// -// N/A -/// -internal class E2_Navigate -{ - - private readonly string _ArgZero; - private readonly E3_Rename _Rename; - private readonly IConsole _Console; - private readonly Serilog.ILogger? _Log; - private readonly Configuration _Configuration; - - internal E2_Navigate(IConsole console, Configuration configuration, string argZero) - { - _Console = console; - _ArgZero = argZero; - _Configuration = configuration; - _Rename = new E3_Rename(configuration); - _Log = Serilog.Log.ForContext(); - } - - public override string ToString() - { - string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); - return result; - } - - private void DisplayTags(Property.Models.Configuration configuration, string outputResolution, string[] directories, Dictionary directoryKeyValuePairs, string[] files, Dictionary fileKeyValuePairs) - { - if (_Log is null) - throw new NullReferenceException(nameof(_Log)); - bool all = false; - FileSystem fileSystem; - string requestPath = "/RootResultsDirectory"; - string? rootResultsDirectory = Path.GetDirectoryName(Property.Models.Stateless.IResult.GetResultsGroupDirectory(configuration, nameof(B_Metadata))); - if (string.IsNullOrEmpty(rootResultsDirectory)) - throw new Exception(); - string rootResultsDirectoryAbsoluteUri = new Uri(rootResultsDirectory).AbsoluteUri; - string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()"); - string cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"); - string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]"); - (string RootResultsDirectoryAbsoluteUri, string C_ResizeContentDirectory, string D_FacesContentDirectory, string E_DistanceCollectionDirectory) tuple = new(rootResultsDirectoryAbsoluteUri, cResizeContentDirectory, dFacesContentDirectory, eDistanceCollectionDirectory); - List fileSystemCollection = Shared.Models.Stateless.Methods.IFileSystem.GetFileSystemCollection(requestPath, tuple, directories, files, all); - Queue queue = new(fileSystemCollection); - foreach (KeyValuePair element in directoryKeyValuePairs) - { - fileSystem = queue.Dequeue(); - _Log.Warn(string.Concat(element.Key, " - D) ", " <", fileSystem.Display, ">")); - // _Log.Info(string.Join(Environment.NewLine, from l in fileSystem where !string.IsNullOrEmpty(l) select l)); - _Log.Info(string.Empty); - } - foreach (KeyValuePair element in fileKeyValuePairs) - { - fileSystem = queue.Dequeue(); - _Log.Warn(string.Concat(element.Key, " - F) [", fileSystem.Display, '}')); - // _Log.Info(string.Join(Environment.NewLine, from l in fileSystem where !string.IsNullOrEmpty(l) select l)); - _Log.Info(string.Empty); - } - } - - private void DisplayFaces(Property.Models.Configuration configuration, string outputResolution, string selectedFileFullName) - { - if (_Log is null) - throw new NullReferenceException(nameof(_Log)); - string requestPath = "/RootResultsDirectory"; - string? rootResultsDirectory = Path.GetDirectoryName(Property.Models.Stateless.IResult.GetResultsGroupDirectory(configuration, nameof(B_Metadata))); - if (string.IsNullOrEmpty(rootResultsDirectory)) - throw new Exception(); - string rootResultsDirectoryAbsoluteUri = new Uri(rootResultsDirectory).AbsoluteUri; - string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()"); - string cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"); - string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]"); - (string RootResultsDirectoryAbsoluteUri, string C_ResizeContentDirectory, string D_FacesContentDirectory, string E_DistanceCollectionDirectory) tuple = new(rootResultsDirectoryAbsoluteUri, cResizeContentDirectory, dFacesContentDirectory, eDistanceCollectionDirectory); - FaceFileSystem[] faceFileSystemCollection = Shared.Models.Stateless.Methods.IFaceFileSystem.GetFaceFileSystemCollection(requestPath, tuple, selectedFileFullName); - for (int i = 0; i < faceFileSystemCollection.Length; i++) - { - _Log.Warn(string.Concat(i, " - F) [", faceFileSystemCollection[i].Display, '}')); - // _Log.Info(string.Join(Environment.NewLine, from l in fileSystemCollection[i] where !string.IsNullOrEmpty(l) select l)); - _Log.Info(string.Empty); - } - // } - } - - private string Rename(Property.Models.Configuration configuration, string subSourceDirectory) - { - string result; - if (_Log is null) - throw new NullReferenceException(nameof(_Log)); - _Log.Warn(string.Concat("What is the new name for [", Path.GetFileName(subSourceDirectory), "]<", subSourceDirectory, ">?")); - string? newDirectoryName = _Console.ReadLine(); - _Log.Warn("Are you sure y[es] || n[o]?"); - if (string.IsNullOrEmpty(newDirectoryName) || _Console.ReadKey() != ConsoleKey.Y) - { - _Log.Warn(string.Empty); - _Log.Warn("No changes made."); - result = subSourceDirectory; - } - else - { - _Log.Warn(string.Empty); - string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), _Configuration.ValidResolutions[0], includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]"); - string relativePath = Shared.Models.Stateless.Methods.IPath.GetRelativePath(subSourceDirectory, eDistanceCollectionDirectory.Length); - if (relativePath.Length == 1) - throw new Exception(); - if (Directory.Exists(Path.Combine(string.Concat(_Configuration.PropertyConfiguration.RootDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName))) - { - _Log.Warn("\"To\" directory already exits!"); - result = subSourceDirectory; - } - else - { - _Rename.DirectoryRename(configuration, relativePath, newDirectoryName); - _Log.Warn("Renamed..."); - string? directoryName = Path.GetDirectoryName(subSourceDirectory); - if (string.IsNullOrEmpty(directoryName)) - throw new Exception(); - result = Path.Combine(directoryName, newDirectoryName); - } - } - return result; - } - - internal void Navigate(Property.Models.Configuration configuration, string outputResolution) - { - if (_Log is null) - throw new NullReferenceException(nameof(_Log)); - string[] subFiles; - ConsoleKey consoleKey; - string[] subDirectories; - string selectedFileFullName; - string rootDirectory = string.Empty; - string? subSourceDirectory = string.Empty; - Dictionary fileKeyValuePairs = new(); - Dictionary directoryKeyValuePairs = new(); - string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), _Configuration.OutputResolutions[0], includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]"); - if (!Directory.Exists(eDistanceCollectionDirectory)) - _ = Directory.CreateDirectory(eDistanceCollectionDirectory); - for (int z = 0; z < int.MaxValue; z++) - { - if (string.IsNullOrEmpty(subSourceDirectory)) - { - rootDirectory = eDistanceCollectionDirectory; - subSourceDirectory = rootDirectory; - } - subFiles = Directory.GetFiles(subSourceDirectory, "*.json", SearchOption.TopDirectoryOnly); - subDirectories = Directory.GetDirectories(subSourceDirectory, "*", SearchOption.TopDirectoryOnly); - directoryKeyValuePairs.Clear(); - for (int i = (int)ConsoleKey.A; i < (subDirectories.Length + (int)ConsoleKey.A) && i <= (int)ConsoleKey.RightWindows; i++) - directoryKeyValuePairs.Add((ConsoleKey)i, i - (int)ConsoleKey.A); - fileKeyValuePairs.Clear(); - for (int i = (int)ConsoleKey.A + subDirectories.Length; i < (subFiles.Length + (int)ConsoleKey.A + subDirectories.Length) && i <= (int)ConsoleKey.RightWindows; i++) - fileKeyValuePairs.Add((ConsoleKey)i, i - (int)ConsoleKey.A); - if (!directoryKeyValuePairs.Any() && !fileKeyValuePairs.Any()) - break; - _Log.Warn(""); - DisplayTags(configuration, outputResolution, subDirectories, directoryKeyValuePairs, subFiles, fileKeyValuePairs); - _Log.Warn(string.Empty); - _Log.Warn(string.Empty); - _Log.Warn(string.Empty); - _Log.Warn("Select a file system object. Enter \"Backspace\" to go up a directory, \"F2\" to rename and \"Esc\" to end navigation."); - consoleKey = _Console.ReadKey(); - _Log.Warn(string.Empty); - if (consoleKey == ConsoleKey.Escape) - break; - if (consoleKey == ConsoleKey.F2) - { - if (subSourceDirectory == rootDirectory) - { - _Log.Warn("Root directory can not be renamed! Try again."); - continue; - } - else - { - subSourceDirectory = Rename(configuration, subSourceDirectory); - continue; - } - } - else if (consoleKey is ConsoleKey.Backspace or ConsoleKey.LeftArrow) - { - if (subSourceDirectory != rootDirectory) - subSourceDirectory = Path.GetDirectoryName(subSourceDirectory); - else - { - _Log.Warn("At root directory. Try again."); - continue; - } - } - else if (directoryKeyValuePairs.ContainsKey(consoleKey)) - { - subSourceDirectory = subDirectories[directoryKeyValuePairs[consoleKey]]; - _Log.Warn(string.Concat(">>> [", Path.GetFileName(subSourceDirectory), "]<", subSourceDirectory, ">?")); - continue; - } - else - { - if (!fileKeyValuePairs.ContainsKey(consoleKey)) - { - subSourceDirectory = _ArgZero; - _Log.Warn("Invalid selection. Try again."); - continue; - } - else - { - selectedFileFullName = subFiles[fileKeyValuePairs[consoleKey]]; - _Log.Warn(string.Concat(">>> [", Path.GetFileName(selectedFileFullName), "]<", selectedFileFullName, ">?")); - DisplayFaces(configuration, outputResolution, selectedFileFullName); - _Log.Warn(string.Empty); - _Log.Warn(string.Empty); - _Log.Warn(string.Empty); - _Log.Warn("Go up a directory? Enter escape end."); - consoleKey = _Console.ReadKey(); - if (consoleKey == ConsoleKey.Escape) - break; - subSourceDirectory = Path.GetDirectoryName(subSourceDirectory); - continue; - } - } - } - } - -} \ No newline at end of file diff --git a/Instance/Models/_E3_Rename.cs b/Instance/Models/_E3_Rename.cs deleted file mode 100644 index 778356e..0000000 --- a/Instance/Models/_E3_Rename.cs +++ /dev/null @@ -1,336 +0,0 @@ -using System.Text.Json; -using View_by_Distance.Distance.Models; -using View_by_Distance.Face.Models; -using View_by_Distance.FaceParts.Models; -using View_by_Distance.Metadata.Models; -using View_by_Distance.Resize.Models; - -namespace View_by_Distance.Instance.Models; - -/// -// N/A -/// -internal class E3_Rename -{ - - private readonly Serilog.ILogger? _Log; - private readonly Configuration _Configuration; - private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions; - - internal E3_Rename(Configuration configuration) - { - _Configuration = configuration; - _Log = Serilog.Log.ForContext(); - _WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true }; - } - - public override string ToString() - { - string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); - return result; - } - - internal string[] GetDirectoryRenameCollection(Property.Models.Configuration configuration, string relativePath, string newDirectoryName, bool jsonFiles4InfoAny) - { - List results = new(); - bool add; - string to; - string dFacesContentDirectory; - string cResizeContentDirectory; - string dFacesCollectionDirectory; - string cResizeSingletonDirectory; - string eDistanceContentDirectory; - string aPropertySingletonDirectory; - string d2FacePartsContentDirectory; - string bMetadataSingletonDirectory; - string eDistanceCollectionDirectory; - string g2IdentifyCollectionDirectory; - add = Directory.Exists(string.Concat(Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), _Configuration.ValidResolutions[0], includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"), relativePath)); - bMetadataSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(B_Metadata), "{}"); - if (Directory.Exists(bMetadataSingletonDirectory)) - { - to = Path.Combine(string.Concat(bMetadataSingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(Property.Models.A_Property), "{}"); - if (Directory.Exists(aPropertySingletonDirectory)) - { - to = Path.Combine(string.Concat(aPropertySingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), _Configuration.ValidResolutions[0], includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"); - if (Directory.Exists(cResizeContentDirectory)) - { - to = Path.Combine(string.Concat(cResizeContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - foreach (string outputResolution in _Configuration.ValidResolutions) - { - cResizeSingletonDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "{}"); - if (Directory.Exists(cResizeSingletonDirectory)) - { - to = Path.Combine(string.Concat(cResizeSingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()"); - if (Directory.Exists(dFacesContentDirectory)) - { - to = Path.Combine(string.Concat(dFacesContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - dFacesCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]"); - if (Directory.Exists(dFacesCollectionDirectory)) - { - to = Path.Combine(string.Concat(dFacesCollectionDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - d2FacePartsContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D2_FaceParts), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()"); - if (add && _Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution) && Directory.Exists(d2FacePartsContentDirectory)) - { - to = Path.Combine(string.Concat(d2FacePartsContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - eDistanceContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()"); - if (Directory.Exists(eDistanceContentDirectory)) - { - to = Path.Combine(string.Concat(eDistanceContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]"); - if (Directory.Exists(eDistanceCollectionDirectory)) - { - to = Path.Combine(string.Concat(eDistanceCollectionDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - g2IdentifyCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(G2_Identify), "[]"); - if (add && jsonFiles4InfoAny && Directory.Exists(g2IdentifyCollectionDirectory)) - { - to = Path.Combine(string.Concat(g2IdentifyCollectionDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(to); - } - } - return results.ToArray(); - } - - internal List GetDirectoryRenameCollections(Property.Models.Configuration configuration, string relativePath, string newDirectoryName, bool jsonFiles4InfoAny) - { - List results = new(); - bool add; - string to; - bool exists; - string from; - string dFacesContentDirectory; - string cResizeContentDirectory; - string dFacesCollectionDirectory; - string cResizeSingletonDirectory; - string eDistanceContentDirectory; - string bMetadataSingletonDirectory; - string aPropertySingletonDirectory; - string d2FacePartsContentDirectory; - string eDistanceCollectionDirectory; - string g2IdentifyCollectionDirectory; - if (!string.IsNullOrEmpty(relativePath)) - { - from = string.Concat(_Configuration.PropertyConfiguration.RootDirectory, relativePath); - to = Path.Combine(string.Concat(_Configuration.PropertyConfiguration.RootDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - foreach (string outputResolution in _Configuration.ValidResolutions) - { - add = Directory.Exists(string.Concat(Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"), relativePath)); - bMetadataSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(B_Metadata), "{}"); - from = string.Concat(bMetadataSingletonDirectory, relativePath); - exists = Directory.Exists(bMetadataSingletonDirectory); - if (exists) - { - to = Path.Combine(string.Concat(bMetadataSingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(Property.Models.A_Property), "{}"); - from = string.Concat(aPropertySingletonDirectory, relativePath); - exists = Directory.Exists(aPropertySingletonDirectory); - if (exists) - { - to = Path.Combine(string.Concat(aPropertySingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"); - from = string.Concat(cResizeContentDirectory, relativePath); - exists = Directory.Exists(cResizeContentDirectory); - if (exists) - { - to = Path.Combine(string.Concat(cResizeContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - cResizeSingletonDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "{}"); - from = string.Concat(cResizeSingletonDirectory, relativePath); - exists = Directory.Exists(cResizeSingletonDirectory); - if (exists) - { - to = Path.Combine(string.Concat(cResizeSingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()"); - from = string.Concat(dFacesContentDirectory, relativePath); - exists = Directory.Exists(dFacesContentDirectory); - if (exists) - { - to = Path.Combine(string.Concat(dFacesContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - dFacesCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]"); - from = string.Concat(dFacesCollectionDirectory, relativePath); - exists = Directory.Exists(dFacesCollectionDirectory); - if (exists) - { - to = Path.Combine(string.Concat(dFacesCollectionDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - d2FacePartsContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D2_FaceParts), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()"); - from = string.Concat(d2FacePartsContentDirectory, relativePath); - exists = Directory.Exists(d2FacePartsContentDirectory); - if (!exists && add && _Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution)) - results.Add(new string[] { from }); - else if (exists) - { - to = Path.Combine(string.Concat(d2FacePartsContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - eDistanceContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()"); - from = string.Concat(eDistanceContentDirectory, relativePath); - exists = Directory.Exists(eDistanceContentDirectory); - if (exists) - { - to = Path.Combine(string.Concat(eDistanceContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]"); - from = string.Concat(eDistanceCollectionDirectory, relativePath); - exists = Directory.Exists(eDistanceCollectionDirectory); - if (exists) - { - to = Path.Combine(string.Concat(eDistanceCollectionDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - g2IdentifyCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(G2_Identify), "[]"); - from = string.Concat(g2IdentifyCollectionDirectory, relativePath); - exists = Directory.Exists(g2IdentifyCollectionDirectory); - if (!exists && add && jsonFiles4InfoAny) - results.Add(new string[] { from }); - else if (exists) - { - to = Path.Combine(string.Concat(g2IdentifyCollectionDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName); - results.Add(new string[] { from, to }); - } - } - return results; - } - - internal void DirectoryRename(Property.Models.Configuration configuration, string relativePath, string newDirectoryName) - { - string json; - FileInfo current; - FileInfo fileInfo; - string error = "Error"; - string target = "Target"; - string pending = "Pending"; - DirectoryInfo directoryInfo; - IEnumerator fileInfoCollection; - string oldValue = string.Concat("\"", relativePath); - string oldDirectoryName = Path.GetFileName(relativePath); - string traceFileName = string.Concat(DateTime.Now.Ticks, ".tsv"); - string directoryName = Path.GetFileName(_Configuration.PropertyConfiguration.RootDirectory); - string? relativePathParent = Path.GetDirectoryName(relativePath); - if (string.IsNullOrEmpty(relativePathParent)) - throw new Exception(); - string newValue = string.Concat("\"", Path.Combine(relativePathParent, newDirectoryName)); - string e3RenameContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(E3_Rename), "()"); - string jsonRootDirectory = Path.Combine(string.Concat(_Configuration.PropertyConfiguration.RootDirectory, " - Copied"), string.Concat(directoryName, " - 4) Info"), _Configuration.PropertyConfiguration.DateGroup, "[]"); - directoryInfo = new DirectoryInfo(jsonRootDirectory); - if (!directoryInfo.Exists) - directoryInfo.Create(); - IEnumerator fileInfoCollection4 = directoryInfo.EnumerateFiles("*.json", SearchOption.AllDirectories).GetEnumerator(); - bool fileInfoCollection4MoveNext = fileInfoCollection4.MoveNext(); - if (!fileInfoCollection4MoveNext) - current = new(string.Empty); - else - current = fileInfoCollection4.Current; - List directoryCollections = GetDirectoryRenameCollections(configuration, relativePath, newDirectoryName, fileInfoCollection4MoveNext); - if ((from l in directoryCollections where l.Length != 2 select true).Any()) - throw new Exception(); - if (!Directory.Exists(e3RenameContentDirectory)) - { - _ = Directory.CreateDirectory(e3RenameContentDirectory); - _ = Directory.CreateDirectory(Path.Combine(e3RenameContentDirectory, error)); - _ = Directory.CreateDirectory(Path.Combine(e3RenameContentDirectory, target)); - _ = Directory.CreateDirectory(Path.Combine(e3RenameContentDirectory, "Test")); - _ = Directory.CreateDirectory(Path.Combine(e3RenameContentDirectory, pending)); - } - string fRandomSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(F_Random), "{}"); - string[] files = Directory.GetFiles(fRandomSingletonDirectory, "*", SearchOption.TopDirectoryOnly); - foreach (string file in files) - File.Delete(file); - File.WriteAllText(Path.Combine(e3RenameContentDirectory, pending, traceFileName), string.Concat(relativePath, newDirectoryName, Environment.NewLine)); - try - { - foreach (string[] directoryCollection in directoryCollections) - { - directoryInfo = new DirectoryInfo(directoryCollection[0]); - if (!directoryInfo.Exists) - continue; - fileInfoCollection = directoryInfo.EnumerateFiles("*.json", SearchOption.AllDirectories).GetEnumerator(); - for (int i = 0; i < int.MaxValue; i++) - { - if (fileInfoCollection.MoveNext()) - fileInfo = fileInfoCollection.Current; - else if (fileInfoCollection4MoveNext && fileInfoCollection4.MoveNext()) - fileInfo = fileInfoCollection4.Current; - else if (fileInfoCollection4MoveNext && current is not null) - { - fileInfo = current; - current = new(string.Empty); - } - else - break; - json = Shared.Models.Stateless.Methods.IIndex.GetJson(fileInfo.FullName, fileInfo); - if (json.Contains(oldValue)) - { - json = json.Replace(oldValue, newValue); - if (!Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches: true, compareBeforeWrite: true)) - continue; - File.SetLastWriteTime(fileInfo.FullName, fileInfo.LastWriteTime); - } - } - Directory.Move(directoryCollection[0], directoryCollection[1]); - } - File.Move(Path.Combine(e3RenameContentDirectory, pending, traceFileName), Path.Combine(e3RenameContentDirectory, target, traceFileName)); - } - catch (Exception) - { - File.Move(Path.Combine(e3RenameContentDirectory, pending, traceFileName), Path.Combine(e3RenameContentDirectory, error, traceFileName)); - throw; - } - } - - internal void RenameQueue(Property.Models.Configuration configuration) - { - string[] lines; - string[] segments; - string e3RenameContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(E3_Rename), "()"); - string[] files = Directory.GetFiles(e3RenameContentDirectory, "*.tsv", SearchOption.TopDirectoryOnly); - foreach (string file in files) - { - lines = File.ReadAllLines(file); - foreach (string line in lines) - { - if (string.IsNullOrEmpty(line) || !line.Contains('\t')) - continue; - segments = line.Split('\t'); - if (segments.Length != 2) - throw new Exception(); - DirectoryRename(configuration, segments[0], segments[1]); - } - } - } - -} \ No newline at end of file diff --git a/Instance/Models/_G2_Identify.cs b/Instance/Models/_G2_Identify.cs deleted file mode 100644 index f7a71c5..0000000 --- a/Instance/Models/_G2_Identify.cs +++ /dev/null @@ -1,234 +0,0 @@ -using Phares.Shared; -using System.Text.Json; -using System.Text.Json.Serialization; -using View_by_Distance.Shared.Models; -using View_by_Distance.Shared.Models.Methods; - -namespace View_by_Distance.Instance.Models; - -/// -// List -/// -public class G2_Identify : Shared.Models.Properties.IIdentify, IIdentify -{ - - protected int _DirectoryCount; - protected string _ParentDirectoryName; - protected string _Person; - protected string _PossibleYear; - protected string _RelativePath; - public int DirectoryCount => _DirectoryCount; - public string ParentDirectoryName => _ParentDirectoryName; - public string Person => _Person; - public string PossibleYear => _PossibleYear; - public string RelativePath => _RelativePath; - - private readonly Serilog.ILogger? _Log; - private readonly Configuration _Configuration; - private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions; - -#nullable disable - [JsonConstructor] - public G2_Identify(int directoryCount, string parentDirectoryName, string person, string possibleYear, string relativePath) - { - _DirectoryCount = directoryCount; - _ParentDirectoryName = parentDirectoryName; - _Person = person; - _PossibleYear = possibleYear; - _RelativePath = relativePath; - } - - internal G2_Identify(Configuration configuration) - { - _DirectoryCount = 0; - _ParentDirectoryName = string.Empty; - _Person = string.Empty; - _PossibleYear = string.Empty; - _RelativePath = string.Empty; - _Configuration = configuration; - _Log = Serilog.Log.ForContext(); - _WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true }; - } - - public override string ToString() - { - string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); - return result; - } - - private FileInfo GetNamed() - { - FileInfo result; - string[] jsonFiles = Directory.GetFiles(_Configuration.PropertyConfiguration.RootDirectory, "*Named*.json", SearchOption.TopDirectoryOnly); - if (!jsonFiles.Any()) - result = null; - else - result = new FileInfo(jsonFiles[0]); - return result; - } - - private void CheckLastWriteTimes(IsEnvironment isEnvironment, string facesFileNameExtension, FileInfo named, string g2IdentifySingletonDirectory) - { - string json; - FileInfo fileInfo; - DateTime dateTime = DateTime.MinValue; - string[] jsonFiles = Directory.GetFiles(g2IdentifySingletonDirectory, "*.json", SearchOption.AllDirectories); - foreach (string jsonFile in jsonFiles) - { - fileInfo = new(jsonFile); - if (dateTime < fileInfo.LastWriteTime) - dateTime = fileInfo.LastWriteTime; - } - if (named.LastWriteTime > dateTime) - { - if (!isEnvironment.DebuggerWasAttachedDuringConstructor) - throw new Exception("Only allowed when debugger is attached during constructor!"); - foreach (string file in jsonFiles) - File.Delete(file); - } - json = File.ReadAllText(named.FullName); - Dictionary resultKeyValuePairs = new(); - string rootDirectory = _Configuration.PropertyConfiguration.RootDirectory; - string peopleRootDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A2_People)); - string rootResultsDirectory = Path.GetDirectoryName(Path.GetDirectoryName(peopleRootDirectory)); - if (rootResultsDirectory is null) - throw new Exception(); - Storage storage = new(rootDirectory, rootResultsDirectory, peopleRootDirectory); - PersonContainer[] personContainers = Shared.Models.Stateless.Methods.IPersonContainer.GetPersonContainers(storage, _Configuration.PersonBirthdayFormat, _Configuration.PersonCharacters.ToArray(), facesFileNameExtension); - string[] peopleBirthDates = (from l in personContainers select Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, l.Person.Birthday)).ToArray(); - Dictionary sourceKeyValuePairs = JsonSerializer.Deserialize>(json); - foreach (KeyValuePair keyValuePair in sourceKeyValuePairs) - { - if (!(from l in keyValuePair.Value where peopleBirthDates.Contains(l) select false).Any()) - continue; - resultKeyValuePairs.Add(keyValuePair.Key, keyValuePair.Value); - } - if (resultKeyValuePairs.Count != sourceKeyValuePairs.Count) - { - json = JsonSerializer.Serialize(resultKeyValuePairs, _WriteIndentedJsonSerializerOptions); - if (!isEnvironment.DebuggerWasAttachedDuringConstructor) - throw new Exception("Only allowed when debugger is attached during constructor!"); - _ = Shared.Models.Stateless.Methods.IPath.WriteAllText(named.FullName, json, updateDateWhenMatches: true, compareBeforeWrite: true); - } - } - - internal List GetIdentifiedCollection(IsEnvironment isEnvironment, Property.Models.Configuration configuration, string facesFileNameExtension) - { - List results = new(); - string json; - string[] people; - string[] jsonFiles; - int directoryCount; - string possibleYear; - G2_Identify identify; - FileInfo named = GetNamed(); - string testDirectoryFullName; - string checkDirectoryFullName; - Dictionary keyValuePairs; - List missing = new(); - List indices = new(); - string directoryName = Path.GetFileName(_Configuration.PropertyConfiguration.RootDirectory); - string g2IdentifySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(G2_Identify), "[]"); - string jsonRootDirectory = Path.Combine(string.Concat(_Configuration.PropertyConfiguration.RootDirectory, " - Copied"), string.Concat(directoryName, " - 4) Info"), _Configuration.PropertyConfiguration.DateGroup, "[]"); - if (named is not null && named.Exists) - CheckLastWriteTimes(isEnvironment, facesFileNameExtension, named, g2IdentifySingletonDirectory); - if (Directory.Exists(jsonRootDirectory)) - { - jsonFiles = Directory.GetFiles(jsonRootDirectory, "*.json", SearchOption.AllDirectories); - for (int i = 0; i < jsonFiles.Length; i++) - { - json = Shared.Models.Stateless.Methods.IIndex.GetJson(jsonFiles[i], fileInfo: null); - indices.AddRange(JsonSerializer.Deserialize>(json)); - } - if (named is not null && named.Exists) - { - json = File.ReadAllText(named.FullName); - keyValuePairs = JsonSerializer.Deserialize>(json); - foreach (G_Index index in indices) - { - if (index?.Index is null) - continue; - if (!keyValuePairs.ContainsKey(index.Index.Value)) - { - missing.Add(index.Index.Value.ToString()); - continue; - } - if (index.RelativePaths is null) - { - missing.Add(index.Index.Value.ToString()); - continue; - } - people = keyValuePairs[index.Index.Value]; - foreach (string relativePath in index.RelativePaths) - { - foreach (string person in people) - { - directoryCount = 0; - checkDirectoryFullName = string.Concat(_Configuration.PropertyConfiguration.RootDirectory, relativePath); - for (int i = 0; i < int.MaxValue; i++) - { - testDirectoryFullName = Path.GetDirectoryName(checkDirectoryFullName); - if (testDirectoryFullName == _Configuration.PropertyConfiguration.RootDirectory) - break; - directoryCount += 1; - checkDirectoryFullName = testDirectoryFullName; - } - possibleYear = checkDirectoryFullName.Split(' ').Last(); - if (possibleYear.Length != 4) - possibleYear = "0000"; - identify = new G2_Identify(directoryCount, Path.GetFileName(checkDirectoryFullName), person, possibleYear, relativePath); - results.Add(identify); - } - } - } - } - } - results = (from l in results orderby l.PossibleYear descending, l.DirectoryCount, l.ParentDirectoryName, l.RelativePath select l).ToList(); - return results; - } - - internal void WriteAllText(Property.Models.Configuration configuration, string outputResolution, List identifiedCollection) - { - string key; - string json; - string jsonFile; - string directoryFullName; - string fileNameWithoutExtension; - string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(Property.Models.A_Property), "{}"); - string g2IdentifyCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(G2_Identify), "[]"); - Dictionary>> keyValuePairs = new(); - foreach (G2_Identify identified in identifiedCollection) - { - key = Path.GetDirectoryName(identified.RelativePath); - if (!keyValuePairs.ContainsKey(key)) - keyValuePairs.Add(key, new List>()); - keyValuePairs[key].Add(new KeyValuePair(identified.RelativePath, identified.Person)); - } - foreach (KeyValuePair>> keyValuePair in keyValuePairs) - { - directoryFullName = string.Concat(aPropertySingletonDirectory, keyValuePair.Key); - if (!Directory.Exists(directoryFullName)) - continue; - foreach (KeyValuePair keyValue in keyValuePair.Value) - { - fileNameWithoutExtension = Path.GetFileNameWithoutExtension(keyValue.Key); - jsonFile = Path.Combine(directoryFullName, $"{fileNameWithoutExtension}.json"); - if (!File.Exists(jsonFile)) - { - directoryFullName = string.Empty; - break; - } - } - if (string.IsNullOrEmpty(directoryFullName)) - continue; - directoryFullName = Path.GetDirectoryName(string.Concat(g2IdentifyCollectionDirectory, keyValuePair.Key)); - if (!Directory.Exists(directoryFullName)) - _ = Directory.CreateDirectory(directoryFullName); - jsonFile = string.Concat(g2IdentifyCollectionDirectory, keyValuePair.Key, ".json"); - json = JsonSerializer.Serialize(keyValuePair.Value, _WriteIndentedJsonSerializerOptions); - if (!Shared.Models.Stateless.Methods.IPath.WriteAllText(jsonFile, json, updateDateWhenMatches: true, compareBeforeWrite: true)) - continue; - } - } - -} \ No newline at end of file diff --git a/Instance/Models/_G_Index.cs b/Instance/Models/_G_Index.cs deleted file mode 100644 index a9e9bb1..0000000 --- a/Instance/Models/_G_Index.cs +++ /dev/null @@ -1,202 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using View_by_Distance.Shared.Models.Methods; - -namespace View_by_Distance.Instance.Models; - -/// -// G_Index && G_Index[] -/// -public class G_Index : Shared.Models.Properties.IIndex, IIndex -{ - - private readonly Serilog.ILogger? _Log; - private readonly Configuration _Configuration; - private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions; - - protected DateTime? _DateTime; - protected int? _Index; - protected List _RelativePaths; - public DateTime? DateTime => _DateTime; - public int? Index => _Index; - public List RelativePaths => _RelativePaths; - -#nullable disable - [JsonConstructor] - public G_Index(DateTime? dateTime, int? index, List relativePaths) - { - _DateTime = dateTime; - _Index = index; - _RelativePaths = relativePaths; - } - - internal G_Index() - { - _DateTime = null; - _Index = null; - _RelativePaths = new(); - } - - internal G_Index(Configuration configuration) - { - _Configuration = configuration; - _Log = Serilog.Log.ForContext(); - _WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true }; - } - - public override string ToString() - { - string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); - return result; - } - - private G_Index GetIndexInfo(FileInfo fileInfo, List parseExceptions) - { - G_Index result; - List indices = new(); - string json = File.ReadAllText(fileInfo.FullName); - try - { - result = JsonSerializer.Deserialize(json); - } - catch (Exception) - { - result = null; - parseExceptions.Add(nameof(G_Index)); - } - if (_Configuration.MappedMaxIndex.HasValue && result.Index.HasValue && _Configuration.MappedMaxIndex.Value < result.Index.Value) - { - result = null; - File.Delete(fileInfo.FullName); - } - else if (result.Index is null) - result = null; - return result; - } - - private void WriteNeeded(List indices, List, string, Shared.Models.Property>> neededTuples) - { - string json; - DateTime dateTime; - Shared.Models.Property property; - G_Index indexInfo; - int maxIndexPlusOne; - DateTime?[] dateTimes; - if (indices.Any()) - maxIndexPlusOne = indices.Max() + 1; - else - { - maxIndexPlusOne = 1000000; - throw new Exception("Are you sure exception. Use debugger to step over."); - } - foreach (Tuple, string, Shared.Models.Property> tuple in neededTuples) - { - maxIndexPlusOne += 1; - property = tuple.Item3; - dateTimes = new DateTime?[] { property.CreationTime, property.LastWriteTime, property.DateTime, property.DateTimeDigitized, property.DateTimeOriginal, property.GPSDateStamp }; - dateTime = (from l in dateTimes where l.HasValue select l.Value).Min(); - indexInfo = new(dateTime, maxIndexPlusOne, tuple.Item1); - json = JsonSerializer.Serialize(indexInfo, _WriteIndentedJsonSerializerOptions); - if (!Shared.Models.Stateless.Methods.IPath.WriteAllText(tuple.Item2, json, updateDateWhenMatches: true, compareBeforeWrite: true)) - continue; - } - } - - private void WriteGroup(Property.Models.Configuration configuration, string outputResolution, List>> indexInfoTuples) - { - string json; - G_Index[] indices; - List directoryInfoCollection; - foreach (Tuple> tuple in indexInfoTuples) - { - indices = (from l in tuple.Item2 select l.Value).ToArray(); - directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration, tuple.Item1, nameof(G_Index), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false, contentDescription: string.Empty, singletonDescription: string.Empty, collectionDescription: "Unknown A"); - json = JsonSerializer.Serialize(indices, _WriteIndentedJsonSerializerOptions); - if (!Shared.Models.Stateless.Methods.IPath.WriteAllText(string.Concat(directoryInfoCollection[0].Replace("<>", "[]"), ".json"), json, updateDateWhenMatches: true, compareBeforeWrite: true)) - continue; - } - } - - private void AppendTSV(Property.Models.Configuration configuration, string outputResolution, Dictionary>> filePropertiesKeyValuePairs) - { - Shared.Models.Property property; - DateTime?[] dateTimes; - DateTime? maximumDateTime; - DateTime? minimumDateTime; - List directoryInfoCollection; - long ticks = System.DateTime.Now.Ticks; - foreach (KeyValuePair>> tuples in filePropertiesKeyValuePairs) - { - maximumDateTime = null; - minimumDateTime = null; - foreach (Tuple tuple in tuples.Value) - { - property = tuple.Item2; - dateTimes = new DateTime?[] { maximumDateTime, minimumDateTime, property.CreationTime, property.LastWriteTime, property.DateTime, property.DateTimeDigitized, property.DateTimeOriginal, property.GPSDateStamp }; - maximumDateTime = (from l in dateTimes where l.HasValue select l.Value).Max(); - minimumDateTime = (from l in dateTimes where l.HasValue select l.Value).Min(); - } - directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration, tuples.Key, nameof(G_Index), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false, contentDescription: string.Empty, singletonDescription: "Unkown B", collectionDescription: string.Empty); - } - } - - internal void SetIndex(Property.Models.Configuration configuration, string outputResolution) - { - Dictionary>> filePropertiesKeyValuePairs = new(); - FileInfo fileInfo; - G_Index indexInfo; - List indices = new(); - Dictionary valuePairs; - List directoryInfoCollection; - List parseExceptions = new(); - List, string, Shared.Models.Property>> neededTuples = new(); - List>> indexInfoTuples = new(); - for (short i = 0; i < short.MaxValue; i++) - { - if (i != 0) - { - if (!neededTuples.Any() && !parseExceptions.Any()) - break; - indices.Clear(); - indexInfoTuples.Clear(); - parseExceptions.Clear(); - } - neededTuples.Clear(); - foreach (KeyValuePair>> tuples in filePropertiesKeyValuePairs) - { - valuePairs = new Dictionary(); - directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration, tuples.Key, nameof(G_Index), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false, contentDescription: string.Empty, singletonDescription: "Unknown C", collectionDescription: string.Empty); - foreach (Tuple tuple in tuples.Value) - { - fileInfo = new FileInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "{}"), string.Concat(Path.GetFileNameWithoutExtension(tuple.Item1), ".json"))); - if (_Configuration.PropertiesChangedForIndex) - indexInfo = null; - else if (!fileInfo.Exists) - indexInfo = null; - else - indexInfo = GetIndexInfo(fileInfo, parseExceptions); - if (indexInfo?.Index is not null) - { - indices.Add(indexInfo.Index.Value); - valuePairs.Add(indexInfo.Index.Value, indexInfo); - } - else - neededTuples.Add(new Tuple, string, Shared.Models.Property>(new List { tuple.Item1 }, fileInfo.FullName, tuple.Item2)); - } - indexInfoTuples.Add(new Tuple>(tuples.Key, valuePairs)); - } - if (_Configuration.MappedMaxIndex.HasValue) - break; - WriteNeeded(indices, neededTuples); - } - if (parseExceptions.Any()) - throw new Exception(string.Join(Environment.NewLine, parseExceptions)); - if (neededTuples.Any()) - throw new Exception(); - WriteGroup(configuration, outputResolution, indexInfoTuples); - AppendTSV(configuration, outputResolution, filePropertiesKeyValuePairs); - } - - string Shared.Models.Stateless.Methods.IIndex.TestStatic_GetJson(string jsonFileFullName, FileInfo fileInfo) => throw new NotImplementedException(); - -} \ No newline at end of file diff --git a/Instance/appsettings.json b/Instance/appsettings.json index e780ead..93f488d 100644 --- a/Instance/appsettings.json +++ b/Instance/appsettings.json @@ -68,10 +68,8 @@ "ForceMetadataLastWriteTimeToCreationTime": false, "ForcePropertyLastWriteTimeToCreationTime": false, "ForceResizeLastWriteTimeToCreationTime": false, - "LoadOrCreateThenSaveIndex": false, "LocationDigits": 9, "LocationFactor": 10000, - "MappedMaxIndex": 1034720, "MappingDefaultName": "John Doe~25", "MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping": false, "MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping": false, diff --git a/Not-Copy-Copy/.vscode/format-report.json b/Not-Copy-Copy/.vscode/format-report.json deleted file mode 100644 index 0637a08..0000000 --- a/Not-Copy-Copy/.vscode/format-report.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/Not-Copy-Copy/.vscode/launch.json b/Not-Copy-Copy/.vscode/launch.json deleted file mode 100644 index c3363e6..0000000 --- a/Not-Copy-Copy/.vscode/launch.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/bin/Debug/net7.0/win-x64/Not-Copy-Copy.dll", - "args": [], - "env": { - "ASPNETCORE_ENVIRONMENT": "Development", - }, - "cwd": "${workspaceFolder}", - // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console - "console": "externalTerminal", - "stopAtEntry": false - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processName": "Not-Copy-Copy" - } - ] -} \ No newline at end of file diff --git a/Not-Copy-Copy/.vscode/settings.json b/Not-Copy-Copy/.vscode/settings.json deleted file mode 100644 index 09ac856..0000000 --- a/Not-Copy-Copy/.vscode/settings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "cSpell.words": [ - "Barrick", - "Beichler", - "Bohdi", - "Dlib", - "Phares", - "Serilog", - "Vericruz" - ] -} \ No newline at end of file diff --git a/Not-Copy-Copy/.vscode/tasks.json b/Not-Copy-Copy/.vscode/tasks.json deleted file mode 100644 index 0154bfa..0000000 --- a/Not-Copy-Copy/.vscode/tasks.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "process", - "args": [ - "build", - "${workspaceFolder}/Not-Copy-Copy.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "publish", - "command": "dotnet", - "type": "process", - "args": [ - "publish", - "${workspaceFolder}/Not-Copy-Copy.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "watch", - "command": "dotnet", - "type": "process", - "args": [ - "watch", - "run", - "${workspaceFolder}/Not-Copy-Copy.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file diff --git a/Not-Copy-Copy/Models/AppSettings.cs b/Not-Copy-Copy/Models/AppSettings.cs deleted file mode 100644 index 2c8fe49..0000000 --- a/Not-Copy-Copy/Models/AppSettings.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace View_by_Distance.Not.Copy.Copy.Models; - -public class AppSettings -{ - - public string Company { init; get; } - public int MaxDegreeOfParallelism { init; get; } - public string WorkingDirectoryName { init; get; } - - [JsonConstructor] - public AppSettings(string company, int maxDegreeOfParallelism, string workingDirectoryName) - { - Company = company; - MaxDegreeOfParallelism = maxDegreeOfParallelism; - WorkingDirectoryName = workingDirectoryName; - } - - public override string ToString() - { - string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); - return result; - } - -} \ No newline at end of file diff --git a/Not-Copy-Copy/Models/Binder/AppSettings.cs b/Not-Copy-Copy/Models/Binder/AppSettings.cs deleted file mode 100644 index 6aa9ef0..0000000 --- a/Not-Copy-Copy/Models/Binder/AppSettings.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.Extensions.Configuration; -using System.Text.Json; - -namespace View_by_Distance.Not.Copy.Copy.Models.Binder; - -public class AppSettings -{ - -#nullable disable - - public string Company { get; set; } - public int? MaxDegreeOfParallelism { get; set; } - public string WorkingDirectoryName { get; set; } - -#nullable restore - - public override string ToString() - { - string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); - return result; - } - - private static Models.AppSettings Get(AppSettings? appSettings) - { - Models.AppSettings result; - if (appSettings?.MaxDegreeOfParallelism is null) - throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism)); - result = new( - appSettings.Company, - appSettings.MaxDegreeOfParallelism.Value, - appSettings.WorkingDirectoryName - ); - return result; - } - - public static Models.AppSettings Get(IConfigurationRoot configurationRoot) - { - Models.AppSettings result; - AppSettings? appSettings = configurationRoot.Get(); - result = Get(appSettings); - return result; - } - -} \ No newline at end of file diff --git a/Not-Copy-Copy/Models/Binder/Configuration.cs b/Not-Copy-Copy/Models/Binder/Configuration.cs deleted file mode 100644 index a7d231f..0000000 --- a/Not-Copy-Copy/Models/Binder/Configuration.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Text.Json; - -namespace View_by_Distance.Not.Copy.Copy.Models.Binder; - -public class Configuration -{ - -#nullable disable - - [Display(Name = "Compare Source"), Required] public string CompareSource { get; set; } - [Display(Name = "Empty Destination"), Required] public string EmptyDestination { get; set; } - [Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; } - [Display(Name = "Selected Source"), Required] public string SelectedSource { get; set; } - -#nullable restore - - public override string ToString() - { - string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); - return result; - } - -} \ No newline at end of file diff --git a/Not-Copy-Copy/Models/Configuration.cs b/Not-Copy-Copy/Models/Configuration.cs deleted file mode 100644 index 11b2458..0000000 --- a/Not-Copy-Copy/Models/Configuration.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace View_by_Distance.Not.Copy.Copy.Models; - -public class Configuration -{ - - protected string _CompareSource; - protected string _EmptyDestination; - protected Property.Models.Configuration _PropertyConfiguration; - protected string _SelectedSource; - public string CompareSource => _CompareSource; - public string EmptyDestination => _EmptyDestination; - public Property.Models.Configuration PropertyConfiguration => _PropertyConfiguration; - public string SelectedSource => _SelectedSource; - - [JsonConstructor] - public Configuration(string compareSource, string emptyDestination, Property.Models.Configuration propertyConfiguration, string selectedSource) - { - _CompareSource = compareSource; - _EmptyDestination = emptyDestination; - _PropertyConfiguration = propertyConfiguration; - _SelectedSource = selectedSource; - } - - public override string ToString() - { - string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); - return result; - } - - public void Set(Property.Models.Configuration configuration) => _PropertyConfiguration = configuration; - - public void SetAndUpdate(Property.Models.Configuration configuration) - { - _PropertyConfiguration.Update(); - _CompareSource = Path.GetFullPath(_CompareSource); - _SelectedSource = Path.GetFullPath(_SelectedSource); - _EmptyDestination = Path.GetFullPath(_EmptyDestination); - } - -} \ No newline at end of file diff --git a/Not-Copy-Copy/Models/Stateless/Configuration.cs b/Not-Copy-Copy/Models/Stateless/Configuration.cs deleted file mode 100644 index 88e8d0b..0000000 --- a/Not-Copy-Copy/Models/Stateless/Configuration.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Phares.Shared; -using System.Text.Json; - -namespace View_by_Distance.Not.Copy.Copy.Models.Stateless; - -public abstract class Configuration -{ - - public static Models.Configuration Get(IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, string workingDirectory, Property.Models.Configuration propertyConfiguration) - { - Models.Configuration? result; - string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment); - string section = string.Concat(environmentName, ":", nameof(Binder.Configuration)); - IConfigurationSection configurationSection = configurationRoot.GetSection(section); - Binder.Configuration? configuration = configurationSection.Get(); - string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true }); - result = JsonSerializer.Deserialize(json); - if (result is null) - throw new Exception(json); - string jsonThis = result.ToString(); - result.SetAndUpdate(propertyConfiguration); - if (jsonThis != json) - { - int? check = null; - int min = new int[] { json.Length, jsonThis.Length }.Min(); - for (int i = 0; i < min; i++) - { - if (json[i] == jsonThis[i]) - continue; - check = i; - break; - } - if (check is null) - throw new Exception(); - string a = json[..check.Value].Split(',')[^1]; - string b = json[check.Value..].Split(',')[0]; - throw new Exception($"{a}{b}"); - } - return result; - } - -} \ No newline at end of file diff --git a/Not-Copy-Copy/Models/Stateless/SerilogExtensionMethods.cs b/Not-Copy-Copy/Models/Stateless/SerilogExtensionMethods.cs deleted file mode 100644 index ae89478..0000000 --- a/Not-Copy-Copy/Models/Stateless/SerilogExtensionMethods.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace View_by_Distance.Not.Copy.Copy.Models.Stateless; - -public static class SerilogExtensionMethods -{ - - internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate); - - internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate); - -} \ No newline at end of file diff --git a/Not-Copy-Copy/Not-Copy-Copy.cs b/Not-Copy-Copy/Not-Copy-Copy.cs deleted file mode 100644 index 80a36b5..0000000 --- a/Not-Copy-Copy/Not-Copy-Copy.cs +++ /dev/null @@ -1,148 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Phares.Shared; -using View_by_Distance.Not.Copy.Copy.Models; -using View_by_Distance.Property.Models; -using View_by_Distance.Shared.Models.Methods; - -namespace View_by_Distance.Not.Copy.Copy; - -public class NotCopyCopy -{ - - private readonly Serilog.ILogger? _Log; - private readonly AppSettings _AppSettings; - private readonly IsEnvironment _IsEnvironment; - private readonly Models.Configuration _Configuration; - - public NotCopyCopy(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console) - { - if (isSilent) - { } - if (args is null) - { } - if (console is null) - { } - _AppSettings = appSettings; - _IsEnvironment = isEnvironment; - _Log = Serilog.Log.ForContext(); - Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot); - Models.Configuration configuration = Models.Stateless.Configuration.Get(isEnvironment, configurationRoot, workingDirectory, propertyConfiguration); - _Log.Information(propertyConfiguration.RootDirectory); - Property.Models.Configuration.Verify(propertyConfiguration, requireExist: true); - Verify(configuration); - _Configuration = configuration; - if (!_IsEnvironment.Development) - throw new Exception("This program only allows development environments!"); - propertyConfiguration.ChangeRootDirectory(configuration.CompareSource); - string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property), "{}"); - (_, Shared.Models.Container[] compareContainers) = Shared.Models.Stateless.Methods.IContainer.GetContainers(propertyConfiguration, aPropertySingletonDirectory); - propertyConfiguration.ChangeRootDirectory(configuration.SelectedSource); - (_, Shared.Models.Container[] selectedContainers) = Shared.Models.Stateless.Methods.IContainer.GetContainers(propertyConfiguration, aPropertySingletonDirectory); - if (compareContainers.Length == selectedContainers.Length) - throw new Exception(); - string directoryName; - List distinct = new(); - List compareSourceGroupCollection = new(); - List selectedSourceGroupCollection = new(); - List<(string Source, string[] Destination)> copyCollection = GetCopyCollection(compareSourceGroupCollection, selectedSourceGroupCollection); - foreach ((string source, string[] destination) in copyCollection) - { - directoryName = Path.Combine(destination.Take(destination.Length - 1).ToArray()); - if (distinct.Contains(directoryName)) - continue; - distinct.Add(directoryName); - if (!Directory.Exists(directoryName)) - _ = Directory.CreateDirectory(directoryName); - } - _Log.Information($"Ready to copy {copyCollection.Count} file(s)?"); - for (int y = 0; y < int.MaxValue; y++) - { - _Log.Information("Press \"Y\" key to to copy file(s)"); - if (Console.ReadKey().Key == ConsoleKey.Y) - break; - } - _Log.Information(". . ."); - int copied = 0; - string fullFileName; - foreach ((string source, string[] destination) in copyCollection) - { - if (copied % 500 == 0) - _Log.Information($"{copied})"); - fullFileName = Path.Combine(destination); - if (File.Exists(fullFileName)) - continue; - File.Copy(source, fullFileName); - copied += 1; - } - _Log.Information($"{copied} file(s) copied"); - for (int y = 0; y < int.MaxValue; y++) - { - _Log.Information("Press \"Y\" key to continue or close console"); - if (Console.ReadKey().Key == ConsoleKey.Y) - break; - } - _Log.Information(". . ."); - } - - private static void Verify(Models.Configuration configuration) - { - if (Path.GetPathRoot(configuration.SelectedSource) == configuration.SelectedSource) - throw new NullReferenceException(nameof(configuration.SelectedSource)); - if (string.IsNullOrEmpty(configuration.CompareSource) || !Directory.Exists(configuration.CompareSource)) - throw new NullReferenceException(nameof(configuration.CompareSource)); - if (string.IsNullOrEmpty(configuration.EmptyDestination) || Directory.Exists(configuration.EmptyDestination)) - throw new NullReferenceException(nameof(configuration.EmptyDestination)); - if (string.IsNullOrEmpty(configuration.SelectedSource) || !Directory.Exists(configuration.SelectedSource)) - throw new NullReferenceException(nameof(configuration.SelectedSource)); - if (configuration.SelectedSource.Length != configuration.CompareSource.Length) - throw new NullReferenceException(nameof(configuration.SelectedSource)); - } - - private List<(string Source, string[] Destination)> GetCopyCollection(List compareSourceGroupCollection, List selectedSourceGroupCollection) - { - List<(string Source, string[] Destination)> results = new(); - if (_Configuration?.PropertyConfiguration is null) - throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration)); - string key; - string fileName; - string[] directoryNames; - string destinationDirectory; - Shared.Models.Property? property; - List destinationCollection; - string filteredSourceDirectoryFile; - Dictionary keyValuePairs = new(); - foreach (Property.Models.DirectoryInfo group in compareSourceGroupCollection) - { - for (int i = 0; i < group.SourceDirectoryFileHolderCollection.Length; i++) - { - property = group.PropertyCollection[i]; - if (property is null) - continue; - key = string.Concat(group.SourceDirectory[_Configuration.CompareSource.Length..], Path.GetFileName(group.FilteredSourceDirectoryFiles[i])); - keyValuePairs.Add(key, property); - } - } - foreach (Property.Models.DirectoryInfo group in selectedSourceGroupCollection) - { - for (int i = 0; i < group.SourceDirectoryFileHolderCollection.Length; i++) - { - destinationCollection = new(); - property = group.PropertyCollection[i]; - if (property is null) - continue; - filteredSourceDirectoryFile = group.FilteredSourceDirectoryFiles[i]; - fileName = Path.GetFileName(filteredSourceDirectoryFile); - key = string.Concat(group.SourceDirectory[_Configuration.SelectedSource.Length..], fileName); - if (keyValuePairs.ContainsKey(key) && keyValuePairs[key].LastWriteTime == property.LastWriteTime) - continue; - destinationDirectory = string.Concat(_Configuration.EmptyDestination, group.SourceDirectory[_Configuration.SelectedSource.Length..]); - directoryNames = Shared.Models.Stateless.Methods.IPath.GetDirectoryNames(destinationDirectory); - destinationCollection.AddRange(directoryNames); - destinationCollection.Add(fileName); - results.Add(new(filteredSourceDirectoryFile, destinationCollection.ToArray())); - } - } - return results; - } - -} \ No newline at end of file diff --git a/Not-Copy-Copy/Not-Copy-Copy.csproj b/Not-Copy-Copy/Not-Copy-Copy.csproj deleted file mode 100644 index b0c3e82..0000000 --- a/Not-Copy-Copy/Not-Copy-Copy.csproj +++ /dev/null @@ -1,59 +0,0 @@ - - - enable - 10.0 - enable - Exe - win-x64 - net7.0 - - - Phares.View.by.Distance.Not.Copy.Copy - false - 7.0.101.1 - Mike Phares - Phares - true - snupkg - - - true - true - true - - - Windows - - - OSX - - - Linux - - - - - - - - - - - - - - - - - - - - - - - - - Always - - - \ No newline at end of file diff --git a/Not-Copy-Copy/Program.cs b/Not-Copy-Copy/Program.cs deleted file mode 100644 index 1703672..0000000 --- a/Not-Copy-Copy/Program.cs +++ /dev/null @@ -1,126 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Phares.Shared; -using Serilog; -using System.Diagnostics; -using System.Reflection; -using View_by_Distance.Not.Copy.Copy.Models; -using View_by_Distance.Shared.Models.Stateless.Methods; - -namespace View_by_Distance.Not.Copy.Copy; - -public class Program -{ - - public static void Secondary(List args) - { - LoggerConfiguration loggerConfiguration = new(); - Assembly assembly = Assembly.GetExecutingAssembly(); - bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug"); - IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero); - IConfigurationBuilder configurationBuilder = new ConfigurationBuilder() - .AddEnvironmentVariables() - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true); - IConfigurationRoot configurationRoot = configurationBuilder.Build(); - AppSettings appSettings = Models.Binder.AppSettings.Get(configurationRoot); - if (appSettings.MaxDegreeOfParallelism > Environment.ProcessorCount) - throw new Exception("MaxDegreeOfParallelism must be =< Environment.ProcessorCount!"); - if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName)) - throw new Exception("Working directory name must have a value!"); - string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName); - Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory); - _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot); - Log.Logger = loggerConfiguration.CreateLogger(); - ILogger log = Log.ForContext(); - int silentIndex = args.IndexOf("s"); - if (silentIndex > -1) - args.RemoveAt(silentIndex); - try - { - if (args is null) - throw new Exception("args is null!"); -#nullable disable - if (IProperty.IsWrongYear("-".Split(' '), "2021").Item1.HasValue) - throw new Exception("-"); - if (IProperty.IsWrongYear("Christmass".Split(' '), "2021").Item1.HasValue) - throw new Exception("Christmass"); - if (IProperty.IsWrongYear("Christmass 2021".Split(' '), "2021").Item1.Value) - throw new Exception("Christmass"); - if (IProperty.IsWrongYear("Christmass ~2021".Split(' '), "2021").Item1.Value) - throw new Exception("Christmass"); - if (IProperty.IsWrongYear("Christmass ~2021.4".Split(' '), "2021").Item1.Value) - throw new Exception("Christmass"); - if (!IProperty.IsWrongYear("Christmass 2021".Split(' '), "2025").Item1.Value) - throw new Exception("Christmass"); - if (!IProperty.IsWrongYear("Christmass ~2021".Split(' '), "2025").Item1.Value) - throw new Exception("Christmass"); - if (!IProperty.IsWrongYear("Christmass ~2021.4".Split(' '), "2025").Item1.Value) - throw new Exception("Christmass"); - if (IProperty.IsWrongYear("England 2017".Split(' '), "2017").Item1.Value) - throw new Exception("England"); - if (IProperty.IsWrongYear("Logan Michael".Split(' '), "2021").Item1.HasValue) - throw new Exception("Logan Michael"); - if (IProperty.IsWrongYear("Logan Michael 2021".Split(' '), "2021").Item1.Value) - throw new Exception("Logan Michael"); - if (IProperty.IsWrongYear("Logan Michael ~2021".Split(' '), "2021").Item1.Value) - throw new Exception("Logan Michael"); - if (IProperty.IsWrongYear("Logan Michael ~2021.4".Split(' '), "2021").Item1.Value) - throw new Exception("Logan Michael"); - if (!IProperty.IsWrongYear("Logan Michael 2021".Split(' '), "2025").Item1.Value) - throw new Exception("Logan Michael"); - if (!IProperty.IsWrongYear("Logan Michael ~2021".Split(' '), "2025").Item1.Value) - throw new Exception("Logan Michael"); - if (!IProperty.IsWrongYear("Logan Michael ~2021.4".Split(' '), "2025").Item1.Value) - throw new Exception("Logan Michael"); - if (IProperty.IsWrongYear("Logan Michael ~2021.4".Split(' '), "2021").Item2[0] != "~2021.4") - throw new Exception("Logan Michael"); - if (IProperty.IsWrongYear("Chelsea's 2nd Birthday =2014".Split(' '), "2014").Item1.Value) - throw new Exception("Chelsea"); -#nullable restore - if (IPath.GetDirectoryNames(@"C:\Tmp")[0] != @"C:\") - throw new Exception(); - if (IPath.GetDirectoryNames(@"C:\Tmp")[1] != "Tmp") - throw new Exception(); - if (IPath.GetDirectoryNames(@"C:\Tmp\mike.txt")[1] != "Tmp") - throw new Exception(); - if (IPath.GetDirectoryNames(@"C:\Tmp\a.txt")[1] != "Tmp") - throw new Exception(); - if (IPath.GetDirectoryNames(@"C:\Tmp\Mike\a.txt")[2] != "Mike") - throw new Exception(); - if (IPath.GetDirectoryNames(@"I:\Images 2019-06-08 - 34a9240ac28b52da97428d7725153a80a757ee6b - II\=2010.2 Summer\Dsc_8558.jpg")[0] != @"I:\") - throw new Exception(); - if (IPath.GetDirectoryNames(@"I:\Images 2019-06-08 - 34a9240ac28b52da97428d7725153a80a757ee6b - II\=2010.2 Summer\Dsc_8558.jpg")[1] != @"Images 2019-06-08 - 34a9240ac28b52da97428d7725153a80a757ee6b - II") - throw new Exception(); - if (IPath.GetDirectoryNames(@"I:\Images 2019-06-08 - 34a9240ac28b52da97428d7725153a80a757ee6b - II\=2010.2 Summer\Dsc_8558.jpg")[2] != @"=2010.2 Summer") - throw new Exception(); - if (IPath.GetDirectoryNames(@"I:\Images 2019-06-08 - 34a9240ac28b52da97428d7725153a80a757ee6b - II\=2010.2 Summer")[2] != @"=2010.2 Summer") - throw new Exception(); - Shared.Models.Console console = new(); - NotCopyCopy _ = new(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console); - } - catch (Exception ex) - { - log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace)); - } - finally - { - Log.CloseAndFlush(); - } - if (silentIndex > -1) - log.Debug("Done. Bye"); - else - { - log.Debug("Done. Press 'Enter' to end"); - _ = Console.ReadLine(); - } - } - - public static void Main(string[] args) - { - if (args is not null) - Secondary(args.ToList()); - else - Secondary(new List()); - } - -} \ No newline at end of file diff --git a/Not-Copy-Copy/appsettings.Development.json b/Not-Copy-Copy/appsettings.Development.json deleted file mode 100644 index 97c0bba..0000000 --- a/Not-Copy-Copy/appsettings.Development.json +++ /dev/null @@ -1,337 +0,0 @@ -{ - "Company": "Mike Phares", - "Linux": {}, - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Log4netProvider": "Debug", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "MaxDegreeOfParallelism": 6, - "Serilog": { - "Using": [ - "Serilog.Sinks.Console", - "Serilog.Sinks.File" - ], - "MinimumLevel": "Debug", - "WriteTo": [ - { - "Name": "Debug", - "Args": { - "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}" - } - }, - { - "Name": "Console", - "Args": { - "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}" - } - }, - { - "Name": "File", - "Args": { - "path": "%workingDirectory% - Log/log-.txt", - "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}", - "rollingInterval": "Hour" - } - } - ], - "Enrich": [ - "FromLogContext", - "WithMachineName", - "WithThreadId" - ], - "Properties": { - "Application": "Sample" - } - }, - "WorkingDirectoryName": "PharesApps", - "Windows": { - "Configuration": { - "DateGroup": "45f4401", - "FileNameDirectorySeparator": ".Z.", - "ForcePropertyLastWriteTimeToCreationTime": false, - "MaxImagesInDirectoryForTopLevelFirstPass": 10, - "Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]", - "PopulatePropertyId": false, - "PropertiesChangedForProperty": false, - "CompareSource": "E:/Images 2021-10-29 - 34a9240ac28b52da97428d7725153a80a757ee6b - III", - "SelectedSource": "E:/Images 2018-05-12 - b01d4763d8853b6d6057a3870b2723449726da75 - III", - "EmptyDestination": "E:/. Not-Copy-Copy/Images 2018-05-12 - b01d4763d8853b6d6057a3870b2723449726da75 - Not-Copy-Copy", - "WriteBitmapDataBytes": false, - "IgnoreExtensions": [ - ".gif", - ".GIF" - ], - "PropertyContentCollectionFiles": [], - "ValidImageFormatExtensions": [ - ".bmp", - ".BMP", - ".gif", - ".GIF", - ".jpeg", - ".JPEG", - ".jpg", - ".JPG", - ".png", - ".PNG", - ".tiff", - ".TIFF" - ], - "ValidMetadataExtensions": [ - ".3gp", - ".3GP", - ".avi", - ".AVI", - ".bmp", - ".BMP", - ".gif", - ".GIF", - ".ico", - ".ICO", - ".jpeg", - ".JPEG", - ".jpg", - ".JPG", - ".m4v", - ".M4V", - ".mov", - ".MOV", - ".mp4", - ".MP4", - ".mta", - ".MTA", - ".png", - ".PNG", - ".tiff", - ".TIFF" - ], - "VerifyToSeason": [ - ". 2000", - ". 2001", - ". 2002", - ". 2003", - ". 2004", - ". 2005", - ". 2006", - ". 2007", - ". 2008", - ". 2009", - ". 2010", - ". 2011", - ". 2012", - ". 2013", - ". 2014", - ". 2015", - ". 2016", - ". 2017", - ". 2018", - ". 2019", - ". 2020", - ". 2021", - ". 2022", - ". 2023", - ". 2024", - ". 2025", - ". 2026", - ". 2027", - ". 2028", - ". 2029", - "2000.0 Winter", - "2002.1 Spring", - "2002.4 Winter", - "2003.0 Winter", - "2003.1 Spring", - "2003.3 Fall", - "2003.4 Winter", - "2004.0 Winter", - "2005.1 Spring", - "2005.2 Summer", - "2005.3 Fall", - "2005.4 Winter", - "2006.0 Winter", - "2006.1 Spring", - "2006.3 Fall", - "2007.0 Winter", - "2007.2 Summer Logan Michael", - "2007.2 Summer", - "2007.3 Fall Logan Michael", - "2007.4 Winter Logan Michael", - "2008.0 Winter Logan Michael", - "2008.1 Spring Logan Michael", - "2008.2 Summer Logan Michael", - "2008.2 Summer", - "2008.3 Fall Logan Michael", - "2009.0 Winter Logan Michael", - "2009.0 Winter", - "2009.1 Spring Logan Michael", - "2009.1 Spring", - "2009.2 Summer Logan Michael", - "2009.2 Summer", - "2009.3 Fall Logan Michael", - "2009.3 Fall", - "2009.4 Winter Logan Michael", - "2009.4 Winter", - "2010.0 Winter Logan Michael", - "2010.0 Winter", - "2010.1 Spring Logan Michael", - "2010.1 Spring", - "2010.2 Summer", - "2010.3 Fall Logan Michael", - "2010.3 Fall", - "2010.4 Winter", - "2011.0 Winter", - "2011.1 Spring", - "2011.2 Summer", - "2011.3 Fall", - "2011.4 Winter", - "2012.0 Winter Chelsea 2012", - "2012.0 Winter Chelsea", - "2012.0 Winter", - "2012.1 Spring Chelsea", - "2012.1 Spring", - "2012.2 Summer Chelsea", - "2012.2 Summer", - "2012.3 Fall Chelsea", - "2012.3 Fall", - "2012.4 Winter Chelsea", - "2012.4 Winter", - "2013.0 Winter Chelsea 2013", - "2013.0 Winter Chelsea", - "2013.0 Winter", - "2013.1 Spring", - "2013.2 Summer Chelsea", - "2013.2 Summer", - "2013.3 Fall Chelsea", - "2013.3 Fall", - "2013.4 Winter", - "2014.0 Winter", - "2014.1 Spring", - "2014.2 Summer", - "2014.3 Fall", - "2014.4 Winter", - "2015.0 Winter", - "2015.1 Spring", - "2015.2 Summer", - "2015.3 Fall", - "2015.4 Winter", - "2016.0 Winter", - "2016.1 Spring", - "2016.2 Summer", - "2016.3 Fall", - "2016.4 Winter", - "2017.1 Spring", - "2017.2 Summer", - "2017.3 Fall", - "2017.4 Winter", - "2018.0 Winter", - "2018.1 Spring", - "2018.3 Fall", - "2018.4 Winter", - "2019.0 Winter", - "2019.1 Spring", - "2019.2 Summer", - "2019.3 Fall", - "2019.4 Winter", - "2020.0 Winter", - "2020.1 Spring", - "2020.2 Summer", - "2020.3 Fall", - "2020.4 Winter", - "2021.1 Spring", - "2021.2 Summer", - "2021.3 Fall", - "2021.4 Winter", - "2022.0 Winter", - "2022.1 Spring", - "Anthem 2015", - "April 2010", - "April 2013", - "December 2006", - "December 2010", - "Fall 2005", - "Fall 2015", - "Fall 2016", - "Fall 2017", - "Fall 2018", - "Fall 2019", - "Fall 2020", - "Fall 2021", - "February 2010", - "January 2015", - "July 2010", - "June 2010", - "Kids 2005", - "March 2013", - "May 2010", - "May 2011", - "May 2013", - "October 2005", - "October 2014", - "Spring 2013", - "Spring 2014", - "Spring 2016", - "Spring 2018", - "Spring 2019", - "Spring 2020", - "Summer 2011", - "Summer 2012", - "Summer 2013", - "Summer 2014", - "Summer 2015", - "Summer 2016", - "Summer 2017", - "Summer 2018", - "Summer 2020", - "Summer 2021", - "Winter 2015", - "Winter 2016", - "Winter 2017", - "Winter 2018", - "Winter 2019-2020", - "Winter 2020", - "zzz 2005.0 Winter Tracy Pictures", - "zzz 2005.1 Spring Tracy Pictures", - "zzz 2005.2 Summer Tracy Pictures", - "zzz 2005.3 Fall Tracy Pictures", - "zzz 2005.4 Winter Tracy Pictures", - "zzz 2006.1 Spring Tracy Pictures", - "zzz 2007.0 Winter Tracy Pictures", - "zzz 2007.2 Summer Tracy Pictures", - "zzz 2008.0 Winter Tracy Pictures", - "zzz 2008.2 Summer Tracy Pictures", - "zzz 2009.0 Winter Tracy Pictures", - "zzz 2009.2 Summer Tracy Pictures", - "zzz 2009.3 Fall Tracy Pictures", - "zzz 2009.4 Winter Tracy Pictures", - "zzz 2010.0 Winter Tracy Pictures", - "zzz 2010.1 Spring Tracy Pictures", - "zzz 2010.2 Summer Tracy Pictures", - "zzz 2010.3 Fall Tracy Pictures", - "zzz 2011.0 Winter Tracy Pictures", - "zzz 2011.1 Spring Tracy Pictures", - "zzz 2011.2 Summer Tracy Pictures", - "zzz 2011.3 Fall Tracy Pictures", - "zzz 2011.4 Winter Tracy Pictures", - "zzz 2012.0 Winter Tracy Pictures", - "zzz 2012.1 Spring Tracy Pictures", - "zzz 2012.2 Summer Tracy Pictures", - "zzz 2012.3 Fall Tracy Pictures", - "zzz 2012.4 Winter Tracy Pictures", - "zzz 2013.0 Winter Tracy Pictures", - "zzz 2013.1 Spring Tracy Pictures", - "zzz 2013.2 Summer Tracy Pictures", - "zzz 2013.3 Fall Tracy Pictures", - "zzz 2013.4 Winter Tracy Pictures", - "zzz 2014.0 Winter Tracy Pictures", - "zzz 2014.1 Spring Tracy Pictures", - "zzz 2014.2 Summer Tracy Pictures", - "zzz 2014.3 Fall Tracy Pictures", - "zzz 2014.4 Winter Tracy Pictures", - "zzz 2015.0 Winter Tracy Pictures" - ] - } - } -} \ No newline at end of file diff --git a/Property/Models/DirectoryInfo.cs b/Property/Models/DirectoryInfo.cs deleted file mode 100644 index 5a1d7b5..0000000 --- a/Property/Models/DirectoryInfo.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace View_by_Distance.Property.Models; - -public class DirectoryInfo -{ - - protected readonly Shared.Models.FileHolder[] _SourceDirectoryFileHolderCollection; - protected readonly string[] _FilteredSourceDirectoryFiles; - protected readonly int _G; - protected readonly bool[] _Moved; - protected readonly bool?[] _Changed; - protected readonly Shared.Models.Property?[] _PropertyCollection; - protected readonly FileInfo?[] _PropertyFileHolderCollection; - protected readonly int _R; - protected readonly string _SourceDirectory; - protected readonly bool[] _ValidImageFormatExtensionCollection; - protected readonly bool[] _WrongYear; - public Shared.Models.FileHolder[] SourceDirectoryFileHolderCollection => _SourceDirectoryFileHolderCollection; - [Obsolete($"Use {nameof(SourceDirectoryFileHolderCollection)}")] - public string[] FilteredSourceDirectoryFiles => _FilteredSourceDirectoryFiles; - public int G => _G; - public bool[] Moved => _Moved; - public bool?[] Changed => _Changed; - public Shared.Models.Property?[] PropertyCollection => _PropertyCollection; - public FileInfo?[] PropertyFileHolderCollection => _PropertyFileHolderCollection; - public int R => _R; - public string SourceDirectory => _SourceDirectory; - public bool[] ValidImageFormatExtensionCollection => _ValidImageFormatExtensionCollection; - public bool[] WrongYear => _WrongYear; - - public DirectoryInfo(int g, string sourceDirectory, string[] filteredSourceDirectoryFiles, int r) - { - int length = filteredSourceDirectoryFiles.Length; - _G = g; - _R = r; - _Changed = Array.Empty(); - _SourceDirectory = sourceDirectory; - _Moved = Enumerable.Repeat(false, length).ToArray(); - _WrongYear = Enumerable.Repeat(false, length).ToArray(); - _FilteredSourceDirectoryFiles = filteredSourceDirectoryFiles; - _ValidImageFormatExtensionCollection = Enumerable.Repeat(false, length).ToArray(); - _PropertyFileHolderCollection = Enumerable.Repeat(null, length).ToArray(); - _PropertyCollection = Enumerable.Repeat(null, length).ToArray(); - _SourceDirectoryFileHolderCollection = (from l in filteredSourceDirectoryFiles select new Shared.Models.FileHolder(l)).ToArray(); - - } - -} \ No newline at end of file diff --git a/Tests/Models/Binder/Configuration.cs b/Tests/Models/Binder/Configuration.cs index e7692c7..6a134aa 100644 --- a/Tests/Models/Binder/Configuration.cs +++ b/Tests/Models/Binder/Configuration.cs @@ -22,8 +22,6 @@ public class Configuration [Display(Name = "Julie Phares Copy Birthdays"), Required] public string[] JLinks { get; set; } [Display(Name = "Load Or Create Then Save Distance Results"), Required] public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; } [Display(Name = "Load Or Create Then Save Image Faces Results"), Required] public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; } - [Display(Name = "Load Or Create Then Save Index"), Required] public bool? LoadOrCreateThenSaveIndex { get; set; } - [Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; } [Display(Name = "Mixed Year Relative Paths"), Required] public string[] MixedYearRelativePaths { get; set; } [Display(Name = "Model Directory"), Required] public string ModelDirectory { get; set; } [Display(Name = "Model Name"), Required] public string ModelName { get; set; } @@ -85,8 +83,6 @@ public class Configuration throw new NullReferenceException(nameof(configuration.IgnoreRelativePaths)); configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ??= Array.Empty(); configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions ??= Array.Empty(); - if (configuration.LoadOrCreateThenSaveIndex is null) - throw new NullReferenceException(nameof(configuration.LoadOrCreateThenSaveIndex)); if (configuration.MixedYearRelativePaths is null) throw new NullReferenceException(nameof(configuration.MixedYearRelativePaths)); if (configuration.NumberOfJitters is null) @@ -141,8 +137,6 @@ public class Configuration configuration.JLinks, configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions, configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions, - configuration.LoadOrCreateThenSaveIndex.Value, - configuration.MappedMaxIndex, configuration.MixedYearRelativePaths, configuration.ModelDirectory, configuration.ModelName, diff --git a/Tests/Models/Configuration.cs b/Tests/Models/Configuration.cs index 4ef6376..fb12ee7 100644 --- a/Tests/Models/Configuration.cs +++ b/Tests/Models/Configuration.cs @@ -21,8 +21,6 @@ public class Configuration public string[] JLinks { init; get; } public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { init; get; } public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { init; get; } - public bool LoadOrCreateThenSaveIndex { init; get; } - public int? MappedMaxIndex { init; get; } public string[] MixedYearRelativePaths { init; get; } public string ModelDirectory { init; get; } public string ModelName { init; get; } @@ -64,8 +62,6 @@ public class Configuration string[] jLinks, string[] loadOrCreateThenSaveDistanceResultsForOutputResolutions, string[] loadOrCreateThenSaveImageFacesResultsForOutputResolutions, - bool loadOrCreateThenSaveIndex, - int? mappedMaxIndex, string[] mixedYearRelativePaths, string modelDirectory, string modelName, @@ -106,8 +102,6 @@ public class Configuration JLinks = jLinks; LoadOrCreateThenSaveDistanceResultsForOutputResolutions = loadOrCreateThenSaveDistanceResultsForOutputResolutions; LoadOrCreateThenSaveImageFacesResultsForOutputResolutions = loadOrCreateThenSaveImageFacesResultsForOutputResolutions; - LoadOrCreateThenSaveIndex = loadOrCreateThenSaveIndex; - MappedMaxIndex = mappedMaxIndex; MixedYearRelativePaths = mixedYearRelativePaths; ModelDirectory = modelDirectory; ModelName = modelName; diff --git a/TestsWithFaceRecognitionDotNet/Models/Binder/Configuration.cs b/TestsWithFaceRecognitionDotNet/Models/Binder/Configuration.cs index 4135e98..6f299c4 100644 --- a/TestsWithFaceRecognitionDotNet/Models/Binder/Configuration.cs +++ b/TestsWithFaceRecognitionDotNet/Models/Binder/Configuration.cs @@ -28,10 +28,8 @@ public class Configuration [Display(Name = "Julie Phares Copy Birthdays"), Required] public string[] JLinks { get; set; } [Display(Name = "Load Or Create Then Save Distance Results"), Required] public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; } [Display(Name = "Load Or Create Then Save Image Faces Results"), Required] public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; } - [Display(Name = "Load Or Create Then Save Index"), Required] public bool? LoadOrCreateThenSaveIndex { get; set; } [Display(Name = "Location Digits"), Required] public int? LocationDigits { get; set; } [Display(Name = "Location Factor"), Required] public int? LocationFactor { get; set; } - [Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; } [Display(Name = "Mapping Default Name"), Required] public string MappingDefaultName { get; set; } [Display(Name = "Mapping Use Deterministic Hash Code Unknown Face Key Value Pairs for Add to Mapping"), Required] public bool? MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { get; set; } [Display(Name = "Mapping Use Deterministic Hash Code Unknown Face Key Value Pairs for Save Mapping"), Required] public bool? MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping { get; set; } @@ -118,8 +116,6 @@ public class Configuration throw new NullReferenceException(nameof(configuration.IgnoreRelativePaths)); configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ??= Array.Empty(); configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions ??= Array.Empty(); - if (configuration.LoadOrCreateThenSaveIndex is null) - throw new NullReferenceException(nameof(configuration.LoadOrCreateThenSaveIndex)); if (configuration.LocationDigits is null) throw new NullReferenceException(nameof(configuration.LocationDigits)); if (configuration.LocationFactor is null) @@ -211,10 +207,8 @@ public class Configuration configuration.JLinks, configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions, configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions, - configuration.LoadOrCreateThenSaveIndex.Value, configuration.LocationDigits.Value, configuration.LocationFactor.Value, - configuration.MappedMaxIndex, configuration.MappingDefaultName, configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping.Value, configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping.Value, diff --git a/TestsWithFaceRecognitionDotNet/Models/Configuration.cs b/TestsWithFaceRecognitionDotNet/Models/Configuration.cs index 7327dfd..8df9a94 100644 --- a/TestsWithFaceRecognitionDotNet/Models/Configuration.cs +++ b/TestsWithFaceRecognitionDotNet/Models/Configuration.cs @@ -27,10 +27,8 @@ public class Configuration public string[] JLinks { init; get; } public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { init; get; } public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { init; get; } - public bool LoadOrCreateThenSaveIndex { init; get; } public int LocationDigits { init; get; } public int LocationFactor { init; get; } - public int? MappedMaxIndex { init; get; } public string MappingDefaultName { init; get; } public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { init; get; } public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping { init; get; } @@ -91,10 +89,8 @@ public class Configuration string[] jLinks, string[] loadOrCreateThenSaveDistanceResultsForOutputResolutions, string[] loadOrCreateThenSaveImageFacesResultsForOutputResolutions, - bool loadOrCreateThenSaveIndex, int locationDigits, int locationFactor, - int? mappedMaxIndex, string mappingDefaultName, bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping, bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping, @@ -154,10 +150,8 @@ public class Configuration JLinks = jLinks; LoadOrCreateThenSaveDistanceResultsForOutputResolutions = loadOrCreateThenSaveDistanceResultsForOutputResolutions; LoadOrCreateThenSaveImageFacesResultsForOutputResolutions = loadOrCreateThenSaveImageFacesResultsForOutputResolutions; - LoadOrCreateThenSaveIndex = loadOrCreateThenSaveIndex; LocationDigits = locationDigits; LocationFactor = locationFactor; - MappedMaxIndex = mappedMaxIndex; MappingDefaultName = mappingDefaultName; MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping; MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping; diff --git a/View-by-Distance-MKLink-Console.sln b/View-by-Distance-MKLink-Console.sln index cd38563..3bbd8f8 100644 --- a/View-by-Distance-MKLink-Console.sln +++ b/View-by-Distance-MKLink-Console.sln @@ -29,8 +29,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Map", "Map\Map.csproj", "{9 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata", "Metadata\Metadata.csproj", "{961D11A0-44C8-48CD-BEEE-A6E6903AE58F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Not-Copy-Copy", "Not-Copy-Copy\Not-Copy-Copy.csproj", "{BF81D265-36E3-4DCA-891B-A0D875C1E68A}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoPrism", "PhotoPrism\PhotoPrism.csproj", "{DF4B0776-E0E5-4220-8721-8D1E491FF263}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrepareForOld", "PrepareForOld\PrepareForOld.csproj", "{F73F9468-0139-4B05-99CE-C6C0403D03E5}"