43 lines
2.2 KiB
C#
43 lines
2.2 KiB
C#
using File_Folder_Helper.Models;
|
|
using Microsoft.Extensions.Logging;
|
|
using System.Text.Json;
|
|
using Phares.Metadata.Models.Stateless;
|
|
using Phares.Shared.Models;
|
|
|
|
namespace File_Folder_Helper.Helpers;
|
|
|
|
internal static partial class ExifHelper
|
|
{
|
|
|
|
internal static void DragAndDrop(ILogger<Worker> logger, string argZero)
|
|
{
|
|
string? json;
|
|
string secrets = "L:/Git/AA/Rename/.vscode/.UserSecrets/secrets.json";
|
|
json = !File.Exists(secrets) ? null : File.ReadAllText(secrets);
|
|
if (string.IsNullOrEmpty(json))
|
|
throw new Exception($"Use mklink to map user secrets for rename!");
|
|
ResultSettings? resultSettings = JsonSerializer.Deserialize(json, ResultSettingsSourceGenerationContext.Default.ResultSettings) ??
|
|
throw new Exception(nameof(ResultSettings));
|
|
MetadataSettings? metadataSettings = JsonSerializer.Deserialize(json, MetadataSettingsSourceGenerationContext.Default.MetadataSettings) ??
|
|
throw new Exception(nameof(MetadataSettings));
|
|
FileInfo fileInfo = new(argZero);
|
|
logger.LogInformation("<{argZero}> exists", argZero);
|
|
if (!string.IsNullOrEmpty(fileInfo.Directory?.FullName))
|
|
{
|
|
string[] files = Directory.GetFiles(fileInfo.Directory.FullName, "*.json", SearchOption.TopDirectoryOnly);
|
|
json = files.Length != 1 ? string.Empty : File.ReadAllText(files[0]);
|
|
Dictionary<long, Person>? people = string.IsNullOrEmpty(json) ? [] : JsonSerializer.Deserialize(json, PeopleSourceGenerationContext.Default.DictionaryInt64Person) ?? throw new NullReferenceException();
|
|
logger.LogInformation("<{people}> value", people?.Count);
|
|
}
|
|
ExifDirectory? exifDirectory = IMetadata.GetExifDirectory(resultSettings, metadataSettings, fileInfo);
|
|
FaceFile? faceFile = IMetadata.GetFaceFile(exifDirectory);
|
|
if (faceFile is not null)
|
|
{
|
|
if (faceFile.MappingFromPerson is null)
|
|
logger.LogInformation("<{Confidence}> value", faceFile.Location?.Confidence);
|
|
else
|
|
logger.LogInformation("<{DisplayDirectoryName}> value", faceFile.MappingFromPerson.DisplayDirectoryName);
|
|
}
|
|
}
|
|
|
|
} |