a
This commit is contained in:
parent
2cd2c2b434
commit
cd5ab223c9
@ -3,25 +3,21 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Compare.Models;
|
namespace View_by_Distance.Compare.Models;
|
||||||
|
|
||||||
public class AppSettings
|
public record AppSettings(string Company,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company, int maxDegreeOfParallelism, string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
2
Compare/Models/Binder/.editorconfig
Normal file
2
Compare/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,4 +1,3 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Compare.Models.Binder;
|
namespace View_by_Distance.Compare.Models.Binder;
|
||||||
@ -7,12 +6,12 @@ public class Configuration
|
|||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
[Display(Name = "Diff Property Directory"), Required] public string DiffPropertyDirectory { get; set; }
|
public string DiffPropertyDirectory { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Rename"), Required] public string[] Rename { get; set; }
|
public string[] Rename { get; set; }
|
||||||
[Display(Name = "Rename B"), Required] public string[] RenameB { get; set; }
|
public string[] RenameB { get; set; }
|
||||||
[Display(Name = "Rename C"), Required] public string[] RenameC { get; set; }
|
public string[] RenameC { get; set; }
|
||||||
[Display(Name = "Spelling"), Required] public string[] Spelling { get; set; }
|
public string[] Spelling { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
|
@ -16,8 +16,7 @@ public abstract class Configuration
|
|||||||
Binder.Configuration? configuration = configurationSection.Get<Binder.Configuration>();
|
Binder.Configuration? configuration = configurationSection.Get<Binder.Configuration>();
|
||||||
string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true });
|
string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
result = JsonSerializer.Deserialize<Models.Configuration>(json);
|
result = JsonSerializer.Deserialize<Models.Configuration>(json);
|
||||||
if (result is null)
|
if (result is null) throw new Exception(json);
|
||||||
throw new Exception(json);
|
|
||||||
string jsonThis = result.ToString();
|
string jsonThis = result.ToString();
|
||||||
if (jsonThis != json)
|
if (jsonThis != json)
|
||||||
{
|
{
|
||||||
@ -30,11 +29,10 @@ public abstract class Configuration
|
|||||||
check = i;
|
check = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (check is null)
|
if (check is null) throw new Exception();
|
||||||
throw new Exception();
|
|
||||||
string a = json[..check.Value].Split(',')[^1];
|
string a = json[..check.Value].Split(',')[^1];
|
||||||
string b = json[check.Value..].Split(',')[0];
|
string b = json[check.Value..].Split(',')[0];
|
||||||
throw new Exception($"{a}{b}");
|
throw new Exception($"{a}{b}");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
2
Copy-Distinct/Models/Binder/.editorconfig
Normal file
2
Copy-Distinct/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Copy.Distinct.Models.Binder;
|
namespace View_by_Distance.Copy.Distinct.Models.Binder;
|
||||||
@ -10,9 +9,9 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
public string[] IgnoreExtensions { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
public string PersonBirthdayFormat { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
@ -25,12 +24,9 @@ public class Configuration
|
|||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.IgnoreExtensions is null)
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
|
||||||
if (configuration.PersonBirthdayFormat is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
|
@ -3,25 +3,21 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Date.Group.Models;
|
namespace View_by_Distance.Date.Group.Models;
|
||||||
|
|
||||||
public class AppSettings
|
public record AppSettings(string Company,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company, int maxDegreeOfParallelism, string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
2
Date-Group/Models/Binder/.editorconfig
Normal file
2
Date-Group/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Date.Group.Models.Binder;
|
namespace View_by_Distance.Date.Group.Models.Binder;
|
||||||
@ -10,13 +9,13 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "By Create Date Shortcut"), Required] public bool? ByCreateDateShortcut { get; set; }
|
public bool? ByCreateDateShortcut { get; set; }
|
||||||
[Display(Name = "By Date"), Required] public bool? ByDay { get; set; }
|
public bool? ByDay { get; set; }
|
||||||
[Display(Name = "By Hash"), Required] public bool? ByHash { get; set; }
|
public bool? ByHash { get; set; }
|
||||||
[Display(Name = "By Season"), Required] public bool? BySeason { get; set; }
|
public bool? BySeason { get; set; }
|
||||||
[Display(Name = "By Week"), Required] public bool? ByWeek { get; set; }
|
public bool? ByWeek { get; set; }
|
||||||
[Display(Name = "Ignore Subdirectories for Rename"), Required] public bool? KeepFullPath { get; set; }
|
public bool? KeepFullPath { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
@ -29,20 +28,13 @@ public class Configuration
|
|||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
if (configuration.ByCreateDateShortcut is null) throw new NullReferenceException(nameof(configuration.ByCreateDateShortcut));
|
||||||
if (configuration.ByCreateDateShortcut is null)
|
if (configuration.ByDay is null) throw new NullReferenceException(nameof(configuration.ByDay));
|
||||||
throw new NullReferenceException(nameof(configuration.ByCreateDateShortcut));
|
if (configuration.ByHash is null) throw new NullReferenceException(nameof(configuration.ByHash));
|
||||||
if (configuration.ByDay is null)
|
if (configuration.BySeason is null) throw new NullReferenceException(nameof(configuration.BySeason));
|
||||||
throw new NullReferenceException(nameof(configuration.ByDay));
|
if (configuration.ByWeek is null) throw new NullReferenceException(nameof(configuration.ByWeek));
|
||||||
if (configuration.ByHash is null)
|
if (configuration.KeepFullPath is null) throw new NullReferenceException(nameof(configuration.KeepFullPath));
|
||||||
throw new NullReferenceException(nameof(configuration.ByHash));
|
|
||||||
if (configuration.BySeason is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.BySeason));
|
|
||||||
if (configuration.ByWeek is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.ByWeek));
|
|
||||||
if (configuration.KeepFullPath is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.KeepFullPath));
|
|
||||||
result = new(
|
result = new(
|
||||||
configuration.PropertyConfiguration,
|
configuration.PropertyConfiguration,
|
||||||
configuration.ByCreateDateShortcut.Value,
|
configuration.ByCreateDateShortcut.Value,
|
||||||
@ -68,8 +60,7 @@ public class Configuration
|
|||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
}
|
}
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,29 +3,23 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Delete.By.Relative.Models;
|
namespace View_by_Distance.Delete.By.Relative.Models;
|
||||||
|
|
||||||
public class AppSettings
|
public record AppSettings(string Company,
|
||||||
|
string CompareRootDirectory,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
string OutputExtension,
|
||||||
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public string CompareRootDirectory { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public string OutputExtension { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company, string compareRootDirectory, int maxDegreeOfParallelism, string outputExtension, string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
CompareRootDirectory = compareRootDirectory;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
OutputExtension = outputExtension;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -3,25 +3,21 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Drag_Drop_Explorer.Models;
|
namespace View_by_Distance.Drag_Drop_Explorer.Models;
|
||||||
|
|
||||||
public class AppSettings
|
public record AppSettings(string Company,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company, int maxDegreeOfParallelism, string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -3,25 +3,21 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Drag_Drop.Models;
|
namespace View_by_Distance.Drag_Drop.Models;
|
||||||
|
|
||||||
public class AppSettings
|
public record AppSettings(string Company,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company, int maxDegreeOfParallelism, string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
2
Drag-Drop-Search/Models/Binder/.editorconfig
Normal file
2
Drag-Drop-Search/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Drag_Drop.Models.Binder;
|
namespace View_by_Distance.Drag_Drop.Models.Binder;
|
||||||
@ -10,45 +9,45 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Check D Face and Up Dates"), Required] public bool? CheckDFaceAndUpWriteDates { get; set; }
|
public bool? CheckDFaceAndUpWriteDates { get; set; }
|
||||||
[Display(Name = "Check Json For Distance Results"), Required] public bool? CheckJsonForDistanceResults { get; set; }
|
public bool? CheckJsonForDistanceResults { get; set; }
|
||||||
[Display(Name = "CrossDirectory Max Items In Distance Collection"), Required] public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; }
|
public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; }
|
||||||
[Display(Name = "Distance Factor"), Required] public int? DistanceFactor { get; set; }
|
public int? DistanceFactor { get; set; }
|
||||||
[Display(Name = "Force Face Last Write Time to Creation Time"), Required] public bool? ForceFaceLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceFaceLastWriteTimeToCreationTime { get; set; }
|
||||||
[Display(Name = "Force Metadata Last Write Time to Creation Time"), Required] public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
||||||
[Display(Name = "Force Resize Last Write Time to Creation Time"), Required] public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
||||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
public string[] IgnoreExtensions { get; set; }
|
||||||
[Display(Name = "Julie Phares Copy Birthdays"), Required] public string[] JLinks { get; set; }
|
public string[] JLinks { get; set; }
|
||||||
[Display(Name = "Load Or Create Then Save Distance Results"), Required] public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; }
|
public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Load Or Create Then Save Image Faces Results"), Required] public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; }
|
public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Mixed Year Relative Paths"), Required] public string[] MixedYearRelativePaths { get; set; }
|
public string[] MixedYearRelativePaths { get; set; }
|
||||||
[Display(Name = "Model Directory"), Required] public string ModelDirectory { get; set; }
|
public string ModelDirectory { get; set; }
|
||||||
[Display(Name = "Model Name"), Required] public string ModelName { get; set; }
|
public string ModelName { get; set; }
|
||||||
[Display(Name = "Number Jitters"), Required] public int? NumberOfJitters { get; set; }
|
public int? NumberOfJitters { get; set; }
|
||||||
[Display(Name = "Number of Times To Up Sample"), Required] public int? NumberOfTimesToUpsample { get; set; }
|
public int? NumberOfTimesToUpsample { get; set; }
|
||||||
[Display(Name = "Output Extension"), Required] public string OutputExtension { get; set; }
|
public string OutputExtension { get; set; }
|
||||||
[Display(Name = "Output Quality"), Required] public int? OutputQuality { get; set; }
|
public int? OutputQuality { get; set; }
|
||||||
[Display(Name = "Output Resolutions"), Required] public string[] OutputResolutions { get; set; }
|
public string[] OutputResolutions { get; set; }
|
||||||
[Display(Name = "Override For Face Images"), Required] public bool? OverrideForFaceImages { get; set; }
|
public bool? OverrideForFaceImages { get; set; }
|
||||||
[Display(Name = "Override For Face Landmark Images"), Required] public bool? OverrideForFaceLandmarkImages { get; set; }
|
public bool? OverrideForFaceLandmarkImages { get; set; }
|
||||||
[Display(Name = "Override For Resize Images"), Required] public bool? OverrideForResizeImages { get; set; }
|
public bool? OverrideForResizeImages { get; set; }
|
||||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
public string PersonBirthdayFormat { get; set; }
|
||||||
[Display(Name = "Predictor Model Name"), Required] public string PredictorModelName { get; set; }
|
public string PredictorModelName { get; set; }
|
||||||
[Display(Name = "Properties Changed For Distance"), Required] public bool? PropertiesChangedForDistance { get; set; }
|
public bool? PropertiesChangedForDistance { get; set; }
|
||||||
[Display(Name = "Properties Changed For Faces"), Required] public bool? PropertiesChangedForFaces { get; set; }
|
public bool? PropertiesChangedForFaces { get; set; }
|
||||||
[Display(Name = "Properties Changed For Index"), Required] public bool? PropertiesChangedForIndex { get; set; }
|
public bool? PropertiesChangedForIndex { get; set; }
|
||||||
[Display(Name = "Properties Changed For Metadata"), Required] public bool? PropertiesChangedForMetadata { get; set; }
|
public bool? PropertiesChangedForMetadata { get; set; }
|
||||||
[Display(Name = "Properties Changed For Resize"), Required] public bool? PropertiesChangedForResize { get; set; }
|
public bool? PropertiesChangedForResize { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Reverse"), Required] public bool? Reverse { get; set; }
|
public bool? Reverse { get; set; }
|
||||||
[Display(Name = "Save Face Landmark For Output Resolutions"), Required] public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
|
public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Save Full Year Of Random Files"), Required] public bool? SaveFullYearOfRandomFiles { get; set; }
|
public bool? SaveFullYearOfRandomFiles { get; set; }
|
||||||
[Display(Name = "Save Resized Images by Person Key Formatted"), Required] public string[] SaveFilteredOriginalImagesFromJLinksForOutputResolutions { get; set; }
|
public string[] SaveFilteredOriginalImagesFromJLinksForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Save Shortcuts"), Required] public string[] SaveShortcutsForOutputResolutions { get; set; }
|
public string[] SaveShortcutsForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Save Resized Subfiles"), Required] public bool? SaveResizedSubfiles { get; set; }
|
public bool? SaveResizedSubfiles { get; set; }
|
||||||
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
|
public bool? SkipSearch { get; set; }
|
||||||
[Display(Name = "Test Distance Results"), Required] public bool? TestDistanceResults { get; set; }
|
public bool? TestDistanceResults { get; set; }
|
||||||
[Display(Name = "Valid Resolutions"), Required] public string[] ValidResolutions { get; set; }
|
public string[] ValidResolutions { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
@ -61,69 +60,40 @@ public class Configuration
|
|||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
if (configuration.CheckDFaceAndUpWriteDates is null) throw new NullReferenceException(nameof(configuration.CheckDFaceAndUpWriteDates));
|
||||||
if (configuration.CheckDFaceAndUpWriteDates is null)
|
if (configuration.CheckJsonForDistanceResults is null) throw new NullReferenceException(nameof(configuration.CheckJsonForDistanceResults));
|
||||||
throw new NullReferenceException(nameof(configuration.CheckDFaceAndUpWriteDates));
|
if (configuration.CrossDirectoryMaxItemsInDistanceCollection is null) throw new NullReferenceException(nameof(configuration.CrossDirectoryMaxItemsInDistanceCollection));
|
||||||
if (configuration.CheckJsonForDistanceResults is null)
|
if (configuration.DistanceFactor is null) throw new NullReferenceException(nameof(configuration.DistanceFactor));
|
||||||
throw new NullReferenceException(nameof(configuration.CheckJsonForDistanceResults));
|
if (configuration.ForceFaceLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceFaceLastWriteTimeToCreationTime));
|
||||||
if (configuration.CrossDirectoryMaxItemsInDistanceCollection is null)
|
if (configuration.ForceMetadataLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
||||||
throw new NullReferenceException(nameof(configuration.CrossDirectoryMaxItemsInDistanceCollection));
|
if (configuration.ForceResizeLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
||||||
if (configuration.DistanceFactor is null)
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
throw new NullReferenceException(nameof(configuration.DistanceFactor));
|
|
||||||
if (configuration.ForceFaceLastWriteTimeToCreationTime is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.ForceFaceLastWriteTimeToCreationTime));
|
|
||||||
if (configuration.ForceMetadataLastWriteTimeToCreationTime is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
|
||||||
if (configuration.ForceResizeLastWriteTimeToCreationTime is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
|
||||||
if (configuration.IgnoreExtensions is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
|
||||||
configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ??= Array.Empty<string>();
|
configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ??= Array.Empty<string>();
|
||||||
configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions ??= Array.Empty<string>();
|
configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions ??= Array.Empty<string>();
|
||||||
if (configuration.MixedYearRelativePaths is null)
|
if (configuration.MixedYearRelativePaths is null) throw new NullReferenceException(nameof(configuration.MixedYearRelativePaths));
|
||||||
throw new NullReferenceException(nameof(configuration.MixedYearRelativePaths));
|
if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
||||||
if (configuration.NumberOfJitters is null)
|
if (configuration.NumberOfTimesToUpsample is null) throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
||||||
throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
if (configuration.OutputQuality is null) throw new NullReferenceException(nameof(configuration.OutputQuality));
|
||||||
if (configuration.NumberOfTimesToUpsample is null)
|
if (configuration.OutputResolutions is null) throw new NullReferenceException(nameof(configuration.OutputResolutions));
|
||||||
throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
if (configuration.OverrideForFaceImages is null) throw new NullReferenceException(nameof(configuration.OverrideForFaceImages));
|
||||||
if (configuration.OutputQuality is null)
|
if (configuration.OverrideForFaceLandmarkImages is null) throw new NullReferenceException(nameof(configuration.OverrideForFaceLandmarkImages));
|
||||||
throw new NullReferenceException(nameof(configuration.OutputQuality));
|
if (configuration.OverrideForResizeImages is null) throw new NullReferenceException(nameof(configuration.OverrideForResizeImages));
|
||||||
if (configuration.OutputResolutions is null)
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
throw new NullReferenceException(nameof(configuration.OutputResolutions));
|
if (configuration.PropertiesChangedForDistance is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForDistance));
|
||||||
if (configuration.OverrideForFaceImages is null)
|
if (configuration.PropertiesChangedForFaces is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForFaces));
|
||||||
throw new NullReferenceException(nameof(configuration.OverrideForFaceImages));
|
if (configuration.PropertiesChangedForIndex is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForIndex));
|
||||||
if (configuration.OverrideForFaceLandmarkImages is null)
|
if (configuration.PropertiesChangedForMetadata is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForMetadata));
|
||||||
throw new NullReferenceException(nameof(configuration.OverrideForFaceLandmarkImages));
|
if (configuration.PropertiesChangedForResize is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForResize));
|
||||||
if (configuration.OverrideForResizeImages is null)
|
if (configuration.Reverse is null) throw new NullReferenceException(nameof(configuration.Reverse));
|
||||||
throw new NullReferenceException(nameof(configuration.OverrideForResizeImages));
|
|
||||||
if (configuration.PersonBirthdayFormat is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
|
||||||
if (configuration.PropertiesChangedForDistance is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForDistance));
|
|
||||||
if (configuration.PropertiesChangedForFaces is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForFaces));
|
|
||||||
if (configuration.PropertiesChangedForIndex is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForIndex));
|
|
||||||
if (configuration.PropertiesChangedForMetadata is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForMetadata));
|
|
||||||
if (configuration.PropertiesChangedForResize is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForResize));
|
|
||||||
if (configuration.Reverse is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.Reverse));
|
|
||||||
configuration.SaveFaceLandmarkForOutputResolutions ??= Array.Empty<string>();
|
configuration.SaveFaceLandmarkForOutputResolutions ??= Array.Empty<string>();
|
||||||
if (configuration.SaveFullYearOfRandomFiles is null)
|
if (configuration.SaveFullYearOfRandomFiles is null) throw new NullReferenceException(nameof(configuration.SaveFullYearOfRandomFiles));
|
||||||
throw new NullReferenceException(nameof(configuration.SaveFullYearOfRandomFiles));
|
|
||||||
configuration.SaveFilteredOriginalImagesFromJLinksForOutputResolutions ??= Array.Empty<string>();
|
configuration.SaveFilteredOriginalImagesFromJLinksForOutputResolutions ??= Array.Empty<string>();
|
||||||
if (configuration.SaveResizedSubfiles is null)
|
if (configuration.SaveResizedSubfiles is null) throw new NullReferenceException(nameof(configuration.SaveResizedSubfiles));
|
||||||
throw new NullReferenceException(nameof(configuration.SaveResizedSubfiles));
|
|
||||||
configuration.SaveShortcutsForOutputResolutions ??= Array.Empty<string>();
|
configuration.SaveShortcutsForOutputResolutions ??= Array.Empty<string>();
|
||||||
if (configuration.SkipSearch is null)
|
if (configuration.SkipSearch is null) throw new NullReferenceException(nameof(configuration.SkipSearch));
|
||||||
throw new NullReferenceException(nameof(configuration.SkipSearch));
|
if (configuration.TestDistanceResults is null) throw new NullReferenceException(nameof(configuration.TestDistanceResults));
|
||||||
if (configuration.TestDistanceResults is null)
|
if (configuration.ValidResolutions is null) throw new NullReferenceException(nameof(configuration.ValidResolutions));
|
||||||
throw new NullReferenceException(nameof(configuration.TestDistanceResults));
|
|
||||||
if (configuration.ValidResolutions is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.ValidResolutions));
|
|
||||||
result = new(configuration.PropertyConfiguration,
|
result = new(configuration.PropertyConfiguration,
|
||||||
configuration.CheckDFaceAndUpWriteDates.Value,
|
configuration.CheckDFaceAndUpWriteDates.Value,
|
||||||
configuration.CheckJsonForDistanceResults.Value,
|
configuration.CheckJsonForDistanceResults.Value,
|
||||||
|
@ -59,6 +59,7 @@ public partial class DragDropSetPropertyItem : Form
|
|||||||
Log.Logger = loggerConfiguration.CreateLogger();
|
Log.Logger = loggerConfiguration.CreateLogger();
|
||||||
logger = Log.ForContext<DragDropSetPropertyItem>();
|
logger = Log.ForContext<DragDropSetPropertyItem>();
|
||||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||||
|
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
|
||||||
_PropertyConfiguration = propertyConfiguration;
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
logger.Information("Complete");
|
logger.Information("Complete");
|
||||||
_Logger = logger;
|
_Logger = logger;
|
||||||
@ -169,7 +170,7 @@ public partial class DragDropSetPropertyItem : Form
|
|||||||
{
|
{
|
||||||
if (record.PropertyItemType is not null && record.PropertyItemType.Value != type)
|
if (record.PropertyItemType is not null && record.PropertyItemType.Value != type)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if ((record.DateTimeOriginal is null || !string.IsNullOrEmpty(record.Value) || record.Value == setTo) && !_AppSettings.IgnoreRulesKeyWords.Contains(setTo))
|
if ((record.DateTimeOriginal is null || !string.IsNullOrEmpty(record.Value) || record.Value == setTo) && !_PropertyConfiguration.IgnoreRulesKeyWords.Contains(setTo))
|
||||||
continue;
|
continue;
|
||||||
checkFile = $"{record.FileHolder.FullName}.exif";
|
checkFile = $"{record.FileHolder.FullName}.exif";
|
||||||
propertyItem = Property.Models.Stateless.IProperty.GetPropertyItem(constructorInfo, tagId, type, setTo);
|
propertyItem = Property.Models.Stateless.IProperty.GetPropertyItem(constructorInfo, tagId, type, setTo);
|
||||||
|
@ -3,7 +3,6 @@ using System.Text.Json;
|
|||||||
namespace View_by_Distance.Drag.Drop.Set.Item.Models;
|
namespace View_by_Distance.Drag.Drop.Set.Item.Models;
|
||||||
|
|
||||||
public record AppSettings(string Company,
|
public record AppSettings(string Company,
|
||||||
string[] IgnoreRulesKeyWords,
|
|
||||||
int MaxDegreeOfParallelism,
|
int MaxDegreeOfParallelism,
|
||||||
string[] ValidKeyWords,
|
string[] ValidKeyWords,
|
||||||
string WorkingDirectoryName)
|
string WorkingDirectoryName)
|
||||||
|
2
Drag-Drop-Set-Property-Item/Models/Binder/.editorconfig
Normal file
2
Drag-Drop-Set-Property-Item/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -7,7 +7,6 @@ public class AppSettings
|
|||||||
{
|
{
|
||||||
|
|
||||||
public string? Company { get; set; }
|
public string? Company { get; set; }
|
||||||
public string[]? IgnoreRulesKeyWords { get; set; }
|
|
||||||
public int? MaxDegreeOfParallelism { get; set; }
|
public int? MaxDegreeOfParallelism { get; set; }
|
||||||
public string[]? ValidKeyWords { get; set; }
|
public string[]? ValidKeyWords { get; set; }
|
||||||
public string? WorkingDirectoryName { get; set; }
|
public string? WorkingDirectoryName { get; set; }
|
||||||
@ -21,19 +20,12 @@ public class AppSettings
|
|||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
if (appSettings?.Company is null)
|
if (appSettings?.Company is null) throw new NullReferenceException(nameof(appSettings.Company));
|
||||||
throw new NullReferenceException(nameof(appSettings.Company));
|
if (appSettings?.MaxDegreeOfParallelism is null) throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||||
if (appSettings?.IgnoreRulesKeyWords is null)
|
if (appSettings?.ValidKeyWords is null) throw new NullReferenceException(nameof(appSettings.ValidKeyWords));
|
||||||
throw new NullReferenceException(nameof(appSettings.IgnoreRulesKeyWords));
|
if (appSettings?.WorkingDirectoryName is null) throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
||||||
if (appSettings?.MaxDegreeOfParallelism is null)
|
|
||||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
|
||||||
if (appSettings?.ValidKeyWords is null)
|
|
||||||
throw new NullReferenceException(nameof(appSettings.ValidKeyWords));
|
|
||||||
if (appSettings?.WorkingDirectoryName is null)
|
|
||||||
throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.Company,
|
appSettings.Company,
|
||||||
appSettings.IgnoreRulesKeyWords,
|
|
||||||
appSettings.MaxDegreeOfParallelism.Value,
|
appSettings.MaxDegreeOfParallelism.Value,
|
||||||
appSettings.ValidKeyWords,
|
appSettings.ValidKeyWords,
|
||||||
appSettings.WorkingDirectoryName
|
appSettings.WorkingDirectoryName
|
||||||
|
@ -3,31 +3,24 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Duplicate.Search.Models;
|
namespace View_by_Distance.Duplicate.Search.Models;
|
||||||
|
|
||||||
public class AppSettings
|
public record AppSettings(string Company,
|
||||||
|
bool IndexOnly,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
string OutputExtension,
|
||||||
|
bool Reverse,
|
||||||
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public bool IndexOnly { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public string OutputExtension { init; get; }
|
|
||||||
public bool Reverse { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company, bool indexOnly, int maxDegreeOfParallelism, string outputExtension, bool reverse, string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
IndexOnly = indexOnly;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
OutputExtension = outputExtension;
|
|
||||||
Reverse = reverse;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -933,7 +933,6 @@ public partial class DlibDotNet
|
|||||||
Shared.Models.Property? property;
|
Shared.Models.Property? property;
|
||||||
List<string> parseExceptions = new();
|
List<string> parseExceptions = new();
|
||||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||||
List<KeyValuePair<string, string>> metadataCollection;
|
|
||||||
string[] changesFrom = new string[] { nameof(A_Property) };
|
string[] changesFrom = new string[] { nameof(A_Property) };
|
||||||
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber);
|
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber);
|
||||||
ReadOnlyCollection<LocationContainer<MetadataExtractor.Directory>> locationContainers = mapLogic.GetLocationContainers(item);
|
ReadOnlyCollection<LocationContainer<MetadataExtractor.Directory>> locationContainers = mapLogic.GetLocationContainers(item);
|
||||||
@ -966,7 +965,7 @@ public partial class DlibDotNet
|
|||||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value));
|
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value));
|
||||||
else
|
else
|
||||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime));
|
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime));
|
||||||
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex();
|
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex(_Configuration.PropertyConfiguration.Offset);
|
||||||
bool nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(item.ImageFileHolder);
|
bool nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(item.ImageFileHolder);
|
||||||
bool nameWithoutExtensionIsPaddedIdFormat = IDirectory.NameWithoutExtensionIsPaddedIdFormat(item.ImageFileHolder, sortOrderOnlyLengthIndex);
|
bool nameWithoutExtensionIsPaddedIdFormat = IDirectory.NameWithoutExtensionIsPaddedIdFormat(item.ImageFileHolder, sortOrderOnlyLengthIndex);
|
||||||
if (nameWithoutExtensionIsIdFormat && item.ImageFileHolder.NameWithoutExtension != item.Property.Id.ToString())
|
if (nameWithoutExtensionIsIdFormat && item.ImageFileHolder.NameWithoutExtension != item.Property.Id.ToString())
|
||||||
@ -985,10 +984,32 @@ public partial class DlibDotNet
|
|||||||
item.SetResizedFileHolder(_Resize.FileNameExtension, resizedFileHolder);
|
item.SetResizedFileHolder(_Resize.FileNameExtension, resizedFileHolder);
|
||||||
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(containerDateTimes, item, resizedFileHolder);
|
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(containerDateTimes, item, resizedFileHolder);
|
||||||
Map.Models.Stateless.Methods.IMapLogic.SetCreationTimeMaybeMoveToDecade(_Configuration.PropertyConfiguration, _Configuration.MoveToDecade && _Configuration.LocationContainerDistanceTolerance is null, mappingFromItem, locationContainers);
|
Map.Models.Stateless.Methods.IMapLogic.SetCreationTimeMaybeMoveToDecade(_Configuration.PropertyConfiguration, _Configuration.MoveToDecade && _Configuration.LocationContainerDistanceTolerance is null, mappingFromItem, locationContainers);
|
||||||
(int metadataGroups, metadataCollection) = metadata.GetMetadataCollection(subFileTuples, parseExceptions, changesFrom, mappingFromItem);
|
ReadOnlyDictionary<string, MetadataExtractorDirectory> metadataExtractorDirectories = metadata.GetMetadataCollection(subFileTuples, parseExceptions, changesFrom, mappingFromItem);
|
||||||
if (_AppSettings.MaxDegreeOfParallelism < 2)
|
if (_AppSettings.MaxDegreeOfParallelism < 2)
|
||||||
ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection));
|
ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection));
|
||||||
Dictionary<string, int[]> outputResolutionToResize = _Resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, metadataCollection, item.Property, mappingFromItem);
|
if (_AppSettings.Places.Count > 0)
|
||||||
|
{
|
||||||
|
float latitude;
|
||||||
|
float longitude;
|
||||||
|
double? distance;
|
||||||
|
MetadataExtractor.GeoLocation? geoLocation = Metadata.Models.Stateless.Methods.IMetadata.GeoLocation(metadataExtractorDirectories);
|
||||||
|
foreach (Place place in _AppSettings.Places)
|
||||||
|
{
|
||||||
|
if (geoLocation is null)
|
||||||
|
continue;
|
||||||
|
latitude = Math.Abs(place.Latitude.Degrees) + (place.Latitude.Minutes / 60) + (place.Latitude.Seconds / 3600);
|
||||||
|
if (place.Latitude.Degrees < 0)
|
||||||
|
latitude *= -1;
|
||||||
|
longitude = Math.Abs(place.Longitude.Degrees) + (place.Longitude.Minutes / 60) + (place.Longitude.Seconds / 3600);
|
||||||
|
if (place.Longitude.Degrees < 0)
|
||||||
|
longitude *= -1;
|
||||||
|
distance = geoLocation is null ? null : Metadata.Models.Stateless.Methods.IMetadata.GetDistance(latitude, longitude, geoLocation.Latitude, geoLocation.Longitude);
|
||||||
|
if (distance is null or > 3)
|
||||||
|
continue;
|
||||||
|
distance += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Dictionary<string, int[]> outputResolutionToResize = _Resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, item.Property, mappingFromItem);
|
||||||
if (_AppSettings.MaxDegreeOfParallelism < 2)
|
if (_AppSettings.MaxDegreeOfParallelism < 2)
|
||||||
ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs));
|
ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs));
|
||||||
if (_Configuration.SaveResizedSubfiles)
|
if (_Configuration.SaveResizedSubfiles)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
@ -5,6 +6,7 @@ namespace View_by_Distance.Instance.Models;
|
|||||||
|
|
||||||
public record AppSettings(string Company,
|
public record AppSettings(string Company,
|
||||||
int MaxDegreeOfParallelism,
|
int MaxDegreeOfParallelism,
|
||||||
|
ReadOnlyCollection<Place> Places,
|
||||||
string WorkingDirectoryName)
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ public class AppSettings
|
|||||||
|
|
||||||
public string? Company { get; set; }
|
public string? Company { get; set; }
|
||||||
public int? MaxDegreeOfParallelism { get; set; }
|
public int? MaxDegreeOfParallelism { get; set; }
|
||||||
|
public string[]? Places { get; set; }
|
||||||
public string? WorkingDirectoryName { get; set; }
|
public string? WorkingDirectoryName { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -22,10 +24,13 @@ public class AppSettings
|
|||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
if (appSettings?.Company is null) throw new NullReferenceException(nameof(appSettings.Company));
|
if (appSettings?.Company is null) throw new NullReferenceException(nameof(appSettings.Company));
|
||||||
if (appSettings?.MaxDegreeOfParallelism is null) throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
if (appSettings?.MaxDegreeOfParallelism is null) throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||||
|
// if (appSettings?.Places is null) throw new NullReferenceException(nameof(appSettings.Places));
|
||||||
if (appSettings?.WorkingDirectoryName is null) throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
if (appSettings?.WorkingDirectoryName is null) throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
||||||
|
ReadOnlyCollection<Models.Place> places = Place.GetPlaces(appSettings.Places);
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.Company,
|
appSettings.Company,
|
||||||
appSettings.MaxDegreeOfParallelism.Value,
|
appSettings.MaxDegreeOfParallelism.Value,
|
||||||
|
places,
|
||||||
appSettings.WorkingDirectoryName
|
appSettings.WorkingDirectoryName
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
|
25
Instance/Models/Binder/DegreesMinutesSeconds.cs
Normal file
25
Instance/Models/Binder/DegreesMinutesSeconds.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Instance.Models.Binder;
|
||||||
|
|
||||||
|
public class DegreesMinutesSeconds
|
||||||
|
{
|
||||||
|
|
||||||
|
public float? Degrees { get; set; }
|
||||||
|
public float? Minutes { get; set; }
|
||||||
|
public float? Seconds { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, BinderDegreesMinutesSecondsSourceGenerationContext.Default.DegreesMinutesSeconds);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(DegreesMinutesSeconds))]
|
||||||
|
internal partial class BinderDegreesMinutesSecondsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
66
Instance/Models/Binder/Place.cs
Normal file
66
Instance/Models/Binder/Place.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Instance.Models.Binder;
|
||||||
|
|
||||||
|
public class Place
|
||||||
|
{
|
||||||
|
|
||||||
|
public string? Title { get; set; }
|
||||||
|
public DegreesMinutesSeconds? Latitude { get; set; }
|
||||||
|
public DegreesMinutesSeconds? Longitude { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, BinderPlaceSourceGenerationContext.Default.Place);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Models.Place Get(Place? Place)
|
||||||
|
{
|
||||||
|
Models.Place result;
|
||||||
|
Models.DegreesMinutesSeconds latitude;
|
||||||
|
Models.DegreesMinutesSeconds longitude;
|
||||||
|
if (Place is null) throw new NullReferenceException(nameof(Place));
|
||||||
|
if (Place.Title is null) throw new NullReferenceException(nameof(Place.Title));
|
||||||
|
if (Place.Latitude is null) throw new NullReferenceException(nameof(Place.Latitude));
|
||||||
|
if (Place.Latitude.Degrees is null) throw new NullReferenceException(nameof(Place.Latitude.Degrees));
|
||||||
|
if (Place.Latitude.Minutes is null) throw new NullReferenceException(nameof(Place.Latitude.Minutes));
|
||||||
|
if (Place.Latitude.Seconds is null) throw new NullReferenceException(nameof(Place.Latitude.Seconds));
|
||||||
|
if (Place.Longitude is null) throw new NullReferenceException(nameof(Place.Longitude));
|
||||||
|
latitude = new(Place.Latitude.Degrees.Value, Place.Latitude.Minutes.Value, Place.Latitude.Seconds.Value);
|
||||||
|
if (Place.Longitude.Degrees is null) throw new NullReferenceException(nameof(Place.Longitude.Degrees));
|
||||||
|
if (Place.Longitude.Minutes is null) throw new NullReferenceException(nameof(Place.Longitude.Minutes));
|
||||||
|
if (Place.Longitude.Seconds is null) throw new NullReferenceException(nameof(Place.Longitude.Seconds));
|
||||||
|
longitude = new(Place.Longitude.Degrees.Value, Place.Longitude.Minutes.Value, Place.Longitude.Seconds.Value);
|
||||||
|
result = new(
|
||||||
|
Place.Title,
|
||||||
|
latitude,
|
||||||
|
longitude
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static ReadOnlyCollection<Models.Place> GetPlaces(string[]? places)
|
||||||
|
{
|
||||||
|
List<Models.Place> results = new();
|
||||||
|
if (places is not null)
|
||||||
|
{
|
||||||
|
Place? place;
|
||||||
|
foreach (string jsonElement in places)
|
||||||
|
{
|
||||||
|
place = JsonSerializer.Deserialize(jsonElement, BinderPlaceSourceGenerationContext.Default.Place);
|
||||||
|
results.Add(Get(place));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Place))]
|
||||||
|
internal partial class BinderPlaceSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
23
Instance/Models/DegreesMinutesSeconds.cs
Normal file
23
Instance/Models/DegreesMinutesSeconds.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Instance.Models;
|
||||||
|
|
||||||
|
public record DegreesMinutesSeconds(float Degrees,
|
||||||
|
float Minutes,
|
||||||
|
float Seconds)
|
||||||
|
{
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, DegreesMinutesSecondsSourceGenerationContext.Default.DegreesMinutesSeconds);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(DegreesMinutesSeconds))]
|
||||||
|
internal partial class DegreesMinutesSecondsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
23
Instance/Models/Place.cs
Normal file
23
Instance/Models/Place.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Instance.Models;
|
||||||
|
|
||||||
|
public record Place(string Title,
|
||||||
|
DegreesMinutesSeconds Latitude,
|
||||||
|
DegreesMinutesSeconds Longitude)
|
||||||
|
{
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, PlaceSourceGenerationContext.Default.Place);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Place))]
|
||||||
|
internal partial class PlaceSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -1343,14 +1343,14 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
|
|||||||
string? directoryName;
|
string? directoryName;
|
||||||
List<int> distinctFilteredIds = IContainer.GetFilteredDistinctIds(propertyConfiguration, containers);
|
List<int> distinctFilteredIds = IContainer.GetFilteredDistinctIds(propertyConfiguration, containers);
|
||||||
LookForAbandoned(propertyConfiguration, distinctFilteredIds);
|
LookForAbandoned(propertyConfiguration, distinctFilteredIds);
|
||||||
Stateless.LookForAbandonedLogic.LookForAbandoned(bResultsFullGroupDirectory, distinctFilteredIds);
|
Stateless.LookForAbandonedLogic.LookForAbandoned(propertyConfiguration, bResultsFullGroupDirectory, distinctFilteredIds);
|
||||||
directories = Directory.GetDirectories(cResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly);
|
directories = Directory.GetDirectories(cResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
foreach (string directory in directories)
|
foreach (string directory in directories)
|
||||||
{
|
{
|
||||||
directoryName = Path.GetFileName(directory);
|
directoryName = Path.GetFileName(directory);
|
||||||
if (string.IsNullOrEmpty(directoryName) || directoryName.Length != 2 && directoryName.Length != 4)
|
if (string.IsNullOrEmpty(directoryName) || directoryName.Length != 2 && directoryName.Length != 4)
|
||||||
continue;
|
continue;
|
||||||
Stateless.LookForAbandonedLogic.LookForAbandoned(distinctFilteredIds, directory, directoryName);
|
Stateless.LookForAbandonedLogic.LookForAbandoned(propertyConfiguration, distinctFilteredIds, directory, directoryName);
|
||||||
}
|
}
|
||||||
directories = Directory.GetDirectories(dResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly);
|
directories = Directory.GetDirectories(dResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
foreach (string directory in directories)
|
foreach (string directory in directories)
|
||||||
@ -1358,7 +1358,7 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
|
|||||||
directoryName = Path.GetFileName(directory);
|
directoryName = Path.GetFileName(directory);
|
||||||
if (string.IsNullOrEmpty(directoryName) || directoryName.Length != 2 && directoryName.Length != 4)
|
if (string.IsNullOrEmpty(directoryName) || directoryName.Length != 2 && directoryName.Length != 4)
|
||||||
continue;
|
continue;
|
||||||
Stateless.LookForAbandonedLogic.LookForAbandoned(distinctFilteredIds, directory, directoryName);
|
Stateless.LookForAbandonedLogic.LookForAbandoned(propertyConfiguration, distinctFilteredIds, directory, directoryName);
|
||||||
}
|
}
|
||||||
directories = Directory.GetDirectories(d2ResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly);
|
directories = Directory.GetDirectories(d2ResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
foreach (string directory in directories)
|
foreach (string directory in directories)
|
||||||
@ -1366,7 +1366,7 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
|
|||||||
directoryName = Path.GetFileName(directory);
|
directoryName = Path.GetFileName(directory);
|
||||||
if (string.IsNullOrEmpty(directoryName) || directoryName.Length != 2 && directoryName.Length != 4)
|
if (string.IsNullOrEmpty(directoryName) || directoryName.Length != 2 && directoryName.Length != 4)
|
||||||
continue;
|
continue;
|
||||||
Stateless.LookForAbandonedLogic.LookForAbandoned(distinctFilteredIds, directory, directoryName);
|
Stateless.LookForAbandonedLogic.LookForAbandoned(propertyConfiguration, distinctFilteredIds, directory, directoryName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,13 @@ namespace View_by_Distance.Map.Models.Stateless;
|
|||||||
internal abstract class LookForAbandonedLogic
|
internal abstract class LookForAbandonedLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static void LookForAbandoned(List<int> distinctFilteredIds, string directory, string directoryName)
|
internal static void LookForAbandoned(Property.Models.Configuration propertyConfiguration, List<int> distinctFilteredIds, string directory, string directoryName)
|
||||||
{
|
{
|
||||||
string fileNameWithoutExtension;
|
string fileNameWithoutExtension;
|
||||||
bool nameWithoutExtensionIsIdFormat;
|
bool nameWithoutExtensionIsIdFormat;
|
||||||
List<string> renameCollection = new();
|
List<string> renameCollection = new();
|
||||||
bool nameWithoutExtensionIsPaddedIdFormat;
|
bool nameWithoutExtensionIsPaddedIdFormat;
|
||||||
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex();
|
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex(propertyConfiguration.Offset);
|
||||||
string[] distinctFilteredIdsValues = distinctFilteredIds.Select(l => l.ToString()).ToArray();
|
string[] distinctFilteredIdsValues = distinctFilteredIds.Select(l => l.ToString()).ToArray();
|
||||||
string[] files = Directory.GetFiles(directory, "*", SearchOption.AllDirectories);
|
string[] files = Directory.GetFiles(directory, "*", SearchOption.AllDirectories);
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
@ -36,7 +36,7 @@ internal abstract class LookForAbandonedLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void LookForAbandoned(string bResultsFullGroupDirectory, List<int> distinctFilteredIds)
|
internal static void LookForAbandoned(Property.Models.Configuration propertyConfiguration, string bResultsFullGroupDirectory, List<int> distinctFilteredIds)
|
||||||
{
|
{
|
||||||
string[] directories = Directory.GetDirectories(bResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly);
|
string[] directories = Directory.GetDirectories(bResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
foreach (string directory in directories)
|
foreach (string directory in directories)
|
||||||
@ -44,7 +44,7 @@ internal abstract class LookForAbandonedLogic
|
|||||||
string? directoryName = Path.GetFileName(directory);
|
string? directoryName = Path.GetFileName(directory);
|
||||||
if (string.IsNullOrEmpty(directoryName) || (directoryName.Length != 2 && directoryName.Length != 4))
|
if (string.IsNullOrEmpty(directoryName) || (directoryName.Length != 2 && directoryName.Length != 4))
|
||||||
continue;
|
continue;
|
||||||
LookForAbandoned(distinctFilteredIds, directory, directoryName);
|
LookForAbandoned(propertyConfiguration, distinctFilteredIds, directory, directoryName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
Metadata-Query/Models/Binder/.editorconfig
Normal file
2
Metadata-Query/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Metadata.Query.Models.Binder;
|
namespace View_by_Distance.Metadata.Query.Models.Binder;
|
||||||
@ -10,9 +9,9 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
public string[] IgnoreExtensions { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
public string PersonBirthdayFormat { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
@ -25,12 +24,9 @@ public class Configuration
|
|||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.IgnoreExtensions is null)
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
|
||||||
if (configuration.PersonBirthdayFormat is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
|
@ -2,13 +2,11 @@ using MetadataExtractor;
|
|||||||
using MetadataExtractor.Formats.Avi;
|
using MetadataExtractor.Formats.Avi;
|
||||||
using MetadataExtractor.Formats.Exif;
|
using MetadataExtractor.Formats.Exif;
|
||||||
using MetadataExtractor.Formats.QuickTime;
|
using MetadataExtractor.Formats.QuickTime;
|
||||||
using System.Diagnostics;
|
using System.Collections.ObjectModel;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using View_by_Distance.Metadata.Models.Stateless;
|
|
||||||
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;
|
using View_by_Distance.Shared.Models.Properties;
|
||||||
using View_by_Distance.Shared.Models.Stateless;
|
|
||||||
|
|
||||||
namespace View_by_Distance.Metadata.Models;
|
namespace View_by_Distance.Metadata.Models;
|
||||||
|
|
||||||
@ -51,54 +49,10 @@ public class B_Metadata : IMetadata<MetadataExtractor.Directory>
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, List<KeyValuePair<string, string>>> GetMetadataCollection(string subFile)
|
public ReadOnlyDictionary<string, MetadataExtractorDirectory> GetMetadataCollection(List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, string[] changesFrom, MappingFromItem mappingFromItem)
|
||||||
{
|
{
|
||||||
Dictionary<string, List<KeyValuePair<string, string>>> results = new();
|
Dictionary<string, MetadataExtractorDirectory>? results = null;
|
||||||
if (_Log is null)
|
|
||||||
throw new NullReferenceException(nameof(_Log));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
object? @object;
|
|
||||||
string? tagDescription;
|
|
||||||
List<string> tagNames = new();
|
|
||||||
int type = (int)IExif.Tags.Orientation;
|
|
||||||
string key = nameof(IExif.Tags.Orientation);
|
|
||||||
IReadOnlyList<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(subFile);
|
|
||||||
foreach (MetadataExtractor.Directory directory in directories)
|
|
||||||
{
|
|
||||||
if (!results.ContainsKey(directory.Name))
|
|
||||||
results.Add(directory.Name, new());
|
|
||||||
foreach (Tag tag in directory.Tags)
|
|
||||||
{
|
|
||||||
tagNames.Add(tag.Name);
|
|
||||||
if (string.IsNullOrEmpty(tag.Description))
|
|
||||||
continue;
|
|
||||||
results[directory.Name].Add(new KeyValuePair<string, string>(string.Concat(tag.Type, '\t', tag.Name), tag.Description));
|
|
||||||
}
|
|
||||||
if (tagNames.Contains(key) && !results.ContainsKey(key))
|
|
||||||
{
|
|
||||||
@object = directory.GetObject(type);
|
|
||||||
if (@object is null)
|
|
||||||
continue;
|
|
||||||
tagDescription = @object.ToString();
|
|
||||||
if (string.IsNullOrEmpty(tagDescription))
|
|
||||||
continue;
|
|
||||||
results.Add(key, new() { new(string.Concat(type, '\t', key), tagDescription) });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
_Log.Info(string.Concat(new StackFrame().GetMethod()?.Name, " <", subFile, ">"));
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public (int, List<KeyValuePair<string, string>>) GetMetadataCollection(List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, string[] changesFrom, MappingFromItem mappingFromItem)
|
|
||||||
{
|
|
||||||
List<KeyValuePair<string, string>> results = new();
|
|
||||||
string json = string.Empty;
|
string json = string.Empty;
|
||||||
Dictionary<string, List<KeyValuePair<string, string>>>? dictionary;
|
|
||||||
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();
|
||||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, mappingFromItem.ImageFileHolder.Name);
|
(_, 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"));
|
FileInfo fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{mappingFromItem.ImageFileHolder.NameWithoutExtension}{mappingFromItem.ImageFileHolder.ExtensionLowered}.json"));
|
||||||
@ -113,33 +67,34 @@ public class B_Metadata : IMetadata<MetadataExtractor.Directory>
|
|||||||
fileInfo.Refresh();
|
fileInfo.Refresh();
|
||||||
}
|
}
|
||||||
if (_PropertiesChangedForMetadata)
|
if (_PropertiesChangedForMetadata)
|
||||||
dictionary = new();
|
results = null;
|
||||||
else if (!fileInfo.Exists)
|
else if (!fileInfo.Exists)
|
||||||
dictionary = new();
|
results = null;
|
||||||
else if (!fileInfo.FullName.EndsWith(".json") && !fileInfo.FullName.EndsWith(".old"))
|
else if (!fileInfo.FullName.EndsWith(".json") && !fileInfo.FullName.EndsWith(".old"))
|
||||||
throw new ArgumentException("must be a *.json file");
|
throw new ArgumentException("must be a *.json file");
|
||||||
else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||||
dictionary = new();
|
results = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
json = File.ReadAllText(fileInfo.FullName);
|
json = File.ReadAllText(fileInfo.FullName);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dictionary = JsonSerializer.Deserialize<Dictionary<string, List<KeyValuePair<string, string>>>>(json);
|
results = Stateless.Methods.Metadata.Deserialize(json);
|
||||||
if (dictionary is null)
|
if (results is null)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(B_Metadata), fileInfo.LastWriteTime));
|
subFileTuples.Add(new Tuple<string, DateTime>(nameof(B_Metadata), fileInfo.LastWriteTime));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
dictionary = new();
|
results = null;
|
||||||
parseExceptions.Add(nameof(B_Metadata));
|
parseExceptions.Add(nameof(B_Metadata));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dictionary is null || !dictionary.Any())
|
if (results is null || results.Count == 0)
|
||||||
{
|
{
|
||||||
dictionary = GetMetadataCollection(mappingFromItem.ImageFileHolder.FullName);
|
IReadOnlyList<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(mappingFromItem.ImageFileHolder.FullName);
|
||||||
json = JsonSerializer.Serialize(dictionary, _WriteIndentedJsonSerializerOptions);
|
results = Stateless.Methods.Metadata.Covert(directories);
|
||||||
|
json = JsonSerializer.Serialize(results, DictionaryStringMetadataExtractorDirectorySourceGenerationContext.Default.DictionaryStringMetadataExtractorDirectory);
|
||||||
bool updateDateWhenMatches = dateTimes.Any() && fileInfo.Exists && dateTimes.Max() > fileInfo.LastWriteTime;
|
bool updateDateWhenMatches = dateTimes.Any() && fileInfo.Exists && dateTimes.Max() > fileInfo.LastWriteTime;
|
||||||
DateTime? dateTime = !updateDateWhenMatches ? null : dateTimes.Max();
|
DateTime? dateTime = !updateDateWhenMatches ? null : dateTimes.Max();
|
||||||
if (Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches, compareBeforeWrite: true, updateToWhenMatches: dateTime))
|
if (Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches, compareBeforeWrite: true, updateToWhenMatches: dateTime))
|
||||||
@ -154,12 +109,7 @@ public class B_Metadata : IMetadata<MetadataExtractor.Directory>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (KeyValuePair<string, List<KeyValuePair<string, string>>> keyValuePair in dictionary)
|
return new(results);
|
||||||
{
|
|
||||||
foreach (KeyValuePair<string, string> keyValue in keyValuePair.Value)
|
|
||||||
results.Add(new(string.Concat(keyValuePair.Key, '\t', keyValue.Key), keyValue.Value));
|
|
||||||
}
|
|
||||||
return new(dictionary.Count, results);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(DateTime?, DateTime?[]) IMetadata<MetadataExtractor.Directory>.GetDateTimes(FileHolder fileHolder, IReadOnlyList<MetadataExtractor.Directory> directories)
|
(DateTime?, DateTime?[]) IMetadata<MetadataExtractor.Directory>.GetDateTimes(FileHolder fileHolder, IReadOnlyList<MetadataExtractor.Directory> directories)
|
||||||
|
43
Metadata/Models/MetadataExtractorDirectory.cs
Normal file
43
Metadata/Models/MetadataExtractorDirectory.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Metadata.Models;
|
||||||
|
|
||||||
|
public record MetadataExtractorDirectory(string Name,
|
||||||
|
bool HasError,
|
||||||
|
ReadOnlyCollection<string> Errors,
|
||||||
|
ReadOnlyDictionary<int, MetadataExtractorTag> Tags)
|
||||||
|
{
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, MetadataExtractorDirectorySourceGenerationContext.Default.MetadataExtractorDirectory);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(MetadataExtractorDirectory))]
|
||||||
|
public partial class MetadataExtractorDirectorySourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(List<MetadataExtractorDirectory>))]
|
||||||
|
public partial class MetadataExtractorDirectoryCollectionSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Dictionary<string, MetadataExtractorDirectory>))]
|
||||||
|
public partial class DictionaryStringMetadataExtractorDirectorySourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(ReadOnlyDictionary<string, MetadataExtractorDirectory>))]
|
||||||
|
public partial class ReadOnlyDictionaryStringMetadataExtractorDirectorySourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
43
Metadata/Models/MetadataExtractorTag.cs
Normal file
43
Metadata/Models/MetadataExtractorTag.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Metadata.Models;
|
||||||
|
|
||||||
|
public record MetadataExtractorTag(int Type,
|
||||||
|
string? Description,
|
||||||
|
bool HasName,
|
||||||
|
string Name)
|
||||||
|
{
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, MetadataExtractorTagSourceGenerationContext.Default.MetadataExtractorTag);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(MetadataExtractorTag))]
|
||||||
|
public partial class MetadataExtractorTagSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(List<MetadataExtractorTag>))]
|
||||||
|
public partial class MetadataExtractorTagCollectionSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Dictionary<string, MetadataExtractorTag>))]
|
||||||
|
public partial class DictionaryStringMetadataExtractorTagSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(ReadOnlyDictionary<string, MetadataExtractorTag>))]
|
||||||
|
public partial class ReadOnlyDictionaryStringMetadataExtractorTagSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
24
Metadata/Models/Record.cs
Normal file
24
Metadata/Models/Record.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
||||||
|
|
||||||
|
internal record Record(string Name,
|
||||||
|
bool HasError,
|
||||||
|
List<string> Errors,
|
||||||
|
Dictionary<int, MetadataExtractorTag> Tags)
|
||||||
|
{
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, RecordSourceGenerationContext.Default.Record);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Record))]
|
||||||
|
internal partial class RecordSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -1,8 +1,24 @@
|
|||||||
|
using MetadataExtractor;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
||||||
|
|
||||||
public interface IMetadata
|
public interface IMetadata
|
||||||
{
|
{
|
||||||
|
|
||||||
|
enum DistanceUnit
|
||||||
|
{
|
||||||
|
Miles,
|
||||||
|
NauticalMiles,
|
||||||
|
Kilometers,
|
||||||
|
Meters
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadOnlyDictionary<string, MetadataExtractorDirectory> TestStatic_Covert(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
||||||
|
Covert(directories);
|
||||||
|
static ReadOnlyDictionary<string, MetadataExtractorDirectory> Covert(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
||||||
|
new(Metadata.Covert(directories));
|
||||||
|
|
||||||
string? TestStatic_GetModel(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
string? TestStatic_GetModel(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
||||||
GetModel(directories);
|
GetModel(directories);
|
||||||
static string? GetModel(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
static string? GetModel(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
||||||
@ -18,9 +34,19 @@ public interface IMetadata
|
|||||||
static string? GetOutputResolution(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
static string? GetOutputResolution(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
||||||
Metadata.GetOutputResolution(directories);
|
Metadata.GetOutputResolution(directories);
|
||||||
|
|
||||||
int TestStatic_GetOrientation(List<KeyValuePair<string, string>> metadataCollection) =>
|
GeoLocation? TestStatic_GeoLocation(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
||||||
GetOrientation(metadataCollection);
|
GeoLocation(directories);
|
||||||
static int GetOrientation(List<KeyValuePair<string, string>> metadataCollection) =>
|
static GeoLocation? GeoLocation(IReadOnlyList<MetadataExtractor.Directory> directories) =>
|
||||||
Metadata.GetOrientation(metadataCollection);
|
Metadata.GeoLocation(directories);
|
||||||
|
|
||||||
|
GeoLocation? TestStatic_GeoLocation(ReadOnlyDictionary<string, MetadataExtractorDirectory> metadataExtractorDirectories) =>
|
||||||
|
GeoLocation(metadataExtractorDirectories);
|
||||||
|
static GeoLocation? GeoLocation(ReadOnlyDictionary<string, MetadataExtractorDirectory> metadataExtractorDirectories) =>
|
||||||
|
Metadata.GeoLocation(metadataExtractorDirectories);
|
||||||
|
|
||||||
|
double? TestStatic_GetDistance(double originLatitude, double originLongitude, double destinationLatitude, double destinationLongitude, int decimalPlaces = 1, DistanceUnit distanceUnit = DistanceUnit.Miles) =>
|
||||||
|
GetDistance(originLatitude, originLongitude, destinationLatitude, destinationLongitude, decimalPlaces, distanceUnit);
|
||||||
|
static double? GetDistance(double originLatitude, double originLongitude, double destinationLatitude, double destinationLongitude, int decimalPlaces = 1, DistanceUnit distanceUnit = DistanceUnit.Miles) =>
|
||||||
|
Metadata.GetDistance(originLatitude, originLongitude, destinationLatitude, destinationLongitude, decimalPlaces, distanceUnit);
|
||||||
|
|
||||||
}
|
}
|
@ -1,12 +1,55 @@
|
|||||||
using MetadataExtractor;
|
using MetadataExtractor;
|
||||||
using MetadataExtractor.Formats.Exif;
|
using MetadataExtractor.Formats.Exif;
|
||||||
using View_by_Distance.Shared.Models.Stateless;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text.Json;
|
||||||
|
using static View_by_Distance.Metadata.Models.Stateless.Methods.IMetadata;
|
||||||
|
|
||||||
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
||||||
|
|
||||||
internal class Metadata
|
internal partial class Metadata
|
||||||
{
|
{
|
||||||
|
|
||||||
|
internal static Dictionary<string, MetadataExtractorDirectory> Covert(IReadOnlyList<MetadataExtractor.Directory> directories)
|
||||||
|
{
|
||||||
|
Dictionary<string, MetadataExtractorDirectory> results = new();
|
||||||
|
MetadataExtractorTag metadataExtractorTag;
|
||||||
|
MetadataExtractorDirectory? metadataExtractorDirectory;
|
||||||
|
Dictionary<int, MetadataExtractorTag> metadataExtractorTags;
|
||||||
|
foreach (MetadataExtractor.Directory directory in directories)
|
||||||
|
{
|
||||||
|
metadataExtractorTags = new();
|
||||||
|
if (results.TryGetValue(directory.Name, out metadataExtractorDirectory))
|
||||||
|
continue;
|
||||||
|
foreach (Tag tag in directory.Tags)
|
||||||
|
{
|
||||||
|
metadataExtractorTag = new(tag.Type, tag.Description, tag.HasName, tag.Name);
|
||||||
|
metadataExtractorTags.Add(tag.Type, metadataExtractorTag);
|
||||||
|
}
|
||||||
|
metadataExtractorDirectory = new(directory.Name, directory.HasError, new(directory.Errors.ToArray()), new(metadataExtractorTags));
|
||||||
|
results.Add(directory.Name, metadataExtractorDirectory);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static Dictionary<string, MetadataExtractorDirectory> Deserialize(string json)
|
||||||
|
{
|
||||||
|
Dictionary<string, MetadataExtractorDirectory> results = new();
|
||||||
|
Record? record;
|
||||||
|
MetadataExtractorDirectory metadataExtractorDirectory;
|
||||||
|
Dictionary<string, JsonElement>? keyValuePairs = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(json);
|
||||||
|
if (keyValuePairs is null)
|
||||||
|
throw new NullReferenceException(nameof(keyValuePairs));
|
||||||
|
foreach (KeyValuePair<string, JsonElement> keyValuePair in keyValuePairs)
|
||||||
|
{
|
||||||
|
record = JsonSerializer.Deserialize(keyValuePair.Value.ToString(), RecordSourceGenerationContext.Default.Record);
|
||||||
|
if (record is null)
|
||||||
|
throw new NullReferenceException(nameof(record));
|
||||||
|
metadataExtractorDirectory = new(record.Name, record.HasError, new(record.Errors), new(record.Tags));
|
||||||
|
results.Add(record.Name, metadataExtractorDirectory);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
internal static string? GetFaceEncoding(IReadOnlyList<MetadataExtractor.Directory> directories)
|
internal static string? GetFaceEncoding(IReadOnlyList<MetadataExtractor.Directory> directories)
|
||||||
{
|
{
|
||||||
string? result;
|
string? result;
|
||||||
@ -62,15 +105,124 @@ internal class Metadata
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int GetOrientation(List<KeyValuePair<string, string>> metadataCollection)
|
internal static GeoLocation? GeoLocation(IReadOnlyList<MetadataExtractor.Directory> directories)
|
||||||
{
|
{
|
||||||
int result;
|
GeoLocation? result;
|
||||||
const string orientation = nameof(IExif.Tags.Orientation);
|
GpsDirectory? gpsDirectory = directories.OfType<GpsDirectory>().FirstOrDefault();
|
||||||
List<string> orientations = (from l in metadataCollection where l.Key.Contains(orientation) select l.Value).ToList();
|
if (gpsDirectory is null)
|
||||||
if (!orientations.Any())
|
result = null;
|
||||||
result = 0;
|
else
|
||||||
else if (!int.TryParse(orientations[0], out result))
|
result = gpsDirectory.GetGeoLocation();
|
||||||
result = 0;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool CoordinateValidatorValidate(double latitude, double longitude)
|
||||||
|
{
|
||||||
|
if (latitude is < (-90) or > 90)
|
||||||
|
return false;
|
||||||
|
if (longitude is < (-180) or > 180)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double GetRadius(DistanceUnit distanceUnit)
|
||||||
|
{
|
||||||
|
return distanceUnit switch
|
||||||
|
{
|
||||||
|
DistanceUnit.Kilometers => 6371.0, // EarthRadiusInKilometers;
|
||||||
|
DistanceUnit.Meters => 6371000.0, // EarthRadiusInMeters;
|
||||||
|
DistanceUnit.NauticalMiles => 3440.0, // EarthRadiusInNauticalMiles;
|
||||||
|
DistanceUnit.Miles => 3959.0, // EarthRadiusInMiles;
|
||||||
|
_ => throw new NotSupportedException()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double ToRadian(double d) =>
|
||||||
|
d * (Math.PI / 180);
|
||||||
|
|
||||||
|
private static double DiffRadian(double val1, double val2) =>
|
||||||
|
ToRadian(val2) - ToRadian(val1);
|
||||||
|
|
||||||
|
internal static double GetDistance(double originLatitude, double originLongitude, double destinationLatitude, double destinationLongitude, int decimalPlaces = 1, DistanceUnit distanceUnit = DistanceUnit.Miles)
|
||||||
|
{
|
||||||
|
if (!CoordinateValidatorValidate(originLatitude, originLongitude))
|
||||||
|
throw new ArgumentException("Invalid origin coordinates supplied.");
|
||||||
|
if (!CoordinateValidatorValidate(destinationLatitude, destinationLongitude))
|
||||||
|
throw new ArgumentException("Invalid destination coordinates supplied.");
|
||||||
|
double radius = GetRadius(distanceUnit);
|
||||||
|
return Math.Round(
|
||||||
|
radius * 2 *
|
||||||
|
Math.Asin(Math.Min(1,
|
||||||
|
Math.Sqrt(
|
||||||
|
Math.Pow(Math.Sin(DiffRadian(originLatitude, destinationLatitude) / 2.0), 2.0) +
|
||||||
|
Math.Cos(ToRadian(originLatitude)) * Math.Cos(ToRadian(destinationLatitude)) *
|
||||||
|
Math.Pow(Math.Sin(DiffRadian(originLongitude, destinationLongitude) / 2.0),
|
||||||
|
2.0)))), decimalPlaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double ParseValueFromDmsString(string value)
|
||||||
|
{
|
||||||
|
double result;
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
return double.MinValue;
|
||||||
|
|
||||||
|
double secondsValue;
|
||||||
|
string[] degrees = value.Split('°');
|
||||||
|
if (degrees.Length != 2)
|
||||||
|
return double.MinValue;
|
||||||
|
if (!double.TryParse(degrees[0], out double degreesValue))
|
||||||
|
return double.MinValue;
|
||||||
|
|
||||||
|
string[] minutes = degrees[1].Split('\'');
|
||||||
|
if (minutes.Length != 2)
|
||||||
|
return double.MinValue;
|
||||||
|
if (!double.TryParse(minutes[0], out double minutesValue))
|
||||||
|
return double.MinValue;
|
||||||
|
|
||||||
|
string[] seconds = minutes[1].Split('"');
|
||||||
|
if (seconds.Length != 2)
|
||||||
|
secondsValue = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!double.TryParse(seconds[0], out secondsValue))
|
||||||
|
return double.MinValue;
|
||||||
|
}
|
||||||
|
result = Math.Abs(degreesValue) + (minutesValue / 60) + (secondsValue / 3600);
|
||||||
|
|
||||||
|
if (degreesValue < 0)
|
||||||
|
result *= -1;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static GeoLocation? GeoLocation(ReadOnlyDictionary<string, MetadataExtractorDirectory> metadataExtractorDirectories)
|
||||||
|
{
|
||||||
|
GeoLocation? result;
|
||||||
|
if (!metadataExtractorDirectories.TryGetValue("GPS", out MetadataExtractorDirectory? metadataExtractorDirectory))
|
||||||
|
result = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MetadataExtractorTag? metadataExtractorTag;
|
||||||
|
if (!metadataExtractorDirectory.Tags.TryGetValue((int)Shared.Models.Stateless.IExif.Tags.GPSLatitude, out metadataExtractorTag) || string.IsNullOrEmpty(metadataExtractorTag.Description))
|
||||||
|
result = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string latitudeDMS = metadataExtractorTag.Description;
|
||||||
|
double latitude = ParseValueFromDmsString(latitudeDMS);
|
||||||
|
if (!metadataExtractorDirectory.Tags.TryGetValue((int)Shared.Models.Stateless.IExif.Tags.GPSLongitude, out metadataExtractorTag) || string.IsNullOrEmpty(metadataExtractorTag.Description))
|
||||||
|
result = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string longitudeDMS = metadataExtractorTag.Description;
|
||||||
|
double longitude = ParseValueFromDmsString(longitudeDMS);
|
||||||
|
result = new(latitude, longitude);
|
||||||
|
string dms = result.ToDmsString();
|
||||||
|
if ($"{latitudeDMS}, {longitudeDMS}" != dms)
|
||||||
|
result = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
Mirror-Length/Models/Binder/.editorconfig
Normal file
2
Mirror-Length/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Mirror.Length.Models.Binder;
|
namespace View_by_Distance.Mirror.Length.Models.Binder;
|
||||||
@ -10,9 +9,9 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
public string[] IgnoreExtensions { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
public string PersonBirthdayFormat { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
@ -25,12 +24,9 @@ public class Configuration
|
|||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.IgnoreExtensions is null)
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
|
||||||
if (configuration.PersonBirthdayFormat is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
|
@ -3,36 +3,24 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Move.By.Id.Models;
|
namespace View_by_Distance.Move.By.Id.Models;
|
||||||
|
|
||||||
public class AppSettings
|
public record AppSettings(string Company,
|
||||||
|
string MoveTo,
|
||||||
|
string ComparePathsFile,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
int MaxMinutesDelta,
|
||||||
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public string MoveTo { init; get; }
|
|
||||||
public string ComparePathsFile { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public int MaxMinutesDelta { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company,
|
|
||||||
string moveTo,
|
|
||||||
string comparePathsFile,
|
|
||||||
int maxDegreeOfParallelism,
|
|
||||||
int maxMinutesDelta,
|
|
||||||
string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
MoveTo = moveTo;
|
|
||||||
ComparePathsFile = comparePathsFile;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
MaxMinutesDelta = maxMinutesDelta;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
2
Move-By-Id/Models/Binder/.editorconfig
Normal file
2
Move-By-Id/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Move.By.Id.Models.Binder;
|
namespace View_by_Distance.Move.By.Id.Models.Binder;
|
||||||
@ -10,9 +9,9 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
public string[] IgnoreExtensions { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
public string PersonBirthdayFormat { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
@ -25,12 +24,9 @@ public class Configuration
|
|||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.IgnoreExtensions is null)
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
|
||||||
if (configuration.PersonBirthdayFormat is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
|
@ -49,12 +49,4 @@
|
|||||||
<ProjectReference Include="..\Resize\Resize.csproj" />
|
<ProjectReference Include="..\Resize\Resize.csproj" />
|
||||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="appsettings.Development.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Include="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
@ -40,6 +40,7 @@ public class MoveById
|
|||||||
if (comparePathRoot is null || comparePathRoot == propertyConfiguration.RootDirectory)
|
if (comparePathRoot is null || comparePathRoot == propertyConfiguration.RootDirectory)
|
||||||
throw new Exception("Nested isn't allowed!");
|
throw new Exception("Nested isn't allowed!");
|
||||||
log.Information(propertyConfiguration.RootDirectory);
|
log.Information(propertyConfiguration.RootDirectory);
|
||||||
|
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
|
||||||
Verify();
|
Verify();
|
||||||
string json = File.ReadAllText(appSettings.ComparePathsFile);
|
string json = File.ReadAllText(appSettings.ComparePathsFile);
|
||||||
MatchNginx[]? matchNginxCollection = System.Text.Json.JsonSerializer.Deserialize<MatchNginx[]>(json);
|
MatchNginx[]? matchNginxCollection = System.Text.Json.JsonSerializer.Deserialize<MatchNginx[]>(json);
|
||||||
@ -112,7 +113,7 @@ public class MoveById
|
|||||||
ASCIIEncoding asciiEncoding = new();
|
ASCIIEncoding asciiEncoding = new();
|
||||||
bool nameWithoutExtensionIsIdFormat;
|
bool nameWithoutExtensionIsIdFormat;
|
||||||
bool nameWithoutExtensionIsPaddedIdFormat;
|
bool nameWithoutExtensionIsPaddedIdFormat;
|
||||||
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex();
|
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex(_PropertyConfiguration.Offset);
|
||||||
foreach (string file in allFiles)
|
foreach (string file in allFiles)
|
||||||
{
|
{
|
||||||
progressBar.Tick();
|
progressBar.Tick();
|
||||||
|
@ -19,8 +19,6 @@ public class Program
|
|||||||
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
||||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
|
||||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
|
||||||
.AddUserSecrets<Program>();
|
.AddUserSecrets<Program>();
|
||||||
IConfigurationRoot configurationRoot = configurationBuilder.Build();
|
IConfigurationRoot configurationRoot = configurationBuilder.Build();
|
||||||
AppSettings appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
AppSettings appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Log4netProvider": "Debug"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Serilog": {
|
|
||||||
"MinimumLevel": "Debug"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
{
|
|
||||||
"ComparePathsFile": "",
|
|
||||||
"Company": "Mike Phares",
|
|
||||||
"MoveTo": "",
|
|
||||||
"Linux": {},
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft": "Warning",
|
|
||||||
"Log4netProvider": "Debug",
|
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MaxDegreeOfParallelism": 6,
|
|
||||||
"MaxMinutesDelta": 2,
|
|
||||||
"Serilog": {
|
|
||||||
"Using": [
|
|
||||||
"Serilog.Sinks.Console",
|
|
||||||
"Serilog.Sinks.File"
|
|
||||||
],
|
|
||||||
"MinimumLevel": "Information",
|
|
||||||
"WriteTo": [
|
|
||||||
{
|
|
||||||
"Name": "Debug",
|
|
||||||
"Args": {
|
|
||||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "Console",
|
|
||||||
"Args": {
|
|
||||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "File",
|
|
||||||
"Args": {
|
|
||||||
"path": "%workingDirectory% - Log/log-.txt",
|
|
||||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
|
|
||||||
"rollingInterval": "Hour"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"Enrich": [
|
|
||||||
"FromLogContext",
|
|
||||||
"WithMachineName",
|
|
||||||
"WithThreadId"
|
|
||||||
],
|
|
||||||
"Properties": {
|
|
||||||
"Application": "Sample"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WorkingDirectoryName": "PharesApps",
|
|
||||||
"Windows": {
|
|
||||||
"Configuration": {
|
|
||||||
"DateGroup": "dd514b88",
|
|
||||||
"DiffPropertyDirectory": "",
|
|
||||||
"FileNameDirectorySeparator": ".Z.",
|
|
||||||
"ForcePropertyLastWriteTimeToCreationTime": false,
|
|
||||||
"MaxImagesInDirectoryForTopLevelFirstPass": 10,
|
|
||||||
"OutputExtension": ".jpg",
|
|
||||||
"Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]",
|
|
||||||
"PersonBirthdayFormat": "yyyy-MM-dd_HH",
|
|
||||||
"PopulatePropertyId": true,
|
|
||||||
"PropertiesChangedForProperty": false,
|
|
||||||
"ResultAllInOne": "_ _ _",
|
|
||||||
"ResultAllInOneSubdirectoryLength": 2,
|
|
||||||
"ResultCollection": "[]",
|
|
||||||
"ResultContent": "()",
|
|
||||||
"ResultSingleton": "{}",
|
|
||||||
"RootDirectory": "C:/Tmp/Phares/Compare/Images-dd514b88",
|
|
||||||
"IgnoreExtensions": [
|
|
||||||
".gif",
|
|
||||||
".GIF",
|
|
||||||
".nef",
|
|
||||||
".NEF",
|
|
||||||
".pdf",
|
|
||||||
".PDF"
|
|
||||||
],
|
|
||||||
"ValidImageFormatExtensions": [
|
|
||||||
".bmp",
|
|
||||||
".BMP",
|
|
||||||
".gif",
|
|
||||||
".GIF",
|
|
||||||
".jpeg",
|
|
||||||
".JPEG",
|
|
||||||
".jpg",
|
|
||||||
".JPG",
|
|
||||||
".png",
|
|
||||||
".PNG",
|
|
||||||
".tiff",
|
|
||||||
".TIFF",
|
|
||||||
".tif",
|
|
||||||
".TIF"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
2
Offset-Date-Time-Original/Models/Binder/.editorconfig
Normal file
2
Offset-Date-Time-Original/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Offset.Date.Time.Original.Models.Binder;
|
namespace View_by_Distance.Offset.Date.Time.Original.Models.Binder;
|
||||||
@ -10,9 +9,9 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
public string[] IgnoreExtensions { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
public string PersonBirthdayFormat { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
@ -25,12 +24,9 @@ public class Configuration
|
|||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.IgnoreExtensions is null)
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
|
||||||
if (configuration.PersonBirthdayFormat is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
|
@ -3,25 +3,21 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.PrepareForOld.Models;
|
namespace View_by_Distance.PrepareForOld.Models;
|
||||||
|
|
||||||
public class AppSettings
|
public record AppSettings(string Company,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company, int maxDegreeOfParallelism, string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
2
PrepareForOld/Models/Binder/.editorconfig
Normal file
2
PrepareForOld/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,4 +1,3 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.PrepareForOld.Models.Binder;
|
namespace View_by_Distance.PrepareForOld.Models.Binder;
|
||||||
@ -8,8 +7,8 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Spelling"), Required] public string[] Spelling { get; set; }
|
public string[] Spelling { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
|
@ -16,8 +16,7 @@ public abstract class Configuration
|
|||||||
Binder.Configuration? configuration = configurationSection.Get<Binder.Configuration>();
|
Binder.Configuration? configuration = configurationSection.Get<Binder.Configuration>();
|
||||||
string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true });
|
string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
result = JsonSerializer.Deserialize<Models.Configuration>(json);
|
result = JsonSerializer.Deserialize<Models.Configuration>(json);
|
||||||
if (result is null)
|
if (result is null) throw new Exception(json);
|
||||||
throw new Exception(json);
|
|
||||||
string jsonThis = result.ToString();
|
string jsonThis = result.ToString();
|
||||||
if (jsonThis != json)
|
if (jsonThis != json)
|
||||||
{
|
{
|
||||||
@ -30,11 +29,10 @@ public abstract class Configuration
|
|||||||
check = i;
|
check = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (check is null)
|
if (check is null) throw new Exception();
|
||||||
throw new Exception();
|
|
||||||
string a = json[..check.Value].Split(',')[^1];
|
string a = json[..check.Value].Split(',')[^1];
|
||||||
string b = json[check.Value..].Split(',')[0];
|
string b = json[check.Value..].Split(',')[0];
|
||||||
throw new Exception($"{a}{b}");
|
throw new Exception($"{a}{b}");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,12 @@ public class Configuration
|
|||||||
public string? FileNameDirectorySeparator { get; set; }
|
public string? FileNameDirectorySeparator { get; set; }
|
||||||
public bool? ForcePropertyLastWriteTimeToCreationTime { get; set; }
|
public bool? ForcePropertyLastWriteTimeToCreationTime { get; set; }
|
||||||
public string[]? IgnoreExtensions { get; set; }
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
|
public string[]? IgnoreRulesKeyWords { get; set; }
|
||||||
public int? MaxImagesInDirectoryForTopLevelFirstPass { get; set; }
|
public int? MaxImagesInDirectoryForTopLevelFirstPass { get; set; }
|
||||||
public string? ModelName { init; get; }
|
public string? ModelName { init; get; }
|
||||||
public int? NumberOfJitters { init; get; }
|
public int? NumberOfJitters { init; get; }
|
||||||
public int? NumberOfTimesToUpsample { init; get; }
|
public int? NumberOfTimesToUpsample { init; get; }
|
||||||
|
public int? Offset { init; get; }
|
||||||
public string? Pattern { get; set; }
|
public string? Pattern { get; set; }
|
||||||
public string? PersonBirthdayFormat { get; set; }
|
public string? PersonBirthdayFormat { get; set; }
|
||||||
public bool? PopulatePropertyId { get; set; }
|
public bool? PopulatePropertyId { get; set; }
|
||||||
@ -43,11 +45,13 @@ public class Configuration
|
|||||||
if (configuration.DateGroup is null) throw new NullReferenceException(nameof(configuration.DateGroup));
|
if (configuration.DateGroup is null) throw new NullReferenceException(nameof(configuration.DateGroup));
|
||||||
if (configuration.FileNameDirectorySeparator is null) throw new NullReferenceException(nameof(configuration.FileNameDirectorySeparator));
|
if (configuration.FileNameDirectorySeparator is null) throw new NullReferenceException(nameof(configuration.FileNameDirectorySeparator));
|
||||||
if (configuration.ForcePropertyLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForcePropertyLastWriteTimeToCreationTime));
|
if (configuration.ForcePropertyLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForcePropertyLastWriteTimeToCreationTime));
|
||||||
// if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
|
if (configuration.IgnoreRulesKeyWords is null) throw new NullReferenceException(nameof(configuration.IgnoreRulesKeyWords));
|
||||||
if (configuration.MaxImagesInDirectoryForTopLevelFirstPass is null) throw new NullReferenceException(nameof(configuration.MaxImagesInDirectoryForTopLevelFirstPass));
|
if (configuration.MaxImagesInDirectoryForTopLevelFirstPass is null) throw new NullReferenceException(nameof(configuration.MaxImagesInDirectoryForTopLevelFirstPass));
|
||||||
// if (configuration.ModelName is null) throw new NullReferenceException(nameof(configuration.ModelName));
|
// if (configuration.ModelName is null) throw new NullReferenceException(nameof(configuration.ModelName));
|
||||||
// if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
// if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
||||||
// if (configuration.NumberOfTimesToUpsample is null) throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
// if (configuration.NumberOfTimesToUpsample is null) throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
||||||
|
if (configuration.Offset is null) throw new NullReferenceException(nameof(configuration.Offset));;
|
||||||
if (configuration.Pattern is null) throw new NullReferenceException(nameof(configuration.Pattern));
|
if (configuration.Pattern is null) throw new NullReferenceException(nameof(configuration.Pattern));
|
||||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
if (configuration.PopulatePropertyId is null) throw new NullReferenceException(nameof(configuration.PopulatePropertyId));
|
if (configuration.PopulatePropertyId is null) throw new NullReferenceException(nameof(configuration.PopulatePropertyId));
|
||||||
@ -60,16 +64,18 @@ public class Configuration
|
|||||||
if (configuration.ResultContent is null) throw new NullReferenceException(nameof(configuration.ResultContent));
|
if (configuration.ResultContent is null) throw new NullReferenceException(nameof(configuration.ResultContent));
|
||||||
if (configuration.ResultSingleton is null) throw new NullReferenceException(nameof(configuration.ResultSingleton));
|
if (configuration.ResultSingleton is null) throw new NullReferenceException(nameof(configuration.ResultSingleton));
|
||||||
if (configuration.RootDirectory is null) throw new NullReferenceException(nameof(configuration.RootDirectory));
|
if (configuration.RootDirectory is null) throw new NullReferenceException(nameof(configuration.RootDirectory));
|
||||||
// if (configuration.ValidImageFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidImageFormatExtensions));
|
if (configuration.ValidImageFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidImageFormatExtensions));
|
||||||
// if (configuration.VerifyToSeason is null) throw new NullReferenceException(nameof(configuration.VerifyToSeason));
|
// if (configuration.VerifyToSeason is null) throw new NullReferenceException(nameof(configuration.VerifyToSeason));
|
||||||
result = new(configuration.DateGroup,
|
result = new(configuration.DateGroup,
|
||||||
configuration.FileNameDirectorySeparator,
|
configuration.FileNameDirectorySeparator,
|
||||||
configuration.ForcePropertyLastWriteTimeToCreationTime.Value,
|
configuration.ForcePropertyLastWriteTimeToCreationTime.Value,
|
||||||
configuration.IgnoreExtensions ?? Array.Empty<string>(),
|
configuration.IgnoreExtensions,
|
||||||
|
configuration.IgnoreRulesKeyWords,
|
||||||
configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value,
|
configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value,
|
||||||
configuration.ModelName,
|
configuration.ModelName,
|
||||||
configuration.NumberOfJitters,
|
configuration.NumberOfJitters,
|
||||||
configuration.NumberOfTimesToUpsample,
|
configuration.NumberOfTimesToUpsample,
|
||||||
|
configuration.Offset.Value,
|
||||||
configuration.Pattern,
|
configuration.Pattern,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
configuration.PopulatePropertyId.Value,
|
configuration.PopulatePropertyId.Value,
|
||||||
@ -82,7 +88,7 @@ public class Configuration
|
|||||||
configuration.ResultContent,
|
configuration.ResultContent,
|
||||||
configuration.ResultSingleton,
|
configuration.ResultSingleton,
|
||||||
Path.GetFullPath(configuration.RootDirectory),
|
Path.GetFullPath(configuration.RootDirectory),
|
||||||
configuration.ValidImageFormatExtensions ?? Array.Empty<string>(),
|
configuration.ValidImageFormatExtensions,
|
||||||
configuration.VerifyToSeason ?? Array.Empty<string>());
|
configuration.VerifyToSeason ?? Array.Empty<string>());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,12 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
public string FileNameDirectorySeparator { init; get; }
|
public string FileNameDirectorySeparator { init; get; }
|
||||||
public bool ForcePropertyLastWriteTimeToCreationTime { init; get; }
|
public bool ForcePropertyLastWriteTimeToCreationTime { init; get; }
|
||||||
public string[] IgnoreExtensions { init; get; }
|
public string[] IgnoreExtensions { init; get; }
|
||||||
|
public string[] IgnoreRulesKeyWords { init; get; }
|
||||||
public int MaxImagesInDirectoryForTopLevelFirstPass { init; get; }
|
public int MaxImagesInDirectoryForTopLevelFirstPass { init; get; }
|
||||||
public string? ModelName { init; get; }
|
public string? ModelName { init; get; }
|
||||||
public int? NumberOfJitters { init; get; }
|
public int? NumberOfJitters { init; get; }
|
||||||
public int? NumberOfTimesToUpsample { init; get; }
|
public int? NumberOfTimesToUpsample { init; get; }
|
||||||
|
public int Offset { init; get; }
|
||||||
public string Pattern { init; get; }
|
public string Pattern { init; get; }
|
||||||
public string PersonBirthdayFormat { init; get; }
|
public string PersonBirthdayFormat { init; get; }
|
||||||
public bool PopulatePropertyId { init; get; }
|
public bool PopulatePropertyId { init; get; }
|
||||||
@ -36,10 +38,12 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
string fileNameDirectorySeparator,
|
string fileNameDirectorySeparator,
|
||||||
bool forcePropertyLastWriteTimeToCreationTime,
|
bool forcePropertyLastWriteTimeToCreationTime,
|
||||||
string[] ignoreExtensions,
|
string[] ignoreExtensions,
|
||||||
|
string[] ignoreRulesKeyWords,
|
||||||
int maxImagesInDirectoryForTopLevelFirstPass,
|
int maxImagesInDirectoryForTopLevelFirstPass,
|
||||||
string? modelName,
|
string? modelName,
|
||||||
int? numberOfJitters,
|
int? numberOfJitters,
|
||||||
int? numberOfTimesToUpsample,
|
int? numberOfTimesToUpsample,
|
||||||
|
int offset,
|
||||||
string pattern,
|
string pattern,
|
||||||
string personBirthdayFormat,
|
string personBirthdayFormat,
|
||||||
bool populatePropertyId,
|
bool populatePropertyId,
|
||||||
@ -59,10 +63,12 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
FileNameDirectorySeparator = fileNameDirectorySeparator;
|
FileNameDirectorySeparator = fileNameDirectorySeparator;
|
||||||
ForcePropertyLastWriteTimeToCreationTime = forcePropertyLastWriteTimeToCreationTime;
|
ForcePropertyLastWriteTimeToCreationTime = forcePropertyLastWriteTimeToCreationTime;
|
||||||
IgnoreExtensions = ignoreExtensions;
|
IgnoreExtensions = ignoreExtensions;
|
||||||
|
IgnoreRulesKeyWords = ignoreRulesKeyWords;
|
||||||
MaxImagesInDirectoryForTopLevelFirstPass = maxImagesInDirectoryForTopLevelFirstPass;
|
MaxImagesInDirectoryForTopLevelFirstPass = maxImagesInDirectoryForTopLevelFirstPass;
|
||||||
ModelName = modelName;
|
ModelName = modelName;
|
||||||
NumberOfJitters = numberOfJitters;
|
NumberOfJitters = numberOfJitters;
|
||||||
NumberOfTimesToUpsample = numberOfTimesToUpsample;
|
NumberOfTimesToUpsample = numberOfTimesToUpsample;
|
||||||
|
Offset = offset;
|
||||||
Pattern = pattern;
|
Pattern = pattern;
|
||||||
PersonBirthdayFormat = personBirthdayFormat;
|
PersonBirthdayFormat = personBirthdayFormat;
|
||||||
PredictorModelName = predictorModelName;
|
PredictorModelName = predictorModelName;
|
||||||
@ -89,26 +95,17 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
|
|
||||||
public static void Verify(Configuration propertyConfiguration, bool requireExist)
|
public static void Verify(Configuration propertyConfiguration, bool requireExist)
|
||||||
{
|
{
|
||||||
if (propertyConfiguration is null)
|
if (propertyConfiguration is null) throw new NullReferenceException(nameof(propertyConfiguration));
|
||||||
throw new NullReferenceException(nameof(propertyConfiguration));
|
if (propertyConfiguration.IgnoreExtensions is null || propertyConfiguration.IgnoreExtensions.Length == 0) throw new NullReferenceException(nameof(propertyConfiguration.IgnoreExtensions));
|
||||||
if (propertyConfiguration.IgnoreExtensions is null || propertyConfiguration.IgnoreExtensions.Length == 0)
|
if (propertyConfiguration.IgnoreRulesKeyWords is null || propertyConfiguration.IgnoreRulesKeyWords.Length == 0) throw new NullReferenceException(nameof(propertyConfiguration.IgnoreRulesKeyWords));
|
||||||
throw new NullReferenceException(nameof(propertyConfiguration.IgnoreExtensions));
|
if (propertyConfiguration.PropertyContentCollectionFiles is null) throw new NullReferenceException(nameof(propertyConfiguration.PropertyContentCollectionFiles));
|
||||||
if (propertyConfiguration.PropertyContentCollectionFiles is null)
|
if (propertyConfiguration.ValidImageFormatExtensions is null || propertyConfiguration.ValidImageFormatExtensions.Length == 0) throw new NullReferenceException(nameof(propertyConfiguration.ValidImageFormatExtensions));
|
||||||
throw new NullReferenceException(nameof(propertyConfiguration.PropertyContentCollectionFiles));
|
if (propertyConfiguration is null) throw new NullReferenceException(nameof(propertyConfiguration));
|
||||||
if (propertyConfiguration.ValidImageFormatExtensions is null || propertyConfiguration.ValidImageFormatExtensions.Length == 0)
|
if (string.IsNullOrEmpty(propertyConfiguration.DateGroup)) throw new NullReferenceException(nameof(propertyConfiguration.DateGroup));
|
||||||
throw new NullReferenceException(nameof(propertyConfiguration.ValidImageFormatExtensions));
|
if (string.IsNullOrEmpty(propertyConfiguration.FileNameDirectorySeparator)) throw new NullReferenceException(nameof(propertyConfiguration.FileNameDirectorySeparator));
|
||||||
if (propertyConfiguration is null)
|
if (string.IsNullOrEmpty(propertyConfiguration.Pattern)) throw new NullReferenceException(nameof(propertyConfiguration.Pattern));
|
||||||
throw new NullReferenceException(nameof(propertyConfiguration));
|
if (string.IsNullOrEmpty(propertyConfiguration.RootDirectory) || (requireExist && !Directory.Exists(propertyConfiguration.RootDirectory))) throw new NullReferenceException(nameof(propertyConfiguration.RootDirectory));
|
||||||
if (string.IsNullOrEmpty(propertyConfiguration.DateGroup))
|
if (propertyConfiguration.RootDirectory != Path.GetFullPath(propertyConfiguration.RootDirectory)) throw new Exception();
|
||||||
throw new NullReferenceException(nameof(propertyConfiguration.DateGroup));
|
|
||||||
if (string.IsNullOrEmpty(propertyConfiguration.FileNameDirectorySeparator))
|
|
||||||
throw new NullReferenceException(nameof(propertyConfiguration.FileNameDirectorySeparator));
|
|
||||||
if (string.IsNullOrEmpty(propertyConfiguration.Pattern))
|
|
||||||
throw new NullReferenceException(nameof(propertyConfiguration.Pattern));
|
|
||||||
if (string.IsNullOrEmpty(propertyConfiguration.RootDirectory) || (requireExist && !Directory.Exists(propertyConfiguration.RootDirectory)))
|
|
||||||
throw new NullReferenceException(nameof(propertyConfiguration.RootDirectory));
|
|
||||||
if (propertyConfiguration.RootDirectory != Path.GetFullPath(propertyConfiguration.RootDirectory))
|
|
||||||
throw new Exception();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -214,10 +214,10 @@ internal class Property
|
|||||||
DateTime?[] dateTimes;
|
DateTime?[] dateTimes;
|
||||||
string dateTimeFormat;
|
string dateTimeFormat;
|
||||||
DateTime checkDateTime;
|
DateTime checkDateTime;
|
||||||
|
int? orientation = null;
|
||||||
DateTime? dateTime = null;
|
DateTime? dateTime = null;
|
||||||
string[]? keywords = null;
|
string[]? keywords = null;
|
||||||
PropertyItem? propertyItem;
|
PropertyItem? propertyItem;
|
||||||
string? orientation = null;
|
|
||||||
DateTime? gpsDateStamp = null;
|
DateTime? gpsDateStamp = null;
|
||||||
List<DateTime> dateTimesByLogic;
|
List<DateTime> dateTimesByLogic;
|
||||||
DateTime? dateTimeOriginal = null;
|
DateTime? dateTimeOriginal = null;
|
||||||
@ -312,28 +312,19 @@ internal class Property
|
|||||||
{
|
{
|
||||||
propertyItem = image.GetPropertyItem((int)IExif.Tags.Make);
|
propertyItem = image.GetPropertyItem((int)IExif.Tags.Make);
|
||||||
if (propertyItem?.Value is not null)
|
if (propertyItem?.Value is not null)
|
||||||
{
|
make = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
|
||||||
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
|
|
||||||
make = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (image.PropertyIdList.Contains((int)IExif.Tags.Model))
|
if (image.PropertyIdList.Contains((int)IExif.Tags.Model))
|
||||||
{
|
{
|
||||||
propertyItem = image.GetPropertyItem((int)IExif.Tags.Model);
|
propertyItem = image.GetPropertyItem((int)IExif.Tags.Model);
|
||||||
if (propertyItem?.Value is not null)
|
if (propertyItem?.Value is not null)
|
||||||
{
|
model = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
|
||||||
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
|
|
||||||
model = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (image.PropertyIdList.Contains((int)IExif.Tags.Orientation))
|
if (image.PropertyIdList.Contains((int)IExif.Tags.Orientation))
|
||||||
{
|
{
|
||||||
propertyItem = image.GetPropertyItem((int)IExif.Tags.Orientation);
|
propertyItem = image.GetPropertyItem((int)IExif.Tags.Orientation);
|
||||||
if (propertyItem?.Value is not null)
|
if (propertyItem?.Value is not null)
|
||||||
{
|
orientation = BitConverter.ToInt16(propertyItem.Value, 0);
|
||||||
value = BitConverter.ToInt16(propertyItem.Value, 0).ToString();
|
|
||||||
orientation = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (image.PropertyIdList.Contains((int)IExif.Tags.XPKeywords))
|
if (image.PropertyIdList.Contains((int)IExif.Tags.XPKeywords))
|
||||||
{
|
{
|
||||||
@ -381,9 +372,9 @@ internal class Property
|
|||||||
if (fileHolder.LastWriteTime is null && property?.LastWriteTime is null)
|
if (fileHolder.LastWriteTime is null && property?.LastWriteTime is null)
|
||||||
throw new NullReferenceException(nameof(fileHolder.LastWriteTime));
|
throw new NullReferenceException(nameof(fileHolder.LastWriteTime));
|
||||||
if (fileHolder.CreationTime is not null && fileHolder.LastWriteTime is not null)
|
if (fileHolder.CreationTime is not null && fileHolder.LastWriteTime is not null)
|
||||||
result = new(fileHolder.CreationTime.Value, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginalByLogic, fileLength, gpsDateStamp, height, id, keywords, fileHolder.LastWriteTime.Value, make, model, orientation, width);
|
result = new(fileHolder.CreationTime.Value, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginalByLogic, fileLength, gpsDateStamp, height, id, keywords, fileHolder.LastWriteTime.Value, make, model, orientation?.ToString(), width);
|
||||||
else if (property is not null)
|
else if (property is not null)
|
||||||
result = new(property.CreationTime, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginalByLogic, fileLength, gpsDateStamp, height, id, keywords, property.LastWriteTime, make, model, orientation, width);
|
result = new(property.CreationTime, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginalByLogic, fileLength, gpsDateStamp, height, id, keywords, property.LastWriteTime, make, model, orientation?.ToString(), width);
|
||||||
else
|
else
|
||||||
throw new NullReferenceException(nameof(property));
|
throw new NullReferenceException(nameof(property));
|
||||||
return (message, dateTimesByLogic.ToArray(), result);
|
return (message, dateTimesByLogic.ToArray(), result);
|
||||||
|
2
Rename/Models/Binder/.editorconfig
Normal file
2
Rename/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -24,20 +24,13 @@ public class AppSettings
|
|||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
if (appSettings?.Company is null)
|
if (appSettings?.Company is null) throw new NullReferenceException(nameof(appSettings.Company));
|
||||||
throw new NullReferenceException(nameof(appSettings.Company));
|
if (appSettings?.DefaultUnknownDirectoryName is null) throw new NullReferenceException(nameof(appSettings.DefaultUnknownDirectoryName));
|
||||||
if (appSettings?.DefaultUnknownDirectoryName is null)
|
if (appSettings?.ForceIdName is null) throw new NullReferenceException(nameof(appSettings.ForceIdName));
|
||||||
throw new NullReferenceException(nameof(appSettings.DefaultUnknownDirectoryName));
|
if (appSettings?.MaxDegreeOfParallelism is null) throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||||
if (appSettings?.ForceIdName is null)
|
if (appSettings?.MaxMinutesDelta is null) throw new NullReferenceException(nameof(appSettings.MaxMinutesDelta));
|
||||||
throw new NullReferenceException(nameof(appSettings.ForceIdName));
|
if (appSettings?.RenameUndo is null) throw new NullReferenceException(nameof(appSettings.RenameUndo));
|
||||||
if (appSettings?.MaxDegreeOfParallelism is null)
|
if (appSettings?.WorkingDirectoryName is null) throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
||||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
|
||||||
if (appSettings?.MaxMinutesDelta is null)
|
|
||||||
throw new NullReferenceException(nameof(appSettings.MaxMinutesDelta));
|
|
||||||
if (appSettings?.RenameUndo is null)
|
|
||||||
throw new NullReferenceException(nameof(appSettings.RenameUndo));
|
|
||||||
if (appSettings?.WorkingDirectoryName is null)
|
|
||||||
throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.Company,
|
appSettings.Company,
|
||||||
appSettings.DefaultUnknownDirectoryName,
|
appSettings.DefaultUnknownDirectoryName,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Rename.Models.Binder;
|
namespace View_by_Distance.Rename.Models.Binder;
|
||||||
@ -10,9 +9,9 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
public string[] IgnoreExtensions { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
public string PersonBirthdayFormat { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
@ -25,12 +24,9 @@ public class Configuration
|
|||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.IgnoreExtensions is null)
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
|
||||||
if (configuration.PersonBirthdayFormat is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
|
@ -1,32 +1,6 @@
|
|||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace View_by_Distance.Rename.Models;
|
namespace View_by_Distance.Rename.Models;
|
||||||
|
|
||||||
public class Configuration
|
public record Configuration(string[] IgnoreExtensions,
|
||||||
{
|
string PersonBirthdayFormat,
|
||||||
|
Property.Models.Configuration PropertyConfiguration);
|
||||||
protected Property.Models.Configuration _PropertyConfiguration;
|
|
||||||
public string[] IgnoreExtensions { init; get; }
|
|
||||||
public string PersonBirthdayFormat { init; get; }
|
|
||||||
|
|
||||||
public Property.Models.Configuration PropertyConfiguration => _PropertyConfiguration;
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public Configuration(
|
|
||||||
string[] ignoreExtensions,
|
|
||||||
string personBirthdayFormat,
|
|
||||||
Property.Models.Configuration propertyConfiguration)
|
|
||||||
{
|
|
||||||
IgnoreExtensions = ignoreExtensions;
|
|
||||||
PersonBirthdayFormat = personBirthdayFormat;
|
|
||||||
_PropertyConfiguration = propertyConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -47,6 +47,7 @@ public class Rename
|
|||||||
_PropertyConfiguration = propertyConfiguration;
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
_Configuration = configuration;
|
_Configuration = configuration;
|
||||||
log.Information(propertyConfiguration.RootDirectory);
|
log.Information(propertyConfiguration.RootDirectory);
|
||||||
|
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
|
||||||
Verify();
|
Verify();
|
||||||
List<string> lines = RenameFilesInDirectories(log);
|
List<string> lines = RenameFilesInDirectories(log);
|
||||||
if (lines.Any())
|
if (lines.Any())
|
||||||
@ -81,7 +82,6 @@ public class Rename
|
|||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
List<Record> records = new();
|
List<Record> records = new();
|
||||||
const string fileSearchFilter = "*";
|
const string fileSearchFilter = "*";
|
||||||
int offset = IDirectory.GetOffset();
|
|
||||||
const bool useCeilingAverage = false;
|
const bool useCeilingAverage = false;
|
||||||
const string directorySearchFilter = "*";
|
const string directorySearchFilter = "*";
|
||||||
List<string> distinctDirectories = new();
|
List<string> distinctDirectories = new();
|
||||||
@ -115,12 +115,12 @@ public class Rename
|
|||||||
progressBar = new(files.Length, message, options);
|
progressBar = new(files.Length, message, options);
|
||||||
nefPresentCheck = files.Any(l => l.EndsWith(".NEF"));
|
nefPresentCheck = files.Any(l => l.EndsWith(".NEF"));
|
||||||
if (!nefPresentCheck)
|
if (!nefPresentCheck)
|
||||||
records.AddRange(GetRecords(metadata, offset + records.Count, progressBar, files));
|
records.AddRange(GetRecords(metadata, _PropertyConfiguration.Offset + records.Count, progressBar, files));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!nefPresent)
|
if (!nefPresent)
|
||||||
nefPresent = true;
|
nefPresent = true;
|
||||||
records.AddRange(GetRecords(metadata, offset + records.Count, progressBar, (from l in files where l.EndsWith(".JPG") select l).ToArray()));
|
records.AddRange(GetRecords(metadata, _PropertyConfiguration.Offset + records.Count, progressBar, (from l in files where l.EndsWith(".JPG") select l).ToArray()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
progressBar.Dispose();
|
progressBar.Dispose();
|
||||||
@ -226,7 +226,7 @@ public class Rename
|
|||||||
bool nameWithoutExtensionIsIdFormat;
|
bool nameWithoutExtensionIsIdFormat;
|
||||||
bool nameWithoutExtensionIsPaddedIdFormat;
|
bool nameWithoutExtensionIsPaddedIdFormat;
|
||||||
IReadOnlyList<MetadataExtractor.Directory> directories;
|
IReadOnlyList<MetadataExtractor.Directory> directories;
|
||||||
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex();
|
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex(_PropertyConfiguration.Offset);
|
||||||
for (int i = 0; i < files.Length; i++)
|
for (int i = 0; i < files.Length; i++)
|
||||||
{
|
{
|
||||||
progressBar.Tick();
|
progressBar.Tick();
|
||||||
|
@ -364,21 +364,17 @@ public class C_Resize
|
|||||||
return results.ToArray();
|
return results.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, int[]> GetImageResizes(Shared.Models.Property property, List<KeyValuePair<string, string>> metadataCollection)
|
private Dictionary<string, int[]> GetImageResizes(Shared.Models.Property property)
|
||||||
{
|
{
|
||||||
Dictionary<string, int[]> results = new();
|
Dictionary<string, int[]> results = new();
|
||||||
int[] desired;
|
int[] desired;
|
||||||
int checkWidth;
|
int checkWidth;
|
||||||
int orientation;
|
|
||||||
int checkHeight;
|
int checkHeight;
|
||||||
int desiredWidth;
|
int desiredWidth;
|
||||||
int desiredHeight;
|
int desiredHeight;
|
||||||
|
int orientation = property.Orientation is null || string.IsNullOrEmpty(property.Orientation) || !int.TryParse(property.Orientation, out int propertyOrientation) ? 0 : propertyOrientation;
|
||||||
if (property is null || property.Width is null || property.Height is null)
|
if (property is null || property.Width is null || property.Height is null)
|
||||||
throw new Exception();
|
throw new NotSupportedException();
|
||||||
if (!string.IsNullOrEmpty(property.Orientation) && int.TryParse(property.Orientation, out int propertyOrientation))
|
|
||||||
orientation = propertyOrientation;
|
|
||||||
else
|
|
||||||
orientation = Metadata.Models.Stateless.Methods.IMetadata.GetOrientation(metadataCollection);
|
|
||||||
checkWidth = property.Width.Value;
|
checkWidth = property.Width.Value;
|
||||||
checkHeight = property.Height.Value;
|
checkHeight = property.Height.Value;
|
||||||
if (!_ValidResolutions.Contains(_Original))
|
if (!_ValidResolutions.Contains(_Original))
|
||||||
@ -438,7 +434,7 @@ public class C_Resize
|
|||||||
public FileHolder GetResizedFileHolder(string cResultsFullGroupDirectory, Item item, bool outputResolutionHasNumber, int id) =>
|
public FileHolder GetResizedFileHolder(string cResultsFullGroupDirectory, Item item, bool outputResolutionHasNumber, int id) =>
|
||||||
GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber, $"{id}{item.ImageFileHolder.ExtensionLowered}");
|
GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber, $"{id}{item.ImageFileHolder.ExtensionLowered}");
|
||||||
|
|
||||||
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)
|
public Dictionary<string, int[]> GetResizeKeyValuePairs(Configuration configuration, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Shared.Models.Property property, MappingFromItem mappingFromItem)
|
||||||
{
|
{
|
||||||
Dictionary<string, int[]>? results;
|
Dictionary<string, int[]>? results;
|
||||||
string json;
|
string json;
|
||||||
@ -482,7 +478,7 @@ public class C_Resize
|
|||||||
}
|
}
|
||||||
if (results is null)
|
if (results is null)
|
||||||
{
|
{
|
||||||
results = GetImageResizes(property, metadataCollection);
|
results = GetImageResizes(property);
|
||||||
json = JsonSerializer.Serialize(results, _WriteIndentedJsonSerializerOptions);
|
json = JsonSerializer.Serialize(results, _WriteIndentedJsonSerializerOptions);
|
||||||
bool updateDateWhenMatches = dateTimes.Any() && fileInfo.Exists && dateTimes.Max() > fileInfo.LastWriteTime;
|
bool updateDateWhenMatches = dateTimes.Any() && fileInfo.Exists && dateTimes.Max() > fileInfo.LastWriteTime;
|
||||||
DateTime? dateTime = !updateDateWhenMatches ? null : dateTimes.Max();
|
DateTime? dateTime = !updateDateWhenMatches ? null : dateTimes.Max();
|
||||||
|
@ -3,30 +3,22 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Set.Created.Date.Models;
|
namespace View_by_Distance.Set.Created.Date.Models;
|
||||||
|
|
||||||
public class AppSettings
|
public record AppSettings(string Company,
|
||||||
|
string CopyTo,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public string CopyTo { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company,
|
|
||||||
string copyTo,
|
|
||||||
int maxDegreeOfParallelism,
|
|
||||||
string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
CopyTo = copyTo;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AppSettings))]
|
||||||
|
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
2
Set-Created-Date/Models/Binder/.editorconfig
Normal file
2
Set-Created-Date/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[*.cs]
|
||||||
|
csharp_preserve_single_line_statements = true
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Set.Created.Date.Models.Binder;
|
namespace View_by_Distance.Set.Created.Date.Models.Binder;
|
||||||
@ -10,9 +9,9 @@ public class Configuration
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
public string[] IgnoreExtensions { get; set; }
|
||||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
public string PersonBirthdayFormat { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
@ -25,12 +24,9 @@ public class Configuration
|
|||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null)
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
throw new NullReferenceException(nameof(configuration));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.IgnoreExtensions is null)
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
|
||||||
if (configuration.PersonBirthdayFormat is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
type: "Kanban"
|
type: Kanban
|
||||||
created: "2023-08-23T22:44:24.920Z"
|
created: '2023-08-23T22:44:24.920Z'
|
||||||
updated: "2023-09-30T02:39:33.671Z"
|
updated: '2023-09-30T02:39:33.671Z'
|
||||||
startedColumns:
|
startedColumns:
|
||||||
- 'In Progress'
|
- 'In Progress'
|
||||||
completedColumns:
|
completedColumns:
|
||||||
@ -42,9 +42,11 @@ taskTemplate: '^+^_${overdue ? ''^R'' : ''''}${name}^: ${relations ? (''\n^-^/^g
|
|||||||
- [verify-camera-model-still-works](tasks/verify-camera-model-still-works.md)
|
- [verify-camera-model-still-works](tasks/verify-camera-model-still-works.md)
|
||||||
- [run-limiting-on-days](tasks/run-limiting-on-days.md)
|
- [run-limiting-on-days](tasks/run-limiting-on-days.md)
|
||||||
- [merge-kristy-files](tasks/merge-kristy-files.md)
|
- [merge-kristy-files](tasks/merge-kristy-files.md)
|
||||||
|
- [limit-amazon-sync](tasks/limit-amazon-sync.md)
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
|
- [sftp-sync](tasks/sftp-sync.md)
|
||||||
- [eof-error](tasks/eof-error.md)
|
- [eof-error](tasks/eof-error.md)
|
||||||
- [shrink-percent](tasks/shrink-percent.md)
|
- [shrink-percent](tasks/shrink-percent.md)
|
||||||
- [setup-photo-prism-again-in-wsl-docker](tasks/setup-photo-prism-again-in-wsl-docker.md)
|
- [setup-photo-prism-again-in-wsl-docker](tasks/setup-photo-prism-again-in-wsl-docker.md)
|
||||||
|
14
Shared/.kanbn/tasks/limit-amazon-sync.md
Normal file
14
Shared/.kanbn/tasks/limit-amazon-sync.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
created: 2023-10-14T22:34:13.711Z
|
||||||
|
updated: 2023-10-15T08:07:29.699Z
|
||||||
|
assigned: ""
|
||||||
|
progress: 0
|
||||||
|
tags: []
|
||||||
|
started: 2023-10-14T00:00:00.000Z
|
||||||
|
---
|
||||||
|
|
||||||
|
# Limit Amazon Sync
|
||||||
|
|
||||||
|
Don't sync using ValidKeyWordsToIgnoreInRandom
|
||||||
|
|
||||||
|
https://github.com/trevorhobenshield/amazon_photos#installation
|
11
Shared/.kanbn/tasks/sftp-sync.md
Normal file
11
Shared/.kanbn/tasks/sftp-sync.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
created: 2023-10-14T22:29:10.180Z
|
||||||
|
updated: 2023-10-14T22:29:16.518Z
|
||||||
|
assigned: ""
|
||||||
|
progress: 0
|
||||||
|
tags: []
|
||||||
|
started: 2023-10-14T22:29:10.181Z
|
||||||
|
completed: 2023-10-14T22:29:16.518Z
|
||||||
|
---
|
||||||
|
|
||||||
|
# SFTP Sync
|
@ -5,6 +5,7 @@ public interface IPropertyConfiguration
|
|||||||
|
|
||||||
public string DateGroup { init; get; }
|
public string DateGroup { init; get; }
|
||||||
public string[] IgnoreExtensions { init; get; }
|
public string[] IgnoreExtensions { init; get; }
|
||||||
|
public string[] IgnoreRulesKeyWords { init; get; }
|
||||||
public string PersonBirthdayFormat { init; get; }
|
public string PersonBirthdayFormat { init; get; }
|
||||||
public bool PropertiesChangedForProperty { init; get; }
|
public bool PropertiesChangedForProperty { init; get; }
|
||||||
public string[] PropertyContentCollectionFiles { init; get; }
|
public string[] PropertyContentCollectionFiles { init; get; }
|
||||||
@ -17,6 +18,7 @@ public interface IPropertyConfiguration
|
|||||||
public string? ModelName { get; }
|
public string? ModelName { get; }
|
||||||
public int? NumberOfJitters { get; }
|
public int? NumberOfJitters { get; }
|
||||||
public int? NumberOfTimesToUpsample { get; }
|
public int? NumberOfTimesToUpsample { get; }
|
||||||
|
public int Offset { init; get; }
|
||||||
public string? PredictorModelName { get; }
|
public string? PredictorModelName { get; }
|
||||||
public string RootDirectory { get; }
|
public string RootDirectory { get; }
|
||||||
|
|
||||||
|
@ -3,13 +3,10 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
public interface IDirectory
|
public interface IDirectory
|
||||||
{
|
{
|
||||||
|
|
||||||
static int GetOffset() =>
|
short TestStatic_GetSortOrderOnlyLengthIndex(int offset) =>
|
||||||
1000000;
|
GetSortOrderOnlyLengthIndex(offset);
|
||||||
|
static short GetSortOrderOnlyLengthIndex(int offset) =>
|
||||||
int TestStatic_GetSortOrderOnlyLengthIndex() =>
|
(short)(offset.ToString().Length + 3);
|
||||||
GetSortOrderOnlyLengthIndex();
|
|
||||||
static int GetSortOrderOnlyLengthIndex() =>
|
|
||||||
GetOffset().ToString().Length + 3;
|
|
||||||
|
|
||||||
char TestStatic_GetDirectory(string fileName) =>
|
char TestStatic_GetDirectory(string fileName) =>
|
||||||
GetDirectory(fileName);
|
GetDirectory(fileName);
|
||||||
@ -84,14 +81,14 @@ public interface IDirectory
|
|||||||
static List<string> CopyOrMove(List<(Models.FileHolder, string?, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
|
static List<string> CopyOrMove(List<(Models.FileHolder, string?, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
|
||||||
XDirectory.CopyOrMove(toDoCollection, move, moveBack, tick);
|
XDirectory.CopyOrMove(toDoCollection, move, moveBack, tick);
|
||||||
|
|
||||||
(bool, int?) TestStatic_GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
(bool, int?) TestStatic_GetId(short sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
||||||
GetId(sortOrderOnlyLengthIndex, fileHolder);
|
GetId(sortOrderOnlyLengthIndex, fileHolder);
|
||||||
static (bool, int?) GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
static (bool, int?) GetId(short sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
|
||||||
XDirectory.GetId(sortOrderOnlyLengthIndex, fileHolder);
|
XDirectory.GetId(sortOrderOnlyLengthIndex, fileHolder);
|
||||||
|
|
||||||
(bool, int?) TestStatic_GetId(Models.FileHolder fileHolder) =>
|
(bool, int?) TestStatic_GetId(int offset, Models.FileHolder fileHolder) =>
|
||||||
GetId(fileHolder);
|
GetId(offset, fileHolder);
|
||||||
static (bool, int?) GetId(Models.FileHolder fileHolder) =>
|
static (bool, int?) GetId(int offset, Models.FileHolder fileHolder) =>
|
||||||
XDirectory.GetId(GetSortOrderOnlyLengthIndex(), fileHolder);
|
XDirectory.GetId(GetSortOrderOnlyLengthIndex(offset), fileHolder);
|
||||||
|
|
||||||
}
|
}
|
@ -281,7 +281,7 @@ internal abstract partial class XDirectory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static (bool, int?) GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder)
|
internal static (bool, int?) GetId(short sortOrderOnlyLengthIndex, Models.FileHolder fileHolder)
|
||||||
{
|
{
|
||||||
int? id;
|
int? id;
|
||||||
short? multiplier;
|
short? multiplier;
|
||||||
@ -319,13 +319,13 @@ internal abstract partial class XDirectory
|
|||||||
return (nameWithoutExtensionIsIdFormat, id);
|
return (nameWithoutExtensionIsIdFormat, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SortedRecord[] GetSortedRecords(List<string[]> filesCollection)
|
private static SortedRecord[] GetSortedRecords(int offset, List<string[]> filesCollection)
|
||||||
{
|
{
|
||||||
List<SortedRecord> results = new();
|
List<SortedRecord> results = new();
|
||||||
int? id;
|
int? id;
|
||||||
Models.FileHolder fileHolder;
|
Models.FileHolder fileHolder;
|
||||||
bool nameWithoutExtensionIsIdFormat;
|
bool nameWithoutExtensionIsIdFormat;
|
||||||
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex();
|
short sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex(offset);
|
||||||
foreach (string[] files in filesCollection)
|
foreach (string[] files in filesCollection)
|
||||||
{
|
{
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
@ -357,10 +357,9 @@ internal abstract partial class XDirectory
|
|||||||
Models.FileHolder fileHolder;
|
Models.FileHolder fileHolder;
|
||||||
List<int> distinctIds = new();
|
List<int> distinctIds = new();
|
||||||
List<string> distinct = new();
|
List<string> distinct = new();
|
||||||
int offset = IDirectory.GetOffset();
|
|
||||||
List<string> distinctDirectories = new();
|
List<string> distinctDirectories = new();
|
||||||
int intMinValueLength = int.MinValue.ToString().Length;
|
int intMinValueLength = int.MinValue.ToString().Length;
|
||||||
SortedRecord[] sortedRecords = GetSortedRecords(filesCollection);
|
SortedRecord[] sortedRecords = GetSortedRecords(propertyConfiguration.Offset, filesCollection);
|
||||||
string? alternateResultAllInOne = !propertyConfiguration.ResultAllInOne.Contains(' ') ? null : propertyConfiguration.ResultAllInOne.Replace(' ', '-');
|
string? alternateResultAllInOne = !propertyConfiguration.ResultAllInOne.Contains(' ') ? null : propertyConfiguration.ResultAllInOne.Replace(' ', '-');
|
||||||
for (int i = 0; i < sortedRecords.Length; i++)
|
for (int i = 0; i < sortedRecords.Length; i++)
|
||||||
{
|
{
|
||||||
@ -390,7 +389,7 @@ internal abstract partial class XDirectory
|
|||||||
}
|
}
|
||||||
if (ifCanUseId && sortedRecord.NameWithoutExtensionIsIdFormat && sortedRecord.Id is not null && fileHolder.DirectoryName is not null)
|
if (ifCanUseId && sortedRecord.NameWithoutExtensionIsIdFormat && sortedRecord.Id is not null && fileHolder.DirectoryName is not null)
|
||||||
{
|
{
|
||||||
paddedId = IDirectory.GetPaddedId(intMinValueLength, offset + i, sortedRecord.Id.Value);
|
paddedId = IDirectory.GetPaddedId(intMinValueLength, propertyConfiguration.Offset + i, sortedRecord.Id.Value);
|
||||||
paddedIdFile = Path.Combine(fileHolder.DirectoryName, $"{paddedId}{fileHolder.ExtensionLowered}");
|
paddedIdFile = Path.Combine(fileHolder.DirectoryName, $"{paddedId}{fileHolder.ExtensionLowered}");
|
||||||
if (!File.Exists(paddedIdFile))
|
if (!File.Exists(paddedIdFile))
|
||||||
{
|
{
|
||||||
@ -462,9 +461,9 @@ internal abstract partial class XDirectory
|
|||||||
foreach ((Models.FileHolder fileHolder, string? alternateFile, string to) in toDoCollection)
|
foreach ((Models.FileHolder fileHolder, string? alternateFile, string to) in toDoCollection)
|
||||||
{
|
{
|
||||||
tick?.Invoke();
|
tick?.Invoke();
|
||||||
if (alternateFile is not null)
|
|
||||||
_ = XPath.WriteAllText(alternateFile, fileHolder.FullName, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
|
||||||
fileInfo = new(to);
|
fileInfo = new(to);
|
||||||
|
if (!fileInfo.Exists && alternateFile is not null)
|
||||||
|
_ = XPath.WriteAllText(alternateFile, fileHolder.FullName, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
if (fileInfo.Exists)
|
if (fileInfo.Exists)
|
||||||
{
|
{
|
||||||
if (fileHolder.Length != fileInfo.Length || fileHolder.LastWriteTime != fileInfo.LastWriteTime)
|
if (fileHolder.Length != fileInfo.Length || fileHolder.LastWriteTime != fileInfo.LastWriteTime)
|
||||||
|
@ -286,8 +286,9 @@ internal abstract class XPath
|
|||||||
internal static Dictionary<string, string[]> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? directories)
|
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 directory;
|
||||||
string checkDirectory;
|
string checkDirectory;
|
||||||
|
int converted = int.Parse($"1{new string('0', propertyConfiguration.ResultAllInOneSubdirectoryLength)}");
|
||||||
int plusOne = converted + 1;
|
int plusOne = converted + 1;
|
||||||
List<string> collection = new();
|
List<string> collection = new();
|
||||||
if (directories is not null)
|
if (directories is not null)
|
||||||
@ -308,10 +309,11 @@ internal abstract class XPath
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
directory = Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne);
|
||||||
if (i == converted)
|
if (i == converted)
|
||||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)));
|
checkDirectory = Path.GetFullPath(Path.Combine(directory, new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)));
|
||||||
else
|
else
|
||||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')));
|
checkDirectory = Path.GetFullPath(Path.Combine(directory, i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')));
|
||||||
}
|
}
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
|
@ -2,9 +2,11 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
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;
|
||||||
using View_by_Distance.Resize.Models;
|
using View_by_Distance.Resize.Models;
|
||||||
@ -53,6 +55,7 @@ public class UnitTestResize
|
|||||||
logger = Log.ForContext<UnitTestResize>();
|
logger = Log.ForContext<UnitTestResize>();
|
||||||
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||||
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||||
|
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
|
||||||
logger.Information("Complete");
|
logger.Information("Complete");
|
||||||
_Logger = logger;
|
_Logger = logger;
|
||||||
_AppSettings = appSettings;
|
_AppSettings = appSettings;
|
||||||
@ -132,8 +135,10 @@ public class UnitTestResize
|
|||||||
throw new NullReferenceException(nameof(_PropertyConfiguration.NumberOfJitters));
|
throw new NullReferenceException(nameof(_PropertyConfiguration.NumberOfJitters));
|
||||||
if (_PropertyConfiguration.NumberOfTimesToUpsample is null)
|
if (_PropertyConfiguration.NumberOfTimesToUpsample is null)
|
||||||
throw new NullReferenceException(nameof(_PropertyConfiguration.NumberOfTimesToUpsample));
|
throw new NullReferenceException(nameof(_PropertyConfiguration.NumberOfTimesToUpsample));
|
||||||
string sourceFileName = "100000507001158650387.jpg";
|
// string sourceFileName = "100000507001158650387.jpg";
|
||||||
string sourceDirectoryName = "Facebook/2023.2 Summer Facebook";
|
// string sourceDirectoryName = "Facebook/2023.2 Summer Facebook";
|
||||||
|
string sourceFileName = "105131603001106320328.jpg";
|
||||||
|
string sourceDirectoryName = "Mike iCloud Have Date Taken 2022 !9";
|
||||||
Item item;
|
Item item;
|
||||||
bool reverse = false;
|
bool reverse = false;
|
||||||
FileHolder resizedFileHolder;
|
FileHolder resizedFileHolder;
|
||||||
@ -142,7 +147,6 @@ public class UnitTestResize
|
|||||||
const bool isValidImageFormatExtension = true;
|
const bool isValidImageFormatExtension = true;
|
||||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||||
string[] alternateFileLines = Array.Empty<string>();
|
string[] alternateFileLines = Array.Empty<string>();
|
||||||
List<KeyValuePair<string, string>> metadataCollection;
|
|
||||||
int length = _PropertyConfiguration.RootDirectory.Length;
|
int length = _PropertyConfiguration.RootDirectory.Length;
|
||||||
string[] changesFrom = new string[] { nameof(A_Property) };
|
string[] changesFrom = new string[] { nameof(A_Property) };
|
||||||
string outputResolution = _Configuration.OutputResolutions[0];
|
string outputResolution = _Configuration.OutputResolutions[0];
|
||||||
@ -165,7 +169,7 @@ public class UnitTestResize
|
|||||||
FileHolder sourceDirectoryFileHolder = new(".json");
|
FileHolder sourceDirectoryFileHolder = new(".json");
|
||||||
string sourceDirectory = Path.GetFullPath(Path.Combine(_PropertyConfiguration.RootDirectory, sourceDirectoryName));
|
string sourceDirectory = Path.GetFullPath(Path.Combine(_PropertyConfiguration.RootDirectory, sourceDirectoryName));
|
||||||
FileHolder fileHolder = new(Path.Combine(sourceDirectory, sourceFileName));
|
FileHolder fileHolder = new(Path.Combine(sourceDirectory, sourceFileName));
|
||||||
(_, int? id) = IDirectory.GetId(fileHolder);
|
(_, int? id) = IDirectory.GetId(_PropertyConfiguration.Offset, fileHolder);
|
||||||
Assert.IsNotNull(id);
|
Assert.IsNotNull(id);
|
||||||
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));
|
||||||
@ -186,12 +190,16 @@ public class UnitTestResize
|
|||||||
resizedFileHolder = resize.GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber, id.Value);
|
resizedFileHolder = resize.GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber, id.Value);
|
||||||
item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder);
|
item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder);
|
||||||
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item);
|
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item);
|
||||||
(int _, metadataCollection) = metadata.GetMetadataCollection(subFileTuples, parseExceptions, changesFrom, mappingFromItem);
|
Dictionary<string, int[]> outputResolutionToResize = resize.GetResizeKeyValuePairs(_PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, item.Property, mappingFromItem);
|
||||||
Dictionary<string, int[]> outputResolutionToResize = resize.GetResizeKeyValuePairs(_PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, metadataCollection, item.Property, mappingFromItem);
|
|
||||||
Assert.IsNotNull(mappingFromItem.ResizedFileHolder);
|
Assert.IsNotNull(mappingFromItem.ResizedFileHolder);
|
||||||
resize.SaveResizedSubfile(_PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, outputResolutionToResize);
|
resize.SaveResizedSubfile(_PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, outputResolutionToResize);
|
||||||
string blurHash = blurHasher.Encode(resizedFileHolder);
|
string blurHash = blurHasher.Encode(resizedFileHolder);
|
||||||
Assert.IsNotNull(blurHash);
|
Assert.IsNotNull(blurHash);
|
||||||
|
ReadOnlyDictionary<string, MetadataExtractorDirectory> metadataExtractorDirectories = metadata.GetMetadataCollection(subFileTuples, parseExceptions, changesFrom, mappingFromItem);
|
||||||
|
string json = JsonSerializer.Serialize(metadataExtractorDirectories, ReadOnlyDictionaryStringMetadataExtractorDirectorySourceGenerationContext.Default.ReadOnlyDictionaryStringMetadataExtractorDirectory);
|
||||||
|
File.WriteAllText("../../../.json", json);
|
||||||
|
MetadataExtractor.GeoLocation? geoLocation = Metadata.Models.Stateless.Methods.IMetadata.GeoLocation(metadataExtractorDirectories);
|
||||||
|
double? distance = geoLocation is null ? null : Metadata.Models.Stateless.Methods.IMetadata.GetDistance(1, 1, geoLocation.Latitude, geoLocation.Longitude);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,11 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Phares.Shared;
|
using Phares.Shared;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text.Json;
|
||||||
using View_by_Distance.FaceRecognitionDotNet;
|
using View_by_Distance.FaceRecognitionDotNet;
|
||||||
using View_by_Distance.Metadata.Models;
|
using View_by_Distance.Metadata.Models;
|
||||||
using View_by_Distance.Property.Models;
|
using View_by_Distance.Property.Models;
|
||||||
@ -55,6 +57,7 @@ public class UnitTestFace
|
|||||||
logger = Log.ForContext<UnitTestFace>();
|
logger = Log.ForContext<UnitTestFace>();
|
||||||
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||||
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||||
|
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
|
||||||
logger.Information("Complete");
|
logger.Information("Complete");
|
||||||
_Logger = logger;
|
_Logger = logger;
|
||||||
_AppSettings = appSettings;
|
_AppSettings = appSettings;
|
||||||
@ -217,7 +220,6 @@ public class UnitTestFace
|
|||||||
const bool isValidImageFormatExtension = true;
|
const bool isValidImageFormatExtension = true;
|
||||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||||
string[] alternateFileLines = Array.Empty<string>();
|
string[] alternateFileLines = Array.Empty<string>();
|
||||||
List<KeyValuePair<string, string>> metadataCollection;
|
|
||||||
int length = _PropertyConfiguration.RootDirectory.Length;
|
int length = _PropertyConfiguration.RootDirectory.Length;
|
||||||
string[] changesFrom = new string[] { nameof(A_Property) };
|
string[] changesFrom = new string[] { nameof(A_Property) };
|
||||||
string outputResolution = _Configuration.OutputResolutions[0];
|
string outputResolution = _Configuration.OutputResolutions[0];
|
||||||
@ -240,7 +242,7 @@ public class UnitTestFace
|
|||||||
FileHolder sourceDirectoryFileHolder = new(".json");
|
FileHolder sourceDirectoryFileHolder = new(".json");
|
||||||
string sourceDirectory = Path.GetFullPath(Path.Combine(_PropertyConfiguration.RootDirectory, sourceDirectoryName));
|
string sourceDirectory = Path.GetFullPath(Path.Combine(_PropertyConfiguration.RootDirectory, sourceDirectoryName));
|
||||||
FileHolder fileHolder = new(Path.Combine(sourceDirectory, sourceFileName));
|
FileHolder fileHolder = new(Path.Combine(sourceDirectory, sourceFileName));
|
||||||
(_, int? id) = IDirectory.GetId(fileHolder);
|
(_, int? id) = IDirectory.GetId(_PropertyConfiguration.Offset, fileHolder);
|
||||||
Assert.IsNotNull(id);
|
Assert.IsNotNull(id);
|
||||||
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));
|
||||||
@ -261,12 +263,15 @@ public class UnitTestFace
|
|||||||
resizedFileHolder = resize.GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber, id.Value);
|
resizedFileHolder = resize.GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber, id.Value);
|
||||||
item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder);
|
item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder);
|
||||||
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item);
|
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item);
|
||||||
(int _, metadataCollection) = metadata.GetMetadataCollection(subFileTuples, parseExceptions, changesFrom, mappingFromItem);
|
IReadOnlyList<MetadataExtractor.Directory> directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(resizedFileHolder.FullName);
|
||||||
Dictionary<string, int[]> outputResolutionToResize = resize.GetResizeKeyValuePairs(_PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, metadataCollection, item.Property, mappingFromItem);
|
Dictionary<string, int[]> outputResolutionToResize = resize.GetResizeKeyValuePairs(_PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, item.Property, mappingFromItem);
|
||||||
Assert.IsNotNull(mappingFromItem.ResizedFileHolder);
|
Assert.IsNotNull(mappingFromItem.ResizedFileHolder);
|
||||||
resize.SaveResizedSubfile(_PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, outputResolutionToResize);
|
resize.SaveResizedSubfile(_PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, outputResolutionToResize);
|
||||||
string blurHash = blurHasher.Encode(resizedFileHolder);
|
string blurHash = blurHasher.Encode(resizedFileHolder);
|
||||||
Assert.IsNotNull(blurHash);
|
Assert.IsNotNull(blurHash);
|
||||||
|
ReadOnlyDictionary<string, MetadataExtractorDirectory>? metadataExtractorDirectories = metadata.GetMetadataCollection(subFileTuples, parseExceptions, changesFrom, mappingFromItem);
|
||||||
|
string json = JsonSerializer.Serialize(metadataExtractorDirectories, ReadOnlyDictionaryStringMetadataExtractorDirectorySourceGenerationContext.Default.ReadOnlyDictionaryStringMetadataExtractorDirectory);
|
||||||
|
File.WriteAllText("../../../.json", json);
|
||||||
Image image = FaceRecognition.LoadImageFile(mappingFromItem.ResizedFileHolder.FullName);
|
Image image = FaceRecognition.LoadImageFile(mappingFromItem.ResizedFileHolder.FullName);
|
||||||
Assert.IsNotNull(image);
|
Assert.IsNotNull(image);
|
||||||
(Model model, PredictorModel predictorModel, ModelParameter modelParameter) = GetModel(_Configuration);
|
(Model model, PredictorModel predictorModel, ModelParameter modelParameter) = GetModel(_Configuration);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user