ResultAllInOneSubdirectoryLength
This commit is contained in:
parent
8dfcc33e74
commit
3092cd5b9e
@ -10,23 +10,27 @@ completedColumns:
|
|||||||
## Backlog
|
## Backlog
|
||||||
|
|
||||||
- [asdf](tasks/asdf.md)
|
- [asdf](tasks/asdf.md)
|
||||||
|
- [merge-scan-photos](tasks/merge-scan-photos.md)
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
|
|
||||||
- [nef-support](tasks/nef-support.md)
|
|
||||||
- [determine-if-location-container-collection-is-needed-in-get-faces](tasks/determine-if-location-container-collection-is-needed-in-get-faces.md)
|
|
||||||
- [use-photo-prism-to-map](tasks/use-photo-prism-to-map.md)
|
|
||||||
- [import-face-region-metadata](tasks/import-face-region-metadata.md)
|
- [import-face-region-metadata](tasks/import-face-region-metadata.md)
|
||||||
|
- [use-photo-prism-to-map](tasks/use-photo-prism-to-map.md)
|
||||||
|
- [determine-if-location-container-collection-is-needed-in-get-faces](tasks/determine-if-location-container-collection-is-needed-in-get-faces.md)
|
||||||
|
- [google-timeline-for-geo](tasks/google-timeline-for-geo.md)
|
||||||
|
- [merge-kristy-files](tasks/merge-kristy-files.md)
|
||||||
|
- [setup-syncthing-server](tasks/setup-syncthing-server.md)
|
||||||
|
|
||||||
## In Progress
|
## In Progress
|
||||||
|
|
||||||
- [import-know-faces-into-db](tasks/import-know-faces-into-db.md)
|
|
||||||
- [setup-photo-prism-again-in-wsl-docker](tasks/setup-photo-prism-again-in-wsl-docker.md)
|
|
||||||
- [run-scan-originals](tasks/run-scan-originals.md)
|
|
||||||
- [find-incorrectly-mapped-faces](tasks/find-incorrectly-mapped-faces.md)
|
- [find-incorrectly-mapped-faces](tasks/find-incorrectly-mapped-faces.md)
|
||||||
- [shrink-percent](tasks/shrink-percent.md)
|
- [nef-support](tasks/nef-support.md)
|
||||||
- [use-eyes-to-find-orientation](tasks/use-eyes-to-find-orientation.md)
|
- [use-eyes-to-find-orientation](tasks/use-eyes-to-find-orientation.md)
|
||||||
|
- [import-know-faces-into-db](tasks/import-know-faces-into-db.md)
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
- [eof-error](tasks/eof-error.md)
|
- [eof-error](tasks/eof-error.md)
|
||||||
|
- [setup-photo-prism-again-in-wsl-docker](tasks/setup-photo-prism-again-in-wsl-docker.md)
|
||||||
|
- [run-scan-originals](tasks/run-scan-originals.md)
|
||||||
|
- [shrink-percent](tasks/shrink-percent.md)
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-12T21:54:44.803Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-12T21:54:44.803Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "1-Backlog"
|
||||||
---
|
---
|
||||||
|
|
||||||
# asdf
|
# asdf
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-24T02:12:00.629Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-24T02:12:47.758Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "2-Todo"
|
||||||
---
|
---
|
||||||
|
|
||||||
# determine-if-location-container-collection-is-needed-in-get-faces
|
# determine-if-location-container-collection-is-needed-in-get-faces
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-12T21:55:20.591Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-18T15:18:01.941Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "4-Done"
|
||||||
---
|
---
|
||||||
|
|
||||||
# eof-error
|
# eof-error
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-18T20:29:10.288Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-19T01:50:22.660Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "3-In Progress"
|
||||||
---
|
---
|
||||||
|
|
||||||
# find-incorrectly-mapped-faces
|
# find-incorrectly-mapped-faces
|
||||||
|
15
.kanbn/tasks/google-timeline-for-geo.md
Normal file
15
.kanbn/tasks/google-timeline-for-geo.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
created: 2023-06-25T15:26:35.170Z
|
||||||
|
updated: 2023-06-25T15:29:50.594Z
|
||||||
|
assigned: ""
|
||||||
|
progress: 0
|
||||||
|
tags: []
|
||||||
|
status: "2-Todo"
|
||||||
|
---
|
||||||
|
|
||||||
|
# google-timeline-for-geo
|
||||||
|
|
||||||
|
## Sub-tasks
|
||||||
|
|
||||||
|
- [ ] Download google-timeline then update images within time frame
|
||||||
|
- [ ] Determine if NIKON CORPORATION NIKON D3400 changes timezones
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-19T21:38:12.818Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-19T21:38:12.818Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "2-Todo"
|
||||||
---
|
---
|
||||||
|
|
||||||
# import-face-region-metadata
|
# import-face-region-metadata
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-12T21:54:44.803Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-25T01:24:50.138Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "3-In Progress"
|
||||||
---
|
---
|
||||||
|
|
||||||
# import-know-faces-into-db
|
# import-know-faces-into-db
|
||||||
|
14
.kanbn/tasks/merge-kristy-files.md
Normal file
14
.kanbn/tasks/merge-kristy-files.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
created: 2023-06-25T16:35:28.627Z
|
||||||
|
updated: 2023-06-25T16:35:35.404Z
|
||||||
|
assigned: ""
|
||||||
|
progress: 0
|
||||||
|
tags: []
|
||||||
|
status: "2-Todo"
|
||||||
|
---
|
||||||
|
|
||||||
|
# merge-kristy-files
|
||||||
|
|
||||||
|
## Sub-tasks
|
||||||
|
|
||||||
|
- [ ] asdf
|
20
.kanbn/tasks/merge-scan-photos.md
Normal file
20
.kanbn/tasks/merge-scan-photos.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
created: 2023-06-12T21:54:44.803Z
|
||||||
|
updated: 2023-06-12T21:54:44.803Z
|
||||||
|
assigned: ""
|
||||||
|
progress: 0
|
||||||
|
tags: []
|
||||||
|
status: "1-Backlog"
|
||||||
|
---
|
||||||
|
|
||||||
|
# merge-scan-photos
|
||||||
|
|
||||||
|
- Inform about the few file name duplicates
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd "D:/7) Question/- Scans 12.22 (2043)"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Sub-tasks
|
||||||
|
|
||||||
|
- [ ] asdf
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-24T02:13:16.426Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-24T02:13:20.545Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "3-In Progress"
|
||||||
---
|
---
|
||||||
|
|
||||||
# nef-support
|
# nef-support
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-12T21:54:44.810Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-25T16:30:22.805Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "4-Done"
|
||||||
---
|
---
|
||||||
|
|
||||||
# run-scan-originals
|
# run-scan-originals
|
||||||
|
|
||||||
## Sub-tasks
|
## Sub-tasks
|
||||||
|
|
||||||
- [ ] run-scan-originals
|
- [x] run-scan-originals
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-12T17:28:20.080Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-25T16:29:52.487Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "4-Done"
|
||||||
---
|
---
|
||||||
|
|
||||||
# Setup PhotoPrism again in WSL / Docker
|
# Setup PhotoPrism again in WSL / Docker
|
||||||
|
|
||||||
## Sub-tasks
|
## Sub-tasks
|
||||||
|
|
||||||
- [ ] Install Docker
|
- [x] Install Docker
|
||||||
- [ ] Install WSL
|
- [x] Install WSL
|
||||||
|
19
.kanbn/tasks/setup-syncthing-server.md
Normal file
19
.kanbn/tasks/setup-syncthing-server.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
created: 2023-06-12T21:54:44.803Z
|
||||||
|
updated: 2023-06-12T21:54:44.803Z
|
||||||
|
assigned: ""
|
||||||
|
progress: 0
|
||||||
|
tags: []
|
||||||
|
status: "1-Backlog"
|
||||||
|
---
|
||||||
|
|
||||||
|
# setup-syncthing-server
|
||||||
|
|
||||||
|
- Share one folder at a time
|
||||||
|
- Use push only feature
|
||||||
|
|
||||||
|
## Sub-tasks
|
||||||
|
|
||||||
|
- [ ] Use Windows box to create Syncthing server
|
||||||
|
- [ ] Find 256 GB SSD to put pictures on
|
||||||
|
- [ ] asdf
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-19T21:39:09.103Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-25T16:24:52.333Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "4-Done"
|
||||||
---
|
---
|
||||||
|
|
||||||
# shrink-percent
|
# shrink-percent
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-23T13:56:11.956Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-24T15:11:14.038Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "3-In Progress"
|
||||||
---
|
---
|
||||||
|
|
||||||
# use-eyes-to-find-orientation
|
# use-eyes-to-find-orientation
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
created: 2023-06-12T15:44:11.932Z
|
created: 2023-06-19T21:38:12.818Z
|
||||||
updated: 2023-06-12T15:45:59.891Z
|
updated: 2023-06-19T21:38:12.818Z
|
||||||
assigned: ""
|
assigned: ""
|
||||||
progress: 0
|
progress: 0
|
||||||
tags: []
|
tags: []
|
||||||
|
status: "2-Todo"
|
||||||
---
|
---
|
||||||
|
|
||||||
# use-photo-prism-to-map
|
# use-photo-prism-to-map
|
||||||
@ -11,4 +12,4 @@ tags: []
|
|||||||
## Sub-tasks
|
## Sub-tasks
|
||||||
|
|
||||||
- [ ] Do I need to join makers with subjects
|
- [ ] Do I need to join makers with subjects
|
||||||
- [ ] Build logic to use photo prism to suggest missing mapping
|
- [ ] Build logic to use photo prism to suggest missing mapping
|
||||||
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -34,6 +34,7 @@
|
|||||||
"Serilog",
|
"Serilog",
|
||||||
"Subfile",
|
"Subfile",
|
||||||
"Subfiles",
|
"Subfiles",
|
||||||
|
"Syncthing",
|
||||||
"Unmanaged",
|
"Unmanaged",
|
||||||
"Upsample",
|
"Upsample",
|
||||||
"Vericruz"
|
"Vericruz"
|
||||||
|
@ -2,16 +2,21 @@ using System.Drawing;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using View_by_Distance.Shared.Models;
|
using View_by_Distance.Shared.Models;
|
||||||
using View_by_Distance.Shared.Models.Methods;
|
using View_by_Distance.Shared.Models.Methods;
|
||||||
|
using View_by_Distance.Shared.Models.Properties;
|
||||||
|
|
||||||
namespace View_by_Distance.BlurHash.Models;
|
namespace View_by_Distance.BlurHash.Models;
|
||||||
|
|
||||||
public class C2_BlurHasher : IBlurHasher
|
public class C2_BlurHasher : IBlurHasher
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||||
|
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
|
||||||
|
|
||||||
public C2_BlurHasher(string resultAllInOne, string? resultsFullGroupDirectory) =>
|
public C2_BlurHasher(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory)
|
||||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory, new string[] { "{}", "()" }, maxValue: 102);
|
{
|
||||||
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
|
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, resultsFullGroupDirectory, new string[] { propertyConfiguration.ResultContent, propertyConfiguration.ResultSingleton });
|
||||||
|
}
|
||||||
|
|
||||||
string IBlurHasher.Encode(FileHolder fileHolder)
|
string IBlurHasher.Encode(FileHolder fileHolder)
|
||||||
{
|
{
|
||||||
@ -26,24 +31,21 @@ public class C2_BlurHasher : IBlurHasher
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string? IBlurHasher.GetFile(FileHolder fileHolder)
|
string IBlurHasher.GetFile(FileHolder fileHolder)
|
||||||
{
|
{
|
||||||
string? result;
|
string result;
|
||||||
string directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(fileHolder.Name, length: 2);
|
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, fileHolder.Name);
|
||||||
result = !int.TryParse(directory, out int directoryIndex) ? null : Path.Combine(_JsonGroups["{}"][directoryIndex], $"{fileHolder.Name}.csv");
|
result = Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{fileHolder.Name}.csv");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string IBlurHasher.EncodeAndSave(FileHolder fileHolder)
|
string IBlurHasher.EncodeAndSave(FileHolder fileHolder)
|
||||||
{
|
{
|
||||||
string? file;
|
|
||||||
string result;
|
string result;
|
||||||
int actualByte;
|
int actualByte;
|
||||||
string extension = ".png";
|
string extension = ".png";
|
||||||
IBlurHasher blurHasher = this;
|
IBlurHasher blurHasher = this;
|
||||||
file = blurHasher.GetFile(fileHolder);
|
string file = blurHasher.GetFile(fileHolder);
|
||||||
if (file is null)
|
|
||||||
throw new NullReferenceException(nameof(file));
|
|
||||||
#pragma warning disable CA1416
|
#pragma warning disable CA1416
|
||||||
Image image = Image.FromFile(fileHolder.FullName);
|
Image image = Image.FromFile(fileHolder.FullName);
|
||||||
int outputWidth = (int)(image.Width * .25);
|
int outputWidth = (int)(image.Width * .25);
|
||||||
@ -57,23 +59,20 @@ public class C2_BlurHasher : IBlurHasher
|
|||||||
string fileNameWithoutExtension = $"{componentsX}x{componentsY}-{outputWidth}x{outputHeight}-{joined}";
|
string fileNameWithoutExtension = $"{componentsX}x{componentsY}-{outputWidth}x{outputHeight}-{joined}";
|
||||||
string contents = string.Concat(result, Environment.NewLine, fileNameWithoutExtension, Environment.NewLine, extension);
|
string contents = string.Concat(result, Environment.NewLine, fileNameWithoutExtension, Environment.NewLine, extension);
|
||||||
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(file, contents, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(file, contents, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
string directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(joined, length: 2);
|
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, joined);
|
||||||
if (int.TryParse(directory, out int directoryIndex))
|
file = Path.Combine(_FileGroups[_PropertyConfiguration.ResultContent][directoryIndex], $"{fileNameWithoutExtension}{extension}");
|
||||||
|
if (!File.Exists(file))
|
||||||
{
|
{
|
||||||
file = Path.Combine(_JsonGroups["()"][directoryIndex], $"{fileNameWithoutExtension}{extension}");
|
try
|
||||||
if (!File.Exists(file))
|
|
||||||
{
|
{
|
||||||
try
|
using FileStream fileStream = new(file, FileMode.CreateNew);
|
||||||
{
|
actualImage.Save(fileStream, System.Drawing.Imaging.ImageFormat.Png);
|
||||||
using FileStream fileStream = new(file, FileMode.CreateNew);
|
_ = fileStream.Seek(0, SeekOrigin.Begin);
|
||||||
actualImage.Save(fileStream, System.Drawing.Imaging.ImageFormat.Png);
|
actualByte = fileStream.ReadByte();
|
||||||
_ = fileStream.Seek(0, SeekOrigin.Begin);
|
while (actualByte > -1)
|
||||||
actualByte = fileStream.ReadByte();
|
actualByte = fileStream.ReadByte();
|
||||||
while (actualByte > -1)
|
|
||||||
actualByte = fileStream.ReadByte();
|
|
||||||
}
|
|
||||||
catch (Exception) { }
|
|
||||||
}
|
}
|
||||||
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
image.Dispose();
|
image.Dispose();
|
||||||
#pragma warning restore CA1416
|
#pragma warning restore CA1416
|
||||||
|
@ -16,7 +16,7 @@ public class CopyDistinct
|
|||||||
private readonly Configuration _Configuration;
|
private readonly Configuration _Configuration;
|
||||||
private readonly IsEnvironment _IsEnvironment;
|
private readonly IsEnvironment _IsEnvironment;
|
||||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||||
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
|
||||||
private readonly Property.Models.Configuration _PropertyConfiguration;
|
private readonly Property.Models.Configuration _PropertyConfiguration;
|
||||||
|
|
||||||
public CopyDistinct(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
public CopyDistinct(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||||
@ -29,10 +29,10 @@ public class CopyDistinct
|
|||||||
_IsEnvironment = isEnvironment;
|
_IsEnvironment = isEnvironment;
|
||||||
_WorkingDirectory = workingDirectory;
|
_WorkingDirectory = workingDirectory;
|
||||||
_ConfigurationRoot = configurationRoot;
|
_ConfigurationRoot = configurationRoot;
|
||||||
string[] directories = new string[] { "()" };
|
|
||||||
ILogger? log = Log.ForContext<CopyDistinct>();
|
ILogger? log = Log.ForContext<CopyDistinct>();
|
||||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration.ResultAllInOne, appSettings.CopyTo, directories, appSettings.MaxValue);
|
string[] directories = new string[] { propertyConfiguration.ResultContent };
|
||||||
|
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, appSettings.CopyTo, directories);
|
||||||
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||||
_PropertyConfiguration = propertyConfiguration;
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
_Configuration = configuration;
|
_Configuration = configuration;
|
||||||
@ -41,7 +41,7 @@ public class CopyDistinct
|
|||||||
Verify();
|
Verify();
|
||||||
List<string> lines = CopyDistinctFilesInDirectories(log);
|
List<string> lines = CopyDistinctFilesInDirectories(log);
|
||||||
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
||||||
if (lines.Any())
|
if (!lines.Any())
|
||||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(propertyConfiguration.RootDirectory);
|
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(propertyConfiguration.RootDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,13 +83,10 @@ public class CopyDistinct
|
|||||||
private List<(FileHolder, string)> GetToDoCollection(ProgressBar progressBar, List<string> files)
|
private List<(FileHolder, string)> GetToDoCollection(ProgressBar progressBar, List<string> files)
|
||||||
{
|
{
|
||||||
List<(FileHolder, string)> results = new();
|
List<(FileHolder, string)> results = new();
|
||||||
string directory;
|
|
||||||
string checkFile;
|
string checkFile;
|
||||||
int directoryIndex;
|
int directoryIndex;
|
||||||
FileHolder fileHolder;
|
FileHolder fileHolder;
|
||||||
bool isIgnoreExtension;
|
|
||||||
List<string> distinct = new();
|
List<string> distinct = new();
|
||||||
bool isValidImageFormatExtension;
|
|
||||||
bool nameWithoutExtensionIsIdFormat;
|
bool nameWithoutExtensionIsIdFormat;
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
@ -99,17 +96,15 @@ public class CopyDistinct
|
|||||||
continue;
|
continue;
|
||||||
if (files.Contains($"{fileHolder.FullName}.id"))
|
if (files.Contains($"{fileHolder.FullName}.id"))
|
||||||
continue;
|
continue;
|
||||||
isValidImageFormatExtension = _PropertyConfiguration.ValidImageFormatExtensions.Contains(fileHolder.ExtensionLowered);
|
|
||||||
isIgnoreExtension = isValidImageFormatExtension && _PropertyConfiguration.IgnoreExtensions.Contains(fileHolder.ExtensionLowered);
|
|
||||||
if (isIgnoreExtension || !isValidImageFormatExtension)
|
|
||||||
continue;
|
|
||||||
nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(fileHolder);
|
nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(fileHolder);
|
||||||
if (!nameWithoutExtensionIsIdFormat)
|
if (!nameWithoutExtensionIsIdFormat)
|
||||||
continue;
|
{
|
||||||
directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(fileHolder.NameWithoutExtension, 2);
|
nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(_PropertyConfiguration.ValidImageFormatExtensions, fileHolder);
|
||||||
if (!int.TryParse(directory, out directoryIndex))
|
if (!nameWithoutExtensionIsIdFormat)
|
||||||
continue;
|
continue;
|
||||||
checkFile = Path.Combine(_JsonGroups["()"][directoryIndex], fileHolder.Name);
|
}
|
||||||
|
(_, directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, fileHolder.NameWithoutExtension);
|
||||||
|
checkFile = Path.Combine(_FileGroups[_PropertyConfiguration.ResultContent][directoryIndex], fileHolder.Name);
|
||||||
if (distinct.Contains(checkFile))
|
if (distinct.Contains(checkFile))
|
||||||
continue;
|
continue;
|
||||||
distinct.Add(checkFile);
|
distinct.Add(checkFile);
|
||||||
@ -160,8 +155,8 @@ public class CopyDistinct
|
|||||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||||
ProgressBar progressBar = new(allFiles.Count, message, options);
|
ProgressBar progressBar = new(allFiles.Count, message, options);
|
||||||
List<(FileHolder, string)> toDoCollection = GetToDoCollection(progressBar, allFiles);
|
List<(FileHolder, string)> toDoCollection = GetToDoCollection(progressBar, allFiles);
|
||||||
results.AddRange(Copy(log, toDoCollection));
|
|
||||||
progressBar.Dispose();
|
progressBar.Dispose();
|
||||||
|
results.AddRange(Copy(log, toDoCollection));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,20 +9,17 @@ public class AppSettings
|
|||||||
public string Company { init; get; }
|
public string Company { init; get; }
|
||||||
public string CopyTo { init; get; }
|
public string CopyTo { init; get; }
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
public int MaxDegreeOfParallelism { init; get; }
|
||||||
public int MaxValue { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
public string WorkingDirectoryName { init; get; }
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public AppSettings(string company,
|
public AppSettings(string company,
|
||||||
string copyTo,
|
string copyTo,
|
||||||
int maxDegreeOfParallelism,
|
int maxDegreeOfParallelism,
|
||||||
int maxValue,
|
|
||||||
string workingDirectoryName)
|
string workingDirectoryName)
|
||||||
{
|
{
|
||||||
Company = company;
|
Company = company;
|
||||||
CopyTo = copyTo;
|
CopyTo = copyTo;
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||||
MaxValue = maxValue;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
WorkingDirectoryName = workingDirectoryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ public class AppSettings
|
|||||||
|
|
||||||
public string Company { get; set; }
|
public string Company { get; set; }
|
||||||
public int? MaxDegreeOfParallelism { get; set; }
|
public int? MaxDegreeOfParallelism { get; set; }
|
||||||
public int? MaxValue { get; set; }
|
|
||||||
public string CopyTo { get; set; }
|
public string CopyTo { get; set; }
|
||||||
public string WorkingDirectoryName { get; set; }
|
public string WorkingDirectoryName { get; set; }
|
||||||
|
|
||||||
@ -27,13 +26,10 @@ public class AppSettings
|
|||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
if (appSettings?.MaxDegreeOfParallelism is null)
|
if (appSettings?.MaxDegreeOfParallelism is null)
|
||||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||||
if (appSettings?.MaxValue is null)
|
|
||||||
throw new NullReferenceException(nameof(appSettings.MaxValue));
|
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.Company,
|
appSettings.Company,
|
||||||
appSettings.CopyTo,
|
appSettings.CopyTo,
|
||||||
appSettings.MaxDegreeOfParallelism.Value,
|
appSettings.MaxDegreeOfParallelism.Value,
|
||||||
appSettings.MaxValue.Value,
|
|
||||||
appSettings.WorkingDirectoryName
|
appSettings.WorkingDirectoryName
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"MaxDegreeOfParallelism": 6,
|
"MaxDegreeOfParallelism": 6,
|
||||||
"MaxValue": 12,
|
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
"Serilog.Sinks.Console",
|
"Serilog.Sinks.Console",
|
||||||
@ -64,6 +63,7 @@
|
|||||||
"PopulatePropertyId": true,
|
"PopulatePropertyId": true,
|
||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
"PopulatePropertyId": false,
|
"PopulatePropertyId": false,
|
||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
"PopulatePropertyId": true,
|
"PopulatePropertyId": true,
|
||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
"PopulatePropertyId": true,
|
"PopulatePropertyId": true,
|
||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
"PopulatePropertyId": true,
|
"PopulatePropertyId": true,
|
||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
|
@ -11,6 +11,7 @@ using View_by_Distance.Property.Models;
|
|||||||
using View_by_Distance.Property.Models.Stateless;
|
using View_by_Distance.Property.Models.Stateless;
|
||||||
using View_by_Distance.Resize.Models;
|
using View_by_Distance.Resize.Models;
|
||||||
using View_by_Distance.Shared.Models;
|
using View_by_Distance.Shared.Models;
|
||||||
|
using View_by_Distance.Shared.Models.Properties;
|
||||||
using View_by_Distance.Shared.Models.Stateless;
|
using View_by_Distance.Shared.Models.Stateless;
|
||||||
|
|
||||||
namespace View_by_Distance.Face.Models;
|
namespace View_by_Distance.Face.Models;
|
||||||
@ -33,7 +34,6 @@ public class D_Face
|
|||||||
private readonly string _ArgZero;
|
private readonly string _ArgZero;
|
||||||
private readonly Serilog.ILogger? _Log;
|
private readonly Serilog.ILogger? _Log;
|
||||||
private readonly bool _OverrideForFaceImages;
|
private readonly bool _OverrideForFaceImages;
|
||||||
private readonly Configuration _Configuration;
|
|
||||||
private readonly bool _LoadPhotoPrismLocations;
|
private readonly bool _LoadPhotoPrismLocations;
|
||||||
private readonly ImageCodecInfo _ImageCodecInfo;
|
private readonly ImageCodecInfo _ImageCodecInfo;
|
||||||
private readonly ModelParameter _ModelParameter;
|
private readonly ModelParameter _ModelParameter;
|
||||||
@ -45,14 +45,16 @@ public class D_Face
|
|||||||
private readonly int _FaceDistanceHiddenImageFactor;
|
private readonly int _FaceDistanceHiddenImageFactor;
|
||||||
private readonly EncoderParameters _EncoderParameters;
|
private readonly EncoderParameters _EncoderParameters;
|
||||||
private readonly ImageCodecInfo _HiddenImageCodecInfo;
|
private readonly ImageCodecInfo _HiddenImageCodecInfo;
|
||||||
|
private readonly Dictionary<string, string[]> _FileGroups;
|
||||||
private readonly bool _ForceFaceLastWriteTimeToCreationTime;
|
private readonly bool _ForceFaceLastWriteTimeToCreationTime;
|
||||||
private readonly EncoderParameters _HiddenEncoderParameters;
|
private readonly EncoderParameters _HiddenEncoderParameters;
|
||||||
|
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||||
private readonly JsonSerializerOptions _WriteIndentedAndWhenWritingNull;
|
private readonly JsonSerializerOptions _WriteIndentedAndWhenWritingNull;
|
||||||
|
|
||||||
public D_Face(
|
public D_Face(
|
||||||
string argZero,
|
string argZero,
|
||||||
|
IPropertyConfiguration propertyConfiguration,
|
||||||
bool checkDFaceAndUpWriteDates,
|
bool checkDFaceAndUpWriteDates,
|
||||||
Configuration configuration,
|
|
||||||
EncoderParameters encoderParameters,
|
EncoderParameters encoderParameters,
|
||||||
int faceDistanceHiddenImageFactor,
|
int faceDistanceHiddenImageFactor,
|
||||||
string filenameExtension,
|
string filenameExtension,
|
||||||
@ -70,7 +72,7 @@ public class D_Face
|
|||||||
float[] rectangleIntersectMinimums)
|
float[] rectangleIntersectMinimums)
|
||||||
{
|
{
|
||||||
_ArgZero = argZero;
|
_ArgZero = argZero;
|
||||||
_Configuration = configuration;
|
_FileGroups = new();
|
||||||
_ImageCodecInfo = imageCodecInfo;
|
_ImageCodecInfo = imageCodecInfo;
|
||||||
_EncoderParameters = encoderParameters;
|
_EncoderParameters = encoderParameters;
|
||||||
_FileNameExtension = filenameExtension;
|
_FileNameExtension = filenameExtension;
|
||||||
@ -78,6 +80,7 @@ public class D_Face
|
|||||||
AngleBracketCollection = new List<string>();
|
AngleBracketCollection = new List<string>();
|
||||||
_HiddenImageCodecInfo = hiddenImageCodecInfo;
|
_HiddenImageCodecInfo = hiddenImageCodecInfo;
|
||||||
_OverrideForFaceImages = overrideForFaceImages;
|
_OverrideForFaceImages = overrideForFaceImages;
|
||||||
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
_HiddenEncoderParameters = hiddenEncoderParameters;
|
_HiddenEncoderParameters = hiddenEncoderParameters;
|
||||||
_HiddenFileNameExtension = hiddenFileNameExtension;
|
_HiddenFileNameExtension = hiddenFileNameExtension;
|
||||||
_LoadPhotoPrismLocations = loadPhotoPrismLocations;
|
_LoadPhotoPrismLocations = loadPhotoPrismLocations;
|
||||||
@ -101,6 +104,14 @@ public class D_Face
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update(string dResultsFullGroupDirectory)
|
||||||
|
{
|
||||||
|
_FileGroups.Clear();
|
||||||
|
Dictionary<string, string[]> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, dResultsFullGroupDirectory, new string[] { _PropertyConfiguration.ResultCollection });
|
||||||
|
foreach (KeyValuePair<string, string[]> keyValuePair in keyValuePairs)
|
||||||
|
_FileGroups.Add(keyValuePair.Key, keyValuePair.Value);
|
||||||
|
}
|
||||||
|
|
||||||
private static (Model model, PredictorModel predictorModel, ModelParameter modelParameter) GetModel(string modelDirectory, string modelName, string predictorModelName)
|
private static (Model model, PredictorModel predictorModel, ModelParameter modelParameter) GetModel(string modelDirectory, string modelName, string predictorModelName)
|
||||||
{
|
{
|
||||||
(Model, PredictorModel, ModelParameter) result;
|
(Model, PredictorModel, ModelParameter) result;
|
||||||
@ -179,7 +190,7 @@ public class D_Face
|
|||||||
continue;
|
continue;
|
||||||
if (face.FaceEncoding is null || face?.Location is null || face?.OutputResolution is null)
|
if (face.FaceEncoding is null || face?.Location is null || face?.OutputResolution is null)
|
||||||
continue;
|
continue;
|
||||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, ILocation.Digits, ILocation.Factor, source.Height, source.Width, collection.Count);
|
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, source.Height, source.Width, collection.Count);
|
||||||
if (location is null)
|
if (location is null)
|
||||||
continue;
|
continue;
|
||||||
width = location.Right - location.Left;
|
width = location.Right - location.Left;
|
||||||
@ -202,7 +213,7 @@ public class D_Face
|
|||||||
}
|
}
|
||||||
if (File.Exists(fileName))
|
if (File.Exists(fileName))
|
||||||
File.Delete(fileName);
|
File.Delete(fileName);
|
||||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(_FaceDistanceHiddenImageFactor, face.Location, ILocation.Digits, ILocation.Factor, source.Height, source.Width, collection.Count);
|
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(_FaceDistanceHiddenImageFactor, face.Location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, source.Height, source.Width, collection.Count);
|
||||||
if (location is null)
|
if (location is null)
|
||||||
continue;
|
continue;
|
||||||
width = location.Right - location.Left;
|
width = location.Right - location.Left;
|
||||||
@ -222,10 +233,10 @@ public class D_Face
|
|||||||
{
|
{
|
||||||
if (_Log is null)
|
if (_Log is null)
|
||||||
throw new NullReferenceException(nameof(_Log));
|
throw new NullReferenceException(nameof(_Log));
|
||||||
if (_Configuration.NumberOfJitters is null)
|
if (_PropertyConfiguration.NumberOfJitters is null)
|
||||||
throw new NullReferenceException(nameof(_Configuration.NumberOfJitters));
|
throw new NullReferenceException(nameof(_PropertyConfiguration.NumberOfJitters));
|
||||||
if (_Configuration.NumberOfTimesToUpsample is null)
|
if (_PropertyConfiguration.NumberOfTimesToUpsample is null)
|
||||||
throw new NullReferenceException(nameof(_Configuration.NumberOfTimesToUpsample));
|
throw new NullReferenceException(nameof(_PropertyConfiguration.NumberOfTimesToUpsample));
|
||||||
List<Shared.Models.Face> results = new();
|
List<Shared.Models.Face> results = new();
|
||||||
FaceRecognitionDotNet.Image? unknownImage;
|
FaceRecognitionDotNet.Image? unknownImage;
|
||||||
try
|
try
|
||||||
@ -239,7 +250,7 @@ public class D_Face
|
|||||||
{
|
{
|
||||||
(int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation) = Resize.Models.Stateless.Methods.IResize.Get(outputResolution, outputResolutionToResize);
|
(int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation) = Resize.Models.Stateless.Methods.IResize.Get(outputResolution, outputResolutionToResize);
|
||||||
List<(Location Location, FaceRecognitionDotNet.FaceEncoding? FaceEncoding, Dictionary<FacePart, FacePoint[]>? FaceParts)> collection;
|
List<(Location Location, FaceRecognitionDotNet.FaceEncoding? FaceEncoding, Dictionary<FacePart, FacePoint[]>? FaceParts)> collection;
|
||||||
FaceRecognition faceRecognition = new(_Configuration.NumberOfJitters.Value, _Configuration.NumberOfTimesToUpsample.Value, _Model, _ModelParameter, _PredictorModel);
|
FaceRecognition faceRecognition = new(_PropertyConfiguration.NumberOfJitters.Value, _PropertyConfiguration.NumberOfTimesToUpsample.Value, _Model, _ModelParameter, _PredictorModel);
|
||||||
collection = faceRecognition.GetCollection(unknownImage, locations, includeFaceEncoding: true, includeFaceParts: true);
|
collection = faceRecognition.GetCollection(unknownImage, locations, includeFaceEncoding: true, includeFaceParts: true);
|
||||||
if (!collection.Any())
|
if (!collection.Any())
|
||||||
results.Add(new(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, location: null));
|
results.Add(new(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, location: null));
|
||||||
@ -271,7 +282,7 @@ public class D_Face
|
|||||||
public void SetAngleBracketCollection(string dResultsFullGroupDirectory, string sourceDirectory)
|
public void SetAngleBracketCollection(string dResultsFullGroupDirectory, string sourceDirectory)
|
||||||
{
|
{
|
||||||
AngleBracketCollection.Clear();
|
AngleBracketCollection.Clear();
|
||||||
AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_Configuration,
|
AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
dResultsFullGroupDirectory,
|
dResultsFullGroupDirectory,
|
||||||
contentDescription: "n png file(s) for each face found",
|
contentDescription: "n png file(s) for each face found",
|
||||||
@ -290,7 +301,7 @@ public class D_Face
|
|||||||
throw new NullReferenceException(nameof(item.ImageFileHolder.DirectoryName));
|
throw new NullReferenceException(nameof(item.ImageFileHolder.DirectoryName));
|
||||||
SetAngleBracketCollection(dResultsFullGroupDirectory, item.ImageFileHolder.DirectoryName);
|
SetAngleBracketCollection(dResultsFullGroupDirectory, item.ImageFileHolder.DirectoryName);
|
||||||
}
|
}
|
||||||
result = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
|
result = Path.Combine(AngleBracketCollection[0].Replace("<>", _PropertyConfiguration.ResultContent), item.ImageFileHolder.NameWithoutExtension);
|
||||||
if (!angleBracketCollectionAny)
|
if (!angleBracketCollectionAny)
|
||||||
AngleBracketCollection.Clear();
|
AngleBracketCollection.Clear();
|
||||||
return result;
|
return result;
|
||||||
@ -311,7 +322,7 @@ public class D_Face
|
|||||||
{
|
{
|
||||||
if (face.Location is null || face.OutputResolution is null)
|
if (face.Location is null || face.OutputResolution is null)
|
||||||
continue;
|
continue;
|
||||||
skip.Add(Shared.Models.Stateless.Methods.ILocation.GetWholePercentages(face.Location, ILocation.Digits, face.OutputResolution));
|
skip.Add(Shared.Models.Stateless.Methods.ILocation.GetWholePercentages(face.Location, Shared.Models.Stateless.ILocation.Digits, face.OutputResolution));
|
||||||
}
|
}
|
||||||
foreach (LocationContainer<MetadataExtractor.Directory> locationContainer in locationContainers)
|
foreach (LocationContainer<MetadataExtractor.Directory> locationContainer in locationContainers)
|
||||||
{
|
{
|
||||||
@ -329,7 +340,7 @@ public class D_Face
|
|||||||
outputResolutionCheck = JsonSerializer.Deserialize<OutputResolution>(json);
|
outputResolutionCheck = JsonSerializer.Deserialize<OutputResolution>(json);
|
||||||
if (outputResolutionCheck is null || outputResolutionCheck.Width != outputResolutionWidth || outputResolutionCheck.Height != outputResolutionHeight)
|
if (outputResolutionCheck is null || outputResolutionCheck.Width != outputResolutionWidth || outputResolutionCheck.Height != outputResolutionHeight)
|
||||||
continue;
|
continue;
|
||||||
rectangle = Shared.Models.Stateless.Methods.ILocation.GetRectangle(ILocation.Digits, outputResolutionCheck, locationContainer.WholePercentages);
|
rectangle = Shared.Models.Stateless.Methods.ILocation.GetRectangle(Shared.Models.Stateless.ILocation.Digits, outputResolutionCheck, locationContainer.WholePercentages);
|
||||||
if (rectangle is null)
|
if (rectangle is null)
|
||||||
continue;
|
continue;
|
||||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(outputResolutionHeight, rectangle.Value, outputResolutionWidth);
|
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(outputResolutionHeight, rectangle.Value, outputResolutionWidth);
|
||||||
@ -353,8 +364,8 @@ public class D_Face
|
|||||||
List<Location>? locations;
|
List<Location>? locations;
|
||||||
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize) };
|
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize) };
|
||||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||||
string dCollectionFile = Path.Combine(dResultsFullGroupDirectory, "[]", _Configuration.ResultAllInOne, $"{mappingFromItem.Id}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json");
|
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, mappingFromItem.ImageFileHolder.Name);
|
||||||
FileInfo fileInfo = new(dCollectionFile);
|
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultCollection][directoryIndex], $"{mappingFromItem.ImageFileHolder.NameWithoutExtension}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json"));
|
||||||
if (_ForceFaceLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
if (_ForceFaceLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||||
{
|
{
|
||||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||||
@ -440,7 +451,7 @@ public class D_Face
|
|||||||
results.Add(new(face, null, string.Empty, save));
|
results.Add(new(face, null, string.Empty, save));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
deterministicHashCodeKey = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(mappingFromItem.Id, face.Location, ILocation.Digits, face.OutputResolution);
|
deterministicHashCodeKey = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(mappingFromItem.Id, face.Location, Shared.Models.Stateless.ILocation.Digits, face.OutputResolution);
|
||||||
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{deterministicHashCodeKey}{mappingFromItem.ImageFileHolder.ExtensionLowered}{_FileNameExtension}"));
|
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{deterministicHashCodeKey}{mappingFromItem.ImageFileHolder.ExtensionLowered}{_FileNameExtension}"));
|
||||||
if (_OverrideForFaceImages)
|
if (_OverrideForFaceImages)
|
||||||
save = true;
|
save = true;
|
||||||
|
@ -85,8 +85,8 @@ public partial class DlibDotNet
|
|||||||
(ImageCodecInfo hiddenImageCodecInfo, EncoderParameters hiddenEncoderParameters, string hiddenFileNameExtension) = C_Resize.GetGifLowQuality();
|
(ImageCodecInfo hiddenImageCodecInfo, EncoderParameters hiddenEncoderParameters, string hiddenFileNameExtension) = C_Resize.GetGifLowQuality();
|
||||||
_Faces = new D_Face(
|
_Faces = new D_Face(
|
||||||
argZero,
|
argZero,
|
||||||
configuration.CheckDFaceAndUpWriteDates,
|
|
||||||
configuration.PropertyConfiguration,
|
configuration.PropertyConfiguration,
|
||||||
|
configuration.CheckDFaceAndUpWriteDates,
|
||||||
encoderParameters,
|
encoderParameters,
|
||||||
configuration.FaceDistanceHiddenImageFactor,
|
configuration.FaceDistanceHiddenImageFactor,
|
||||||
filenameExtension,
|
filenameExtension,
|
||||||
@ -136,6 +136,7 @@ public partial class DlibDotNet
|
|||||||
configuration.OutputExtension,
|
configuration.OutputExtension,
|
||||||
configuration.OutputQuality);
|
configuration.OutputQuality);
|
||||||
_Resize = new C_Resize(
|
_Resize = new C_Resize(
|
||||||
|
configuration.PropertyConfiguration,
|
||||||
configuration.ForceResizeLastWriteTimeToCreationTime,
|
configuration.ForceResizeLastWriteTimeToCreationTime,
|
||||||
configuration.OverrideForResizeImages,
|
configuration.OverrideForResizeImages,
|
||||||
configuration.PropertiesChangedForResize,
|
configuration.PropertiesChangedForResize,
|
||||||
@ -682,7 +683,9 @@ public partial class DlibDotNet
|
|||||||
{
|
{
|
||||||
total = 0;
|
total = 0;
|
||||||
(cResultsFullGroupDirectory, c2ResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory) = GetResultsFullGroupDirectories(outputResolution);
|
(cResultsFullGroupDirectory, c2ResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory) = GetResultsFullGroupDirectories(outputResolution);
|
||||||
_BlurHasher = new BlurHash.Models.C2_BlurHasher(_Configuration.PropertyConfiguration.ResultAllInOne, c2ResultsFullGroupDirectory);
|
_Faces.Update(dResultsFullGroupDirectory);
|
||||||
|
_Resize.Update(cResultsFullGroupDirectory);
|
||||||
|
_BlurHasher = new BlurHash.Models.C2_BlurHasher(_Configuration.PropertyConfiguration, c2ResultsFullGroupDirectory);
|
||||||
for (int i = 0; i < containers.Length; i++)
|
for (int i = 0; i < containers.Length; i++)
|
||||||
{
|
{
|
||||||
container = containers[i];
|
container = containers[i];
|
||||||
@ -702,7 +705,7 @@ public partial class DlibDotNet
|
|||||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||||
_FaceParts.SetAngleBracketCollection(_Configuration.PropertyConfiguration, d2ResultsFullGroupDirectory, container.SourceDirectory);
|
_FaceParts.SetAngleBracketCollection(_Configuration.PropertyConfiguration, d2ResultsFullGroupDirectory, container.SourceDirectory);
|
||||||
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, container.SourceDirectory, anyNullOrNoIsUniqueFileName);
|
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, container.SourceDirectory, anyNullOrNoIsUniqueFileName);
|
||||||
_Resize.SetAngleBracketCollection(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, container.SourceDirectory);
|
_Resize.SetAngleBracketCollection(cResultsFullGroupDirectory, container.SourceDirectory);
|
||||||
exceptionCount = FullParallelWork(maxDegreeOfParallelism,
|
exceptionCount = FullParallelWork(maxDegreeOfParallelism,
|
||||||
propertyLogic,
|
propertyLogic,
|
||||||
metadata,
|
metadata,
|
||||||
|
@ -104,6 +104,7 @@
|
|||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"PropertiesChangedForResize": false,
|
"PropertiesChangedForResize": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
|
@ -3,6 +3,7 @@ using System.Text.Json;
|
|||||||
using View_by_Distance.Metadata.Models.Stateless;
|
using View_by_Distance.Metadata.Models.Stateless;
|
||||||
using View_by_Distance.Property.Models;
|
using View_by_Distance.Property.Models;
|
||||||
using View_by_Distance.Property.Models.Stateless;
|
using View_by_Distance.Property.Models.Stateless;
|
||||||
|
using View_by_Distance.Shared.Models.Properties;
|
||||||
using View_by_Distance.Shared.Models.Stateless;
|
using View_by_Distance.Shared.Models.Stateless;
|
||||||
|
|
||||||
namespace View_by_Distance.Metadata.Models;
|
namespace View_by_Distance.Metadata.Models;
|
||||||
@ -15,17 +16,19 @@ public class B_Metadata
|
|||||||
|
|
||||||
private readonly Serilog.ILogger? _Log;
|
private readonly Serilog.ILogger? _Log;
|
||||||
private readonly bool _PropertiesChangedForMetadata;
|
private readonly bool _PropertiesChangedForMetadata;
|
||||||
|
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||||
private readonly bool _ForceMetadataLastWriteTimeToCreationTime;
|
private readonly bool _ForceMetadataLastWriteTimeToCreationTime;
|
||||||
private readonly IReadOnlyDictionary<string, string[]> _JsonGroups;
|
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
|
||||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||||
|
|
||||||
public B_Metadata(Configuration configuration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata, string bResultsFullGroupDirectory)
|
public B_Metadata(IPropertyConfiguration propertyConfiguration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata, string bResultsFullGroupDirectory)
|
||||||
{
|
{
|
||||||
_Log = Serilog.Log.ForContext<B_Metadata>();
|
_Log = Serilog.Log.ForContext<B_Metadata>();
|
||||||
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
|
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
|
||||||
_ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
|
_ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
|
||||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(configuration.ResultAllInOne, bResultsFullGroupDirectory, new string[] { "{}" });
|
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, bResultsFullGroupDirectory, new string[] { propertyConfiguration.ResultSingleton });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -83,10 +86,9 @@ public class B_Metadata
|
|||||||
string json = string.Empty;
|
string json = string.Empty;
|
||||||
string[] changesFrom = new string[] { nameof(A_Property) };
|
string[] changesFrom = new string[] { nameof(A_Property) };
|
||||||
Dictionary<string, List<KeyValuePair<string, string>>>? dictionary;
|
Dictionary<string, List<KeyValuePair<string, string>>>? dictionary;
|
||||||
char directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(mappingFromItem.ImageFileHolder.Name);
|
|
||||||
int directoryIndex = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(directory);
|
|
||||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||||
FileInfo fileInfo = new(Path.Combine(_JsonGroups["{}"][directoryIndex], $"{mappingFromItem.ImageFileHolder.NameWithoutExtension}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json"));
|
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, mappingFromItem.ImageFileHolder.Name);
|
||||||
|
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{mappingFromItem.ImageFileHolder.NameWithoutExtension}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json"));
|
||||||
if (_ForceMetadataLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
if (_ForceMetadataLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||||
{
|
{
|
||||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||||
|
@ -160,6 +160,7 @@ public class MoveById
|
|||||||
List<string> allFiles = GetAllFiles(matchNginxCollection);
|
List<string> allFiles = GetAllFiles(matchNginxCollection);
|
||||||
ProgressBar progressBar = new(allFiles.Count, message, options);
|
ProgressBar progressBar = new(allFiles.Count, message, options);
|
||||||
List<string> toDoCollection = GetToDoCollection(progressBar, allFiles);
|
List<string> toDoCollection = GetToDoCollection(progressBar, allFiles);
|
||||||
|
progressBar.Dispose();
|
||||||
List<(string, string)> moveCollection = new();
|
List<(string, string)> moveCollection = new();
|
||||||
foreach (string file in toDoCollection)
|
foreach (string file in toDoCollection)
|
||||||
{
|
{
|
||||||
@ -179,7 +180,6 @@ public class MoveById
|
|||||||
continue;
|
continue;
|
||||||
File.Move(from, to);
|
File.Move(from, to);
|
||||||
}
|
}
|
||||||
progressBar.Dispose();
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
"PopulatePropertyId": true,
|
"PopulatePropertyId": true,
|
||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"PopulatePropertyId": true,
|
"PopulatePropertyId": true,
|
||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
@ -134,6 +135,7 @@
|
|||||||
"PopulatePropertyId": true,
|
"PopulatePropertyId": true,
|
||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
|
@ -7,6 +7,7 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using View_by_Distance.Property.Models.Stateless;
|
using View_by_Distance.Property.Models.Stateless;
|
||||||
using View_by_Distance.Shared.Models;
|
using View_by_Distance.Shared.Models;
|
||||||
|
using View_by_Distance.Shared.Models.Properties;
|
||||||
using View_by_Distance.Shared.Models.Stateless;
|
using View_by_Distance.Shared.Models.Stateless;
|
||||||
|
|
||||||
namespace View_by_Distance.Property.Models;
|
namespace View_by_Distance.Property.Models;
|
||||||
@ -25,21 +26,23 @@ public class A_Property
|
|||||||
private readonly ASCIIEncoding _ASCIIEncoding;
|
private readonly ASCIIEncoding _ASCIIEncoding;
|
||||||
private readonly Configuration _Configuration;
|
private readonly Configuration _Configuration;
|
||||||
private readonly List<string> _AngleBracketCollection;
|
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;
|
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;
|
Reverse = reverse;
|
||||||
_Configuration = configuration;
|
|
||||||
_ExceptionsDirectories = new();
|
_ExceptionsDirectories = new();
|
||||||
_OutputExtension = outputExtension;
|
_OutputExtension = outputExtension;
|
||||||
_ASCIIEncoding = new ASCIIEncoding();
|
_ASCIIEncoding = new ASCIIEncoding();
|
||||||
|
_Configuration = propertyConfiguration;
|
||||||
_Log = Serilog.Log.ForContext<A_Property>();
|
_Log = Serilog.Log.ForContext<A_Property>();
|
||||||
_AngleBracketCollection = new List<string>();
|
_AngleBracketCollection = new List<string>();
|
||||||
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
_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()
|
public override string ToString()
|
||||||
@ -263,12 +266,13 @@ public class A_Property
|
|||||||
string[] changesFrom = Array.Empty<string>();
|
string[] changesFrom = Array.Empty<string>();
|
||||||
string angleBracket = _AngleBracketCollection[0];
|
string angleBracket = _AngleBracketCollection[0];
|
||||||
bool populateId = _Configuration.PopulatePropertyId;
|
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)
|
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
|
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();
|
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")))
|
if (_Configuration.ForcePropertyLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||||
{
|
{
|
||||||
@ -378,7 +382,7 @@ public class A_Property
|
|||||||
Shared.Models.Property property;
|
Shared.Models.Property property;
|
||||||
List<string> parseExceptions = new();
|
List<string> parseExceptions = new();
|
||||||
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
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}");
|
string filteredSourceDirectoryFileExtensionLowered = Path.Combine(sourceDirectory, $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}");
|
||||||
if (item.IsValidImageFormatExtension && item.ImageFileHolder.FullName.Length == filteredSourceDirectoryFileExtensionLowered.Length && item.ImageFileHolder.FullName != filteredSourceDirectoryFileExtensionLowered)
|
if (item.IsValidImageFormatExtension && item.ImageFileHolder.FullName.Length == filteredSourceDirectoryFileExtensionLowered.Length && item.ImageFileHolder.FullName != filteredSourceDirectoryFileExtensionLowered)
|
||||||
File.Move(item.ImageFileHolder.FullName, filteredSourceDirectoryFileExtensionLowered);
|
File.Move(item.ImageFileHolder.FullName, filteredSourceDirectoryFileExtensionLowered);
|
||||||
@ -427,7 +431,7 @@ public class A_Property
|
|||||||
if (!anyNullOrNoIsUniqueFileName)
|
if (!anyNullOrNoIsUniqueFileName)
|
||||||
_AngleBracketCollection.AddRange(new[] { Path.Combine(aResultsFullGroupDirectory, "<>") });
|
_AngleBracketCollection.AddRange(new[] { Path.Combine(aResultsFullGroupDirectory, "<>") });
|
||||||
else
|
else
|
||||||
_AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_Configuration,
|
_AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
aResultsFullGroupDirectory,
|
aResultsFullGroupDirectory,
|
||||||
contentDescription: string.Empty,
|
contentDescription: string.Empty,
|
||||||
@ -439,7 +443,7 @@ public class A_Property
|
|||||||
private void SetAngleBracketCollection(string sourceDirectory, bool anyNullOrNoIsUniqueFileName)
|
private void SetAngleBracketCollection(string sourceDirectory, bool anyNullOrNoIsUniqueFileName)
|
||||||
{
|
{
|
||||||
_AngleBracketCollection.Clear();
|
_AngleBracketCollection.Clear();
|
||||||
string aResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(_Configuration,
|
string aResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(_PropertyConfiguration,
|
||||||
nameof(A_Property),
|
nameof(A_Property),
|
||||||
string.Empty,
|
string.Empty,
|
||||||
includeResizeGroup: false,
|
includeResizeGroup: false,
|
||||||
@ -461,7 +465,7 @@ public class A_Property
|
|||||||
int containersLength = containers.Length;
|
int containersLength = containers.Length;
|
||||||
const string outputResolution = "Original";
|
const string outputResolution = "Original";
|
||||||
List<Tuple<string, DateTime>> sourceDirectoryChanges = new();
|
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++)
|
for (int i = 0; i < containers.Length; i++)
|
||||||
{
|
{
|
||||||
container = containers[i];
|
container = containers[i];
|
||||||
@ -506,7 +510,7 @@ public class A_Property
|
|||||||
SetAngleBracketCollection(item.ImageFileHolder.DirectoryName, !item.IsUniqueFileName);
|
SetAngleBracketCollection(item.ImageFileHolder.DirectoryName, !item.IsUniqueFileName);
|
||||||
}
|
}
|
||||||
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(item.ImageFileHolder.ExtensionLowered);
|
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);
|
result = GetPropertyOfPrivate(item, sourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidMetadataExtensions);
|
||||||
if (!angleBracketCollectionAny)
|
if (!angleBracketCollectionAny)
|
||||||
_AngleBracketCollection.Clear();
|
_AngleBracketCollection.Clear();
|
||||||
|
@ -21,6 +21,7 @@ public class Configuration
|
|||||||
[Display(Name = "Properties Changed For Property"), Required] public bool? PropertiesChangedForProperty { get; set; }
|
[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 = "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"), 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 Collection"), Required] public string ResultCollection { get; set; }
|
||||||
[Display(Name = "Result Content"), Required] public string ResultContent { get; set; }
|
[Display(Name = "Result Content"), Required] public string ResultContent { get; set; }
|
||||||
[Display(Name = "Result Singleton"), Required] public string ResultSingleton { 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));
|
throw new NullReferenceException(nameof(configuration.PropertiesChangedForProperty));
|
||||||
if (configuration.ResultAllInOne is null)
|
if (configuration.ResultAllInOne is null)
|
||||||
throw new NullReferenceException(nameof(configuration.ResultAllInOne));
|
throw new NullReferenceException(nameof(configuration.ResultAllInOne));
|
||||||
|
if (configuration.ResultAllInOneSubdirectoryLength is null)
|
||||||
|
throw new NullReferenceException(nameof(configuration.ResultAllInOneSubdirectoryLength));
|
||||||
if (configuration.ResultCollection is null)
|
if (configuration.ResultCollection is null)
|
||||||
throw new NullReferenceException(nameof(configuration.ResultCollection));
|
throw new NullReferenceException(nameof(configuration.ResultCollection));
|
||||||
if (configuration.ResultContent is null)
|
if (configuration.ResultContent is null)
|
||||||
@ -77,6 +80,7 @@ public class Configuration
|
|||||||
configuration.PropertiesChangedForProperty.Value,
|
configuration.PropertiesChangedForProperty.Value,
|
||||||
configuration.PropertyContentCollectionFiles,
|
configuration.PropertyContentCollectionFiles,
|
||||||
configuration.ResultAllInOne,
|
configuration.ResultAllInOne,
|
||||||
|
configuration.ResultAllInOneSubdirectoryLength.Value,
|
||||||
configuration.ResultCollection,
|
configuration.ResultCollection,
|
||||||
configuration.ResultContent,
|
configuration.ResultContent,
|
||||||
configuration.ResultSingleton,
|
configuration.ResultSingleton,
|
||||||
|
@ -29,6 +29,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
public bool PropertiesChangedForProperty { init; get; }
|
public bool PropertiesChangedForProperty { init; get; }
|
||||||
public string[] PropertyContentCollectionFiles { init; get; }
|
public string[] PropertyContentCollectionFiles { init; get; }
|
||||||
public string ResultAllInOne { init; get; }
|
public string ResultAllInOne { init; get; }
|
||||||
|
public int ResultAllInOneSubdirectoryLength { init; get; }
|
||||||
public string ResultCollection { init; get; }
|
public string ResultCollection { init; get; }
|
||||||
public string ResultContent { init; get; }
|
public string ResultContent { init; get; }
|
||||||
public string ResultSingleton { init; get; }
|
public string ResultSingleton { init; get; }
|
||||||
@ -48,6 +49,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
bool propertiesChangedForProperty,
|
bool propertiesChangedForProperty,
|
||||||
string[] propertyContentCollectionFiles,
|
string[] propertyContentCollectionFiles,
|
||||||
string resultAllInOne,
|
string resultAllInOne,
|
||||||
|
int resultAllInOneSubdirectoryLength,
|
||||||
string resultCollection,
|
string resultCollection,
|
||||||
string resultContent,
|
string resultContent,
|
||||||
string resultSingleton,
|
string resultSingleton,
|
||||||
@ -68,6 +70,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
PropertiesChangedForProperty = propertiesChangedForProperty;
|
PropertiesChangedForProperty = propertiesChangedForProperty;
|
||||||
PropertyContentCollectionFiles = propertyContentCollectionFiles;
|
PropertyContentCollectionFiles = propertyContentCollectionFiles;
|
||||||
ResultAllInOne = resultAllInOne;
|
ResultAllInOne = resultAllInOne;
|
||||||
|
ResultAllInOneSubdirectoryLength = resultAllInOneSubdirectoryLength;
|
||||||
ResultCollection = resultCollection;
|
ResultCollection = resultCollection;
|
||||||
ResultContent = resultContent;
|
ResultContent = resultContent;
|
||||||
ResultSingleton = resultSingleton;
|
ResultSingleton = resultSingleton;
|
||||||
|
@ -8,7 +8,6 @@ using View_by_Distance.Property.Models;
|
|||||||
using View_by_Distance.Rename.Models;
|
using View_by_Distance.Rename.Models;
|
||||||
using View_by_Distance.Shared.Models;
|
using View_by_Distance.Shared.Models;
|
||||||
using View_by_Distance.Shared.Models.Methods;
|
using View_by_Distance.Shared.Models.Methods;
|
||||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
|
||||||
|
|
||||||
namespace View_by_Distance.Rename;
|
namespace View_by_Distance.Rename;
|
||||||
|
|
||||||
@ -541,17 +540,17 @@ public class Rename
|
|||||||
private void RenameByDateTakenB(MatchNginx[] matchNginxCollection, string aPropertySingletonDirectory, string[] jsonFiles)
|
private void RenameByDateTakenB(MatchNginx[] matchNginxCollection, string aPropertySingletonDirectory, string[] jsonFiles)
|
||||||
{
|
{
|
||||||
string json;
|
string json;
|
||||||
char directory;
|
|
||||||
string[] files;
|
string[] files;
|
||||||
string fileName;
|
string fileName;
|
||||||
|
string checkFile;
|
||||||
string extension;
|
string extension;
|
||||||
string[] matches;
|
string[] matches;
|
||||||
string checkFile;
|
|
||||||
DateTime dateTime;
|
DateTime dateTime;
|
||||||
string[] segments;
|
string[] segments;
|
||||||
string? checkFileName;
|
string directoryName;
|
||||||
string checkDirectory;
|
|
||||||
string? subdirectory;
|
string? subdirectory;
|
||||||
|
string checkDirectory;
|
||||||
|
string? checkFileName;
|
||||||
Shared.Models.Property? property;
|
Shared.Models.Property? property;
|
||||||
foreach (MatchNginx matchNginx in matchNginxCollection)
|
foreach (MatchNginx matchNginx in matchNginxCollection)
|
||||||
{
|
{
|
||||||
@ -574,9 +573,9 @@ public class Rename
|
|||||||
fileName = Path.GetFileName(file);
|
fileName = Path.GetFileName(file);
|
||||||
segments = fileName.Split('.');
|
segments = fileName.Split('.');
|
||||||
extension = Path.GetExtension(file);
|
extension = Path.GetExtension(file);
|
||||||
directory = IDirectory.GetDirectory(fileName);
|
(directoryName, _) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_Configuration.PropertyConfiguration.ResultAllInOneSubdirectoryLength, fileName);
|
||||||
checkFileName = $"{segments.First()}{Path.GetExtension(Path.GetFileNameWithoutExtension(file))}.json";
|
checkFileName = $"{segments.First()}{Path.GetExtension(Path.GetFileNameWithoutExtension(file))}.json";
|
||||||
checkDirectory = Path.Combine(aPropertySingletonDirectory, _PropertyConfiguration.ResultAllInOne, directory.ToString());
|
checkDirectory = Path.Combine(aPropertySingletonDirectory, _PropertyConfiguration.ResultAllInOne, directoryName);
|
||||||
checkFile = Path.Combine(checkDirectory, checkFileName);
|
checkFile = Path.Combine(checkDirectory, checkFileName);
|
||||||
matches = jsonFiles.Where(l => l == checkFile).ToArray();
|
matches = jsonFiles.Where(l => l == checkFile).ToArray();
|
||||||
if (!matches.Any())
|
if (!matches.Any())
|
||||||
@ -617,7 +616,7 @@ public class Rename
|
|||||||
string aPropertySingletonDirectory = Path.GetFullPath(Path.Combine(aResultsFullGroupDirectory, "{}"));
|
string aPropertySingletonDirectory = Path.GetFullPath(Path.Combine(aResultsFullGroupDirectory, "{}"));
|
||||||
string[] jsonFiles = !Directory.Exists(aPropertySingletonDirectory) ? Array.Empty<string>() : Directory.GetFiles(aPropertySingletonDirectory, "*.json", SearchOption.AllDirectories);
|
string[] jsonFiles = !Directory.Exists(aPropertySingletonDirectory) ? Array.Empty<string>() : Directory.GetFiles(aPropertySingletonDirectory, "*.json", SearchOption.AllDirectories);
|
||||||
if (!jsonFiles.Any())
|
if (!jsonFiles.Any())
|
||||||
log.Information($"No json file(s) found! Check directory <{aPropertySingletonDirectory}>");
|
log.Information($"No json file(s) found! Check directoryName <{aPropertySingletonDirectory}>");
|
||||||
else
|
else
|
||||||
RenameByDateTakenB(matchNginxCollection, aPropertySingletonDirectory, jsonFiles);
|
RenameByDateTakenB(matchNginxCollection, aPropertySingletonDirectory, jsonFiles);
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
"PopulatePropertyId": true,
|
"PopulatePropertyId": true,
|
||||||
"PropertiesChangedForProperty": false,
|
"PropertiesChangedForProperty": false,
|
||||||
"ResultAllInOne": "_ _ _",
|
"ResultAllInOne": "_ _ _",
|
||||||
|
"ResultAllInOneSubdirectoryLength": 2,
|
||||||
"ResultCollection": "[]",
|
"ResultCollection": "[]",
|
||||||
"ResultContent": "()",
|
"ResultContent": "()",
|
||||||
"ResultSingleton": "{}",
|
"ResultSingleton": "{}",
|
||||||
|
@ -5,8 +5,10 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using View_by_Distance.Metadata.Models;
|
using View_by_Distance.Metadata.Models;
|
||||||
|
using View_by_Distance.Property.Models;
|
||||||
using View_by_Distance.Property.Models.Stateless;
|
using View_by_Distance.Property.Models.Stateless;
|
||||||
using View_by_Distance.Shared.Models;
|
using View_by_Distance.Shared.Models;
|
||||||
|
using View_by_Distance.Shared.Models.Properties;
|
||||||
using View_by_Distance.Shared.Models.Stateless;
|
using View_by_Distance.Shared.Models.Stateless;
|
||||||
|
|
||||||
namespace View_by_Distance.Resize.Models;
|
namespace View_by_Distance.Resize.Models;
|
||||||
@ -35,11 +37,14 @@ public class C_Resize
|
|||||||
private readonly int _OutputResolutionHeightIndex;
|
private readonly int _OutputResolutionHeightIndex;
|
||||||
private readonly EncoderParameters _EncoderParameters;
|
private readonly EncoderParameters _EncoderParameters;
|
||||||
private readonly int _OutputResolutionOrientationIndex;
|
private readonly int _OutputResolutionOrientationIndex;
|
||||||
|
private readonly Dictionary<string, string[]> _FileGroups;
|
||||||
private readonly bool _ForceResizeLastWriteTimeToCreationTime;
|
private readonly bool _ForceResizeLastWriteTimeToCreationTime;
|
||||||
|
private readonly IPropertyConfiguration _PropertyConfiguration;
|
||||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||||
|
|
||||||
public C_Resize(bool forceResizeLastWriteTimeToCreationTime, bool overrideForResizeImages, bool propertiesChangedForResize, string[] validResolutions, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension)
|
public C_Resize(IPropertyConfiguration propertyConfiguration, bool forceResizeLastWriteTimeToCreationTime, bool overrideForResizeImages, bool propertiesChangedForResize, string[] validResolutions, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension)
|
||||||
{
|
{
|
||||||
|
_FileGroups = new();
|
||||||
_Original = "Original";
|
_Original = "Original";
|
||||||
_TempResolutionWidth = 3;
|
_TempResolutionWidth = 3;
|
||||||
_TempResolutionHeight = 4;
|
_TempResolutionHeight = 4;
|
||||||
@ -52,6 +57,7 @@ public class C_Resize
|
|||||||
_EncoderParameters = encoderParameters;
|
_EncoderParameters = encoderParameters;
|
||||||
_FileNameExtension = filenameExtension;
|
_FileNameExtension = filenameExtension;
|
||||||
AngleBracketCollection = new List<string>();
|
AngleBracketCollection = new List<string>();
|
||||||
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
_OverrideForResizeImages = overrideForResizeImages;
|
_OverrideForResizeImages = overrideForResizeImages;
|
||||||
_PropertiesChangedForResize = propertiesChangedForResize;
|
_PropertiesChangedForResize = propertiesChangedForResize;
|
||||||
_ForceResizeLastWriteTimeToCreationTime = forceResizeLastWriteTimeToCreationTime;
|
_ForceResizeLastWriteTimeToCreationTime = forceResizeLastWriteTimeToCreationTime;
|
||||||
@ -66,10 +72,18 @@ public class C_Resize
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAngleBracketCollection(Property.Models.Configuration configuration, string cResultsFullGroupDirectory, string sourceDirectory)
|
public void Update(string cResultsFullGroupDirectory)
|
||||||
|
{
|
||||||
|
_FileGroups.Clear();
|
||||||
|
Dictionary<string, string[]> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_PropertyConfiguration, cResultsFullGroupDirectory, new string[] { _PropertyConfiguration.ResultSingleton });
|
||||||
|
foreach (KeyValuePair<string, string[]> keyValuePair in keyValuePairs)
|
||||||
|
_FileGroups.Add(keyValuePair.Key, keyValuePair.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetAngleBracketCollection(string cResultsFullGroupDirectory, string sourceDirectory)
|
||||||
{
|
{
|
||||||
AngleBracketCollection.Clear();
|
AngleBracketCollection.Clear();
|
||||||
AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(configuration,
|
AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
cResultsFullGroupDirectory,
|
cResultsFullGroupDirectory,
|
||||||
contentDescription: "Resized image",
|
contentDescription: "Resized image",
|
||||||
@ -280,7 +294,6 @@ public class C_Resize
|
|||||||
|
|
||||||
private void SaveResizedSubfile(Shared.Models.Property property, MappingFromItem mappingFromItem, int[] resize)
|
private void SaveResizedSubfile(Shared.Models.Property property, MappingFromItem mappingFromItem, int[] resize)
|
||||||
{
|
{
|
||||||
// string subFile, Shared.Models.Property property, Shared.Models.FileHolder? fileHolder
|
|
||||||
string dateTimeFormat = Shared.Models.Stateless.Methods.IProperty.DateTimeFormat();
|
string dateTimeFormat = Shared.Models.Stateless.Methods.IProperty.DateTimeFormat();
|
||||||
DateTime dateTime = property.DateTimeOriginal is not null ? property.DateTimeOriginal.Value : Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(property);
|
DateTime dateTime = property.DateTimeOriginal is not null ? property.DateTimeOriginal.Value : Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(property);
|
||||||
string dateTimeValue = dateTime.ToString(dateTimeFormat);
|
string dateTimeValue = dateTime.ToString(dateTimeFormat);
|
||||||
@ -295,7 +308,7 @@ public class C_Resize
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveResizedSubfile(Property.Models.Configuration configuration, string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Item item, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> outputResolutionToResize)
|
public void SaveResizedSubfile(Configuration configuration, string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Item item, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> outputResolutionToResize)
|
||||||
{
|
{
|
||||||
if (mappingFromItem.ResizedFileHolder is null)
|
if (mappingFromItem.ResizedFileHolder is null)
|
||||||
throw new NullReferenceException(nameof(mappingFromItem.ResizedFileHolder));
|
throw new NullReferenceException(nameof(mappingFromItem.ResizedFileHolder));
|
||||||
@ -310,7 +323,7 @@ public class C_Resize
|
|||||||
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
|
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
|
||||||
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
|
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
|
||||||
int[] originalCollection = outputResolutionToResize[_Original];
|
int[] originalCollection = outputResolutionToResize[_Original];
|
||||||
string[] changesFrom = new string[] { nameof(Property.Models.A_Property), nameof(B_Metadata), nameof(C_Resize) };
|
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize) };
|
||||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||||
if (_OverrideForResizeImages)
|
if (_OverrideForResizeImages)
|
||||||
check = true;
|
check = true;
|
||||||
@ -408,18 +421,18 @@ public class C_Resize
|
|||||||
|
|
||||||
public FileHolder GetResizedFileHolder(Item item)
|
public FileHolder GetResizedFileHolder(Item item)
|
||||||
{
|
{
|
||||||
FileHolder result = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(item.ImageFileHolder.FullName)));
|
FileHolder result = new(Path.Combine(AngleBracketCollection[0].Replace("<>", _PropertyConfiguration.ResultContent), Path.GetFileName(item.ImageFileHolder.FullName)));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, int[]> GetResizeKeyValuePairs(Property.Models.Configuration configuration, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, List<KeyValuePair<string, string>> metadataCollection, Shared.Models.Property property, MappingFromItem mappingFromItem)
|
public Dictionary<string, int[]> GetResizeKeyValuePairs(Configuration configuration, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, List<KeyValuePair<string, string>> metadataCollection, Shared.Models.Property property, MappingFromItem mappingFromItem)
|
||||||
{
|
{
|
||||||
Dictionary<string, int[]>? results;
|
Dictionary<string, int[]>? results;
|
||||||
string json;
|
string json;
|
||||||
string[] changesFrom = new string[] { nameof(Property.Models.A_Property), nameof(B_Metadata) };
|
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata) };
|
||||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||||
string cResizeSingletonFile = Path.Combine(cResultsFullGroupDirectory, "{}", configuration.ResultAllInOne, $"{mappingFromItem.Id}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json");
|
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, mappingFromItem.ImageFileHolder.Name);
|
||||||
FileInfo fileInfo = new(cResizeSingletonFile);
|
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{mappingFromItem.ImageFileHolder.NameWithoutExtension}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json"));
|
||||||
if (_ForceResizeLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
if (_ForceResizeLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||||
{
|
{
|
||||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||||
|
@ -4,7 +4,7 @@ public interface IBlurHasher
|
|||||||
{
|
{
|
||||||
|
|
||||||
string Encode(FileHolder fileHolder);
|
string Encode(FileHolder fileHolder);
|
||||||
string? GetFile(FileHolder fileHolder);
|
string GetFile(FileHolder fileHolder);
|
||||||
string EncodeAndSave(FileHolder fileHolder);
|
string EncodeAndSave(FileHolder fileHolder);
|
||||||
|
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ public interface IPropertyConfiguration
|
|||||||
public bool PropertiesChangedForProperty { init; get; }
|
public bool PropertiesChangedForProperty { init; get; }
|
||||||
public string[] PropertyContentCollectionFiles { init; get; }
|
public string[] PropertyContentCollectionFiles { init; get; }
|
||||||
public string ResultAllInOne { init; get; }
|
public string ResultAllInOne { init; get; }
|
||||||
|
public int ResultAllInOneSubdirectoryLength { init; get; }
|
||||||
public string ResultCollection { init; get; }
|
public string ResultCollection { init; get; }
|
||||||
public string ResultContent { init; get; }
|
public string ResultContent { init; get; }
|
||||||
public string ResultSingleton { init; get; }
|
public string ResultSingleton { init; get; }
|
||||||
|
@ -92,7 +92,7 @@ internal abstract class Container
|
|||||||
compareFileNamesToFiles = IDirectory.GetFilesKeyValuePairs(jsonFilesCollection);
|
compareFileNamesToFiles = IDirectory.GetFilesKeyValuePairs(jsonFilesCollection);
|
||||||
renamed += IDirectory.LookForAbandoned(jsonFilesCollection, fileNamesToFiles, extension);
|
renamed += IDirectory.LookForAbandoned(jsonFilesCollection, fileNamesToFiles, extension);
|
||||||
filePairs = IDirectory.GetFiles(filesCollection, fileNamesToFiles, extension, compareFileNamesToFiles);
|
filePairs = IDirectory.GetFiles(filesCollection, fileNamesToFiles, extension, compareFileNamesToFiles);
|
||||||
renamed += IDirectory.MaybeMove(propertyConfiguration.RootDirectory, propertyConfiguration.ResultAllInOne, filePairs, aPropertySingletonDirectory, extension);
|
renamed += IDirectory.MaybeMove(propertyConfiguration.RootDirectory, propertyConfiguration.ResultAllInOne, propertyConfiguration.ResultAllInOneSubdirectoryLength, filePairs, aPropertySingletonDirectory, extension);
|
||||||
if (renamed == 0)
|
if (renamed == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -119,7 +119,6 @@ internal abstract class Container
|
|||||||
|
|
||||||
private static void ParallelFor(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string extension, int length, Models.FilePair filePair, List<FilePair> results)
|
private static void ParallelFor(Properties.IPropertyConfiguration propertyConfiguration, string aPropertySingletonDirectory, string extension, int length, Models.FilePair filePair, List<FilePair> results)
|
||||||
{
|
{
|
||||||
char directory;
|
|
||||||
string fileName;
|
string fileName;
|
||||||
bool abandoned = false;
|
bool abandoned = false;
|
||||||
Models.FileHolder sourceDirectoryFileHolder;
|
Models.FileHolder sourceDirectoryFileHolder;
|
||||||
@ -136,8 +135,8 @@ internal abstract class Container
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fileName = Path.GetFileName(filePair.Path);
|
fileName = Path.GetFileName(filePair.Path);
|
||||||
directory = IDirectory.GetDirectory(fileName);
|
(string directoryName, _) = IPath.GetDirectoryNameAndIndex(propertyConfiguration.ResultAllInOneSubdirectoryLength, fileName);
|
||||||
sourceDirectoryFileHolder = new(Path.Combine(aPropertySingletonDirectory, propertyConfiguration.ResultAllInOne, directory.ToString(), $"{fileName}{extension}"));
|
sourceDirectoryFileHolder = new(Path.Combine(aPropertySingletonDirectory, propertyConfiguration.ResultAllInOne, directoryName, $"{fileName}{extension}"));
|
||||||
}
|
}
|
||||||
if (imageFileInfo.LastWriteTime is not null && sourceDirectoryFileHolder.CreationTime is not null && sourceDirectoryFileHolder.LastWriteTime is not null && imageFileInfo.LastWriteTime.Value != sourceDirectoryFileHolder.CreationTime.Value)
|
if (imageFileInfo.LastWriteTime is not null && sourceDirectoryFileHolder.CreationTime is not null && sourceDirectoryFileHolder.LastWriteTime is not null && imageFileInfo.LastWriteTime.Value != sourceDirectoryFileHolder.CreationTime.Value)
|
||||||
{
|
{
|
||||||
|
@ -8,11 +8,6 @@ public interface IDirectory
|
|||||||
static char GetDirectory(string fileName) =>
|
static char GetDirectory(string fileName) =>
|
||||||
fileName.Split('-').Length > 2 ? '-' : fileName.Split('.')[0][^1];
|
fileName.Split('-').Length > 2 ? '-' : fileName.Split('.')[0][^1];
|
||||||
|
|
||||||
string TestStatic_GetDirectory(string fileName, int length) =>
|
|
||||||
GetDirectory(fileName, length);
|
|
||||||
static string GetDirectory(string fileName, int length) =>
|
|
||||||
fileName.Length < length ? new('-', length) : fileName.Split('.')[0][^length..];
|
|
||||||
|
|
||||||
int TestStatic_GetDirectory(char directory) =>
|
int TestStatic_GetDirectory(char directory) =>
|
||||||
GetDirectory(directory);
|
GetDirectory(directory);
|
||||||
static int GetDirectory(char directory) =>
|
static int GetDirectory(char directory) =>
|
||||||
@ -33,10 +28,10 @@ public interface IDirectory
|
|||||||
static int LookForAbandoned(List<string[]> jsonFilesCollection, IReadOnlyDictionary<string, List<string>> fileNamesToFiles, string extension) =>
|
static int LookForAbandoned(List<string[]> jsonFilesCollection, IReadOnlyDictionary<string, List<string>> fileNamesToFiles, string extension) =>
|
||||||
XDirectory.LookForAbandoned(jsonFilesCollection, fileNamesToFiles, extension);
|
XDirectory.LookForAbandoned(jsonFilesCollection, fileNamesToFiles, extension);
|
||||||
|
|
||||||
int TestStatic_MaybeMove(string directory, string resultAllInOne, List<FilePair> filePairs, string jsonGroupDirectory, string extension) =>
|
int TestStatic_MaybeMove(string directory, string resultAllInOne, int resultAllInOneSubdirectoryLength, List<FilePair> filePairs, string jsonGroupDirectory, string extension) =>
|
||||||
MaybeMove(directory, resultAllInOne, filePairs, jsonGroupDirectory, extension);
|
MaybeMove(directory, resultAllInOne, resultAllInOneSubdirectoryLength, filePairs, jsonGroupDirectory, extension);
|
||||||
static int MaybeMove(string directory, string resultAllInOne, List<FilePair> filePairs, string jsonGroupDirectory, string extension) =>
|
static int MaybeMove(string directory, string resultAllInOne, int resultAllInOneSubdirectoryLength, List<FilePair> filePairs, string jsonGroupDirectory, string extension) =>
|
||||||
XDirectory.MaybeMove(directory, resultAllInOne, filePairs, jsonGroupDirectory, extension);
|
XDirectory.MaybeMove(directory, resultAllInOne, resultAllInOneSubdirectoryLength, filePairs, jsonGroupDirectory, extension);
|
||||||
|
|
||||||
List<FilePair> TestStatic_GetFiles(List<string[]> filesCollection, IReadOnlyDictionary<string, List<string>> fileNamesToFiles, string extension, IReadOnlyDictionary<string, List<string>> compareFileNamesToFiles) =>
|
List<FilePair> TestStatic_GetFiles(List<string[]> filesCollection, IReadOnlyDictionary<string, List<string>> fileNamesToFiles, string extension, IReadOnlyDictionary<string, List<string>> compareFileNamesToFiles) =>
|
||||||
GetFiles(filesCollection, fileNamesToFiles, extension, compareFileNamesToFiles);
|
GetFiles(filesCollection, fileNamesToFiles, extension, compareFileNamesToFiles);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using View_by_Distance.Shared.Models.Properties;
|
||||||
|
|
||||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||||
|
|
||||||
public interface IPath
|
public interface IPath
|
||||||
@ -59,9 +61,14 @@ public interface IPath
|
|||||||
static string GetDirectory(string sourceDirectory, int level, string directoryName) =>
|
static string GetDirectory(string sourceDirectory, int level, string directoryName) =>
|
||||||
XPath.GetDirectory(sourceDirectory, level, directoryName);
|
XPath.GetDirectory(sourceDirectory, level, directoryName);
|
||||||
|
|
||||||
Dictionary<string, string[]> TestStatic_GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12) =>
|
(string, int) TestStatic_GetDirectoryNameAndIndex(int resultAllInOneSubdirectoryLength, string fileName) =>
|
||||||
GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory, directories, maxValue);
|
GetDirectoryNameAndIndex(resultAllInOneSubdirectoryLength, fileName);
|
||||||
static Dictionary<string, string[]> GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12) =>
|
static (string, int) GetDirectoryNameAndIndex(int resultAllInOneSubdirectoryLength, string fileName) =>
|
||||||
XPath.GetKeyValuePairs(resultAllInOne, resultsFullGroupDirectory, directories, maxValue);
|
XPath.GetDirectoryNameAndIndex(resultAllInOneSubdirectoryLength, fileName);
|
||||||
|
|
||||||
|
Dictionary<string, string[]> TestStatic_GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? directories) =>
|
||||||
|
GetKeyValuePairs(propertyConfiguration, resultsFullGroupDirectory, directories);
|
||||||
|
static Dictionary<string, string[]> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? directories) =>
|
||||||
|
XPath.GetKeyValuePairs(propertyConfiguration, resultsFullGroupDirectory, directories);
|
||||||
|
|
||||||
}
|
}
|
@ -61,6 +61,11 @@ public interface IProperty
|
|||||||
static bool NameWithoutExtensionIsIdFormat(string fileNameWithoutExtension) =>
|
static bool NameWithoutExtensionIsIdFormat(string fileNameWithoutExtension) =>
|
||||||
Property.NameWithoutExtensionIsIdFormat(fileNameWithoutExtension);
|
Property.NameWithoutExtensionIsIdFormat(fileNameWithoutExtension);
|
||||||
|
|
||||||
|
bool TestStatic_NameWithoutExtensionIsIdFormat(string[] validImageFormatExtensions, Models.FileHolder fileHolder) =>
|
||||||
|
NameWithoutExtensionIsIdFormat(validImageFormatExtensions, fileHolder);
|
||||||
|
static bool NameWithoutExtensionIsIdFormat(string[] validImageFormatExtensions, Models.FileHolder fileHolder) =>
|
||||||
|
Property.NameWithoutExtensionIsIdFormat(validImageFormatExtensions, fileHolder);
|
||||||
|
|
||||||
bool TestStatic_NameWithoutExtensionIsIdFormat(Models.FileHolder fileHolder) =>
|
bool TestStatic_NameWithoutExtensionIsIdFormat(Models.FileHolder fileHolder) =>
|
||||||
NameWithoutExtensionIsIdFormat(fileHolder);
|
NameWithoutExtensionIsIdFormat(fileHolder);
|
||||||
static bool NameWithoutExtensionIsIdFormat(Models.FileHolder fileHolder) =>
|
static bool NameWithoutExtensionIsIdFormat(Models.FileHolder fileHolder) =>
|
||||||
|
@ -364,6 +364,30 @@ internal abstract class Property
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static bool NameWithoutExtensionIsIdFormat(string[] validImageFormatExtensions, Models.FileHolder fileHolder)
|
||||||
|
{
|
||||||
|
bool result;
|
||||||
|
bool changed;
|
||||||
|
string? fileNameWithoutExtension = fileHolder.NameWithoutExtension;
|
||||||
|
for (int i = 0; i < validImageFormatExtensions.Length; i++)
|
||||||
|
{
|
||||||
|
changed = false;
|
||||||
|
foreach (string validImageFormatExtension in validImageFormatExtensions)
|
||||||
|
{
|
||||||
|
if (fileNameWithoutExtension.EndsWith(validImageFormatExtension))
|
||||||
|
{
|
||||||
|
changed = true;
|
||||||
|
fileNameWithoutExtension = fileNameWithoutExtension[..^validImageFormatExtension.Length];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!changed)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result = NameWithoutExtensionIsIdFormat(fileNameWithoutExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma warning disable CA1416
|
#pragma warning disable CA1416
|
||||||
|
|
||||||
internal static (DateTime?, DateTime?[], int?, string?) Get(Models.FileHolder fileHolder, bool isIgnoreExtension, bool isValidImageFormatExtension)
|
internal static (DateTime?, DateTime?[], int?, string?) Get(Models.FileHolder fileHolder, bool isIgnoreExtension, bool isValidImageFormatExtension)
|
||||||
|
@ -175,17 +175,17 @@ internal abstract partial class XDirectory
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void IsUniqueLoop(string resultAllInOne, string resultAllInOneDirectory, FilePair item, List<(string, string)> rename)
|
private static void IsUniqueLoop(string resultAllInOne, string resultAllInOneDirectory, int resultAllInOneSubdirectoryLength, FilePair item, List<(string, string)> rename)
|
||||||
{
|
{
|
||||||
char directory;
|
|
||||||
string fileName;
|
string fileName;
|
||||||
|
string directoryName;
|
||||||
foreach (string path in item.Collection)
|
foreach (string path in item.Collection)
|
||||||
{
|
{
|
||||||
if (path.Contains(resultAllInOne))
|
if (path.Contains(resultAllInOne))
|
||||||
continue;
|
continue;
|
||||||
fileName = Path.GetFileName(path);
|
fileName = Path.GetFileName(path);
|
||||||
directory = IDirectory.GetDirectory(fileName);
|
(directoryName, _) = IPath.GetDirectoryNameAndIndex(resultAllInOneSubdirectoryLength, fileName);
|
||||||
rename.Add(new(path, Path.Combine(resultAllInOneDirectory, directory.ToString(), fileName)));
|
rename.Add(new(path, Path.Combine(resultAllInOneDirectory, directoryName, fileName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ internal abstract partial class XDirectory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int MaybeMove(string directory, string resultAllInOne, List<FilePair> filePairs, string jsonGroupDirectory, string extension)
|
internal static int MaybeMove(string directory, string resultAllInOne, int resultAllInOneSubdirectoryLength, List<FilePair> filePairs, string jsonGroupDirectory, string extension)
|
||||||
{
|
{
|
||||||
FileInfo? toFileInfo;
|
FileInfo? toFileInfo;
|
||||||
FileInfo fromFileInfo;
|
FileInfo fromFileInfo;
|
||||||
@ -212,7 +212,7 @@ internal abstract partial class XDirectory
|
|||||||
foreach (FilePair item in filePairs)
|
foreach (FilePair item in filePairs)
|
||||||
{
|
{
|
||||||
if (item.IsUnique)
|
if (item.IsUnique)
|
||||||
IsUniqueLoop(resultAllInOne, resultAllInOneDirectory, item, rename);
|
IsUniqueLoop(resultAllInOne, resultAllInOneDirectory, resultAllInOneSubdirectoryLength, item, rename);
|
||||||
else
|
else
|
||||||
IsNotUniqueLoop(directory, resultAllInOne, jsonGroupDirectory, extension, item, rename);
|
IsNotUniqueLoop(directory, resultAllInOne, jsonGroupDirectory, extension, item, rename);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using View_by_Distance.Shared.Models.Properties;
|
||||||
|
|
||||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||||
|
|
||||||
internal abstract class XPath
|
internal abstract class XPath
|
||||||
@ -257,15 +259,31 @@ internal abstract class XPath
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Dictionary<string, string[]> GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12)
|
internal static (string, int) GetDirectoryNameAndIndex(int resultAllInOneSubdirectoryLength, string fileName)
|
||||||
|
{
|
||||||
|
int converted;
|
||||||
|
string result;
|
||||||
|
string check = fileName.Length < resultAllInOneSubdirectoryLength ? new('-', resultAllInOneSubdirectoryLength) : fileName.Split('.')[0][^resultAllInOneSubdirectoryLength..];
|
||||||
|
if (check.Any(l => !char.IsNumber(l)))
|
||||||
|
{
|
||||||
|
result = new('-', resultAllInOneSubdirectoryLength);
|
||||||
|
converted = int.Parse($"1{new string('0', resultAllInOneSubdirectoryLength)}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = check;
|
||||||
|
converted = int.Parse(check);
|
||||||
|
}
|
||||||
|
return (result, converted);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static Dictionary<string, string[]> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? directories)
|
||||||
{
|
{
|
||||||
Dictionary<string, string[]> results = new();
|
Dictionary<string, string[]> results = new();
|
||||||
|
int converted = int.Parse($"1{new string('0', propertyConfiguration.ResultAllInOneSubdirectoryLength)}");
|
||||||
string checkDirectory;
|
string checkDirectory;
|
||||||
int minusOne = maxValue - 1;
|
int plusOne = converted + 1;
|
||||||
int minusTwo = maxValue - 2;
|
|
||||||
int minusThree = maxValue - 3;
|
|
||||||
List<string> collection = new();
|
List<string> collection = new();
|
||||||
int length = minusThree.ToString().Length;
|
|
||||||
if (directories is not null)
|
if (directories is not null)
|
||||||
{
|
{
|
||||||
foreach (string key in directories)
|
foreach (string key in directories)
|
||||||
@ -273,14 +291,12 @@ internal abstract class XPath
|
|||||||
if (resultsFullGroupDirectory is null)
|
if (resultsFullGroupDirectory is null)
|
||||||
continue;
|
continue;
|
||||||
collection.Clear();
|
collection.Clear();
|
||||||
for (int i = 0; i < maxValue; i++)
|
for (int i = 0; i < plusOne; i++)
|
||||||
{
|
{
|
||||||
if (i == minusTwo)
|
if (i == converted)
|
||||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, new('-', length));
|
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)));
|
||||||
else if (i == minusOne)
|
|
||||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, new('_', length));
|
|
||||||
else
|
else
|
||||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, i.ToString().PadLeft(length, '0'));
|
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')));
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
collection.Add(checkDirectory);
|
collection.Add(checkDirectory);
|
||||||
|
@ -255,43 +255,6 @@ public partial class UnitTestCalculations
|
|||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMovingFiles()
|
|
||||||
{
|
|
||||||
char directory;
|
|
||||||
string fileName;
|
|
||||||
string checkFile;
|
|
||||||
int directoryIndex;
|
|
||||||
string checkDirectory;
|
|
||||||
List<string> collection = new();
|
|
||||||
string source = "C:/1234567890123456789";
|
|
||||||
if (Directory.Exists(source))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 11; i++)
|
|
||||||
{
|
|
||||||
if (i == 10)
|
|
||||||
checkDirectory = Path.Combine(source, "-");
|
|
||||||
else
|
|
||||||
checkDirectory = Path.Combine(source, i.ToString());
|
|
||||||
if (!Directory.Exists(checkDirectory))
|
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
|
||||||
collection.Add(checkDirectory);
|
|
||||||
}
|
|
||||||
Dictionary<string, string[]> jsonGroups = new() { { "{}", collection.ToArray() } };
|
|
||||||
foreach (string file in Directory.GetFiles(source))
|
|
||||||
{
|
|
||||||
fileName = Path.GetFileName(file);
|
|
||||||
directory = IDirectory.GetDirectory(fileName);
|
|
||||||
directoryIndex = IDirectory.GetDirectory(directory);
|
|
||||||
checkFile = Path.Combine(jsonGroups["{}"][directoryIndex], fileName);
|
|
||||||
if (File.Exists(checkFile))
|
|
||||||
continue;
|
|
||||||
File.Move(file, checkFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NonThrowTryCatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodMonth()
|
public void TestMethodMonth()
|
||||||
{
|
{
|
||||||
|
@ -154,7 +154,7 @@ public class UnitTestResize
|
|||||||
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality);
|
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality);
|
||||||
B_Metadata metadata = new(_Configuration.PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, bResultsFullGroupDirectory);
|
B_Metadata metadata = new(_Configuration.PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, bResultsFullGroupDirectory);
|
||||||
_ = metadata.ToString();
|
_ = metadata.ToString();
|
||||||
C_Resize resize = new(_Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension);
|
C_Resize resize = new(_Configuration.PropertyConfiguration, _Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension);
|
||||||
_ = resize.ToString();
|
_ = resize.ToString();
|
||||||
bool isUniqueFileName = false;
|
bool isUniqueFileName = false;
|
||||||
bool? isNotUniqueAndNeedsReview = null;
|
bool? isNotUniqueAndNeedsReview = null;
|
||||||
@ -164,7 +164,7 @@ public class UnitTestResize
|
|||||||
string relativePath = IPath.GetRelativePath(fileHolder.FullName, length);
|
string relativePath = IPath.GetRelativePath(fileHolder.FullName, length);
|
||||||
string propertyLogicSourceDirectory = Path.GetFullPath(Path.Combine(aPropertySingletonDirectory, sourceDirectoryName));
|
string propertyLogicSourceDirectory = Path.GetFullPath(Path.Combine(aPropertySingletonDirectory, sourceDirectoryName));
|
||||||
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, propertyLogicSourceDirectory);
|
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, propertyLogicSourceDirectory);
|
||||||
resize.SetAngleBracketCollection(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, sourceDirectory);
|
resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory);
|
||||||
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, false, false, false);
|
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, false, false, false);
|
||||||
Assert.IsNotNull(item.ImageFileHolder);
|
Assert.IsNotNull(item.ImageFileHolder);
|
||||||
if (item.Property is null)
|
if (item.Property is null)
|
||||||
@ -175,7 +175,7 @@ public class UnitTestResize
|
|||||||
if (property is null || item.Property is null)
|
if (property is null || item.Property is null)
|
||||||
throw new NullReferenceException(nameof(property));
|
throw new NullReferenceException(nameof(property));
|
||||||
resizedFileHolder = resize.GetResizedFileHolder(item);
|
resizedFileHolder = resize.GetResizedFileHolder(item);
|
||||||
Shared.Models.Methods.IBlurHasher blurHasher = new BlurHash.Models.C2_BlurHasher(_Configuration.PropertyConfiguration.ResultAllInOne, resultsFullGroupDirectory: null);
|
Shared.Models.Methods.IBlurHasher blurHasher = new BlurHash.Models.C2_BlurHasher(_Configuration.PropertyConfiguration, resultsFullGroupDirectory: null);
|
||||||
_ = blurHasher.Encode(resizedFileHolder);
|
_ = blurHasher.Encode(resizedFileHolder);
|
||||||
item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder);
|
item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder);
|
||||||
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item);
|
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item);
|
||||||
|
@ -228,7 +228,7 @@ public class UnitTestFace
|
|||||||
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality);
|
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality);
|
||||||
B_Metadata metadata = new(_Configuration.PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, bResultsFullGroupDirectory);
|
B_Metadata metadata = new(_Configuration.PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, bResultsFullGroupDirectory);
|
||||||
_ = metadata.ToString();
|
_ = metadata.ToString();
|
||||||
C_Resize resize = new(_Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension);
|
C_Resize resize = new(_Configuration.PropertyConfiguration, _Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension);
|
||||||
_ = resize.ToString();
|
_ = resize.ToString();
|
||||||
bool isUniqueFileName = false;
|
bool isUniqueFileName = false;
|
||||||
bool? isNotUniqueAndNeedsReview = null;
|
bool? isNotUniqueAndNeedsReview = null;
|
||||||
@ -238,7 +238,7 @@ public class UnitTestFace
|
|||||||
string relativePath = IPath.GetRelativePath(fileHolder.FullName, length);
|
string relativePath = IPath.GetRelativePath(fileHolder.FullName, length);
|
||||||
string propertyLogicSourceDirectory = Path.GetFullPath(Path.Combine(aPropertySingletonDirectory, sourceDirectoryName));
|
string propertyLogicSourceDirectory = Path.GetFullPath(Path.Combine(aPropertySingletonDirectory, sourceDirectoryName));
|
||||||
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, propertyLogicSourceDirectory);
|
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, propertyLogicSourceDirectory);
|
||||||
resize.SetAngleBracketCollection(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, sourceDirectory);
|
resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory);
|
||||||
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, false, false, false);
|
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isNotUniqueAndNeedsReview, isUniqueFileName, isValidImageFormatExtension, property, false, false, false);
|
||||||
Assert.IsNotNull(item.ImageFileHolder);
|
Assert.IsNotNull(item.ImageFileHolder);
|
||||||
if (item.Property is null)
|
if (item.Property is null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user