This commit is contained in:
2023-10-15 12:13:48 -07:00
parent cd5ab223c9
commit 37b7ad2a1f
102 changed files with 631 additions and 975 deletions

View File

@ -31,10 +31,6 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FaceRecognitionDotNet\FaceRecognitionDotNet.csproj" />

View File

@ -1,6 +1,5 @@
using Microsoft.Extensions.Configuration;
using Phares.Shared;
using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Drag_Drop.Models;
@ -14,7 +13,6 @@ namespace View_by_Distance.Drag_Drop;
public partial class DragDropSearch : Form
{
private readonly ILogger _Logger;
private readonly TextBox _TextBox;
private readonly AppSettings _AppSettings;
private readonly ProgressBar _ProgressBar;
@ -29,14 +27,12 @@ public partial class DragDropSearch : Form
public DragDropSearch()
{
InitializeComponent();
ILogger logger;
_IdToItem = new();
AppSettings appSettings;
string workingDirectory;
IsEnvironment isEnvironment;
Models.Configuration configuration;
IConfigurationRoot configurationRoot;
LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
@ -51,14 +47,9 @@ public partial class DragDropSearch : Form
throw new Exception("Working path name must have parentDirectory value!");
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
Log.Logger = loggerConfiguration.CreateLogger();
logger = Log.ForContext<DragDropSearch>();
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
(_, _, string resizeFileNameExtension) = C_Resize.GetTuple(configuration.OutputExtension, configuration.OutputQuality);
logger.Information("Complete");
_Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
@ -128,14 +119,6 @@ public partial class DragDropSearch : Form
continue;
_IdToItem.Add(item.Property.Id.Value, item);
}
if (_Logger is null)
throw new NullReferenceException(nameof(_Logger));
_Logger.Debug((_AppSettings is null).ToString());
_Logger.Debug((_Configuration is null).ToString());
_Logger.Debug((_IsEnvironment is null).ToString());
_Logger.Debug((_WorkingDirectory is null).ToString());
_Logger.Debug((_ConfigurationRoot is null).ToString());
_Logger.Debug((_PropertyConfiguration is null).ToString());
}
public static string? GetFaceEncoding(string file)
@ -179,8 +162,6 @@ public partial class DragDropSearch : Form
{
Text = item.ImageFileHolder.Name;
_TextBox.Text = item.ImageFileHolder.FullName;
if (item.ImageFileHolder.DirectoryName is not null)
_Logger.Information(item.ImageFileHolder.DirectoryName);
if (!string.IsNullOrEmpty(item.ImageFileHolder.DirectoryName))
_ = Process.Start("explorer.exe", string.Concat("\"", item.ImageFileHolder.DirectoryName, "\""));
}