net7.0
This commit is contained in:
@ -45,7 +45,7 @@ internal abstract class Face
|
||||
foreach (JsonElement jsonElement in jsonElements)
|
||||
{
|
||||
tuple = JsonSerializer.Deserialize<Tuple<Models.Face, string>>(jsonElement.ToString());
|
||||
if (tuple is null || tuple.Item1 is null || string.IsNullOrEmpty(tuple.Item1.RelativePath))
|
||||
if (tuple is null || tuple.Item1 is null || string.IsNullOrEmpty("tuple.Item1.RelativePath"))
|
||||
continue;
|
||||
results.Add(tuple.Item1);
|
||||
if (maximum.HasValue && results.Count >= maximum)
|
||||
|
@ -59,10 +59,10 @@ internal abstract class FaceFileSystem
|
||||
if (face[i] is null)
|
||||
continue;
|
||||
locationIndex = 0;
|
||||
directoryName = Path.GetDirectoryName(face[i].RelativePath);
|
||||
directoryName = Path.GetDirectoryName("face[i].RelativePath");
|
||||
if (directoryName is null)
|
||||
continue;
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(face[i].RelativePath);
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension("face[i].RelativePath");
|
||||
jsonFileName = string.Concat(locationIndex.Value, " - ", fileNameWithoutExtension, extension);
|
||||
eDistanceCollectionFileFullName = Path.Combine($"{tuple.E_DistanceCollectionDirectory}{directoryName}", fileNameWithoutExtension, jsonFileName);
|
||||
if (i == 0 && extension is ".json" && eDistanceCollectionFileFullName != selectedFileFullName)
|
||||
|
16
Shared/Models/Stateless/Methods/IMappingFromItem.cs
Normal file
16
Shared/Models/Stateless/Methods/IMappingFromItem.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
public interface IMappingFromItem
|
||||
{ // ...
|
||||
|
||||
MappingFromItem TestStatic_GetMappingFromItem(Models.Item item, Models.FileHolder? resizedFileHolder)
|
||||
=> GetMappingFromItem(item, resizedFileHolder);
|
||||
static MappingFromItem GetMappingFromItem(Models.Item item, Models.FileHolder? resizedFileHolder)
|
||||
=> MappingFromItem.GetMappingFromItem(item, resizedFileHolder);
|
||||
|
||||
MappingFromItem TestStatic_GetMappingFromItem(Models.Item item)
|
||||
=> GetMappingFromItem(item);
|
||||
static MappingFromItem GetMappingFromItem(Models.Item item)
|
||||
=> GetMappingFromItem(item, item.ResizedFileHolder);
|
||||
|
||||
}
|
@ -3,9 +3,10 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
public interface IPersonURL
|
||||
{
|
||||
|
||||
string TestStatic_GetDefaultValue() => PersonURL.GetDefaultValue(); // <{1}>PluralValue
|
||||
|
||||
static string GetDefaultValue() => PersonURL.GetDefaultValue(); // <{1}>PluralValue
|
||||
string TestStatic_GetDefaultValue() =>
|
||||
GetDefaultValue(); // <{1}>PluralValue
|
||||
static string GetDefaultValue() =>
|
||||
PersonURL.GetDefaultValue(); // <{1}>PluralValue
|
||||
|
||||
// ...
|
||||
|
||||
|
@ -6,56 +6,84 @@ public interface IProperty
|
||||
string TestStatic_DateTimeFormat();
|
||||
static string DateTimeFormat() => "yyyy:MM:dd HH:mm:ss";
|
||||
|
||||
int TestStatic_GetDeterministicHashCode(byte[] value);
|
||||
int TestStatic_GetDeterministicHashCode(byte[] value) =>
|
||||
GetDeterministicHashCode(value);
|
||||
static int GetDeterministicHashCode(byte[] value) =>
|
||||
Property.GetDeterministicHashCode(value);
|
||||
|
||||
int TestStatic_GetDeterministicHashCode(string value);
|
||||
List<DateTime> TestStatic_GetMetadataDateTimesByPattern(string dateTimeFormat, Models.FileHolder fileHolder) =>
|
||||
GetMetadataDateTimesByPattern(dateTimeFormat, fileHolder);
|
||||
static List<DateTime> GetMetadataDateTimesByPattern(string dateTimeFormat, Models.FileHolder fileHolder) =>
|
||||
Property.GetMetadataDateTimesByPattern(dateTimeFormat, fileHolder.FullName);
|
||||
|
||||
int TestStatic_GetDeterministicHashCode(string value) =>
|
||||
GetDeterministicHashCode(value);
|
||||
static int GetDeterministicHashCode(string value) =>
|
||||
Property.GetDeterministicHashCode(value);
|
||||
|
||||
DateTime TestStatic_GetDateTime(Models.Property? property);
|
||||
DateTime TestStatic_GetDateTime(Models.Property? property) =>
|
||||
GetDateTime(property);
|
||||
static DateTime GetDateTime(Models.Property? property) =>
|
||||
Property.GetDateTime(property);
|
||||
|
||||
DateTime TestStatic_GetMinimumDateTime(Models.Property? property);
|
||||
DateTime TestStatic_GetMinimumDateTime(Models.Property? property) =>
|
||||
GetMinimumDateTime(property);
|
||||
static DateTime GetMinimumDateTime(Models.Property? property) =>
|
||||
Property.GetMinimumDateTime(property);
|
||||
|
||||
(int Season, string seasonName) TestStatic_GetSeason(int dayOfYear);
|
||||
(int Season, string seasonName) TestStatic_GetSeason(int dayOfYear) =>
|
||||
GetSeason(dayOfYear);
|
||||
static (int Season, string seasonName) GetSeason(int dayOfYear) =>
|
||||
Property.GetSeason(dayOfYear);
|
||||
|
||||
string TestStatic_GetDiffRootDirectory(string diffPropertyDirectory);
|
||||
string TestStatic_GetDiffRootDirectory(string diffPropertyDirectory) =>
|
||||
GetDiffRootDirectory(diffPropertyDirectory);
|
||||
static string GetDiffRootDirectory(string diffPropertyDirectory) =>
|
||||
Property.GetDiffRootDirectory(diffPropertyDirectory);
|
||||
|
||||
bool TestStatic_Any(Models.Container[] propertyHolderCollections);
|
||||
bool TestStatic_Any(Models.Container[] propertyHolderCollections) =>
|
||||
Any(propertyHolderCollections);
|
||||
static bool Any(Models.Container[] propertyHolderCollections) =>
|
||||
Property.Any(propertyHolderCollections);
|
||||
|
||||
(bool?, string[]) TestStatic_IsWrongYear(string[] segments, string year);
|
||||
(bool?, string[]) TestStatic_IsWrongYear(string[] segments, string year) =>
|
||||
IsWrongYear(segments, year);
|
||||
static (bool?, string[]) IsWrongYear(string[] segments, string year) =>
|
||||
Property.IsWrongYear(segments, year);
|
||||
|
||||
List<DateTime> TestStatic_GetDateTimes(Models.Property property);
|
||||
static List<DateTime> GetDateTimes(Models.Property property) =>
|
||||
Property.GetDateTimes(property.CreationTime, property.LastWriteTime, property.DateTime, property.DateTimeDigitized, property.DateTimeOriginal, property.GPSDateStamp);
|
||||
(DateTime?, int?, string?) TestStatic_Get(Models.FileHolder fileHolder) =>
|
||||
Get(fileHolder);
|
||||
static (DateTime?, int?, string?) Get(Models.FileHolder fileHolder) =>
|
||||
Property.Get(fileHolder);
|
||||
|
||||
double TestStatic_GetStandardDeviation(IEnumerable<long> values, double average);
|
||||
DateTime? TestStatic_GetDateTimeFromName(Models.FileHolder fileHolder) =>
|
||||
GetDateTimeFromName(fileHolder);
|
||||
static DateTime? GetDateTimeFromName(Models.FileHolder fileHolder) =>
|
||||
Property.GetDateTimeFromName(fileHolder);
|
||||
|
||||
List<DateTime> TestStatic_GetDateTimes(Models.Property property) =>
|
||||
GetDateTimes(property);
|
||||
static List<DateTime> GetDateTimes(Models.Property property) =>
|
||||
Property.GetDateTimes(property.CreationTime, property.LastWriteTime, property.DateTime, property.DateTimeDigitized, property.DateTimeFromName, property.DateTimeOriginal, property.GPSDateStamp);
|
||||
|
||||
double TestStatic_GetStandardDeviation(IEnumerable<long> values, double average) =>
|
||||
GetStandardDeviation(values, average);
|
||||
static double GetStandardDeviation(IEnumerable<long> values, double average) =>
|
||||
Property.GetStandardDeviation(values, average);
|
||||
|
||||
TimeSpan TestStatic_GetThreeStandardDeviationHigh(int minimum, Models.Container container);
|
||||
TimeSpan TestStatic_GetThreeStandardDeviationHigh(int minimum, Models.Container container) =>
|
||||
GetThreeStandardDeviationHigh(minimum, container);
|
||||
static TimeSpan GetThreeStandardDeviationHigh(int minimum, Models.Container container) =>
|
||||
Property.GetThreeStandardDeviationHigh(minimum, container);
|
||||
|
||||
(int, List<DateTime>, List<Models.Item>) TestStatic_Get(Models.Container container, TimeSpan threeStandardDeviationHigh, int i);
|
||||
(int, List<DateTime>, List<Models.Item>) TestStatic_Get(Models.Container container, TimeSpan threeStandardDeviationHigh, int i) =>
|
||||
Get(container, threeStandardDeviationHigh, i);
|
||||
static (int, List<DateTime>, List<Models.Item>) Get(Models.Container container, TimeSpan threeStandardDeviationHigh, int i) =>
|
||||
Property.Get(container, threeStandardDeviationHigh, i);
|
||||
|
||||
List<DateTime> TestStatic_GetDateTimes(DateTime creationTime, DateTime lastWriteTime, DateTime? dateTime, DateTime? dateTimeDigitized, DateTime? dateTimeOriginal, DateTime? gpsDateStamp);
|
||||
static List<DateTime> GetDateTimes(DateTime creationTime, DateTime lastWriteTime, DateTime? dateTime, DateTime? dateTimeDigitized, DateTime? dateTimeOriginal, DateTime? gpsDateStamp) =>
|
||||
Property.GetDateTimes(creationTime, lastWriteTime, dateTime, dateTimeDigitized, dateTimeOriginal, gpsDateStamp);
|
||||
List<DateTime> TestStatic_GetDateTimes(DateTime creationTime, DateTime lastWriteTime, DateTime? dateTime, DateTime? dateTimeDigitized, DateTime? dateTimeFromName, DateTime? dateTimeOriginal, DateTime? gpsDateStamp) =>
|
||||
GetDateTimes(creationTime, lastWriteTime, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginal, gpsDateStamp);
|
||||
static List<DateTime> GetDateTimes(DateTime creationTime, DateTime lastWriteTime, DateTime? dateTime, DateTime? dateTimeDigitized, DateTime? dateTimeFromName, DateTime? dateTimeOriginal, DateTime? gpsDateStamp) =>
|
||||
Property.GetDateTimes(creationTime, lastWriteTime, dateTime, dateTimeDigitized, dateTimeFromName, dateTimeOriginal, gpsDateStamp);
|
||||
|
||||
}
|
@ -5,8 +5,7 @@ internal abstract class Index
|
||||
|
||||
private static string GetJsonContains(string result, string jsonFileFullName, FileInfo fileInfo, string fileSegmentCollection)
|
||||
{
|
||||
if (fileInfo is null)
|
||||
fileInfo = new FileInfo(jsonFileFullName);
|
||||
fileInfo ??= new FileInfo(jsonFileFullName);
|
||||
result = result.Replace(fileSegmentCollection, nameof(Properties.IIndex.RelativePaths)).Replace("\\\\", "/");
|
||||
File.WriteAllText(fileInfo.FullName, result);
|
||||
File.SetLastWriteTime(fileInfo.FullName, fileInfo.LastWriteTime);
|
||||
@ -15,8 +14,7 @@ internal abstract class Index
|
||||
|
||||
private static string GetJsonSpecial(string result, string jsonFileFullName, FileInfo fileInfo)
|
||||
{
|
||||
if (fileInfo is null)
|
||||
fileInfo = new FileInfo(jsonFileFullName);
|
||||
fileInfo ??= new FileInfo(jsonFileFullName);
|
||||
result = result.Replace("/u0", "\\u0");
|
||||
File.WriteAllText(fileInfo.FullName, result);
|
||||
File.SetLastWriteTime(fileInfo.FullName, fileInfo.LastWriteTime);
|
||||
|
@ -10,15 +10,11 @@ internal abstract class Item
|
||||
List<string> collection = new();
|
||||
foreach (Models.Item item in itemsA)
|
||||
{
|
||||
if (item.ImageFileHolder is null)
|
||||
continue;
|
||||
results.Add(item);
|
||||
collection.Add(item.ImageFileHolder.FullName);
|
||||
}
|
||||
foreach (Models.Item item in itemsB)
|
||||
{
|
||||
if (item.ImageFileHolder is null)
|
||||
continue;
|
||||
if (collection.Contains(item.ImageFileHolder.FullName))
|
||||
continue;
|
||||
result++;
|
||||
|
@ -1,3 +1,10 @@
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class Property
|
||||
@ -85,7 +92,46 @@ internal abstract class Property
|
||||
return new(result, results);
|
||||
}
|
||||
|
||||
internal static List<DateTime> GetDateTimes(DateTime creationTime, DateTime lastWriteTime, DateTime? dateTime, DateTime? dateTimeDigitized, DateTime? dateTimeOriginal, DateTime? gpsDateStamp)
|
||||
internal static DateTime? GetDateTimeFromName(Models.FileHolder fileHolder)
|
||||
{
|
||||
DateTime? result = null;
|
||||
int length;
|
||||
string format;
|
||||
string fullFormat;
|
||||
StringBuilder value = new();
|
||||
string[][] dateFormats = new string[][]
|
||||
{
|
||||
new string[] { string.Empty, "yyyyMMdd_HHmmss", string.Empty },
|
||||
new string[] { string.Empty, "yyyy-MM-dd HH.mm.ss", string.Empty },
|
||||
new string[] { string.Empty, "yyyyMMdd_HHmmss", "_LLS" },
|
||||
new string[] { string.Empty, "yyyyMMdd_HHmmss", "_HDR" },
|
||||
new string[] { "IMG_", "yyyyMMdd_HHmmss", string.Empty },
|
||||
new string[] { "IMG#####-", "yyyyMMdd-HHmm", string.Empty },
|
||||
new string[] { "CameraZOOM-", "yyyyMMddHHmmss", string.Empty },
|
||||
new string[] { "VideoCapture_", "yyyyMMdd-HHmmss ", string.Empty }
|
||||
};
|
||||
foreach (string[] dateFormat in dateFormats)
|
||||
{
|
||||
_ = value.Clear();
|
||||
fullFormat = string.Join(string.Empty, dateFormat);
|
||||
if (fileHolder.NameWithoutExtension.Length != fullFormat.Length)
|
||||
continue;
|
||||
format = dateFormat[1];
|
||||
length = dateFormat[0].Length + dateFormat[1].Length;
|
||||
for (int i = dateFormat[0].Length; i < length; i++)
|
||||
_ = value.Append(fileHolder.NameWithoutExtension[i]);
|
||||
if (value.Length != format.Length)
|
||||
continue;
|
||||
if (DateTime.TryParseExact(value.ToString(), format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime checkDateTime))
|
||||
{
|
||||
result = checkDateTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static List<DateTime> GetDateTimes(DateTime creationTime, DateTime lastWriteTime, DateTime? dateTime, DateTime? dateTimeDigitized, DateTime? dateTimeFromName, DateTime? dateTimeOriginal, DateTime? gpsDateStamp)
|
||||
{
|
||||
List<DateTime> results = new()
|
||||
{
|
||||
@ -96,6 +142,8 @@ internal abstract class Property
|
||||
results.Add(dateTime.Value);
|
||||
if (dateTimeDigitized.HasValue)
|
||||
results.Add(dateTimeDigitized.Value);
|
||||
if (dateTimeFromName.HasValue)
|
||||
results.Add(dateTimeFromName.Value);
|
||||
if (dateTimeOriginal.HasValue)
|
||||
results.Add(dateTimeOriginal.Value);
|
||||
if (gpsDateStamp.HasValue)
|
||||
@ -119,6 +167,8 @@ internal abstract class Property
|
||||
dateTimes.Add(property.DateTime.Value);
|
||||
if (property.DateTimeDigitized.HasValue)
|
||||
dateTimes.Add(property.DateTimeDigitized.Value);
|
||||
if (property.DateTimeFromName.HasValue)
|
||||
dateTimes.Add(property.DateTimeFromName.Value);
|
||||
if (property.DateTimeOriginal.HasValue)
|
||||
dateTimes.Add(property.DateTimeOriginal.Value);
|
||||
if (property.GPSDateStamp.HasValue)
|
||||
@ -269,4 +319,119 @@ internal abstract class Property
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static List<DateTime> GetMetadataDateTimesByPattern(string dateTimeFormat, string sourceDirectoryFile)
|
||||
{
|
||||
List<DateTime> results = new();
|
||||
try
|
||||
{
|
||||
DateTime checkDateTime;
|
||||
DateTime kristy = new(1976, 3, 8);
|
||||
IReadOnlyList<MetadataExtractor.Directory> directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(sourceDirectoryFile);
|
||||
foreach (MetadataExtractor.Directory directory in directories)
|
||||
{
|
||||
foreach (MetadataExtractor.Tag tag in directory.Tags)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tag.Description) || tag.Description.Length != dateTimeFormat.Length)
|
||||
continue;
|
||||
if (!DateTime.TryParseExact(tag.Description, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out checkDateTime))
|
||||
continue;
|
||||
if (checkDateTime < kristy)
|
||||
continue;
|
||||
results.Add(checkDateTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
return results;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1416
|
||||
|
||||
internal static (DateTime?, int?, string?) Get(Models.FileHolder fileHolder)
|
||||
{
|
||||
byte[] bytes;
|
||||
string value;
|
||||
int? id = null;
|
||||
DateTime checkDateTime;
|
||||
string? message = null;
|
||||
DateTime? dateTime = null;
|
||||
PropertyItem? propertyItem;
|
||||
DateTime? gpsDateStamp = null;
|
||||
DateTime? dateTimeOriginal = null;
|
||||
DateTime? dateTimeDigitized = null;
|
||||
ASCIIEncoding asciiEncoding = new();
|
||||
string dateTimeFormat = IProperty.DateTimeFormat();
|
||||
try
|
||||
{
|
||||
using Image image = Image.FromFile(fileHolder.FullName);
|
||||
using Bitmap bitmap = new(image);
|
||||
Rectangle rectangle = new(0, 0, image.Width, image.Height);
|
||||
BitmapData bitmapData = bitmap.LockBits(rectangle, ImageLockMode.ReadOnly, bitmap.PixelFormat);
|
||||
IntPtr intPtr = bitmapData.Scan0;
|
||||
int length = bitmapData.Stride * bitmap.Height;
|
||||
bytes = new byte[length];
|
||||
Marshal.Copy(intPtr, bytes, 0, length);
|
||||
bitmap.UnlockBits(bitmapData);
|
||||
id = IProperty.GetDeterministicHashCode(bytes);
|
||||
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTime))
|
||||
{
|
||||
propertyItem = image.GetPropertyItem((int)IExif.Tags.DateTime);
|
||||
if (propertyItem?.Value is not null)
|
||||
{
|
||||
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
|
||||
if (value.Length > dateTimeFormat.Length)
|
||||
value = value[..dateTimeFormat.Length];
|
||||
if (value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out checkDateTime))
|
||||
dateTime = checkDateTime;
|
||||
}
|
||||
}
|
||||
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTimeDigitized))
|
||||
{
|
||||
propertyItem = image.GetPropertyItem((int)IExif.Tags.DateTimeDigitized);
|
||||
if (propertyItem?.Value is not null)
|
||||
{
|
||||
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
|
||||
if (value.Length > dateTimeFormat.Length)
|
||||
value = value[..dateTimeFormat.Length];
|
||||
if (value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out checkDateTime))
|
||||
dateTimeDigitized = checkDateTime;
|
||||
}
|
||||
}
|
||||
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTimeOriginal))
|
||||
{
|
||||
propertyItem = image.GetPropertyItem((int)IExif.Tags.DateTimeOriginal);
|
||||
if (propertyItem?.Value is not null)
|
||||
{
|
||||
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
|
||||
if (value.Length > dateTimeFormat.Length)
|
||||
value = value[..dateTimeFormat.Length];
|
||||
if (value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out checkDateTime))
|
||||
dateTimeOriginal = checkDateTime;
|
||||
}
|
||||
}
|
||||
if (image.PropertyIdList.Contains((int)IExif.Tags.GPSDateStamp))
|
||||
{
|
||||
propertyItem = image.GetPropertyItem((int)IExif.Tags.GPSDateStamp);
|
||||
if (propertyItem?.Value is not null)
|
||||
{
|
||||
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
|
||||
if (value.Length > dateTimeFormat.Length)
|
||||
value = value[..dateTimeFormat.Length];
|
||||
if (value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out checkDateTime))
|
||||
gpsDateStamp = checkDateTime;
|
||||
}
|
||||
}
|
||||
bitmap.Dispose();
|
||||
image.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
message = string.Concat(new StackFrame().GetMethod()?.Name, " <", fileHolder.FullName, ">");
|
||||
}
|
||||
DateTime?[] dateTimes = new DateTime?[] { fileHolder.LastWriteTime, fileHolder.CreationTime, dateTime, dateTimeDigitized, dateTimeOriginal, gpsDateStamp };
|
||||
return new(dateTimes.Min(), id, message);
|
||||
}
|
||||
|
||||
#pragma warning restore CA1416
|
||||
|
||||
}
|
Reference in New Issue
Block a user