Removed Comments

This commit is contained in:
Mike Phares 2023-02-05 09:33:49 -07:00
parent 1d9b63ffba
commit 75ec814c7c
21 changed files with 27 additions and 1357 deletions

12
.config/dotnet-tools.json Normal file
View File

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"deadcsharp": {
"version": "2.0.0",
"commands": [
"dead-csharp"
]
}
}
}

1
.vscode/launch.json vendored
View File

@ -398,3 +398,4 @@
// '98'
// C:\Program Files\ImageMagick-7.1.0-Q16-HDRI>identify -format '%Q' "D:\7) Question\- - - Images\Mike Goolgle Photos 2014\197616258.jpg"
// '90'
// dotnet dead-csharp --inputs "**/*.cs" --excludes "**/obj/**" "**/I*.cs" "**/UnitTest*.cs"

View File

@ -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))

View File

@ -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);

View File

@ -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 <see cref="System.ObjectDisposedException"/> is thrown.
After:
/// If this object is disposed, then <see cref="ObjectDisposedException"/> 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();
}

View File

@ -96,15 +96,6 @@ public struct Point : IEquatable<Point>
/// <param name="point2">The second <see cref="Point"/> structure to compare.</param>
/// <returns><code>true</code> if <paramref name="point1"/> and <paramref name="point2"/> have different <see cref="X"/> or <see cref="Y"/> coordinates; <code>false</code> if <paramref name="point1"/> and <paramref name="point2"/> have the same <see cref="X"/> and <see cref="Y"/> coordinates.</returns>
/* 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

View File

@ -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;
}
}

View File

@ -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}"));

View File

@ -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;
}

View File

@ -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<string> _Exceptions;
// private readonly IsEnvironment _IsEnvironment;
// private readonly Configuration _Configuration;
// private readonly List<KeyValuePair<string, string>> _FileKeyValuePairs;
// private readonly List<(string Find, string Replace)> _SpellingFindReplace;
// private readonly Dictionary<string, List<Tuple<string, Shared.Models.Property>>> _FilePropertiesKeyValuePairs;
// public PrepareForOld(List<string> 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<string>();
// _Log = Serilog.Log.ForContext<PrepareForOld>();
// _FileKeyValuePairs = new List<KeyValuePair<string, string>>();
// _FilePropertiesKeyValuePairs = new Dictionary<string, List<Tuple<string, Shared.Models.Property>>>();
// 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<Models.SaveTabSeparatedValues.ImageExifInfo> GetExifCollection(string infoDirectory, string infoDirectoryExtra, bool checkDistinct)
// {
// List<Models.SaveTabSeparatedValues.ImageExifInfo> results = new();
// string json;
// Models.SaveTabSeparatedValues.ImageExifInfo[]? exifCollection;
// List<string> 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<Models.SaveTabSeparatedValues.ImageExifInfo[]>(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<DateTime> dateTimes;
// string fileNameWithoutExtension;
// string firstFileSegmentCollection;
// DateTime? dateTimeFromName = null;
// Dictionary<int, long> keyValuePairs = new();
// Models.SaveTabSeparatedValues.IndexInfo[]? indexCollection;
// List<Models.SaveTabSeparatedValues.ImageExifInfo> exifCollection = GetExifCollection(infoDirectory, infoDirectoryExtra, checkDistinct);
// List<string> 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<Models.SaveTabSeparatedValues.IndexInfo[]>(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<int> GetUseTabSeparatedValueIndices(string useDirectory)
// {
// List<int> 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<PropertyCompare.Models.PropertyCompare> 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<int> 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<string> 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<int, List<string>> 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<int, List<int>> keyValuePairs, Dictionary<int, List<string>> mappedLines)
// {
// string[] segments;
// foreach (KeyValuePair<int, List<string>> 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<int, int> GetUseTabSeparatedValue(string useEqualsDirectory, string use18HoursDirectory, string useAnyDateDirectory, Dictionary<int, List<int>> keyValuePairs, List<string> lines)
// {
// Dictionary<int, int> results = new();
// string[] segments;
// Dictionary<int, List<string>> mappedLines = new();
// GetUseTabSeparatedValueLines(useEqualsDirectory, mappedLines);
// GetUseTabSeparatedValueLines(use18HoursDirectory, mappedLines);
// GetUseTabSeparatedValueLines(useAnyDateDirectory, mappedLines);
// Populate(keyValuePairs, mappedLines);
// foreach (KeyValuePair<int, List<string>> 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<int, int> findReplace, List<int> missingIndices)
// {
// string json;
// int propertyId;
// Models.SaveTabSeparatedValues.ImageExifInfo[]? exifCollection;
// List<string> 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<Models.SaveTabSeparatedValues.ImageExifInfo[]>(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<int, int> findReplace, List<int> missingIndices)
// {
// Dictionary<int, string[]> destination = new();
// string json = File.ReadAllText(namedFaceInfoFile);
// List<(int PropertyId, string[] Birthdays)> collection = new();
// JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
// Dictionary<int, string[]>? source = JsonSerializer.Deserialize<Dictionary<int, string[]>>(json);
// if (source is null)
// throw new NullReferenceException(nameof(source));
// {
// int propertyId;
// foreach (KeyValuePair<int, string[]> 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<int, int> findReplace, List<int> missingIndices)
// {
// string json;
// int propertyId;
// Models.SaveTabSeparatedValues.IndexInfo[]? indexCollection;
// List<string> 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<Models.SaveTabSeparatedValues.IndexInfo[]>(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<int> missingIndices = new();
// Dictionary<int, int> findReplace = new();
// List<string> useTabSeparatedValueLines = new();
// Dictionary<int, List<int>> 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<int, int> 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<int, int> findReplace = new();
// List<int> missingIndices = new();
// List<string> useTabSeparatedValueLines = new();
// Dictionary<int, List<int>> 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<int, int> 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<int, List<PropertyCompare.Models.PropertyCompare>> GetKeyValuePairs(PropertyCompare.Models.PropertyCompare[] propertyCompares)
// {
// Dictionary<int, List<PropertyCompare.Models.PropertyCompare>> 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<int, List<PropertyCompare.Models.PropertyCompare>> 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<string> 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)}");
// }
// }

View File

@ -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)
{

View File

@ -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

View File

@ -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;
// }
// }

View File

@ -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<PropertyCompareLogic>();
// _MaxDegreeOfParallelism = Math.Abs(maxDegreeOfParallelism);
// }
// public override string ToString()
// {
// string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
// return result;
// }
// private List<PropertyCompare> GetDuplicates(PropertyCompare[] propertyCompares, int i, PropertyCompare[]? diffPropertyCompares)
// {
// List<PropertyCompare> results = new();
// if (_Log is null)
// throw new NullReferenceException(nameof(_Log));
// int index;
// string value;
// long[] distinctNumberValues;
// List<string> checkValues = new();
// List<long> 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<string[]> FromThenToCollection) Get(string aPropertyCollectionDirectory, PropertyCompare[] propertyCompares, int i, PropertyCompare[]? diffPropertyCompares)
// {
// List<string[]> 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<string> toCollection = new();
// List<string> toDirectories = new();
// List<string> fromCollection = new();
// List<PropertyCompare> 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<PropertyCompare>? duplicates, List<PropertyCompare> results, List<long> ids, List<PropertyCompare> collection, int loadLessThan, string directory, object @lock, string relativeDirectory, string[] files, List<string> filesWithoutExtension, bool isArg, string jsonFile)
// {
// long n;
// string s;
// int index;
// string extension;
// string corrected;
// List<long> numbers;
// string regexResult;
// List<string> 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<Shared.Models.Property>(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<PropertyCompare>? duplicates = null, bool deleteExtension = false)
// {
// List<PropertyCompare> 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<long> ids = new();
// string relativeDirectory;
// if (!deleteExtension)
// searchPattern = "*.json";
// else
// searchPattern = "*.delete";
// long ticks = DateTime.Now.Ticks;
// List<string> filesWithoutExtension;
// List<string> topDirectories = new();
// string extension = searchPattern[1..];
// string[] filteredSourceDirectoryFiles;
// List<PropertyCompare> 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<string[]> 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<PropertyCompare> 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<string> lines;
// string checkDirectory;
// string[] toDirectories;
// ConsoleKey? consoleKey = null;
// List<string[]> 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<string[]> 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<string>();
// 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]));
// }
// }
// }

View File

@ -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<string, DateTime>(nameof(A_Property), fileInfo.LastWriteTime));

View File

@ -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))

View File

@ -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)

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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)