net7.0
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PackageId>Phares.View.by.Distance.Date.Group</PackageId>
|
||||
@ -34,23 +34,19 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MetadataExtractor" Version="2.7.1" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
|
||||
<PackageReference Include="MetadataExtractor" Version="2.7.2" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.1.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.1.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -37,15 +37,11 @@ public class DateGroup
|
||||
_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);
|
||||
Models.Configuration configuration = Models.Stateless.Configuration.Get(isEnvironment, configurationRoot, workingDirectory, propertyConfiguration);
|
||||
Models.Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||
Verify(configuration);
|
||||
bool reverse = false;
|
||||
_Configuration = configuration;
|
||||
string outputExtension = ".jpg";
|
||||
if (configuration.ByHash is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByHash));
|
||||
if (configuration.ByCreateDateShortcut is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByCreateDateShortcut));
|
||||
if (!_IsEnvironment.Development)
|
||||
throw new Exception("This program only allows development environments!");
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
@ -59,10 +55,70 @@ public class DateGroup
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(propertyConfiguration.RootDirectory);
|
||||
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);
|
||||
// }
|
||||
(int j, int f, int t, Container[] containers) = Property.Models.Stateless.Container.GetContainers(propertyConfiguration, propertyLogic);
|
||||
if (propertyLogic.ExceptionsDirectories.Any())
|
||||
throw new Exception();
|
||||
if (propertyConfiguration.PopulatePropertyId && (configuration.ByCreateDateShortcut.Value || configuration.ByHash.Value) && Shared.Models.Stateless.Methods.IProperty.Any(containers))
|
||||
if (propertyConfiguration.PopulatePropertyId && (configuration.ByCreateDateShortcut || configuration.ByHash) && Shared.Models.Stateless.Methods.IProperty.Any(containers))
|
||||
{
|
||||
propertyLogic.SavePropertyParallelWork(ticks, containers);
|
||||
if (appSettings.MaxDegreeOfParallelism < 2)
|
||||
@ -70,35 +126,34 @@ public class DateGroup
|
||||
if (propertyLogic.ExceptionsDirectories.Any())
|
||||
throw new Exception();
|
||||
}
|
||||
if (configuration.ByCreateDateShortcut.HasValue && configuration.ByCreateDateShortcut.Value)
|
||||
if (configuration.ByCreateDateShortcut)
|
||||
CreateDateShortcut(propertyConfiguration, containers);
|
||||
else
|
||||
MoveFiles(propertyConfiguration, containers);
|
||||
MoveFiles(propertyConfiguration, destinationRoot, containers);
|
||||
}
|
||||
|
||||
private static void Verify(Models.Configuration configuration)
|
||||
{
|
||||
if (configuration.ByCreateDateShortcut is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByCreateDateShortcut));
|
||||
if (configuration.ByDay is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByDay));
|
||||
if (configuration.ByHash is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByHash));
|
||||
if (configuration.BySeason is null)
|
||||
throw new NullReferenceException(nameof(configuration.BySeason));
|
||||
if (configuration.ByWeek is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByWeek));
|
||||
if (!configuration.ByCreateDateShortcut.Value && !configuration.ByDay.Value && !configuration.ByWeek.Value && !configuration.BySeason.Value && !configuration.ByHash.Value)
|
||||
int check = 0;
|
||||
if (configuration.ByCreateDateShortcut)
|
||||
check += 1;
|
||||
if (configuration.ByDay)
|
||||
check += 1;
|
||||
if (configuration.ByHash)
|
||||
check += 1;
|
||||
if (configuration.ByNone)
|
||||
check += 1;
|
||||
if (configuration.BySeason)
|
||||
check += 1;
|
||||
if (configuration.ByWeek)
|
||||
check += 1;
|
||||
if (check != 1)
|
||||
throw new Exception("Change configuration!");
|
||||
if (configuration.KeepFullPath is null)
|
||||
throw new NullReferenceException(nameof(configuration.KeepFullPath));
|
||||
if (configuration?.PropertyConfiguration?.PopulatePropertyId is null)
|
||||
throw new NullReferenceException(nameof(configuration.PropertyConfiguration.PopulatePropertyId));
|
||||
if (configuration.PropertyConfiguration.PopulatePropertyId && !configuration.ByCreateDateShortcut.Value && !configuration.ByHash.Value)
|
||||
if (configuration.PropertyConfiguration.PopulatePropertyId && !configuration.ByCreateDateShortcut && !configuration.ByHash)
|
||||
throw new Exception("Change configuration!");
|
||||
if (!configuration.PropertyConfiguration.PopulatePropertyId && configuration.ByHash.Value)
|
||||
throw new Exception("Change configuration!");
|
||||
if (configuration.ByCreateDateShortcut.Value && configuration.ByDay.Value && configuration.ByWeek.Value && configuration.BySeason.Value && configuration.ByHash.Value)
|
||||
if (!configuration.PropertyConfiguration.PopulatePropertyId && configuration.ByHash)
|
||||
throw new Exception("Change configuration!");
|
||||
}
|
||||
|
||||
@ -148,18 +203,6 @@ public class DateGroup
|
||||
private List<(Item Item, long LastWriteTimeTicks, long MinimumDateTimeTicks, string[] Destination)> GetMoveFileCollection(string destinationDirectory, string topDirectory, Item[] filteredItems)
|
||||
{
|
||||
List<(Item Item, long LastWriteTimeTicks, long MinimumDateTimeTicks, string[] Destination)> results = new();
|
||||
if (_Configuration.ByCreateDateShortcut is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.ByCreateDateShortcut));
|
||||
if (_Configuration.ByDay is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.ByDay));
|
||||
if (_Configuration.ByHash is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.ByHash));
|
||||
if (_Configuration.BySeason is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.BySeason));
|
||||
if (_Configuration.ByWeek is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.ByWeek));
|
||||
if (_Configuration.KeepFullPath is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.KeepFullPath));
|
||||
char flag;
|
||||
string day;
|
||||
int season;
|
||||
@ -213,11 +256,10 @@ public class DateGroup
|
||||
if (matches is not null && matches.Any())
|
||||
break;
|
||||
}
|
||||
if (matches is null)
|
||||
matches = Array.Empty<string>();
|
||||
matches ??= Array.Empty<string>();
|
||||
foreach (Item item in filteredItems)
|
||||
{
|
||||
if (item.ImageFileHolder is null || item.Property is null || (_Configuration.PropertyConfiguration.PopulatePropertyId && item.Property.Id is null))
|
||||
if (item.Property is null || (_Configuration.PropertyConfiguration.PopulatePropertyId && item.Property.Id is null))
|
||||
continue;
|
||||
directoryNames.Clear();
|
||||
destinationCollection = new();
|
||||
@ -261,20 +303,23 @@ public class DateGroup
|
||||
}
|
||||
topDirectoryName = Path.GetFileName(topDirectory);
|
||||
weekOfYear = calendar.GetWeekOfYear(minimumDateTime.Value, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
if (_Configuration.ByHash.Value)
|
||||
if (_Configuration.ByNone)
|
||||
directoryNames.Clear();
|
||||
else if (_Configuration.ByHash)
|
||||
directoryNames.Add($"{year} {seasonName}");
|
||||
else if (_Configuration.BySeason.Value && topDirectoryName.Length == 1 && topDirectoryName[0] == '_')
|
||||
else if (_Configuration.BySeason && topDirectoryName.Length == 1 && topDirectoryName[0] == '_')
|
||||
directoryNames.Add($"{year} {seasonName}");
|
||||
else
|
||||
{
|
||||
if (!_Configuration.KeepFullPath.Value)
|
||||
if (!_Configuration.KeepFullPath)
|
||||
{
|
||||
_ = destinationDirectoryName.Append(topDirectoryName);
|
||||
if (_Configuration.BySeason.Value)
|
||||
if (topDirectoryName.Length > 1)
|
||||
_ = destinationDirectoryName.Append(topDirectoryName);
|
||||
if (_Configuration.BySeason)
|
||||
directoryNames.AddRange(new string[] { $"{destinationDirectoryName} {year} {seasonName}" });
|
||||
else if (_Configuration.ByDay.Value)
|
||||
else if (_Configuration.ByDay)
|
||||
directoryNames.AddRange(new string[] { $"{destinationDirectoryName} {year}", $"{weekOfYear}) {year}-{day}" });
|
||||
else if (_Configuration.ByWeek.Value)
|
||||
else if (_Configuration.ByWeek)
|
||||
directoryNames.AddRange(new string[] { $"{destinationDirectoryName} {year}", $"{weekOfYear}) {year} {month}" });
|
||||
else
|
||||
throw new Exception();
|
||||
@ -288,17 +333,17 @@ public class DateGroup
|
||||
else
|
||||
_ = destinationDirectoryName.Append(sourceDirectoryNameSegment);
|
||||
}
|
||||
if (_Configuration.BySeason.Value)
|
||||
if (_Configuration.BySeason)
|
||||
directoryNames.Add($"{year} {seasonName}");
|
||||
else if (_Configuration.ByDay.Value)
|
||||
else if (_Configuration.ByDay)
|
||||
directoryNames.Add($"{weekOfYear}) {year} {day}");
|
||||
else if (_Configuration.ByWeek.Value)
|
||||
else if (_Configuration.ByWeek)
|
||||
directoryNames.Add($"{weekOfYear}) {month} {year}");
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
if (!_Configuration.ByHash.Value || item.Property.Id is null)
|
||||
if (!_Configuration.ByHash || item.Property.Id is null)
|
||||
fileName = item.ImageFileHolder.Name;
|
||||
else
|
||||
fileName = $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}";
|
||||
@ -325,18 +370,15 @@ public class DateGroup
|
||||
foreach (Item item in container.Items)
|
||||
{
|
||||
if (item.ImageFileHolder is not null
|
||||
&& (item.Abandoned is null || !item.Abandoned.Value)
|
||||
&& item.ValidImageFormatExtension)
|
||||
&& (item.Abandoned is null || !item.Abandoned.Value))
|
||||
results.Add(item);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
private (Item Item, long LastWriteTimeTicks, long MinimumDateTimeTicks, string[] Destination)[] GetFileMoveCollectionAll(Property.Models.Configuration configuration, Container[] containers, string destinationRoot)
|
||||
private (Item Item, long LastWriteTimeTicks, long MinimumDateTimeTicks, string[] Destination)[] GetFileMoveCollectionAll(Property.Models.Configuration configuration, string destinationRoot, Container[] containers)
|
||||
{
|
||||
(Item Item, long LastWriteTimeTicks, long MinimumDateTimeTicks, string[] Destination)[] results;
|
||||
if (_Configuration.KeepFullPath is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.KeepFullPath));
|
||||
string? topDirectory;
|
||||
string? checkDirectory;
|
||||
string destinationDirectory;
|
||||
@ -347,7 +389,7 @@ public class DateGroup
|
||||
{
|
||||
if (!container.Items.Any())
|
||||
continue;
|
||||
if (!_Configuration.KeepFullPath.Value)
|
||||
if (!_Configuration.KeepFullPath)
|
||||
destinationDirectory = destinationRoot;
|
||||
else
|
||||
destinationDirectory = string.Concat(destinationRoot, container.SourceDirectory[configuration.RootDirectory.Length..]);
|
||||
@ -373,12 +415,10 @@ public class DateGroup
|
||||
return results;
|
||||
}
|
||||
|
||||
private void MoveFiles(Property.Models.Configuration configuration, Container[] containers)
|
||||
private void MoveFiles(Property.Models.Configuration configuration, string destinationRoot, Container[] containers)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
if (_Configuration.ByHash is null)
|
||||
throw new NullReferenceException(nameof(_Configuration.ByHash));
|
||||
bool hasDuplicate;
|
||||
string fullFileName;
|
||||
string directoryName;
|
||||
@ -387,12 +427,9 @@ public class DateGroup
|
||||
List<string> filesDistinct = new();
|
||||
List<string> filesDuplicate = new();
|
||||
List<string> directoriesDistinct = new();
|
||||
string destinationRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(configuration, "Z) Moved");
|
||||
(Item Item, long LastWriteTimeTicks, long MinimumDateTimeTicks, string[] Destination)[] fileMoveCollectionAll = GetFileMoveCollectionAll(configuration, containers, destinationRoot);
|
||||
(Item Item, long LastWriteTimeTicks, long MinimumDateTimeTicks, string[] Destination)[] fileMoveCollectionAll = GetFileMoveCollectionAll(configuration, destinationRoot, containers);
|
||||
foreach ((Item item, long lastWriteTimeTicks, long minimumDateTimeTicks, string[] destination) in fileMoveCollectionAll)
|
||||
{
|
||||
if (item.ImageFileHolder is null)
|
||||
continue;
|
||||
fullFileName = Path.Combine(destination);
|
||||
if (filesDistinct.Contains(fullFileName))
|
||||
filesDuplicate.Add(fullFileName);
|
||||
@ -403,13 +440,10 @@ public class DateGroup
|
||||
directoriesDistinct.Add(directoryName);
|
||||
if (!Directory.Exists(directoryName))
|
||||
_ = Directory.CreateDirectory(directoryName);
|
||||
if (_Configuration.ByHash.Value)
|
||||
{
|
||||
if (!Directory.Exists(string.Concat(directoryName, duplicate, " I")))
|
||||
_ = Directory.CreateDirectory(string.Concat(directoryName, duplicate, " I"));
|
||||
if (!Directory.Exists(string.Concat(directoryName, duplicate, " II")))
|
||||
_ = Directory.CreateDirectory(string.Concat(directoryName, duplicate, " II"));
|
||||
}
|
||||
if (!Directory.Exists(string.Concat(directoryName, duplicate, " I")))
|
||||
_ = Directory.CreateDirectory(string.Concat(directoryName, duplicate, " I"));
|
||||
if (!Directory.Exists(string.Concat(directoryName, duplicate, " II")))
|
||||
_ = Directory.CreateDirectory(string.Concat(directoryName, duplicate, " II"));
|
||||
}
|
||||
_Log.Information("Ready to move files?");
|
||||
for (int y = 0; y < int.MaxValue; y++)
|
||||
@ -422,8 +456,6 @@ public class DateGroup
|
||||
int moved = 0;
|
||||
foreach ((Item item, long lastWriteTimeTicks, long minimumDateTimeTicks, string[] destination) in fileMoveCollectionAll)
|
||||
{
|
||||
if (item.ImageFileHolder is null)
|
||||
continue;
|
||||
fullFileName = Path.Combine(destination);
|
||||
hasDuplicate = filesDuplicate.Contains(fullFileName);
|
||||
if (hasDuplicate)
|
||||
@ -431,10 +463,10 @@ public class DateGroup
|
||||
destination[1] = string.Concat(destination[1], duplicate, " I");
|
||||
fullFileName = Path.Combine(destination);
|
||||
}
|
||||
if (File.Exists(fullFileName))
|
||||
for (int i = 0; i < 256 - destination[1].Length; i++)
|
||||
{
|
||||
if (!_Configuration.ByHash.Value)
|
||||
continue;
|
||||
if (!File.Exists(fullFileName))
|
||||
break;
|
||||
else
|
||||
{
|
||||
destination[1] = string.Concat(destination[1], "I");
|
||||
@ -456,8 +488,7 @@ public class DateGroup
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
if (_Configuration.ByHash.Value)
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(destinationRoot);
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(destinationRoot);
|
||||
_Log.Information($"{moved} file(s) moved");
|
||||
for (int y = 0; y < int.MaxValue; y++)
|
||||
{
|
||||
@ -468,8 +499,6 @@ public class DateGroup
|
||||
_Log.Information(". . .");
|
||||
foreach ((Item item, long lastWriteTimeTicks, long minimumDateTimeTicks, string[] destination) in fileMoveCollectionAll)
|
||||
{
|
||||
if (item.ImageFileHolder is null)
|
||||
continue;
|
||||
fullFileName = Path.Combine(destination);
|
||||
if (File.Exists(item.ImageFileHolder.FullName))
|
||||
continue;
|
||||
|
@ -20,10 +20,10 @@ public class AppSettings
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Models.AppSettings Get(AppSettings appSettings)
|
||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
if (appSettings.MaxDegreeOfParallelism is null)
|
||||
if (appSettings?.MaxDegreeOfParallelism is null)
|
||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||
result = new(
|
||||
appSettings.Company,
|
||||
@ -36,7 +36,7 @@ public class AppSettings
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
AppSettings appSettings = configurationRoot.Get<AppSettings>();
|
||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Phares.Shared;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
@ -11,6 +13,7 @@ public class Configuration
|
||||
[Display(Name = "By Create Date Shortcut"), Required] public bool? ByCreateDateShortcut { get; set; }
|
||||
[Display(Name = "By Date"), Required] public bool? ByDay { get; set; }
|
||||
[Display(Name = "By Hash"), Required] public bool? ByHash { get; set; }
|
||||
[Display(Name = "By None"), Required] public bool? ByNone { get; set; }
|
||||
[Display(Name = "By Season"), Required] public bool? BySeason { get; set; }
|
||||
[Display(Name = "By Week"), Required] public bool? ByWeek { get; set; }
|
||||
[Display(Name = "Ignore Subdirectories for Rename"), Required] public bool? KeepFullPath { get; set; }
|
||||
@ -24,4 +27,47 @@ public class Configuration
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Models.Configuration Get(Configuration? configuration)
|
||||
{
|
||||
Models.Configuration result;
|
||||
if (configuration is null)
|
||||
throw new NullReferenceException(nameof(configuration));
|
||||
if (configuration.ByCreateDateShortcut is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByCreateDateShortcut));
|
||||
if (configuration.ByDay is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByDay));
|
||||
if (configuration.ByHash is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByHash));
|
||||
if (configuration.ByNone is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByNone));
|
||||
if (configuration.BySeason is null)
|
||||
throw new NullReferenceException(nameof(configuration.BySeason));
|
||||
if (configuration.ByWeek is null)
|
||||
throw new NullReferenceException(nameof(configuration.ByWeek));
|
||||
if (configuration.KeepFullPath is null)
|
||||
throw new NullReferenceException(nameof(configuration.KeepFullPath));
|
||||
result = new(configuration.PropertyConfiguration, configuration.ByCreateDateShortcut.Value, configuration.ByDay.Value, configuration.ByHash.Value, configuration.ByNone.Value, configuration.BySeason.Value, configuration.ByWeek.Value, configuration.KeepFullPath.Value);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Models.Configuration Get(IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, Property.Models.Configuration propertyConfiguration)
|
||||
{
|
||||
Models.Configuration result;
|
||||
Configuration? configuration;
|
||||
if (isEnvironment is null)
|
||||
configuration = configurationRoot.Get<Configuration>();
|
||||
else
|
||||
{
|
||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||
configuration = configurationSection.Get<Configuration>();
|
||||
}
|
||||
result = Get(configuration);
|
||||
if (configuration is null)
|
||||
throw new NullReferenceException(nameof(configuration));
|
||||
result.SetAndUpdate(propertyConfiguration, numberOfJitters: null, numberOfTimesToUpsample: null, modelName: null, predictorModelName: null);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -6,30 +6,27 @@ namespace View_by_Distance.Date.Group.Models;
|
||||
public class Configuration
|
||||
{
|
||||
|
||||
protected readonly bool? _ByCreateDateShortcut;
|
||||
protected readonly bool? _ByDay;
|
||||
protected readonly bool? _ByHash;
|
||||
protected readonly bool? _BySeason;
|
||||
protected readonly bool? _ByWeek;
|
||||
protected readonly bool? _KeepFullPath;
|
||||
protected Property.Models.Configuration _PropertyConfiguration;
|
||||
public bool? ByCreateDateShortcut => _ByCreateDateShortcut;
|
||||
public bool? ByDay => _ByDay;
|
||||
public bool? ByHash => _ByHash;
|
||||
public bool? BySeason => _BySeason;
|
||||
public bool? ByWeek => _ByWeek;
|
||||
public bool? KeepFullPath => _KeepFullPath;
|
||||
public Property.Models.Configuration PropertyConfiguration => _PropertyConfiguration;
|
||||
|
||||
public bool ByCreateDateShortcut { init; get; }
|
||||
public bool ByDay { init; get; }
|
||||
public bool ByHash { init; get; }
|
||||
public bool ByNone { init; get; }
|
||||
public bool BySeason { init; get; }
|
||||
public bool ByWeek { init; get; }
|
||||
public bool KeepFullPath { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public Configuration(bool? byCreateDateShortcut, bool? byDay, bool? byHash, bool? bySeason, bool? byWeek, bool? keepFullPath, Property.Models.Configuration propertyConfiguration)
|
||||
public Configuration(Property.Models.Configuration propertyConfiguration, bool byCreateDateShortcut, bool byDay, bool byHash, bool byNone, bool bySeason, bool byWeek, bool keepFullPath)
|
||||
{
|
||||
_ByCreateDateShortcut = byCreateDateShortcut;
|
||||
_ByDay = byDay;
|
||||
_ByHash = byHash;
|
||||
_BySeason = bySeason;
|
||||
_ByWeek = byWeek;
|
||||
_KeepFullPath = keepFullPath;
|
||||
ByDay = byDay;
|
||||
ByHash = byHash;
|
||||
ByNone = byNone;
|
||||
ByWeek = byWeek;
|
||||
BySeason = bySeason;
|
||||
KeepFullPath = keepFullPath;
|
||||
ByCreateDateShortcut = byCreateDateShortcut;
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
}
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Phares.Shared;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.Date.Group.Models.Stateless;
|
||||
|
||||
public abstract class Configuration
|
||||
{
|
||||
|
||||
public static Models.Configuration Get(IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, string workingDirectory, Property.Models.Configuration propertyConfiguration)
|
||||
{
|
||||
Models.Configuration? result;
|
||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||
string section = string.Concat(environmentName, ":", nameof(Binder.Configuration));
|
||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||
Binder.Configuration configuration = configurationSection.Get<Binder.Configuration>();
|
||||
string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true });
|
||||
result = JsonSerializer.Deserialize<Models.Configuration>(json);
|
||||
if (result is null)
|
||||
throw new Exception(json);
|
||||
string jsonThis = result.ToString();
|
||||
result.SetAndUpdate(propertyConfiguration, null, null, null, null);
|
||||
if (jsonThis != json)
|
||||
{
|
||||
int? check = null;
|
||||
int min = new int[] { json.Length, jsonThis.Length }.Min();
|
||||
for (int i = 0; i < min; i++)
|
||||
{
|
||||
if (json[i] == jsonThis[i])
|
||||
continue;
|
||||
check = i;
|
||||
break;
|
||||
}
|
||||
if (check is null)
|
||||
throw new Exception();
|
||||
string a = json[..check.Value].Split(',')[^1];
|
||||
string b = json[check.Value..].Split(',')[0];
|
||||
throw new Exception($"{a}{b}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -50,20 +50,29 @@
|
||||
"WorkingDirectoryName": "PharesApps",
|
||||
"Windows": {
|
||||
"Configuration": {
|
||||
"ByCreateDateShortcut": true,
|
||||
"ByCreateDateShortcut": false,
|
||||
"ByDay": false,
|
||||
"ByHash": false,
|
||||
"BySeason": false,
|
||||
"ByNone": false,
|
||||
"BySeason": true,
|
||||
"ByWeek": false,
|
||||
"DateGroup": "2022-10-23",
|
||||
"DateGroup": "2022-11-12",
|
||||
"FileNameDirectorySeparator": ".Z.",
|
||||
"ForcePropertyLastWriteTimeToCreationTime": false,
|
||||
"KeepFullPath": false,
|
||||
"MaxImagesInDirectoryForTopLevelFirstPass": 10,
|
||||
"Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]",
|
||||
"PopulatePropertyId": true,
|
||||
"PopulatePropertyId": false,
|
||||
"PropertiesChangedForProperty": false,
|
||||
"RootDirectory": "C:/Tmp/Phares/Compare/Images 2022-10-23 - 239acf2 - III",
|
||||
"ResultAllInOne": "_ _ _",
|
||||
"ResultCollection": "[]",
|
||||
"ResultContent": "()",
|
||||
"ResultSingleton": "{}",
|
||||
"xRootDirectory": "C:/Tmp/phares/Pictures",
|
||||
"xxRootDirectory": "C:/Tmp/Phares/Compare/Images 2022-11-12 - c6aa7e8 - III",
|
||||
"xxxRootDirectory": "F:/Tmp/Phares/Compare/Images 2022-11-12 - c6aa7e8 - III",
|
||||
"xxxxRootDirectory": "F:/Tmp/Phares/2022-11-03-DCIM/DCIM/100D3400 2022",
|
||||
"RootDirectory": "F:/Tmp/Phares/Compare/Images 2022-11-12 - c6aa7e8 - III/D",
|
||||
"WriteBitmapDataBytes": false,
|
||||
"IgnoreExtensions": [
|
||||
".gif",
|
||||
@ -87,8 +96,6 @@
|
||||
"ValidMetadataExtensions": [
|
||||
".3gp",
|
||||
".3GP",
|
||||
".amr",
|
||||
".AMR",
|
||||
".avi",
|
||||
".AVI",
|
||||
".bmp",
|
||||
|
Reference in New Issue
Block a user