(bool? IsWrongYear, string PersonKey,
TimeSpan? TimeSpan)
This commit is contained in:
@ -7,12 +7,13 @@ public class PropertyHolder
|
||||
|
||||
protected readonly bool? _Abandoned;
|
||||
protected readonly bool? _Changed;
|
||||
protected List<object> _Faces;
|
||||
protected readonly FileInfo? _ImageFileInfo;
|
||||
protected readonly string _ImageFileNameWithoutExtension;
|
||||
protected readonly int _G;
|
||||
protected DateTime? _MinimumDateTime;
|
||||
protected bool? _Moved;
|
||||
protected List<(string Directory, string PersonKey, object Object)> _Named;
|
||||
protected List<(bool?, string, TimeSpan?)> _Named;
|
||||
protected readonly bool? _NoJson;
|
||||
protected A_Property? _Property;
|
||||
protected readonly int _R;
|
||||
@ -21,16 +22,16 @@ public class PropertyHolder
|
||||
protected readonly string _SourceDirectory;
|
||||
protected readonly string _SourceDirectoryFile;
|
||||
protected bool? _ValidImageFormatExtension;
|
||||
protected bool? _WrongYear;
|
||||
public bool? Abandoned => _Abandoned;
|
||||
public bool? Changed => _Changed;
|
||||
public List<object> Faces => _Faces;
|
||||
public FileInfo? ImageFileInfo => _ImageFileInfo;
|
||||
public string ImageFileNameWithoutExtension => _ImageFileNameWithoutExtension;
|
||||
public int G => _G;
|
||||
public DateTime? MinimumDateTime => _MinimumDateTime;
|
||||
public bool? Moved => _Moved;
|
||||
public bool? NoJson => _NoJson;
|
||||
public List<(string Directory, string PersonKey, object Object)> Named => _Named;
|
||||
public List<(bool? IsWrongYear, string PersonKey, TimeSpan? TimeSpan)> Named => _Named;
|
||||
public A_Property? Property => _Property;
|
||||
public int R => _R;
|
||||
public string RelativePath => _RelativePath;
|
||||
@ -38,36 +39,36 @@ public class PropertyHolder
|
||||
public string SourceDirectory => _SourceDirectory;
|
||||
public string SourceDirectoryFile => _SourceDirectoryFile;
|
||||
public bool? ValidImageFormatExtension => _ValidImageFormatExtension;
|
||||
public bool? WrongYear => _WrongYear;
|
||||
|
||||
public PropertyHolder()
|
||||
{
|
||||
_G = -1;
|
||||
_R = -1;
|
||||
_Faces = new();
|
||||
_Named = new();
|
||||
_RelativePath = string.Empty;
|
||||
_SourceDirectory = string.Empty;
|
||||
_SourceDirectoryFile = string.Empty;
|
||||
_ImageFileNameWithoutExtension = string.Empty;
|
||||
_R = -1;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public PropertyHolder(int g, string sourceDirectory, string sourceDirectoryFile, string relativePath, int r, FileInfo? imageFileInfo, A_Property? property, bool? abandoned, bool? changed, bool? moved, bool? validImageFormatExtension, bool? wrongYear)
|
||||
public PropertyHolder(int g, string sourceDirectory, string sourceDirectoryFile, string relativePath, int r, FileInfo? imageFileInfo, A_Property? property, bool? abandoned, bool? changed, bool? moved, bool? validImageFormatExtension)
|
||||
{
|
||||
_Abandoned = abandoned;
|
||||
_Changed = changed;
|
||||
_ImageFileInfo = imageFileInfo;
|
||||
_G = g;
|
||||
_Moved = moved;
|
||||
_NoJson = abandoned is null;
|
||||
_Named = new();
|
||||
_Property = property;
|
||||
_R = r;
|
||||
_Faces = new();
|
||||
_Moved = moved;
|
||||
_Named = new();
|
||||
_Changed = changed;
|
||||
_Property = property;
|
||||
_Abandoned = abandoned;
|
||||
_NoJson = abandoned is null;
|
||||
_RelativePath = relativePath;
|
||||
_ImageFileInfo = imageFileInfo;
|
||||
_SourceDirectory = sourceDirectory;
|
||||
_SourceDirectoryFile = sourceDirectoryFile;
|
||||
_ValidImageFormatExtension = validImageFormatExtension;
|
||||
_WrongYear = wrongYear;
|
||||
_MinimumDateTime = Stateless.A_Property.GetMinimumDateTime(property);
|
||||
if (imageFileInfo is null)
|
||||
_ImageFileNameWithoutExtension = string.Empty;
|
||||
@ -81,20 +82,61 @@ public class PropertyHolder
|
||||
|
||||
internal void SetValidImageFormatExtension(bool isValidImageFormatExtension) => _ValidImageFormatExtension = isValidImageFormatExtension;
|
||||
|
||||
internal void SetWrongYear(bool wrongYear) => _WrongYear = wrongYear;
|
||||
|
||||
internal void SetMoved(bool moved) => _Moved = moved;
|
||||
|
||||
public static string GetWrongYearFlag(bool? isWrongYear) => isWrongYear is null ? "#" : isWrongYear.Value ? "~" : "=";
|
||||
|
||||
public void SetResizedFileInfo(FileInfo fileInfo) => _ResizedFileInfo = fileInfo;
|
||||
|
||||
public bool Any() => (_Abandoned.HasValue && _Abandoned.Value) || (_Changed.HasValue && _Changed.Value) || (_Moved.HasValue && _Moved.Value) || (_NoJson.HasValue && _NoJson.Value);
|
||||
|
||||
public void AddNamed(string directory, string personKey, object face) => _Named.Add(new(directory, personKey, face));
|
||||
|
||||
public void Update(A_Property property)
|
||||
{
|
||||
_Property = property;
|
||||
_MinimumDateTime = Stateless.A_Property.GetMinimumDateTime(property);
|
||||
}
|
||||
|
||||
public static void AddToFaces(PropertyHolder[] filteredPropertyHolderCollection, object[] faces)
|
||||
{
|
||||
foreach (PropertyHolder propertyHolder in filteredPropertyHolderCollection)
|
||||
propertyHolder.Faces.AddRange(faces);
|
||||
}
|
||||
|
||||
public static void AddToNamed(PropertyLogic propertyLogic, PropertyHolder[] filteredPropertyHolderCollection)
|
||||
{
|
||||
bool? isWrongYear;
|
||||
TimeSpan? timeSpan;
|
||||
DateTime? birthDate;
|
||||
string[] personKeys;
|
||||
DateTime minimumDateTime;
|
||||
PropertyHolder propertyHolder;
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
{
|
||||
propertyHolder = filteredPropertyHolderCollection[i];
|
||||
if (propertyHolder.ImageFileInfo is null)
|
||||
continue;
|
||||
if (propertyHolder.Property?.Id is null || propertyHolder.MinimumDateTime is null || propertyHolder.ResizedFileInfo is null)
|
||||
continue;
|
||||
if (!propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.ContainsKey(propertyHolder.Property.Id.Value))
|
||||
continue;
|
||||
minimumDateTime = Stateless.A_Property.GetMinimumDateTime(propertyHolder.Property);
|
||||
personKeys = propertyLogic.NamedFaceInfoDeterministicHashCodeIndices[propertyHolder.Property.Id.Value];
|
||||
(isWrongYear, _) = propertyHolder.Property.IsWrongYear(propertyHolder.ImageFileInfo.FullName, minimumDateTime);
|
||||
foreach (string personKey in personKeys)
|
||||
{
|
||||
if (isWrongYear is null || isWrongYear.Value || personKey[..2] is not "19" and not "20")
|
||||
timeSpan = null;
|
||||
else
|
||||
{
|
||||
birthDate = Shared.Models.Stateless.Methods.IPersonBirthday.Get(personKey);
|
||||
if (birthDate is null)
|
||||
timeSpan = null;
|
||||
else
|
||||
timeSpan = new(minimumDateTime.Ticks - birthDate.Value.Ticks);
|
||||
}
|
||||
propertyHolder.Named.Add(new(isWrongYear, personKey, timeSpan));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -523,11 +523,6 @@ public class PropertyLogic
|
||||
dateTime = minimumDateTime;
|
||||
else
|
||||
{
|
||||
if (isWrongYear.HasValue && isWrongYear.Value)
|
||||
{
|
||||
lock (propertyHolder)
|
||||
propertyHolder.SetWrongYear(true);
|
||||
}
|
||||
if (!matches.Any())
|
||||
continue;
|
||||
if (!DateTime.TryParseExact(matches[0], "yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
|
||||
|
@ -173,7 +173,7 @@ public static class A_Property
|
||||
if (keyFileInfo.Extension is ".json")
|
||||
continue;
|
||||
keySourceDirectory = string.Concat(keyFileInfo.DirectoryName);
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, true, null, null, null, null));
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, true, null, null, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -184,11 +184,11 @@ public static class A_Property
|
||||
if (keyFileInfo.Extension is ".json")
|
||||
continue;
|
||||
if (property?.Id is null || property?.Width is null || property?.Height is null)
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, null, null, null, null));
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, null, null, null));
|
||||
else if (configuration.PropertiesChangedForProperty.Value || property.LastWriteTime != keyFileInfo.LastWriteTime || property.FileSize != keyFileInfo.Length)
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, true, null, null, null));
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, true, null, null));
|
||||
else
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, false, null, null, null));
|
||||
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, false, null, null));
|
||||
}
|
||||
}
|
||||
if (propertyHolderCollection.Any())
|
||||
@ -207,7 +207,7 @@ public static class A_Property
|
||||
throw new Exception();
|
||||
if (sourceDirectoryFileInfo.Extension is ".json")
|
||||
continue;
|
||||
propertyHolderCollection.Add(new(g, sourceDirectory, relativePath, sourceDirectoryFileInfo.FullName, r, sourceDirectoryFileInfo, null, null, null, null, null, null));
|
||||
propertyHolderCollection.Add(new(g, sourceDirectory, relativePath, sourceDirectoryFileInfo.FullName, r, sourceDirectoryFileInfo, null, null, null, null, null));
|
||||
}
|
||||
if (propertyHolderCollection.Any())
|
||||
results.Add(propertyHolderCollection.ToArray());
|
||||
|
Reference in New Issue
Block a user