ResultAllInOneSubdirectoryLength
This commit is contained in:
@ -7,6 +7,7 @@ using System.Text;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Property.Models.Stateless;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Property.Models;
|
||||
@ -25,21 +26,23 @@ public class A_Property
|
||||
private readonly ASCIIEncoding _ASCIIEncoding;
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly List<string> _AngleBracketCollection;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
||||
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
|
||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||
|
||||
public A_Property(int maxDegreeOfParallelism, Configuration configuration, string outputExtension, bool reverse, string aResultsFullGroupDirectory)
|
||||
public A_Property(int maxDegreeOfParallelism, Configuration propertyConfiguration, string outputExtension, bool reverse, string aResultsFullGroupDirectory)
|
||||
{
|
||||
Reverse = reverse;
|
||||
_Configuration = configuration;
|
||||
_ExceptionsDirectories = new();
|
||||
_OutputExtension = outputExtension;
|
||||
_ASCIIEncoding = new ASCIIEncoding();
|
||||
_Configuration = propertyConfiguration;
|
||||
_Log = Serilog.Log.ForContext<A_Property>();
|
||||
_AngleBracketCollection = new List<string>();
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(configuration.ResultAllInOne, aResultsFullGroupDirectory, new string[] { "{}" });
|
||||
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, aResultsFullGroupDirectory, new string[] { propertyConfiguration.ResultSingleton });
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@ -263,12 +266,13 @@ public class A_Property
|
||||
string[] changesFrom = Array.Empty<string>();
|
||||
string angleBracket = _AngleBracketCollection[0];
|
||||
bool populateId = _Configuration.PopulatePropertyId;
|
||||
char directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(item.ImageFileHolder.Name);
|
||||
int directoryIndex = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(directory);
|
||||
if (!item.IsUniqueFileName)
|
||||
fileInfo = new(Path.Combine(angleBracket.Replace("<>", "{}"), $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
fileInfo = new(Path.Combine(angleBracket.Replace("<>", _PropertyConfiguration.ResultSingleton), $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
else
|
||||
fileInfo = new(Path.Combine(_JsonGroups["{}"][directoryIndex], $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
{
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, item.ImageFileHolder.Name);
|
||||
fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
}
|
||||
List<DateTime> dateTimes = (from l in sourceDirectoryFileTuples where l is not null && changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
if (_Configuration.ForcePropertyLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
@ -378,7 +382,7 @@ public class A_Property
|
||||
Shared.Models.Property property;
|
||||
List<string> parseExceptions = new();
|
||||
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
bool isIgnoreExtension = item.IsValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
bool isIgnoreExtension = item.IsValidImageFormatExtension && _PropertyConfiguration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
string filteredSourceDirectoryFileExtensionLowered = Path.Combine(sourceDirectory, $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}");
|
||||
if (item.IsValidImageFormatExtension && item.ImageFileHolder.FullName.Length == filteredSourceDirectoryFileExtensionLowered.Length && item.ImageFileHolder.FullName != filteredSourceDirectoryFileExtensionLowered)
|
||||
File.Move(item.ImageFileHolder.FullName, filteredSourceDirectoryFileExtensionLowered);
|
||||
@ -427,7 +431,7 @@ public class A_Property
|
||||
if (!anyNullOrNoIsUniqueFileName)
|
||||
_AngleBracketCollection.AddRange(new[] { Path.Combine(aResultsFullGroupDirectory, "<>") });
|
||||
else
|
||||
_AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_Configuration,
|
||||
_AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
aResultsFullGroupDirectory,
|
||||
contentDescription: string.Empty,
|
||||
@ -439,7 +443,7 @@ public class A_Property
|
||||
private void SetAngleBracketCollection(string sourceDirectory, bool anyNullOrNoIsUniqueFileName)
|
||||
{
|
||||
_AngleBracketCollection.Clear();
|
||||
string aResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(_Configuration,
|
||||
string aResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(_PropertyConfiguration,
|
||||
nameof(A_Property),
|
||||
string.Empty,
|
||||
includeResizeGroup: false,
|
||||
@ -461,7 +465,7 @@ public class A_Property
|
||||
int containersLength = containers.Length;
|
||||
const string outputResolution = "Original";
|
||||
List<Tuple<string, DateTime>> sourceDirectoryChanges = new();
|
||||
string propertyRoot = IResult.GetResultsGroupDirectory(_Configuration, nameof(A_Property));
|
||||
string propertyRoot = IResult.GetResultsGroupDirectory(_PropertyConfiguration, nameof(A_Property));
|
||||
for (int i = 0; i < containers.Length; i++)
|
||||
{
|
||||
container = containers[i];
|
||||
@ -506,7 +510,7 @@ public class A_Property
|
||||
SetAngleBracketCollection(item.ImageFileHolder.DirectoryName, !item.IsUniqueFileName);
|
||||
}
|
||||
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
bool isIgnoreExtension = item.IsValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
bool isIgnoreExtension = item.IsValidImageFormatExtension && _PropertyConfiguration.IgnoreExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
||||
result = GetPropertyOfPrivate(item, sourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidMetadataExtensions);
|
||||
if (!angleBracketCollectionAny)
|
||||
_AngleBracketCollection.Clear();
|
||||
|
@ -21,6 +21,7 @@ public class Configuration
|
||||
[Display(Name = "Properties Changed For Property"), Required] public bool? PropertiesChangedForProperty { get; set; }
|
||||
[Display(Name = "Property Content Collection Files"), Required] public string[] PropertyContentCollectionFiles { get; set; }
|
||||
[Display(Name = "Result All In One"), Required] public string ResultAllInOne { get; set; }
|
||||
[Display(Name = "Result All In One Max Value"), Required] public int? ResultAllInOneSubdirectoryLength { get; set; }
|
||||
[Display(Name = "Result Collection"), Required] public string ResultCollection { get; set; }
|
||||
[Display(Name = "Result Content"), Required] public string ResultContent { get; set; }
|
||||
[Display(Name = "Result Singleton"), Required] public string ResultSingleton { get; set; }
|
||||
@ -53,6 +54,8 @@ public class Configuration
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForProperty));
|
||||
if (configuration.ResultAllInOne is null)
|
||||
throw new NullReferenceException(nameof(configuration.ResultAllInOne));
|
||||
if (configuration.ResultAllInOneSubdirectoryLength is null)
|
||||
throw new NullReferenceException(nameof(configuration.ResultAllInOneSubdirectoryLength));
|
||||
if (configuration.ResultCollection is null)
|
||||
throw new NullReferenceException(nameof(configuration.ResultCollection));
|
||||
if (configuration.ResultContent is null)
|
||||
@ -77,6 +80,7 @@ public class Configuration
|
||||
configuration.PropertiesChangedForProperty.Value,
|
||||
configuration.PropertyContentCollectionFiles,
|
||||
configuration.ResultAllInOne,
|
||||
configuration.ResultAllInOneSubdirectoryLength.Value,
|
||||
configuration.ResultCollection,
|
||||
configuration.ResultContent,
|
||||
configuration.ResultSingleton,
|
||||
|
@ -29,6 +29,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
||||
public bool PropertiesChangedForProperty { init; get; }
|
||||
public string[] PropertyContentCollectionFiles { init; get; }
|
||||
public string ResultAllInOne { init; get; }
|
||||
public int ResultAllInOneSubdirectoryLength { init; get; }
|
||||
public string ResultCollection { init; get; }
|
||||
public string ResultContent { init; get; }
|
||||
public string ResultSingleton { init; get; }
|
||||
@ -48,6 +49,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
||||
bool propertiesChangedForProperty,
|
||||
string[] propertyContentCollectionFiles,
|
||||
string resultAllInOne,
|
||||
int resultAllInOneSubdirectoryLength,
|
||||
string resultCollection,
|
||||
string resultContent,
|
||||
string resultSingleton,
|
||||
@ -68,6 +70,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
||||
PropertiesChangedForProperty = propertiesChangedForProperty;
|
||||
PropertyContentCollectionFiles = propertyContentCollectionFiles;
|
||||
ResultAllInOne = resultAllInOne;
|
||||
ResultAllInOneSubdirectoryLength = resultAllInOneSubdirectoryLength;
|
||||
ResultCollection = resultCollection;
|
||||
ResultContent = resultContent;
|
||||
ResultSingleton = resultSingleton;
|
||||
|
Reference in New Issue
Block a user