Init
This commit is contained in:
123
Property/Models/A_Property.cs
Normal file
123
Property/Models/A_Property.cs
Normal file
@ -0,0 +1,123 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
|
||||
namespace View_by_Distance.Property.Models;
|
||||
|
||||
/// <summary>
|
||||
// A_Property
|
||||
/// </summary>
|
||||
public class A_Property : Shared.Models.Properties.IProperty, IProperty
|
||||
{
|
||||
|
||||
protected DateTime _CreationTime;
|
||||
protected DateTime? _DateTime;
|
||||
protected DateTime? _DateTimeDigitized;
|
||||
protected DateTime? _DateTimeOriginal;
|
||||
protected long _FileSize;
|
||||
protected DateTime? _GPSDateStamp;
|
||||
protected int? _Height;
|
||||
protected int? _Id;
|
||||
protected int[] _Indices;
|
||||
protected DateTime _LastWriteTime;
|
||||
protected string _Make;
|
||||
protected string _Model;
|
||||
protected string _Orientation;
|
||||
protected int? _Width;
|
||||
public DateTime CreationTime => _CreationTime;
|
||||
public DateTime? DateTime => _DateTime;
|
||||
public DateTime? DateTimeDigitized => _DateTimeDigitized;
|
||||
public DateTime? DateTimeOriginal => _DateTimeOriginal;
|
||||
public long FileSize => _FileSize;
|
||||
public DateTime? GPSDateStamp => _GPSDateStamp;
|
||||
public int? Height => _Height;
|
||||
public int? Id => _Id;
|
||||
public int[] Indices => _Indices;
|
||||
public DateTime LastWriteTime => _LastWriteTime;
|
||||
public string Make => _Make;
|
||||
public string Model => _Model;
|
||||
public string Orientation => _Orientation;
|
||||
public int? Width => _Width;
|
||||
|
||||
[JsonConstructor]
|
||||
public A_Property(DateTime creationTime, DateTime? dateTime, DateTime? dateTimeDigitized, DateTime? dateTimeOriginal, long fileSize, DateTime? gpsDateStamp, int? height, int? id, int[] indices, DateTime lastWriteTime, string make, string model, string orientation, int? width)
|
||||
{
|
||||
_CreationTime = creationTime;
|
||||
_DateTime = dateTime;
|
||||
_DateTimeDigitized = dateTimeDigitized;
|
||||
_DateTimeOriginal = dateTimeOriginal;
|
||||
_FileSize = fileSize;
|
||||
_GPSDateStamp = gpsDateStamp;
|
||||
_Height = height;
|
||||
_Id = id;
|
||||
_Indices = indices;
|
||||
_LastWriteTime = lastWriteTime;
|
||||
_Make = make;
|
||||
_Model = model;
|
||||
_Orientation = orientation;
|
||||
_Width = width;
|
||||
}
|
||||
|
||||
#nullable disable
|
||||
|
||||
public A_Property()
|
||||
{
|
||||
_CreationTime = System.DateTime.MinValue;
|
||||
_DateTime = null;
|
||||
_DateTimeDigitized = null;
|
||||
_DateTimeOriginal = null;
|
||||
_FileSize = long.MinValue;
|
||||
_GPSDateStamp = null;
|
||||
_Height = null;
|
||||
_Id = null;
|
||||
_Indices = Array.Empty<int>();
|
||||
_LastWriteTime = System.DateTime.MinValue;
|
||||
_Make = string.Empty;
|
||||
_Model = string.Empty;
|
||||
_Orientation = string.Empty;
|
||||
_Width = null;
|
||||
}
|
||||
|
||||
#nullable restore
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DateTime> GetDateTimes() => Stateless.A_Property.GetDateTimes(_CreationTime, _LastWriteTime, _DateTime, _DateTimeDigitized, _DateTimeOriginal, _GPSDateStamp);
|
||||
|
||||
public (bool?, string[]) IsWrongYear(string filteredSourceDirectoryFile, DateTime? minimumDateTime)
|
||||
{
|
||||
string[] results = Array.Empty<string>();
|
||||
bool? result = null;
|
||||
string year;
|
||||
string directoryName;
|
||||
string[] directorySegments;
|
||||
string? check = Path.GetPathRoot(filteredSourceDirectoryFile);
|
||||
string? pathRoot = Path.GetPathRoot(filteredSourceDirectoryFile);
|
||||
if (string.IsNullOrEmpty(pathRoot))
|
||||
throw new Exception();
|
||||
if (minimumDateTime.HasValue)
|
||||
year = minimumDateTime.Value.ToString("yyyy");
|
||||
else
|
||||
{
|
||||
List<DateTime> datetimes = GetDateTimes();
|
||||
year = datetimes.Min().ToString("yyyy");
|
||||
}
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
check = Path.GetDirectoryName(check);
|
||||
if (string.IsNullOrEmpty(check) || check == pathRoot)
|
||||
break;
|
||||
directoryName = Path.GetFileName(check);
|
||||
directorySegments = directoryName.Split(' ');
|
||||
(result, results) = Stateless.A_Property.IsWrongYear(directorySegments, year);
|
||||
if (result.HasValue)
|
||||
break;
|
||||
}
|
||||
return new(result, results);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user