Approximate Years Fix
This commit is contained in:
parent
52a5a81d98
commit
e22f47c9cd
@ -268,6 +268,7 @@ public partial class E_Distance
|
|||||||
File.Delete(locationContainer.File);
|
File.Delete(locationContainer.File);
|
||||||
else
|
else
|
||||||
File.Move(locationContainer.File, fileInfo.FullName);
|
File.Move(locationContainer.File, fileInfo.FullName);
|
||||||
|
File.WriteAllText($"{fileInfo.FullName}.old", $"{fileInfo.FullName}{Environment.NewLine}{locationContainer.File}");
|
||||||
_Renamed.Add(locationContainer.File);
|
_Renamed.Add(locationContainer.File);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -16,6 +16,7 @@ public class Configuration
|
|||||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
||||||
[Display(Name = "Max Images In Directory For Top Level First Pass"), Required] public int? MaxImagesInDirectoryForTopLevelFirstPass { get; set; }
|
[Display(Name = "Max Images In Directory For Top Level First Pass"), Required] public int? MaxImagesInDirectoryForTopLevelFirstPass { get; set; }
|
||||||
[Display(Name = "Pattern"), Required] public string Pattern { get; set; }
|
[Display(Name = "Pattern"), Required] public string Pattern { get; set; }
|
||||||
|
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
||||||
[Display(Name = "Populate Properties FileId"), Required] public bool? PopulatePropertyId { get; set; }
|
[Display(Name = "Populate Properties FileId"), Required] public bool? PopulatePropertyId { get; set; }
|
||||||
[Display(Name = "Properties Changed For Property"), Required] public bool? PropertiesChangedForProperty { get; set; }
|
[Display(Name = "Properties Changed For Property"), Required] public bool? PropertiesChangedForProperty { get; set; }
|
||||||
[Display(Name = "Property Content Collection Files"), Required] public string[] PropertyContentCollectionFiles { get; set; }
|
[Display(Name = "Property Content Collection Files"), Required] public string[] PropertyContentCollectionFiles { get; set; }
|
||||||
@ -71,6 +72,7 @@ public class Configuration
|
|||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value,
|
configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value,
|
||||||
configuration.Pattern,
|
configuration.Pattern,
|
||||||
|
configuration.PersonBirthdayFormat,
|
||||||
configuration.PopulatePropertyId.Value,
|
configuration.PopulatePropertyId.Value,
|
||||||
configuration.PropertiesChangedForProperty.Value,
|
configuration.PropertiesChangedForProperty.Value,
|
||||||
configuration.PropertyContentCollectionFiles,
|
configuration.PropertyContentCollectionFiles,
|
||||||
|
@ -11,6 +11,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
protected int? _NumberOfTimesToUpsample;
|
protected int? _NumberOfTimesToUpsample;
|
||||||
protected string? _PredictorModelName;
|
protected string? _PredictorModelName;
|
||||||
protected string _RootDirectory;
|
protected string _RootDirectory;
|
||||||
|
|
||||||
public string? ModelName => _ModelName;
|
public string? ModelName => _ModelName;
|
||||||
public int? NumberOfJitters => _NumberOfJitters;
|
public int? NumberOfJitters => _NumberOfJitters;
|
||||||
public int? NumberOfTimesToUpsample => _NumberOfTimesToUpsample;
|
public int? NumberOfTimesToUpsample => _NumberOfTimesToUpsample;
|
||||||
@ -23,6 +24,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
public string[] IgnoreExtensions { init; get; }
|
public string[] IgnoreExtensions { init; get; }
|
||||||
public int MaxImagesInDirectoryForTopLevelFirstPass { init; get; }
|
public int MaxImagesInDirectoryForTopLevelFirstPass { init; get; }
|
||||||
public string Pattern { init; get; }
|
public string Pattern { init; get; }
|
||||||
|
public string PersonBirthdayFormat { init; get; }
|
||||||
public bool PopulatePropertyId { init; get; }
|
public bool PopulatePropertyId { init; get; }
|
||||||
public bool PropertiesChangedForProperty { init; get; }
|
public bool PropertiesChangedForProperty { init; get; }
|
||||||
public string[] PropertyContentCollectionFiles { init; get; }
|
public string[] PropertyContentCollectionFiles { init; get; }
|
||||||
@ -42,6 +44,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
string[] ignoreExtensions,
|
string[] ignoreExtensions,
|
||||||
int maxImagesInDirectoryForTopLevelFirstPass,
|
int maxImagesInDirectoryForTopLevelFirstPass,
|
||||||
string pattern,
|
string pattern,
|
||||||
|
string personBirthdayFormat,
|
||||||
bool populatePropertyId,
|
bool populatePropertyId,
|
||||||
bool propertiesChangedForProperty,
|
bool propertiesChangedForProperty,
|
||||||
string[] propertyContentCollectionFiles,
|
string[] propertyContentCollectionFiles,
|
||||||
@ -61,6 +64,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
|
|||||||
IgnoreExtensions = ignoreExtensions;
|
IgnoreExtensions = ignoreExtensions;
|
||||||
MaxImagesInDirectoryForTopLevelFirstPass = maxImagesInDirectoryForTopLevelFirstPass;
|
MaxImagesInDirectoryForTopLevelFirstPass = maxImagesInDirectoryForTopLevelFirstPass;
|
||||||
Pattern = pattern;
|
Pattern = pattern;
|
||||||
|
PersonBirthdayFormat = personBirthdayFormat;
|
||||||
PopulatePropertyId = populatePropertyId;
|
PopulatePropertyId = populatePropertyId;
|
||||||
PropertiesChangedForProperty = propertiesChangedForProperty;
|
PropertiesChangedForProperty = propertiesChangedForProperty;
|
||||||
PropertyContentCollectionFiles = propertyContentCollectionFiles;
|
PropertyContentCollectionFiles = propertyContentCollectionFiles;
|
||||||
|
@ -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 PersonBirthdayFormat { init; get; }
|
||||||
public bool PropertiesChangedForProperty { init; get; }
|
public bool PropertiesChangedForProperty { init; get; }
|
||||||
public string[] PropertyContentCollectionFiles { init; get; }
|
public string[] PropertyContentCollectionFiles { init; get; }
|
||||||
public string ResultAllInOne { init; get; }
|
public string ResultAllInOne { init; get; }
|
||||||
|
@ -100,7 +100,7 @@ public interface IPersonBirthday
|
|||||||
|
|
||||||
bool TestStatic_DoesBirthDateExits(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
bool TestStatic_DoesBirthDateExits(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
||||||
DoesBirthDateExits(storage, personBirthdayFormat, personBirthday);
|
DoesBirthDateExits(storage, personBirthdayFormat, personBirthday);
|
||||||
internal static bool DoesBirthDateExits(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
static bool DoesBirthDateExits(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
||||||
File.Exists(GetFileFullName(storage, personBirthdayFormat, personBirthday));
|
File.Exists(GetFileFullName(storage, personBirthdayFormat, personBirthday));
|
||||||
|
|
||||||
DateTime? TestStatic_GetDateTime(string personBirthdayFormat, string personKeyFormatted) =>
|
DateTime? TestStatic_GetDateTime(string personBirthdayFormat, string personKeyFormatted) =>
|
||||||
@ -108,4 +108,9 @@ public interface IPersonBirthday
|
|||||||
static DateTime? GetDateTime(string personBirthdayFormat, string personKeyFormatted) =>
|
static DateTime? GetDateTime(string personBirthdayFormat, string personKeyFormatted) =>
|
||||||
DateTime.TryParseExact(GetDateTime(personKeyFormatted), personBirthdayFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime) ? dateTime : null;
|
DateTime.TryParseExact(GetDateTime(personKeyFormatted), personBirthdayFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime) ? dateTime : null;
|
||||||
|
|
||||||
|
List<(string, Models.PersonBirthday)> TestStatic_GetPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectory, string personDisplayDirectoryName) =>
|
||||||
|
GetPersonBirthdays(personBirthdayFormat, personKeyDirectories, personDisplayDirectory, personDisplayDirectoryName);
|
||||||
|
static List<(string, Models.PersonBirthday)> GetPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectory, string personDisplayDirectoryName) =>
|
||||||
|
PersonBirthday.GetPersonBirthdays(personBirthdayFormat, personKeyDirectories, personDisplayDirectory, personDisplayDirectoryName);
|
||||||
|
|
||||||
}
|
}
|
@ -15,4 +15,9 @@ public interface IPersonContainer
|
|||||||
static List<(long?, string)> GetDisplay(string personBirthdayFormat, Models.PersonContainer personContainer) =>
|
static List<(long?, string)> GetDisplay(string personBirthdayFormat, Models.PersonContainer personContainer) =>
|
||||||
PersonContainer.GetDisplay(personBirthdayFormat, personContainer);
|
PersonContainer.GetDisplay(personBirthdayFormat, personContainer);
|
||||||
|
|
||||||
|
string? TestStatic_VerifyAge(char numberSign, string personDisplayDirectory, string? minusOne, string personDisplayDirectoryName, int? approximateYears, List<(string PersonKeyFormatted, Models.PersonBirthday PersonBirthday)> collection) =>
|
||||||
|
VerifyAge(numberSign, personDisplayDirectory, minusOne, personDisplayDirectoryName, approximateYears, collection);
|
||||||
|
static string? VerifyAge(char numberSign, string personDisplayDirectory, string? minusOne, string personDisplayDirectoryName, int? approximateYears, List<(string PersonKeyFormatted, Models.PersonBirthday PersonBirthday)> collection) =>
|
||||||
|
PersonContainer.VerifyAge(numberSign, personDisplayDirectory, minusOne, personDisplayDirectoryName, approximateYears, collection);
|
||||||
|
|
||||||
}
|
}
|
@ -70,7 +70,7 @@ internal abstract class PersonContainer
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string? VerifyAge(char numberSign, string personDisplayDirectory, string minusOne, string personDisplayDirectoryName, int? approximateYears, List<(string PersonKeyFormatted, Models.PersonBirthday PersonBirthday)> collection)
|
internal static string? VerifyAge(char numberSign, string personDisplayDirectory, string? minusOne, string personDisplayDirectoryName, int? approximateYears, List<(string PersonKeyFormatted, Models.PersonBirthday PersonBirthday)> collection)
|
||||||
{
|
{
|
||||||
string? result;
|
string? result;
|
||||||
if (approximateYears is null)
|
if (approximateYears is null)
|
||||||
@ -82,13 +82,13 @@ internal abstract class PersonContainer
|
|||||||
DateTime dateTime = DateTime.Now;
|
DateTime dateTime = DateTime.Now;
|
||||||
Models.PersonBirthday[] orderedPersonBirthdays = (from l in collection where !l.PersonKeyFormatted.Contains(numberSign) orderby l.PersonBirthday.Value.Ticks descending select l.PersonBirthday).ToArray();
|
Models.PersonBirthday[] orderedPersonBirthdays = (from l in collection where !l.PersonKeyFormatted.Contains(numberSign) orderby l.PersonBirthday.Value.Ticks descending select l.PersonBirthday).ToArray();
|
||||||
TimeSpan timeSpan = new(orderedPersonBirthdays[zero].Value.Ticks - dateTime.AddYears(-approximateYears.Value).Ticks);
|
TimeSpan timeSpan = new(orderedPersonBirthdays[zero].Value.Ticks - dateTime.AddYears(-approximateYears.Value).Ticks);
|
||||||
if (timeSpan.TotalDays < -356)
|
if (timeSpan.TotalDays < -366)
|
||||||
updateApproximateYears = approximateYears.Value + 1;
|
updateApproximateYears = approximateYears.Value + 1;
|
||||||
else if (timeSpan.TotalDays > 356)
|
else if (timeSpan.TotalDays > 1)
|
||||||
updateApproximateYears = approximateYears.Value - 1;
|
updateApproximateYears = approximateYears.Value - 1;
|
||||||
else
|
else
|
||||||
updateApproximateYears = null;
|
updateApproximateYears = null;
|
||||||
if (updateApproximateYears is null)
|
if (minusOne is null || updateApproximateYears is null)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -87,6 +87,29 @@ public partial class UnitTestCalculations
|
|||||||
Assert.IsTrue(age.Value > 42.6092);
|
Assert.IsTrue(age.Value > 42.6092);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestMethodGetApproximateYears()
|
||||||
|
{
|
||||||
|
string personDisplayDirectory = @"D:\1) Images A\Images-45f4401-Results\A2) People\45f4401\{}\^\Sydney Dupray^9";
|
||||||
|
if (Directory.Exists(Directory.GetDirectoryRoot(personDisplayDirectory)) && Directory.Exists(personDisplayDirectory))
|
||||||
|
{
|
||||||
|
char numberSign = '#';
|
||||||
|
string? minusOne = null;
|
||||||
|
char[] personCharacters = new char[] { '^' };
|
||||||
|
string personDisplayDirectoryName = Path.GetFileName(personDisplayDirectory);
|
||||||
|
string personBirthdayFormat = _Configuration.PropertyConfiguration.PersonBirthdayFormat;
|
||||||
|
string[] personKeyDirectories = Directory.GetDirectories(personDisplayDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
List<(string, PersonBirthday)> collection = IPersonBirthday.GetPersonBirthdays(personBirthdayFormat, personKeyDirectories, personDisplayDirectory, personDisplayDirectoryName);
|
||||||
|
int? approximateYears = IAge.GetApproximateYears(personCharacters, personDisplayDirectoryName);
|
||||||
|
if (approximateYears is null)
|
||||||
|
throw new NullReferenceException(nameof(approximateYears));
|
||||||
|
Assert.IsNotNull(approximateYears);
|
||||||
|
Assert.IsTrue(approximateYears.Value == 9);
|
||||||
|
string? change = IPersonContainer.VerifyAge(numberSign, personDisplayDirectory, minusOne, personDisplayDirectoryName, approximateYears, collection);
|
||||||
|
Assert.IsNull(change);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodParse()
|
public void TestMethodParse()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user