From 75ec814c7c3283e8695d46be4c2da7c94f78d980 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Sun, 5 Feb 2023 09:33:49 -0700 Subject: [PATCH] Removed Comments --- .config/dotnet-tools.json | 12 + .vscode/launch.json | 3 +- Date-Group/DateGroup.cs | 59 -- Delete-By-Distinct/DeleteByDistinct.cs | 9 - FaceRecognitionDotNet/DisposableObject.cs | 30 - FaceRecognitionDotNet/Point.cs | 9 - Instance/DlibDotNet.cs | 13 - Map/Models/MapLogic.cs | 4 +- Map/Models/Stateless/MapLogic.cs | 3 +- PrepareForOld/PrepareForOld.cs | 606 +----------------- PrepareForOld/Program.cs | 2 - Property-Compare/Models/PropertyCompare.cs | 3 +- .../Models/PropertyCompareItem.cs | 25 +- .../Models/PropertyCompareLogic.cs | 542 +--------------- Property/Models/A_Property.cs | 7 +- Rename/Rename.cs | 12 +- Shared/Models/DirectoryFileSystem.cs | 12 +- Shared/Models/FaceFileSystem.cs | 12 +- Shared/Models/Marker.cs | 4 +- Shared/Models/Stateless/Methods/Location.cs | 4 +- .../Stateless/Methods/OutputResolution.cs | 13 +- 21 files changed, 27 insertions(+), 1357 deletions(-) create mode 100644 .config/dotnet-tools.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..92ebca3 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "deadcsharp": { + "version": "2.0.0", + "commands": [ + "dead-csharp" + ] + } + } +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index cbd086b..cba86c1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -397,4 +397,5 @@ // C:\Program Files\ImageMagick-7.1.0-Q16-HDRI>identify -format '%Q' "D:\7) Question\- - - Images\Mike Goolgle Photos 2014\-1507651551.jpg" // '98' // C:\Program Files\ImageMagick-7.1.0-Q16-HDRI>identify -format '%Q' "D:\7) Question\- - - Images\Mike Goolgle Photos 2014\197616258.jpg" -// '90' \ No newline at end of file +// '90' +// dotnet dead-csharp --inputs "**/*.cs" --excludes "**/obj/**" "**/I*.cs" "**/UnitTest*.cs" \ No newline at end of file diff --git a/Date-Group/DateGroup.cs b/Date-Group/DateGroup.cs index c6cb479..c97d61b 100644 --- a/Date-Group/DateGroup.cs +++ b/Date-Group/DateGroup.cs @@ -55,65 +55,6 @@ public class DateGroup if (true || appSettings.MaxDegreeOfParallelism < 2) ticks = LogDelta(ticks, nameof(Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories)); string destinationRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(propertyConfiguration, "Z) Moved"); - // string[] moveBackFileNames = Directory.GetFiles(destinationRoot, "*", SearchOption.AllDirectories); - // if (moveBackFileNames is not null) - // { - // string checkFile; - // string? directory; - // bool check = false; - // string directoryName; - // string checkDirectory; - // string moveBackFileNameWithExtension; - // foreach (string moveBackFileName in moveBackFileNames) - // { - // moveBackFileNameWithExtension = Path.GetFileName(moveBackFileName); - // foreach ((int g, string sourceDirectory, string[] sourceDirectoryFiles) in jsonCollection) - // { - // foreach (string sourceDirectoryFile in sourceDirectoryFiles) - // { - // check = false; - // if (!sourceDirectoryFile.Contains(moveBackFileNameWithExtension)) - // continue; - // directory = Path.GetDirectoryName(sourceDirectoryFile); - // if (directory is null) - // continue; - // directoryName = Path.GetFileName(directory); - // checkDirectory = Path.Combine(configuration.RootDirectory, directoryName); - // if (!Directory.Exists(checkDirectory)) - // continue; - // checkFile = Path.Combine(checkDirectory, moveBackFileNameWithExtension); - // if (File.Exists(checkFile)) - // continue; - // File.Move(moveBackFileName, checkFile); - // check = true; - // break; - // } - // if (check) - // break; - // } - // if (!check) - // continue; - // } - // // string destinationRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(propertyConfiguration, "Z) Moved"); - // // for (int i = 1; i < 10; i++) - // // _ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(destinationRoot); - // } - // string[] moveBackFileNames = Directory.GetFiles(aPropertySingletonDirectory, "*.jpg", SearchOption.AllDirectories); - // foreach (string moveBackFileName in moveBackFileNames) - // { - // string? directory = Path.GetDirectoryName(moveBackFileName); - // if (directory is null) - // continue; - // string directoryName = Path.GetFileName(directory); - // string moveBackFileNameWithExtension = Path.GetFileName(moveBackFileName); - // string checkDirectory = Path.Combine(configuration.RootDirectory, directoryName); - // if (!Directory.Exists(checkDirectory)) - // continue; - // string checkFile = Path.Combine(checkDirectory, moveBackFileNameWithExtension); - // if (File.Exists(checkFile)) - // continue; - // File.Move(moveBackFileName, checkFile); - // } string aResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property)); string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, "{}"); if (!Directory.Exists(aPropertySingletonDirectory)) diff --git a/Delete-By-Distinct/DeleteByDistinct.cs b/Delete-By-Distinct/DeleteByDistinct.cs index aeeaf95..8f6b8d1 100644 --- a/Delete-By-Distinct/DeleteByDistinct.cs +++ b/Delete-By-Distinct/DeleteByDistinct.cs @@ -65,31 +65,22 @@ public class DeleteByDistinct checkLength = 1; else checkLength = fileInfo.Length; - // checkLength = (long)Math.Round((double)(fileInfo.Length / 1000)); if (!fileSizeToCollection.TryGetValue(checkLength, out fileTicksToNames)) { fileSizeToCollection.Add(checkLength, new()); if (!fileSizeToCollection.TryGetValue(checkLength, out fileTicksToNames)) throw new Exception(); } - // if (!fileTicksToNames.TryGetValue(fileInfo.LastWriteTime.Ticks, out fileNames)) - // { - // fileTicksToNames.Add(fileInfo.LastWriteTime.Ticks, new()); - // if (!fileTicksToNames.TryGetValue(fileInfo.LastWriteTime.Ticks, out fileNames)) - // throw new Exception(); - // } if (appSettings.RecycleOption) checkTicks = 1; else checkTicks = new DateTime(ticks).Ticks; - // checkTicks = new DateTime(fileInfo.LastWriteTime.Year, fileInfo.LastWriteTime.Month, fileInfo.LastWriteTime.Day).Ticks; if (!fileTicksToNames.TryGetValue(checkTicks, out fileNames)) { fileTicksToNames.Add(checkTicks, new()); if (!fileTicksToNames.TryGetValue(checkTicks, out fileNames)) throw new Exception(); } - // checkName = fileInfo.Name[..10]; checkName = fileInfo.Name.ToLower().Replace(".jpeg", ".jpg"); if (fileNames.Contains(checkName)) deletedFiles.Add(file); diff --git a/FaceRecognitionDotNet/DisposableObject.cs b/FaceRecognitionDotNet/DisposableObject.cs index 1c9ed95..ac2a3c0 100644 --- a/FaceRecognitionDotNet/DisposableObject.cs +++ b/FaceRecognitionDotNet/DisposableObject.cs @@ -16,12 +16,6 @@ public abstract class DisposableObject : IDisposable { get; private set; - /* Unmerged change from project 'FaceRecognitionotNet(netstandard2.0)' - Before: - /// If this object is disposed, then is thrown. - After: - /// If this object is disposed, then is thrown. - */ } @@ -74,12 +68,6 @@ public abstract class DisposableObject : IDisposable public void Dispose() { GC.SuppressFinalize(this); - /* Unmerged change from project 'FaceRecognitionotNet(netstandard2.0)' - Before: - Dispose(true); - After: - Dispose(true); - */ Dispose(true); } @@ -93,32 +81,14 @@ public abstract class DisposableObject : IDisposable if (IsDisposed) { return; - /* Unmerged change from project 'FaceRecognitionotNet(netstandard2.0)' - Before: - IsDisposed = true; - After: - IsDisposed = true; - */ } IsDisposed = true; if (disposing) - /* Unmerged change from project 'FaceRecognitionotNet(netstandard2.0)' - Before: - DisposeManaged(); - After: - DisposeManaged(); - */ DisposeManaged(); - /* Unmerged change from project 'FaceRecognitionotNet(netstandard2.0)' - Before: - DisposeUnmanaged(); - After: - DisposeUnmanaged(); - */ DisposeUnmanaged(); } diff --git a/FaceRecognitionDotNet/Point.cs b/FaceRecognitionDotNet/Point.cs index a599ea9..993d70f 100644 --- a/FaceRecognitionDotNet/Point.cs +++ b/FaceRecognitionDotNet/Point.cs @@ -96,15 +96,6 @@ public struct Point : IEquatable /// The second structure to compare. /// true if and have different or coordinates; false if and have the same and coordinates. - /* Unmerged change from project 'FaceRecognition(netstandard2.0)' - Before: - public static bool operator !=(Point point1, Point point2) - { - return !(point1 == point2); - } - After: - public static bool operator !=(Point point1, Point point2) => !(point1 == point2); - */ public static bool operator !=(Point point1, Point point2) => !(point1 == point2); #endregion diff --git a/Instance/DlibDotNet.cs b/Instance/DlibDotNet.cs index 1b46bdd..7e8ca1b 100644 --- a/Instance/DlibDotNet.cs +++ b/Instance/DlibDotNet.cs @@ -534,7 +534,6 @@ public partial class DlibDotNet { total = 0; (cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory) = GetResultsFullGroupDirectories(outputResolution); - // _ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(dResultsFullGroupDirectory); for (int i = 0; i < containers.Length; i++) { container = containers[i]; @@ -584,18 +583,6 @@ public partial class DlibDotNet } _Log.Information(". . ."); } - // if (isSilent && container.SourceDirectory.EndsWith("Bohdi Ray 2016")) // 7#.1 - // break; - // if (isSilent && container.SourceDirectory.EndsWith("Halloween 2013")) // 12#.1 - // break; - // if (isSilent && container.SourceDirectory.EndsWith("zzz =2014.4 Winter Tracy Pictures")) // 30#.2 - // break; - // if (isSilent && container.SourceDirectory.EndsWith("=2009.0 Winter Logan Michael")) //34#.2 - // break; - // if (isSilent && container.SourceDirectory.EndsWith("Animal Kingdom")) //35#.3 - // break; - // if (isSilent && container.SourceDirectory.EndsWith("Texas 2015")) //46#.4 - // break; total += container.Items.Count; } } diff --git a/Map/Models/MapLogic.cs b/Map/Models/MapLogic.cs index df1ddf6..305ef09 100644 --- a/Map/Models/MapLogic.cs +++ b/Map/Models/MapLogic.cs @@ -1,4 +1,4 @@ -using Humanizer; +using Humanizer; using ShellProgressBar; using System.Collections.ObjectModel; using System.Text.Json; @@ -517,10 +517,8 @@ public class MapLogic : Shared.Models.Methods.IMapLogic facePartsDirectory = GetFacePartsDirectory(d2FacePartsContentDirectory, mapping.MappingFromItem); if (facePartsDirectory is null) continue; - // if (!isBySorting || mapping.MappingFromPerson is not null) checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}"); // else - // checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}-Source{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}"); shortcutFile = Path.Combine(personDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}.lnk"); hiddenFaceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesHiddenFileNameExtension}")); facePartsFileHolder = new(Path.Combine(facePartsDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacePartsFileNameExtension}")); diff --git a/Map/Models/Stateless/MapLogic.cs b/Map/Models/Stateless/MapLogic.cs index 8b5e51d..bb89d49 100644 --- a/Map/Models/Stateless/MapLogic.cs +++ b/Map/Models/Stateless/MapLogic.cs @@ -1,4 +1,4 @@ -using Humanizer; +using Humanizer; using ShellProgressBar; using View_by_Distance.Shared.Models; using View_by_Distance.Shared.Models.Stateless.Methods; @@ -439,7 +439,6 @@ internal abstract class MapLogic notMappedAndWithNamedPersonKeys.Add(personContainer); } results.AddRange(notMappedAndNotNamedPersonKeys); - // results.AddRange(notMappedAndWithNamedPersonKeys); return results; } diff --git a/PrepareForOld/PrepareForOld.cs b/PrepareForOld/PrepareForOld.cs index 27ad15a..fdaeab1 100644 --- a/PrepareForOld/PrepareForOld.cs +++ b/PrepareForOld/PrepareForOld.cs @@ -1,658 +1,54 @@ -// using Microsoft.Extensions.Configuration; -// using Phares.Shared; -// using System.Text.Json; -// using System.Text.RegularExpressions; -// using View_by_Distance.PrepareForOld.Models; -// using View_by_Distance.Shared.Models.Methods; - -// namespace View_by_Distance.PrepareForOld; + // public class PrepareForOld -// { -// private readonly Serilog.ILogger? _Log; -// private readonly AppSettings _AppSettings; -// private readonly List _Exceptions; -// private readonly IsEnvironment _IsEnvironment; -// private readonly Configuration _Configuration; -// private readonly List> _FileKeyValuePairs; -// private readonly List<(string Find, string Replace)> _SpellingFindReplace; -// private readonly Dictionary>> _FilePropertiesKeyValuePairs; // public PrepareForOld(List args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console) -// { -// if (isSilent) -// { } -// if (console is null) -// { } -// string spellingA; -// string spellingB; -// _AppSettings = appSettings; -// _SpellingFindReplace = new(); -// _IsEnvironment = isEnvironment; -// _Exceptions = new List(); -// _Log = Serilog.Log.ForContext(); -// _FileKeyValuePairs = new List>(); -// _FilePropertiesKeyValuePairs = new Dictionary>>(); -// Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot); -// Property.Models.Configuration.Verify(propertyConfiguration, requireExist: true); -// Configuration configuration = Models.Stateless.Configuration.Get(isEnvironment, configurationRoot, workingDirectory, propertyConfiguration); -// Verify(configuration); -// if (propertyConfiguration.IgnoreExtensions is null) -// throw new NullReferenceException(nameof(propertyConfiguration.IgnoreExtensions)); -// for (int i = 0; i < configuration.Spelling.Length; i++) -// { -// spellingA = configuration.Spelling[i]; -// spellingB = configuration.Spelling[i + 1]; -// if (spellingB.Contains(spellingA)) -// throw new Exception("Change configuration!"); -// _SpellingFindReplace.Add(new(spellingA, spellingB)); -// i += 1; -// } -// string[] dbFiles = Directory.GetFiles(propertyConfiguration.RootDirectory, "*.db", SearchOption.AllDirectories); -// foreach (string dbFile in dbFiles) -// File.Delete(dbFile); -// string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(propertyConfiguration, nameof(Property.Models.A_Property), "{}"); -// if (!Directory.Exists(aPropertySingletonDirectory)) -// throw new Exception(aPropertySingletonDirectory); -// ConsoleKey? consoleKey = null; -// for (int y = 0; y < int.MaxValue; y++) -// { -// _Log.Information($"Execute {nameof(VerifyAgainstIndexInfoJsonFiles)} \"Y(es)\" or \"N(o)\"?"); -// consoleKey = Console.ReadKey().Key; -// if (consoleKey is ConsoleKey.Y or ConsoleKey.N) -// break; -// } -// _Log.Information(". . ."); -// if (consoleKey == ConsoleKey.Y) -// VerifyAgainstIndexInfoJsonFiles(propertyConfiguration, aPropertySingletonDirectory); -// for (int y = 0; y < int.MaxValue; y++) -// { -// _Log.Information($"Execute {nameof(SaveTabSeparatedValues)} \"Y(es)\" or \"N(o)\"?"); -// consoleKey = Console.ReadKey().Key; -// if (consoleKey is ConsoleKey.Y or ConsoleKey.N) -// break; -// } -// _Log.Information(". . ."); -// if (consoleKey == ConsoleKey.Y) -// SaveTabSeparatedValues(propertyConfiguration, aPropertySingletonDirectory); -// for (int y = 0; y < int.MaxValue; y++) -// { -// _Log.Information($"Execute {nameof(ReSaveJsonFiles)} \"Y(es)\" or \"N(o)\"?"); -// consoleKey = Console.ReadKey().Key; -// if (consoleKey is ConsoleKey.Y or ConsoleKey.N) -// break; -// } -// _Log.Information(". . ."); -// if (consoleKey == ConsoleKey.Y) -// ReSaveJsonFiles(); -// for (int y = 0; y < int.MaxValue; y++) -// { -// _Log.Information($"Execute {nameof(CopyMissingImagesLogs)} \"Y(es)\" or \"N(o)\"?"); -// consoleKey = Console.ReadKey().Key; -// if (consoleKey is ConsoleKey.Y or ConsoleKey.N) -// break; -// } -// _Log.Information(". . ."); -// if (consoleKey == ConsoleKey.Y) -// CopyMissingImagesLogs(); -// string message = $"There were {_Exceptions.Count} exception(s) thrown! {Environment.NewLine}{string.Join(Environment.NewLine, _Exceptions)}"; -// _Log.Information(message); -// if (_Exceptions.Count != 0) -// throw new Exception(message); -// _Configuration = configuration; -// } // private static void Verify(Configuration configuration) -// { -// if (configuration.Spelling is null || !configuration.Spelling.Any()) -// throw new NullReferenceException(nameof(configuration.Spelling)); -// } // private static List GetExifCollection(string infoDirectory, string infoDirectoryExtra, bool checkDistinct) -// { -// List results = new(); -// string json; -// Models.SaveTabSeparatedValues.ImageExifInfo[]? exifCollection; -// List exifInfoFiles = Directory.GetFiles(infoDirectory, "ImageExifInfo.json", SearchOption.AllDirectories).ToList(); -// if (!string.IsNullOrEmpty(infoDirectoryExtra)) -// exifInfoFiles.AddRange(Directory.GetFiles(infoDirectoryExtra, "ImageExifInfo.json", SearchOption.AllDirectories)); -// foreach (string exifInfoFile in exifInfoFiles) -// { -// json = File.ReadAllText(exifInfoFile); -// exifCollection = JsonSerializer.Deserialize(json); -// if (exifCollection is null) -// continue; -// results.AddRange(exifCollection); -// } -// if (checkDistinct) -// { -// int[] check = (from l in results select l.Index).Distinct().ToArray(); -// if (check.Length != results.Count) -// throw new Exception(); -// } -// return results; -// } // private List<(int Index, long Ticks, string RelativeDirectory, string FileNameWithoutExtension, string Extension, string RegexResult)> GetIndexCollection(string infoDirectory, string infoDirectoryExtra, bool checkDistinct) -// { -// List<(int Index, long Ticks, string RelativeDirectory, string FileNameWithoutExtension, string Extension, string RegexResult)> results = new(); -// if (_Configuration?.PropertyConfiguration is null) -// throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration)); -// long ticks; -// string json; -// string extension; -// string corrected; -// string regexResult; -// string relativeDirectory; -// List dateTimes; -// string fileNameWithoutExtension; -// string firstFileSegmentCollection; -// DateTime? dateTimeFromName = null; -// Dictionary keyValuePairs = new(); -// Models.SaveTabSeparatedValues.IndexInfo[]? indexCollection; -// List exifCollection = GetExifCollection(infoDirectory, infoDirectoryExtra, checkDistinct); -// List indexInfoFiles = Directory.GetFiles(infoDirectory, "IndexInfo.json", SearchOption.AllDirectories).ToList(); -// if (!string.IsNullOrEmpty(infoDirectoryExtra)) -// indexInfoFiles.AddRange(Directory.GetFiles(infoDirectoryExtra, "IndexInfo.json", SearchOption.AllDirectories)); -// foreach (Models.SaveTabSeparatedValues.ImageExifInfo exifInfo in exifCollection) -// { -// dateTimes = Shared.Models.Stateless.Methods.IProperty.GetDateTimes(exifInfo.CreationTime, exifInfo.LastWriteTime, exifInfo.DateTime, dateTimeFromName, exifInfo.DateTimeDigitized, exifInfo.DateTimeOriginal, exifInfo.GPSDateStamp); -// if (!checkDistinct && keyValuePairs.ContainsKey(exifInfo.Index)) -// continue; -// keyValuePairs.Add(exifInfo.Index, dateTimes.Min().Ticks); -// } -// foreach (string indexInfoFile in indexInfoFiles) -// { -// json = File.ReadAllText(indexInfoFile); -// indexCollection = JsonSerializer.Deserialize(json); -// if (indexCollection is null) -// continue; -// foreach (Models.SaveTabSeparatedValues.IndexInfo indexInfo in indexCollection) -// { -// if (indexInfo.FileSegmentCollection is null) -// continue; -// // if (indexInfo.FileSegmentCollection.Length != 1) -// // continue; -// ticks = keyValuePairs[indexInfo.Index]; -// firstFileSegmentCollection = indexInfo.FileSegmentCollection[0]; -// extension = Path.GetExtension(firstFileSegmentCollection); -// fileNameWithoutExtension = Path.GetFileNameWithoutExtension(firstFileSegmentCollection); -// corrected = firstFileSegmentCollection[..(firstFileSegmentCollection.Length - extension.Length)]; -// relativeDirectory = firstFileSegmentCollection[..(firstFileSegmentCollection.Length - fileNameWithoutExtension.Length - extension.Length)]; -// if ((from l in _SpellingFindReplace where corrected.Contains(l.Find) select true).Any()) -// { -// foreach ((string find, string replace) in _SpellingFindReplace) -// corrected = corrected.Replace(find, replace); -// } -// if (string.IsNullOrEmpty(_Configuration.PropertyConfiguration.Pattern)) -// regexResult = corrected; // else -// regexResult = Regex.Replace(corrected, _Configuration.PropertyConfiguration.Pattern, string.Empty); -// results.Add(new(indexInfo.Index, ticks, relativeDirectory, fileNameWithoutExtension, extension, regexResult)); -// } -// } -// return results; -// } // private static List GetUseTabSeparatedValueIndices(string useDirectory) -// { -// List results = new(); -// string[] lines; -// string[] segments; -// string[] tabSeparatedValueFiles = Directory.GetFiles(useDirectory, "*.tsv", SearchOption.TopDirectoryOnly); -// foreach (string tabSeparatedValueFile in tabSeparatedValueFiles) -// { -// lines = File.ReadAllLines(tabSeparatedValueFile); -// foreach (string line in lines) -// { -// if (string.IsNullOrEmpty(line)) -// continue; -// segments = line.Split('\t'); -// if (segments.Length < 1) -// continue; -// if (!int.TryParse(segments[0], out int index)) -// continue; -// results.Add(index); -// } -// } -// return results.Distinct().OrderBy(l => l).ToList(); -// } // private void SaveTabSeparatedValues(Property.Models.Configuration configuration, string aPropertySingletonDirectory) -// { -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// if (_Configuration?.PropertyConfiguration is null) -// throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration)); -// string? rootDirectoryParent = Path.GetDirectoryName(_Configuration.PropertyConfiguration.RootDirectory); -// if (string.IsNullOrEmpty(rootDirectoryParent)) -// throw new NullReferenceException(nameof(rootDirectoryParent)); -// int z = 0; -// int mappedIndex; -// int? propertyId; -// long? propertyTicks; -// int loadLessThan = 7; -// string useDirectory = Path.Combine(rootDirectoryParent, "Use - =="); -// if (!Directory.Exists(useDirectory)) -// _ = Directory.CreateDirectory(useDirectory); -// string tempDirectory = Path.Combine(rootDirectoryParent, "Tmp"); -// if (!Directory.Exists(tempDirectory)) -// _ = Directory.CreateDirectory(tempDirectory); -// string diffRootDirectory = string.Empty; -// List duplicates = new(); -// string imageSharedDirectory = Path.Combine(rootDirectoryParent, "Images - Shared"); -// string namedFaceInfoFile = Path.Combine(imageSharedDirectory, "NamedFaceInfo.json"); -// string infoDirectory = Path.Combine(imageSharedDirectory, "Images - 4) Info", "2020-06-07"); -// string infoDirectoryExtra = Path.Combine(imageSharedDirectory, "Images - 4) Info - - - Extra", "2022-04-14"); -// List mappedIndices = GetUseTabSeparatedValueIndices(useDirectory); -// List<(int Index, string RelativeDirectory, string FileName, string RegexResult, long Ticks, int? PropertyId, long? PropertyTicks)> collection = new(); -// PropertyCompare.Models.PropertyCompareLogic propertyCompareLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _SpellingFindReplace, diffRootDirectory); -// PropertyCompare.Models.PropertyCompare[] propertyCompareCollection = propertyCompareLogic.Get(aPropertySingletonDirectory, loadLessThan, duplicates, deleteExtension: false); -// { -// long ticks = DateTime.Now.Ticks; -// string[] lines = (from l in propertyCompareCollection select l.GetSelect()).ToArray(); -// string aPropertyCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(Property.Models.A_Property), "[{}]"); -// File.WriteAllLines(Path.Join(aPropertyCollectionDirectory, $". . . Ids - {ticks}.txt"), lines); -// string json = JsonSerializer.Serialize(propertyCompareCollection, new JsonSerializerOptions { WriteIndented = true }); -// File.WriteAllText(Path.Join(aPropertyCollectionDirectory, $". . . Ids - {ticks}.nosj"), json); -// } -// List<(int Index, long Ticks, string RelativeDirectory, string FileNameWithoutExtension, string Extension, string RegexResult)> indexCollection = GetIndexCollection(infoDirectory, infoDirectoryExtra, checkDistinct: true); -// foreach ((int index, long ticks, string relativeDirectory, string fileNameWithoutExtension, string extension, string regexResult) in indexCollection) -// { -// z += 1; -// if (_IsEnvironment.Development && z % 1000 == 0) -// _Log.Debug($"{z}) Loop {_Configuration.PropertyConfiguration.RootDirectory}"); -// propertyId = null; -// propertyTicks = null; -// foreach (PropertyCompare.Models.PropertyCompare propertyCompare in propertyCompareCollection) -// { -// if (propertyCompare?.Property?.FileId is null) -// continue; -// if (ticks != propertyCompare.MinimumDateTime.Ticks) -// { -// // if (ticks > propertyCompare.MinimumDateTime.AddHours(18).Ticks || ticks < propertyCompare.MinimumDateTime.AddHours(-18).Ticks) -// continue; -// } -// if (!regexResult.Equals(propertyCompare.RegexResult, StringComparison.CurrentCultureIgnoreCase)) -// continue; -// propertyId = propertyCompare.Property.FileId; -// propertyTicks = propertyCompare.MinimumDateTime.Ticks; -// mappedIndex = mappedIndices.IndexOf(index); -// if (mappedIndex > -1) -// mappedIndices.RemoveAt(mappedIndex); -// break; -// } -// collection.Add(new(index, relativeDirectory, $"{fileNameWithoutExtension}{extension}", regexResult, ticks, propertyId, propertyTicks)); -// } -// (int Index, string RelativeDirectory, string FileName, string RegexResult, long Ticks, int? PropertyId, long? PropertyTicks)[] matched = (from l in collection where l.PropertyId.HasValue select l).ToArray(); -// (int Index, string RelativeDirectory, string FileName, string RegexResult, long Ticks, int? PropertyId, long? PropertyTicks)[] notMatched = (from l in collection where l.PropertyId is null select l).ToArray(); -// string[] duplicatesLines = ( // from l // in duplicates // select $"{l.Property.FileId}\t{l.RegexResult}\t{l.MinimumDateTime:yyyy-MM-dd_HH-mm-ss}\t{l.MinimumDateTime}\t{l.RelativeDirectory}\t{l.FileNameWithoutExtension}{l.Extension}.___" -// ).ToArray(); -// string[] matchedLines = ( // from l // in matched // select $"{l.Index}\t{l.PropertyId}\t{l.RegexResult}\t{new DateTime(l.Ticks):yyyy-MM-dd_HH-mm-ss}\t{l.PropertyTicks}\t{l.RelativeDirectory}\t{l.FileName}" -// ).ToArray(); -// List notMatchedLines = ( // from l // in notMatched // where !mappedIndices.Contains(l.Index) // select $"{l.Index}\t______________\t{l.RegexResult}\t{new DateTime(l.Ticks):yyyy-MM-dd_HH-mm-ss}\t_________________\t{l.RelativeDirectory}\t{l.FileName}" -// ).ToList(); -// { -// long ticks = DateTime.Now.Ticks; -// notMatchedLines.AddRange(from l in mappedIndices select $"{l}\tFrom other files"); -// File.WriteAllLines($"{tempDirectory}/{collection.Count}-{ticks}.tsv", matchedLines); -// File.WriteAllLines($"{tempDirectory}/{collection.Count}-{ticks}.txt", duplicatesLines); -// File.WriteAllLines($"{tempDirectory}/{collection.Count}-{ticks}-Not.tsv", notMatchedLines); -// } -// _Log.Debug($"Done with {nameof(SaveTabSeparatedValues)}"); -// } // private static void GetUseTabSeparatedValueLines(string useDirectory, Dictionary> mappedLines) -// { -// string[] lines; -// string[] segments; -// string useDirectoryName = Path.GetFileName(useDirectory).Split('-')[1].Trim(); -// string[] tabSeparatedValueFiles = Directory.GetFiles(useDirectory, "*.tsv", SearchOption.TopDirectoryOnly); -// foreach (string tabSeparatedValueFile in tabSeparatedValueFiles) -// { -// lines = File.ReadAllLines(tabSeparatedValueFile); -// foreach (string line in lines) -// { -// if (string.IsNullOrEmpty(line)) -// continue; -// segments = line.Split('\t'); -// if (segments.Length < 1) -// continue; -// if (!int.TryParse(segments[0], out int index)) -// continue; -// if (!mappedLines.ContainsKey(index)) -// mappedLines.Add(index, new()); -// mappedLines[index].Add($"{line},\t{useDirectoryName}"); -// } -// } -// } // private static void Populate(Dictionary> keyValuePairs, Dictionary> mappedLines) -// { -// string[] segments; -// foreach (KeyValuePair> keyValuePair in mappedLines) -// { -// segments = keyValuePair.Value[0].Split('\t'); -// if (segments.Length < 2) -// continue; -// if (!int.TryParse(segments[1], out int id)) -// continue; -// if (!keyValuePairs.ContainsKey(id)) -// keyValuePairs.Add(id, new() { id }); -// keyValuePairs[id].Add(keyValuePair.Key); -// } -// } // private static Dictionary GetUseTabSeparatedValue(string useEqualsDirectory, string use18HoursDirectory, string useAnyDateDirectory, Dictionary> keyValuePairs, List lines) -// { -// Dictionary results = new(); -// string[] segments; -// Dictionary> mappedLines = new(); -// GetUseTabSeparatedValueLines(useEqualsDirectory, mappedLines); -// GetUseTabSeparatedValueLines(use18HoursDirectory, mappedLines); -// GetUseTabSeparatedValueLines(useAnyDateDirectory, mappedLines); -// Populate(keyValuePairs, mappedLines); -// foreach (KeyValuePair> keyValuePair in mappedLines) -// { -// segments = keyValuePair.Value[0].Split('\t'); -// if (segments.Length < 2) -// continue; -// if (!int.TryParse(segments[1], out int id)) -// continue; -// foreach (string line in keyValuePair.Value) -// lines.Add(line); -// results.Add(keyValuePair.Key, id); -// } -// return results; -// } // private static void ReSaveExifFiles(string infoDirectory, string infoDirectoryIgnore, Dictionary findReplace, List missingIndices) -// { -// string json; -// int propertyId; -// Models.SaveTabSeparatedValues.ImageExifInfo[]? exifCollection; -// List exifInfoFiles = Directory.GetFiles(infoDirectory, "ImageExifInfo.json", SearchOption.AllDirectories).ToList(); -// exifInfoFiles.AddRange(Directory.GetFiles(infoDirectoryIgnore, "ImageExifInfo.json", SearchOption.AllDirectories)); -// foreach (string exifInfoFile in exifInfoFiles) -// { -// json = File.ReadAllText(exifInfoFile); -// exifCollection = JsonSerializer.Deserialize(json); -// if (exifCollection is null) -// continue; -// foreach (Models.SaveTabSeparatedValues.ImageExifInfo exifInfo in exifCollection) -// { -// if (missingIndices.Contains(exifInfo.Index)) -// continue; -// propertyId = findReplace[exifInfo.Index]; -// exifInfo.Index = propertyId; -// } -// json = JsonSerializer.Serialize(exifCollection); -// File.WriteAllText(exifInfoFile, json); -// } -// } // private static void ReSaveNamedFaceInfoFile(string namedFaceInfoFile, Dictionary findReplace, List missingIndices) -// { -// Dictionary destination = new(); -// string json = File.ReadAllText(namedFaceInfoFile); -// List<(int PropertyId, string[] Birthdays)> collection = new(); -// JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true }; -// Dictionary? source = JsonSerializer.Deserialize>(json); -// if (source is null) -// throw new NullReferenceException(nameof(source)); -// { -// int propertyId; -// foreach (KeyValuePair keyValuePair in source) -// { -// if (missingIndices.Contains(keyValuePair.Key)) -// continue; -// propertyId = findReplace[keyValuePair.Key]; -// collection.Add(new(propertyId, keyValuePair.Value)); -// } -// } -// foreach ((int propertyId, string[] birthdays) in collection.OrderBy(l => l.PropertyId)) -// { -// if (destination.ContainsKey(propertyId)) -// { -// if (birthdays.Length != destination[propertyId].Length) -// throw new Exception($"{birthdays.Length} != {destination[propertyId].Length}"); -// if (birthdays[0] != destination[propertyId][0]) -// throw new Exception($"{birthdays[0]} != {destination[propertyId][0]}"); -// continue; -// } -// destination.Add(propertyId, birthdays); -// } -// json = JsonSerializer.Serialize(destination, jsonSerializerOptions); -// File.WriteAllText(namedFaceInfoFile, json); -// } // private static void ReSaveIndexFiles(string infoDirectory, string infoDirectoryIgnore, Dictionary findReplace, List missingIndices) -// { -// string json; -// int propertyId; -// Models.SaveTabSeparatedValues.IndexInfo[]? indexCollection; -// List indexInfoFiles = Directory.GetFiles(infoDirectory, "IndexInfo.json", SearchOption.AllDirectories).ToList(); -// indexInfoFiles.AddRange(Directory.GetFiles(infoDirectoryIgnore, "IndexInfo.json", SearchOption.AllDirectories)); -// foreach (string indexInfoFile in indexInfoFiles) -// { -// json = File.ReadAllText(indexInfoFile); -// indexCollection = JsonSerializer.Deserialize(json); -// if (indexCollection is null) -// continue; -// foreach (Models.SaveTabSeparatedValues.IndexInfo indexInfo in indexCollection) -// { -// if (missingIndices.Contains(indexInfo.Index)) -// continue; -// propertyId = findReplace[indexInfo.Index]; -// indexInfo.Index = propertyId; -// } -// json = JsonSerializer.Serialize(indexCollection); -// File.WriteAllText(indexInfoFile, json); -// } -// } // private void ReSaveJsonFiles() -// { -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// if (_Configuration?.PropertyConfiguration is null) -// throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration)); -// string? rootDirectoryParent = Path.GetDirectoryName(_Configuration.PropertyConfiguration.RootDirectory); -// if (string.IsNullOrEmpty(rootDirectoryParent)) -// throw new NullReferenceException(nameof(rootDirectoryParent)); -// int z = 0; -// int propertyId; -// List missingIndices = new(); -// Dictionary findReplace = new(); -// List useTabSeparatedValueLines = new(); -// Dictionary> keyValuePairs = new(); -// string tempDirectory = Path.Combine(rootDirectoryParent, "Tmp"); -// string useEqualsDirectory = Path.Combine(rootDirectoryParent, "Use - =="); -// string use18HoursDirectory = Path.Combine(rootDirectoryParent, "Use - 18 Hours"); -// string useAnyDateDirectory = Path.Combine(rootDirectoryParent, "Use - Any Date"); -// string imageSharedDirectory = Path.Combine(rootDirectoryParent, "Images - Shared"); -// string namedFaceInfoFile = Path.Combine(imageSharedDirectory, "NamedFaceInfo.json"); -// string infoDirectory = Path.Combine(imageSharedDirectory, "Images - 4) Info", "2020-06-07"); -// string infoDirectoryIgnore = Path.Combine(imageSharedDirectory, "Images - 4) Info - - - Ignore", "2022-04-14"); -// Dictionary useTabSeparatedValueCollection = GetUseTabSeparatedValue(useEqualsDirectory, use18HoursDirectory, useAnyDateDirectory, keyValuePairs, useTabSeparatedValueLines); -// { -// long ticks = DateTime.Now.Ticks; -// string json = JsonSerializer.Serialize(keyValuePairs, new JsonSerializerOptions { WriteIndented = true }); -// File.WriteAllText($"{tempDirectory}/{nameof(keyValuePairs)}-{ticks}.json", json); -// } -// List<(int Index, long Ticks, string RelativeDirectory, string FileNameWithoutExtension, string Extension, string RegexResult)> indexCollection = GetIndexCollection(infoDirectory, infoDirectoryIgnore, checkDistinct: true); -// foreach ((int index, long ticks, string relativeDirectory, string fileNameWithoutExtension, string extension, string regexResult) in indexCollection) -// { -// z += 1; -// if (_IsEnvironment.Development && z % 1000 == 0) -// _Log.Debug($"{z}) Loop {_Configuration.PropertyConfiguration.RootDirectory}"); -// if (!useTabSeparatedValueCollection.ContainsKey(index)) -// { -// missingIndices.Add(index); -// continue; -// } -// propertyId = useTabSeparatedValueCollection[index]; -// findReplace.Add(index, propertyId); -// } -// ReSaveIndexFiles(infoDirectory, infoDirectoryIgnore, findReplace, missingIndices); -// ReSaveExifFiles(infoDirectory, infoDirectoryIgnore, findReplace, missingIndices); -// ReSaveNamedFaceInfoFile(namedFaceInfoFile, findReplace, missingIndices); -// { -// long ticks = DateTime.Now.Ticks; -// File.WriteAllLines($"{tempDirectory}/{nameof(useTabSeparatedValueLines)}-{ticks}.tsv", useTabSeparatedValueLines); -// File.WriteAllText($"{tempDirectory}/{nameof(missingIndices)}-{ticks}.txt", string.Join(Environment.NewLine, missingIndices)); -// } -// _Log.Debug($"Done with {nameof(ReSaveJsonFiles)}"); -// } // private void CopyMissingImagesLogs() -// { -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// if (_Configuration?.PropertyConfiguration is null) -// throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration)); -// string? rootDirectoryParent = Path.GetDirectoryName(_Configuration.PropertyConfiguration.RootDirectory); -// if (_Configuration?.PropertyConfiguration is null) -// throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration)); -// if (string.IsNullOrEmpty(rootDirectoryParent)) -// throw new NullReferenceException(nameof(rootDirectoryParent)); -// int z = 0; -// int propertyId; -// Dictionary findReplace = new(); -// List missingIndices = new(); -// List useTabSeparatedValueLines = new(); -// Dictionary> keyValuePairs = new(); -// string tempDirectory = Path.Combine(rootDirectoryParent, "Tmp"); -// string currentDirectory = Path.Combine(rootDirectoryParent, "@) Images"); -// string useEqualsDirectory = Path.Combine(rootDirectoryParent, "Use - =="); -// string use18HoursDirectory = Path.Combine(rootDirectoryParent, "Use - 18 Hours"); -// string useAnyDateDirectory = Path.Combine(rootDirectoryParent, "Use - Any Date"); -// string imageSharedDirectory = Path.Combine(rootDirectoryParent, "Images - Shared"); -// string namedFaceInfoFile = Path.Combine(imageSharedDirectory, "NamedFaceInfo.json"); -// string infoDirectory = Path.Combine(imageSharedDirectory, "Images - 4) Info", "2020-06-07"); -// string infoDirectoryIgnore = Path.Combine(imageSharedDirectory, "Images - 4) Info - - - Ignore", "2022-04-14"); -// Dictionary useTabSeparatedValueCollection = GetUseTabSeparatedValue(useEqualsDirectory, use18HoursDirectory, useAnyDateDirectory, keyValuePairs, useTabSeparatedValueLines); -// { -// long ticks = DateTime.Now.Ticks; -// string json = JsonSerializer.Serialize(keyValuePairs, new JsonSerializerOptions { WriteIndented = true }); -// File.WriteAllText($"{tempDirectory}/{nameof(keyValuePairs)}-{ticks}.json", json); -// } -// List<(int Index, long Ticks, string RelativeDirectory, string FileNameWithoutExtension, string Extension, string RegexResult)> indexCollection = GetIndexCollection(infoDirectory, infoDirectoryIgnore, checkDistinct: false); -// foreach ((int index, long ticks, string relativeDirectory, string fileNameWithoutExtension, string extension, string regexResult) in indexCollection) -// { -// z += 1; -// if (_IsEnvironment.Development && z % 1000 == 0) -// _Log.Debug($"{z}) Loop {_Configuration.PropertyConfiguration.RootDirectory}"); -// if (!useTabSeparatedValueCollection.ContainsKey(index)) -// { -// missingIndices.Add(index); -// continue; -// } -// propertyId = useTabSeparatedValueCollection[index]; -// findReplace.Add(index, propertyId); -// } -// { -// long ticks = DateTime.Now.Ticks; -// File.WriteAllLines($"{tempDirectory}/{nameof(useTabSeparatedValueLines)}-{ticks}.tsv", useTabSeparatedValueLines); -// File.WriteAllText($"{tempDirectory}/{nameof(missingIndices)}-{ticks}.txt", string.Join(Environment.NewLine, missingIndices)); -// } -// _Log.Debug($"Done with {nameof(CopyMissingImagesLogs)}"); -// } // private static Dictionary> GetKeyValuePairs(PropertyCompare.Models.PropertyCompare[] propertyCompares) -// { -// Dictionary> results = new(); -// foreach (PropertyCompare.Models.PropertyCompare propertyCompare in propertyCompares) -// { -// if (propertyCompare?.Property?.FileId is null) -// continue; -// if (!results.ContainsKey(propertyCompare.Property.FileId.Value)) -// results.Add(propertyCompare.Property.FileId.Value, new()); -// results[propertyCompare.Property.FileId.Value].Add(propertyCompare); -// } -// return results; -// } // private void VerifyAgainstIndexInfoJsonFiles(Property.Models.Configuration configuration, string aPropertySingletonDirectory) -// { -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// if (_Configuration?.PropertyConfiguration is null) -// throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration)); -// string? rootDirectoryParent = Path.GetDirectoryName(_Configuration.PropertyConfiguration.RootDirectory); -// if (string.IsNullOrEmpty(rootDirectoryParent)) -// throw new NullReferenceException(nameof(rootDirectoryParent)); -// int z = 0; -// int? propertyId; -// long? propertyTicks; -// int loadLessThan = 7; -// string diffRootDirectory = string.Empty; -// PropertyCompare.Models.PropertyCompare propertyCompare; -// string tempDirectory = Path.Combine(rootDirectoryParent, "Tmp"); -// if (!Directory.Exists(tempDirectory)) -// _ = Directory.CreateDirectory(tempDirectory); -// string imageSharedDirectory = Path.Combine(rootDirectoryParent, "Images - Shared"); -// string namedFaceInfoFile = Path.Combine(imageSharedDirectory, "NamedFaceInfo.json"); -// string infoDirectory = Path.Combine(imageSharedDirectory, "Images - 4) Info", "2020-06-07"); -// List<(int Index, string RelativeDirectory, string FileName, string RegexResult, long Ticks, int? PropertyId, long? PropertyTicks)> collection = new(); -// PropertyCompare.Models.PropertyCompareLogic propertyCompareLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _SpellingFindReplace, diffRootDirectory); -// PropertyCompare.Models.PropertyCompare[] propertyCompareCollection = propertyCompareLogic.Get(aPropertySingletonDirectory, loadLessThan); -// { -// long ticks = DateTime.Now.Ticks; -// string[] lines = (from l in propertyCompareCollection select l.GetSelect()).ToArray(); -// string aPropertyCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(Property.Models.A_Property), "[{}]"); -// File.WriteAllLines(Path.Join(aPropertyCollectionDirectory, $". . . Ids - {ticks}.txt"), lines); -// string json = JsonSerializer.Serialize(propertyCompareCollection, new JsonSerializerOptions { WriteIndented = true }); -// File.WriteAllText(Path.Join(aPropertyCollectionDirectory, $". . . Ids - {ticks}.nosj"), json); -// } -// Dictionary> keyValuePairs = GetKeyValuePairs(propertyCompareCollection); -// List<(int Index, long Ticks, string RelativeDirectory, string FileNameWithoutExtension, string Extension, string RegexResult)> indexCollection = GetIndexCollection(infoDirectory, infoDirectoryExtra: string.Empty, checkDistinct: false); -// foreach ((int index, long ticks, string relativeDirectory, string fileNameWithoutExtension, string extension, string regexResult) in indexCollection) -// { -// z += 1; -// if (_IsEnvironment.Development && z % 1000 == 0) -// _Log.Debug($"{z}) Loop {_Configuration.PropertyConfiguration.RootDirectory}"); -// propertyId = null; -// propertyTicks = null; -// if (keyValuePairs.ContainsKey(index)) -// { -// propertyCompare = keyValuePairs[index][0]; -// if (propertyCompare?.Property?.FileId is null) -// continue; -// propertyId = propertyCompare.Property.FileId; -// propertyTicks = propertyCompare.MinimumDateTime.Ticks; -// } -// collection.Add(new(index, relativeDirectory, $"{fileNameWithoutExtension}{extension}", regexResult, ticks, propertyId, propertyTicks)); -// } -// (int Index, string RelativeDirectory, string FileName, string RegexResult, long Ticks, int? PropertyId, long? PropertyTicks)[] matched = (from l in collection where l.PropertyId.HasValue select l).ToArray(); -// (int Index, string RelativeDirectory, string FileName, string RegexResult, long Ticks, int? PropertyId, long? PropertyTicks)[] notMatched = (from l in collection where l.PropertyId is null select l).ToArray(); -// string[] matchedLines = ( // from l // in matched // select $"{l.Index}\t{l.PropertyId}\t{l.RegexResult}\t{new DateTime(l.Ticks):yyyy-MM-dd_HH-mm-ss}\t{l.PropertyTicks}\t{l.RelativeDirectory}\t{l.FileName}" -// ).ToArray(); -// List notMatchedLines = ( // from l // in notMatched // select $"{l.Index}\t______________\t{l.RegexResult}\t{new DateTime(l.Ticks):yyyy-MM-dd_HH-mm-ss}\t_________________\t{l.RelativeDirectory}\t{l.FileName}" -// ).ToList(); -// { -// long ticks = DateTime.Now.Ticks; -// File.WriteAllLines($"{tempDirectory}/{collection.Count}-{ticks}.tsv", matchedLines); -// File.WriteAllLines($"{tempDirectory}/{collection.Count}-{ticks}-Not.tsv", notMatchedLines); -// } -// _Log.Debug($"Done with {nameof(VerifyAgainstIndexInfoJsonFiles)}"); -// } -// } \ No newline at end of file diff --git a/PrepareForOld/Program.cs b/PrepareForOld/Program.cs index ea5baa2..8f2631a 100644 --- a/PrepareForOld/Program.cs +++ b/PrepareForOld/Program.cs @@ -39,8 +39,6 @@ public class Program { if (args is null) throw new Exception("args is null!"); - // Shared.Models.Console console = new(); - // PrepareForOld dlibDotNet = new(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console); } catch (Exception ex) { diff --git a/Property-Compare/Models/PropertyCompare.cs b/Property-Compare/Models/PropertyCompare.cs index 9f97480..d00f4e9 100644 --- a/Property-Compare/Models/PropertyCompare.cs +++ b/Property-Compare/Models/PropertyCompare.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Text.Json; namespace View_by_Distance.PropertyCompare.Models; @@ -44,7 +44,6 @@ public partial class PropertyCompare return result; } - // internal static string GetSelect(PropertyCompare item) => string.Concat(item.JsonFileNameWithoutExtension, item.ImageFileName, '\t', item.Property.CreationTime.Ticks, '\t', GetDateTime(item.Property).ToString("yyyy-MM-dd_HH-mm-ss"), '\t', item.Property.FileId, '\t', item.Property.FileSize, '\t', item.Property.Width, '\t', item.Property.Height); #nullable disable diff --git a/Property-Compare/Models/PropertyCompareItem.cs b/Property-Compare/Models/PropertyCompareItem.cs index ee2c6d2..140bb3f 100644 --- a/Property-Compare/Models/PropertyCompareItem.cs +++ b/Property-Compare/Models/PropertyCompareItem.cs @@ -1,29 +1,6 @@ -// namespace View_by_Distance.PropertyCompare.Models; - + // internal class PropertyCompareItem -// { -// protected readonly string _ImageFileName; -// protected readonly bool _IsArg; -// protected readonly string _JsonFileNameWithoutExtension; -// protected readonly long[] _Numbers; -// protected readonly Shared.Models.Property _Property; -// protected readonly string[] _Strings; -// public string ImageFileName => _ImageFileName; -// public bool IsArg => _IsArg; -// public string JsonFileNameWithoutExtension => _JsonFileNameWithoutExtension; -// public long[] Numbers => _Numbers; -// public Shared.Models.Property Property => _Property; -// public string[] Strings => _Strings; // public PropertyCompareItem(string imageFileName, bool isArg, string jsonFileNameWithoutExtension, long[] numbers, Shared.Models.Property property, string[] strings) -// { -// _ImageFileName = imageFileName; -// _IsArg = isArg; -// _JsonFileNameWithoutExtension = jsonFileNameWithoutExtension; -// _Numbers = numbers; -// _Property = property; -// _Strings = strings; -// } -// } \ No newline at end of file diff --git a/Property-Compare/Models/PropertyCompareLogic.cs b/Property-Compare/Models/PropertyCompareLogic.cs index ee7d001..86029b9 100644 --- a/Property-Compare/Models/PropertyCompareLogic.cs +++ b/Property-Compare/Models/PropertyCompareLogic.cs @@ -1,200 +1,24 @@ -// using ShellProgressBar; -// using System.Text.Json; -// using System.Text.RegularExpressions; -// using View_by_Distance.Property.Models; - -// namespace View_by_Distance.PropertyCompare.Models; + // public class PropertyCompareLogic -// { -// private readonly Serilog.ILogger? _Log; -// private readonly string? _DiffRootDirectory; -// private readonly int _MaxDegreeOfParallelism; -// private readonly Configuration _Configuration; -// private readonly List<(string Find, string Replace)>? _SpellingFindReplace; // public PropertyCompareLogic(int maxDegreeOfParallelism, Configuration configuration, List<(string Find, string Replace)>? spellingFindReplace = null, string? diffRootDirectory = null) -// { -// _Configuration = configuration; -// _DiffRootDirectory = diffRootDirectory; -// _SpellingFindReplace = spellingFindReplace; -// _Log = Serilog.Log.ForContext(); -// _MaxDegreeOfParallelism = Math.Abs(maxDegreeOfParallelism); -// } // public override string ToString() -// { -// string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); -// return result; -// } // private List GetDuplicates(PropertyCompare[] propertyCompares, int i, PropertyCompare[]? diffPropertyCompares) -// { -// List results = new(); -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// int index; -// string value; -// long[] distinctNumberValues; -// List checkValues = new(); -// List checkNumberValues = new(); -// if (diffPropertyCompares is null || propertyCompares.Length != diffPropertyCompares.Length) -// { -// foreach (PropertyCompare propertyCompare in propertyCompares) -// { -// value = $"{propertyCompare.Numbers[i]}\t{propertyCompare.Strings[i]}"; -// checkNumberValues.Add(propertyCompare.Numbers[i]); -// checkValues.Add(value); -// } -// distinctNumberValues = checkNumberValues.Distinct().ToArray(); -// if (distinctNumberValues.Length != propertyCompares.Length) -// _Log.Debug($"A) Distinct {nameof(propertyCompares)} - <{distinctNumberValues.Length} != {propertyCompares.Length}>"); -// } -// if (diffPropertyCompares is not null) -// { -// foreach (PropertyCompare propertyCompare in diffPropertyCompares) -// { -// value = $"{propertyCompare.Numbers[i]}\t{propertyCompare.Strings[i]}"; -// if (checkNumberValues.Contains(propertyCompare.Numbers[i])) -// { -// index = checkValues.IndexOf(value); -// if (index > -1) -// { -// if (index >= propertyCompares.Length - 1) -// continue; -// results.Add(propertyCompare); -// results.Add(propertyCompares[index]); -// } -// } -// checkNumberValues.Add(propertyCompare.Numbers[i]); -// checkValues.Add(value); -// } -// distinctNumberValues = checkNumberValues.Distinct().ToArray(); -// if (distinctNumberValues.Length != propertyCompares.Length) -// _Log.Debug($"B) Distinct {nameof(propertyCompares)} - <{distinctNumberValues.Length} != {propertyCompares.Length}>"); -// } -// return results; -// } // private (string[] ToDirectories, List FromThenToCollection) Get(string aPropertyCollectionDirectory, PropertyCompare[] propertyCompares, int i, PropertyCompare[]? diffPropertyCompares) -// { -// List fromThenToCollection = new(); -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// int z = 0; -// string to; -// string from; -// bool extensionIsNullOrEmpty; -// string fileName; -// string toDirectory; -// string fromDirectory; -// List toCollection = new(); -// List toDirectories = new(); -// List fromCollection = new(); -// List bothCollection = new(); -// foreach (PropertyCompare propertyCompare in propertyCompares) -// bothCollection.Add(propertyCompare); -// if (diffPropertyCompares is not null) -// { -// foreach (PropertyCompare propertyCompare in diffPropertyCompares) -// bothCollection.Add(propertyCompare); -// } -// foreach (PropertyCompare propertyCompare in bothCollection) -// { -// z += 1; -// if (z % 1000 == 0) -// { -// if (!propertyCompare.IsArg) -// _Log.Debug($"{z}) Loop {_DiffRootDirectory}"); // else -// _Log.Debug($"{z}) Loop {_Configuration.RootDirectory}"); -// } -// extensionIsNullOrEmpty = string.IsNullOrEmpty(propertyCompare.Extension); -// if (propertyCompare.IsArg) -// fromDirectory = string.Concat(_Configuration.RootDirectory, propertyCompare.RelativeDirectory); // else -// fromDirectory = string.Concat(_DiffRootDirectory, propertyCompare.RelativeDirectory); -// if (!Directory.Exists(fromDirectory)) -// _ = Directory.CreateDirectory(fromDirectory); -// to = string.Empty; -// if (extensionIsNullOrEmpty) -// from = Path.GetFullPath(Path.Combine(fromDirectory, $"{propertyCompare.FileNameWithoutExtension}.jpg")); // else -// from = Path.GetFullPath(Path.Combine(fromDirectory, $"{propertyCompare.FileNameWithoutExtension}{propertyCompare.Extension}")); -// if (fromCollection.Contains(from)) -// continue; -// if (!extensionIsNullOrEmpty && !File.Exists(from)) -// continue; -// fromCollection.Add(from); -// for (short c = 65; c < short.MaxValue; c++) -// { -// if (c > 95) -// break; -// if (extensionIsNullOrEmpty && !propertyCompare.IsArg) -// c += 1; -// fileName = Regex.Replace(propertyCompare.Strings[i], @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_"); -// toDirectory = Path.Combine(aPropertyCollectionDirectory, $". . . {i} - {(char)c}"); -// if (!extensionIsNullOrEmpty) -// to = Path.GetFullPath(Path.Combine(toDirectory, $"{propertyCompare.Numbers[i]}{fileName}{propertyCompare.Extension.ToLower()}")); // else -// { -// to = Path.GetFullPath(Path.Combine(toDirectory, $"{propertyCompare.Numbers[i]}{fileName}.jpg")); -// break; -// } -// if (toCollection.Contains(to)) -// continue; -// if (!toDirectories.Contains(toDirectory)) -// toDirectories.Add(toDirectory); -// toCollection.Add(to); -// break; -// } -// if (string.IsNullOrEmpty(to)) -// continue; -// fromThenToCollection.Add(new string[] { from, to }); -// } -// return new(toDirectories.ToArray(), fromThenToCollection); -// } // private void ParallelGet(List? duplicates, List results, List ids, List collection, int loadLessThan, string directory, object @lock, string relativeDirectory, string[] files, List filesWithoutExtension, bool isArg, string jsonFile) -// { -// long n; -// string s; -// int index; -// string extension; -// string corrected; -// List numbers; -// string regexResult; -// List strings; -// PropertyCompare propertyCompare; -// string jsonFileNameWithoutExtension = Path.GetFileNameWithoutExtension(jsonFile); -// string check = Path.Combine(directory, jsonFileNameWithoutExtension); -// index = filesWithoutExtension.IndexOf(check); -// if (index == -1) -// extension = string.Empty; // else -// extension = Path.GetExtension(files[index]); -// string json = File.ReadAllText(jsonFile); -// Shared.Models.Property? property = JsonSerializer.Deserialize(json); -// if (property?.FileId is null) -// throw new NullReferenceException(nameof(property)); -// DateTime minimumDateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(property); -// corrected = string.Concat(relativeDirectory, jsonFileNameWithoutExtension); -// if (_SpellingFindReplace is not null && (from l in _SpellingFindReplace where corrected.Contains(l.Find) select true).Any()) -// { -// foreach ((string find, string replace) in _SpellingFindReplace) -// corrected = corrected.Replace(find, replace); -// } -// if (string.IsNullOrEmpty(_Configuration.Pattern)) -// regexResult = corrected; // else -// regexResult = Regex.Replace(corrected, _Configuration.Pattern, string.Empty); -// numbers = new(); -// strings = new(); -// for (int i = 0; i < loadLessThan; i++) -// { // n = i switch -// { // 0 => property.FileId.Value, // 1 => property.FileId.Value, // 2 => property.FileId.Value, @@ -206,9 +30,7 @@ // 8 => Shared.Models.Stateless.Methods.IProperty.GetDateTime(property).Ticks, // 9 => property.FileSize, // _ => throw new Exception() -// }; // s = i switch -// { // 0 => $"{jsonFileNameWithoutExtension.ToLower()}", // 1 => $"{property.FileSize}{Shared.Models.Stateless.Methods.IProperty.GetDateTime(property).Ticks}", // 2 => $"{property.FileSize}{property.CreationTime:yyyy-MM-dd_HH-mm-ss}", @@ -220,390 +42,28 @@ // 8 => string.Empty, // 9 => string.Empty, // _ => throw new Exception() -// }; -// numbers.Add(n); -// strings.Add(s); -// } -// propertyCompare = new(extension, jsonFileNameWithoutExtension, isArg, minimumDateTime, numbers, property, regexResult, relativeDirectory, strings); // lock (@lock) -// results.Add(propertyCompare); -// if (duplicates is not null) -// { -// string value = $"{property.FileId.Value}\t{property}"; -// index = ids.IndexOf(property.FileId.Value); -// if (index > -1) -// { // lock (@lock) -// { -// duplicates.Add(propertyCompare); -// duplicates.Add(collection[index]); -// } -// } // lock (@lock) -// { -// ids.Add(property.FileId.Value); -// collection.Add(propertyCompare); -// } -// } -// } // public PropertyCompare[] Get(string aPropertySingletonDirectory, int loadLessThan = 7, List? duplicates = null, bool deleteExtension = false) -// { -// List results = new(); -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// string[] files; -// int totalSeconds; -// string directory; -// string searchPattern; -// object @lock = new(); -// int exceptionCount = 0; -// List ids = new(); -// string relativeDirectory; -// if (!deleteExtension) -// searchPattern = "*.json"; // else -// searchPattern = "*.delete"; -// long ticks = DateTime.Now.Ticks; -// List filesWithoutExtension; -// List topDirectories = new(); -// string extension = searchPattern[1..]; -// string[] filteredSourceDirectoryFiles; -// List collection = new(); -// bool isArg = aPropertySingletonDirectory.Contains(_Configuration.RootDirectory); -// List<(int g, string sourceDirectory, string[] sourceDirectoryFiles)> groupCollection; -// ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = _MaxDegreeOfParallelism }; -// ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true }; -// (int r, groupCollection) = Property.Models.Stateless.Container.GetGroupCollection(aPropertySingletonDirectory, searchPattern, topDirectories); -// foreach ((int g, string sourceDirectory, string[] sourceDirectoryFiles) in groupCollection) -// { -// if (!topDirectories.Any()) -// continue; -// if (!sourceDirectoryFiles.Any()) -// continue; -// relativeDirectory = sourceDirectory[aPropertySingletonDirectory.Length..]; -// if (!isArg) -// directory = string.Concat(_DiffRootDirectory, relativeDirectory); // else -// directory = string.Concat(_Configuration.RootDirectory, relativeDirectory); -// if (!Directory.Exists(directory)) -// _ = Directory.CreateDirectory(directory); -// files = Directory.GetFiles(directory); -// filesWithoutExtension = files.Select(l => Path.Combine($"{Path.GetDirectoryName(l)}", Path.GetFileNameWithoutExtension(l))).ToList(); -// filteredSourceDirectoryFiles = (from l in sourceDirectoryFiles where l.EndsWith(extension) select l).ToArray(); -// if (!filteredSourceDirectoryFiles.Any()) -// continue; -// totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds); -// using ProgressBar progressBar = new(filteredSourceDirectoryFiles.Length, $"{r + 1:000}.{g} / {groupCollection.Count:000}) {filteredSourceDirectoryFiles.Length:000} file(s) - {totalSeconds} total second(s) - {sourceDirectory}", options); // _ = Parallel.For(0, filteredSourceDirectoryFiles.Length, parallelOptions, (i, state) => -// { // try -// { -// ParallelGet(duplicates, results, ids, collection, loadLessThan, directory, @lock, relativeDirectory, files, filesWithoutExtension, isArg, sourceDirectoryFiles[i]); -// progressBar.Tick(); -// } // catch (Exception ex) -// { -// exceptionCount += 1; -// _Log.Error(string.Concat(sourceDirectory, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace), ex); -// if (exceptionCount == filteredSourceDirectoryFiles.Length) -// throw new Exception(string.Concat("All in [", sourceDirectory, "]failed!")); -// } -// }); -// } -// if (exceptionCount != 0) -// throw new Exception(); -// return (from l in results orderby Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(l.Property).Ticks select l).ToArray(); -// } // private void MoveFiles(string[] directories, List fromThenToCollection) -// { -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// int z; -// string to; -// string from; -// int moved = 0; -// _Log.Information("Ready to move?"); -// ConsoleKey? consoleKey = null; -// for (int y = 0; y < int.MaxValue; y++) -// { -// _Log.Information("Press \"Y\" key when ready to continue"); -// if (Console.ReadKey().Key == ConsoleKey.Y) -// break; -// } -// _Log.Information(". . ."); -// foreach (string directory in directories) -// { -// if (!Directory.Exists(directory)) -// _ = Directory.CreateDirectory(directory); -// } -// z = 0; -// foreach (string[] fromThenTo in fromThenToCollection) -// { -// z += 1; -// from = fromThenTo[0]; -// to = fromThenTo[1]; -// if (z % 1000 == 0) -// _Log.Information($"{z})"); -// if (!File.Exists(from)) -// continue; -// if (File.Exists(to)) -// continue; -// File.Move(from, to); -// moved += 1; -// } -// _Log.Information($"{moved} file(s) moved"); -// for (int m = 0; m < int.MaxValue; m++) -// { -// moved = 0; -// _Log.Information($"{m}) Ready to move back?"); -// for (int y = 0; y < int.MaxValue; y++) -// { -// _Log.Information("Press \"Y\" key when ready to continue"); -// if (Console.ReadKey().Key == ConsoleKey.Y) -// break; -// } -// _Log.Information(". . ."); -// z = 0; -// foreach (string[] fromThenTo in fromThenToCollection) -// { -// z += 1; -// from = fromThenTo[1]; -// to = fromThenTo[0]; -// if (z % 1000 == 0) -// _Log.Information($"{z})"); -// if (!File.Exists(from)) -// continue; -// if (File.Exists(to)) -// continue; -// File.Move(from, to); -// moved += 1; -// } -// foreach (string directory in directories) -// { -// if (Directory.Exists(directory)) -// { -// if (!Directory.GetFiles(directory, "*", SearchOption.AllDirectories).Any()) -// Directory.Delete(directory); -// } -// } -// _Log.Information($"Done moving back {moved} file(s) for loop {m})"); -// for (int y = 0; y < int.MaxValue; y++) -// { -// _Log.Information("Press \"Y\" key when ready to continue"); -// _Log.Information("Press \"End\" key when ready to break"); -// consoleKey = Console.ReadKey().Key; -// if (consoleKey is ConsoleKey.Y or ConsoleKey.End) -// break; -// } -// _Log.Information(". . ."); -// if (consoleKey.HasValue && consoleKey == ConsoleKey.End) -// break; -// } -// } // public void SaveDiffFiles(string aPropertyCollectionDirectory, int loadLessThan, PropertyCompare[] propertyCompares, PropertyCompare[]? diffPropertyCompares) -// { -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// string text; -// string[] lines; -// string fileName; -// ConsoleKey? consoleKey = null; -// List duplicateCollection; -// for (int i = 0; i < loadLessThan; i++) -// { -// if (!propertyCompares.Any()) -// continue; -// if (diffPropertyCompares is null || !diffPropertyCompares.Any()) -// duplicateCollection = GetDuplicates(propertyCompares, i, diffPropertyCompares); // else -// { -// if (i != 0) -// { -// if (diffPropertyCompares is null) -// continue; -// } -// if (propertyCompares.Length == diffPropertyCompares.Length) -// continue; -// duplicateCollection = GetDuplicates(propertyCompares, i, diffPropertyCompares); -// } -// lines = (from l in duplicateCollection select l.GetSelect()).ToArray(); -// _Log.Debug($"{i}) loop has {lines.Length} line(s)"); -// if ((duplicateCollection.Count % 2) != 0) -// continue; -// fileName = Path.Join(aPropertyCollectionDirectory, $". . . {i}-Duplicates.txt"); -// if (!duplicateCollection.Any()) -// { -// if (File.Exists(fileName)) -// File.Delete(fileName); -// continue; -// } -// text = string.Join(Environment.NewLine, lines); -// File.WriteAllText(fileName, text); -// for (int y = 0; y < int.MaxValue; y++) -// { -// _Log.Information("Press \"Y\" key when ready to continue"); -// _Log.Information("Press \"End\" key when ready to break"); -// consoleKey = Console.ReadKey().Key; -// if (consoleKey is ConsoleKey.Y or ConsoleKey.End) -// break; -// } -// _Log.Information(". . ."); -// if (consoleKey.HasValue && consoleKey == ConsoleKey.End) -// break; -// } -// } // public void SaveLogAndMoveFiles(string aPropertyCollectionDirectory, int loadLessThan, PropertyCompare[] propertyCompares, PropertyCompare[]? diffPropertyCompares, int i) -// { -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// List lines; -// string checkDirectory; -// string[] toDirectories; -// ConsoleKey? consoleKey = null; -// List fromThenToCollection; -// _Log.Information($"{i}) example - number:{propertyCompares[0].Numbers[i]}; string:{propertyCompares[0].Strings[i]};"); -// (toDirectories, fromThenToCollection) = Get(aPropertyCollectionDirectory, propertyCompares, i, diffPropertyCompares); -// if (toDirectories.Length < 2) -// _Log.Information($"{i}) loop only one directory :)"); // else -// { -// checkDirectory = toDirectories[1]; -// _Log.Information($"{i}) loop {toDirectories.Length} directories and . . .{i}) - B will have ~{fromThenToCollection.Where(l => l[1].StartsWith(checkDirectory)).Count()}"); -// } -// for (int y = 0; y < int.MaxValue; y++) -// { -// _Log.Information($"Press \"Y\" key to {nameof(MoveFiles)} \"N\" to skip"); -// consoleKey = Console.ReadKey().Key; -// if (consoleKey is ConsoleKey.Y or ConsoleKey.N) -// break; -// } -// _Log.Information(". . ."); -// if (consoleKey.HasValue && consoleKey.Value == ConsoleKey.Y) -// { -// lines = new(); -// foreach (string[] fromThenTo in fromThenToCollection) -// { -// lines.Add(fromThenTo[0]); -// lines.Add(fromThenTo[1]); -// } -// File.WriteAllLines(Path.Join(aPropertyCollectionDirectory, $". . . {i}-All.txt"), lines); -// MoveFiles(toDirectories, fromThenToCollection); -// } -// } // public void WithSubdirectory(string propertyDirectory, bool subDirectoriesAny, string fileName, bool renameCompare, bool deleteArg) -// { -// if (_Log is null) -// throw new NullReferenceException(nameof(_Log)); -// List fileCollection = new(); -// if (renameCompare && deleteArg) -// throw new Exception(); -// if (!renameCompare && !deleteArg) -// throw new Exception(); -// string[] lines; -// string[] txtFiles = Directory.GetFiles(propertyDirectory, fileName, SearchOption.TopDirectoryOnly); -// if (txtFiles.Length != 1) -// lines = Array.Empty(); // else -// lines = File.ReadAllLines(txtFiles[0]); -// if (lines.Any()) -// { -// string argLine; -// string moveFile; -// string argFileName; -// string compareLine; -// string? argDirectory; -// string argFullFileName; -// string compareFileName; -// string argDirectoryName; -// string? compareDirectory; -// string compareFullFileName; -// string compareDirectoryName; -// for (int i = 0; i < lines.Length; i++) -// { -// argLine = lines[i]; -// compareLine = lines[i + 1]; -// i += 1; -// if (!subDirectoriesAny) -// { -// if (!argLine.StartsWith(_Configuration.RootDirectory) || !compareLine.StartsWith(_Configuration.RootDirectory)) -// throw new Exception(i.ToString()); -// } // else -// { -// if (!argLine.StartsWith(_Configuration.RootDirectory) || compareLine.StartsWith(_Configuration.RootDirectory)) -// throw new Exception(i.ToString()); -// } -// } -// for (int i = 0; i < lines.Length; i++) -// { -// argLine = lines[i]; -// compareLine = lines[i + 1]; -// i += 1; -// if (!subDirectoriesAny) -// { -// if (!argLine.StartsWith(_Configuration.RootDirectory) || !compareLine.StartsWith(_Configuration.RootDirectory)) -// throw new Exception(i.ToString()); -// } // else -// { -// if (!argLine.StartsWith(_Configuration.RootDirectory) || compareLine.StartsWith(_Configuration.RootDirectory)) -// throw new Exception(i.ToString()); -// } -// argFullFileName = argLine.Split('\t')[0]; -// compareFullFileName = compareLine.Split('\t')[0]; -// argFileName = Path.GetFileName(argFullFileName); -// if (deleteArg) -// { -// if (!File.Exists(argFullFileName)) -// continue; -// fileCollection.Add(new string[] { argFullFileName }); -// } -// else if (renameCompare) -// { -// argDirectory = Path.GetDirectoryName(argFullFileName); -// if (string.IsNullOrEmpty(argDirectory)) -// continue; -// compareDirectory = Path.GetDirectoryName(compareFullFileName); -// if (string.IsNullOrEmpty(compareDirectory)) -// continue; -// argDirectoryName = Path.GetFileName(argDirectory); -// if (argDirectoryName[..3].Equals(argFileName[..3], StringComparison.CurrentCultureIgnoreCase)) -// continue; -// compareDirectoryName = Path.GetFileName(argDirectory); -// compareFileName = Path.GetFileName(compareFullFileName); -// if (!compareDirectoryName[..3].Equals(compareFileName[..3], StringComparison.CurrentCultureIgnoreCase)) -// continue; -// if (!File.Exists(compareFullFileName)) -// { -// if (File.Exists(argFullFileName)) -// fileCollection.Add(new string[] { argFullFileName }); -// continue; -// } -// moveFile = Path.Combine(compareDirectory, argFileName); -// if (File.Exists(moveFile)) -// { -// _Log.Information(argLine); -// _Log.Information(compareLine); -// continue; -// } -// fileCollection.Add(new string[] { compareFullFileName, moveFile }); -// } // else -// throw new Exception(); -// } -// } -// foreach (string[] file in fileCollection) -// { -// if (deleteArg) -// File.Delete(Path.GetFullPath(file[0])); -// else if (renameCompare) -// File.Move(Path.GetFullPath(file[0]), Path.GetFullPath(file[1])); -// } -// } -// } \ No newline at end of file diff --git a/Property/Models/A_Property.cs b/Property/Models/A_Property.cs index 5539bb6..da0ae91 100644 --- a/Property/Models/A_Property.cs +++ b/Property/Models/A_Property.cs @@ -1,4 +1,4 @@ -using ShellProgressBar; +using ShellProgressBar; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; @@ -348,11 +348,6 @@ public class A_Property id = result.Id; result = null; } - // if (filteredSourceDirectoryFileFileInfo.CreationTime != result.CreationTime || filteredSourceDirectoryFileFileInfo.LastWriteTime != result?.LastWriteTime) - // { - // id = null; - // property = ; - // } if (result is not null) { sourceDirectoryFileTuples.Add(new Tuple(nameof(A_Property), fileInfo.LastWriteTime)); diff --git a/Rename/Rename.cs b/Rename/Rename.cs index dd513f1..d027238 100644 --- a/Rename/Rename.cs +++ b/Rename/Rename.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; using Phares.Shared; using Serilog; using ShellProgressBar; @@ -114,14 +114,6 @@ public class Rename { progressBar.Tick(); fileHolder = new(file); - // else if (file.EndsWith(".del") && !file.Contains(".jpg")) - // { - // checkFile = string.Concat(file[..^4], ".jpg"); - // if (File.Exists(checkFile)) - // continue; - // results.Add(new(fileHolder, checkFile)); - // continue; - // } if (file.EndsWith(".jpg.del")) { checkFile = file[..^4]; @@ -211,7 +203,6 @@ public class Rename { name = matchNginx.Name.Trim(); if (name.Length < 1 || (!name.StartsWith("zzz =20") && !name.StartsWith("=20") && !name.StartsWith("#20"))) - // if (name.Length < 1 || !name.Contains(".Z.#20")) continue; directoryName = Path.GetDirectoryName(matchNginx.ConvertedPath); if (directoryName is null) @@ -220,7 +211,6 @@ public class Rename check = Path.Combine(directoryName, name[1..]); else check = Path.Combine(directoryName, $"zzz {name[5..]}"); - // check = Path.Combine(directoryName, name.Replace("#", string.Empty)); if (Directory.Exists(check) || File.Exists(check)) continue; if (!Directory.Exists(matchNginx.ConvertedPath)) diff --git a/Shared/Models/DirectoryFileSystem.cs b/Shared/Models/DirectoryFileSystem.cs index ef92f46..425997f 100644 --- a/Shared/Models/DirectoryFileSystem.cs +++ b/Shared/Models/DirectoryFileSystem.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Text.Json; using System.Text.Json.Serialization; namespace View_by_Distance.Shared.Models; @@ -6,16 +6,6 @@ namespace View_by_Distance.Shared.Models; public class DirectoryFileSystem : FileSystem, Properties.IDirectoryFileSystem { - // protected new string _ClassName; - // protected new string _DataDisplayFileName; - // protected new string _DataFullFileName; - // protected new string _Display; - // protected new DateTime _LastModified; - // public new string ClassName => _ClassName; - // public new string DataDisplayFileName => _DataDisplayFileName; - // public new string DataFullFileName => _DataFullFileName; - // public new string Display => _Display; - // public new DateTime LastModified => _LastModified; [JsonConstructor] public DirectoryFileSystem(string className, string dataDisplayFileName, string dataFullFileName, string display, DateTime lastModified) : base(className, dataDisplayFileName, dataFullFileName, display, lastModified) diff --git a/Shared/Models/FaceFileSystem.cs b/Shared/Models/FaceFileSystem.cs index e36287f..95cec19 100644 --- a/Shared/Models/FaceFileSystem.cs +++ b/Shared/Models/FaceFileSystem.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Text.Json; using System.Text.Json.Serialization; namespace View_by_Distance.Shared.Models; @@ -6,11 +6,7 @@ namespace View_by_Distance.Shared.Models; public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem { - // protected new string _ClassName; protected string _Confidence; - // protected new string _DataDisplayFileName; - // protected new string _DataFullFileName; - // protected new string _Display; protected int? _FaceBottom; protected string _FaceFullFileName; protected int? _FaceHeight; @@ -21,7 +17,6 @@ public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem protected int? _FaceWidth; protected int _ImageHeight; protected int _ImageWidth; - // protected new DateTime _LastModified; protected string _LocationDisplayIndex; protected int? _LocationIndex; protected bool? _Populated; @@ -29,11 +24,7 @@ public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem protected string _SourceFullFileName; protected string _SourceRelativePath; protected long? _SourceSize; - // public new string ClassName => _ClassName; public string Confidence => _Confidence; - // public new string DataDisplayFileName => _DataDisplayFileName; - // public new string DataFullFileName => _DataFullFileName; - // public new string Display => _Display; public int? FaceBottom => _FaceBottom; public string FaceFullFileName => _FaceFullFileName; public int? FaceHeight => _FaceHeight; @@ -44,7 +35,6 @@ public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem public int? FaceWidth => _FaceWidth; public int ImageHeight => _ImageHeight; public int ImageWidth => _ImageWidth; - // public new DateTime LastModified => _LastModified; public string LocationDisplayIndex => _LocationDisplayIndex; public int? LocationIndex => _LocationIndex; public bool? Populated => _Populated; diff --git a/Shared/Models/Marker.cs b/Shared/Models/Marker.cs index 9c06229..68ea5b2 100644 --- a/Shared/Models/Marker.cs +++ b/Shared/Models/Marker.cs @@ -1,4 +1,4 @@ -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace View_by_Distance.Shared.Models; @@ -14,8 +14,6 @@ public record Marker( [property: JsonPropertyName("subj_src")] string SubjSrc, [property: JsonPropertyName("face_id")] string FaceId, [property: JsonPropertyName("face_dist")] double FaceDist, - // [property: JsonPropertyName("embeddings_json")] string EmbeddingsJson, - // [property: JsonPropertyName("landmarks_json")] string LandmarksJson, [property: JsonPropertyName("x")] double X, [property: JsonPropertyName("y")] double Y, [property: JsonPropertyName("w")] double W, diff --git a/Shared/Models/Stateless/Methods/Location.cs b/Shared/Models/Stateless/Methods/Location.cs index b52cc39..c715576 100644 --- a/Shared/Models/Stateless/Methods/Location.cs +++ b/Shared/Models/Stateless/Methods/Location.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; namespace View_by_Distance.Shared.Models.Stateless.Methods; @@ -90,9 +90,7 @@ internal abstract class Location { decimal factor = 100; int factorMinusOne = (int)factor - 1; - // int.MaxPercentage = 21 47 48 36 47; int length = (locationDigits - 1) / 4; - // Rectangle rectangle=new(x, y, width, h); decimal x = left / (decimal)width * factor; decimal y = top / (decimal)height * factor; decimal w = (right - left) / (decimal)width * factor; diff --git a/Shared/Models/Stateless/Methods/OutputResolution.cs b/Shared/Models/Stateless/Methods/OutputResolution.cs index 1c5d64a..44fb062 100644 --- a/Shared/Models/Stateless/Methods/OutputResolution.cs +++ b/Shared/Models/Stateless/Methods/OutputResolution.cs @@ -1,23 +1,12 @@ -namespace View_by_Distance.Shared.Models.Stateless.Methods; +namespace View_by_Distance.Shared.Models.Stateless.Methods; internal abstract class OutputResolution { internal static (int Width, int Height) Get(Models.OutputResolution outputResolution) { - // (int, int) result = outputResolution.Orientation switch // exif 274 - // { // 0 => new(outputResolution.Width, outputResolution.Height), - // 1 => new(outputResolution.Width, outputResolution.Height), // 1 = Horizontal (normal) - // 2 => new(outputResolution.Width, outputResolution.Height), // 2 = Mirror horizontal - // 3 => new(outputResolution.Width, outputResolution.Height), // 3 = Rotate 180 - // 4 => new(outputResolution.Width, outputResolution.Height), // 4 = Mirror vertical - // 5 => new(outputResolution.Height, outputResolution.Width), // 5 = Mirror horizontal and rotate 270 CW - // 6 => new(outputResolution.Height, outputResolution.Width), // 6 = Rotate 90 CW - // 7 => new(outputResolution.Height, outputResolution.Width), // 7 = Mirror horizontal and rotate 90 CW - // 8 => new(outputResolution.Height, outputResolution.Width), // 8 = Rotate 270 CW // _ => throw new Exception() - // }; (int, int) result = outputResolution.Orientation switch // exif 274 { _ => new(outputResolution.Width, outputResolution.Height)