This commit is contained in:
2022-08-22 09:10:19 -07:00
parent f72fcee1db
commit bc2174b17a
150 changed files with 4323 additions and 6259 deletions

View File

@ -1,10 +1,9 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using View_by_Distance.Shared.Models.Methods;
namespace View_by_Distance.Shared.Models;
public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem, IFaceFileSystem
public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem
{
// protected new string _ClassName;
@ -77,6 +76,38 @@ public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem, IFaceFileS
_SourceSize = sourceSize;
}
private static void FileExists(Face face, int? faceBottom, int? faceRight, out int imageHeight, out int imageWidth, out long sourceSize, FileInfo fileInfo)
{
sourceSize = fileInfo.Length;
if (face.OutputResolution is not null)
{
imageWidth = face.OutputResolution.Width;
imageHeight = face.OutputResolution.Height;
}
else
{
System.Drawing.Size size = Stateless.Methods.ImageHelper.GetDimensions(fileInfo.FullName, faceRight, faceBottom);
imageWidth = size.Width;
imageHeight = size.Height;
}
}
private static void FileDoesNotExist(string dataFullFileName, Face face, out int imageHeight, out int imageWidth, out long sourceSize, FileInfo fileInfo)
{
sourceSize = 0;
if (face.OutputResolution is null)
{
imageWidth = 0;
imageHeight = 0;
}
else
{
imageWidth = face.OutputResolution.Width;
imageHeight = face.OutputResolution.Height;
}
Stateless.Methods.IFaceFileSystem.SearchForMissingFile(fileInfo.FullName, fileInfo, dataFullFileName);
}
internal FaceFileSystem(string requestPath, int rootResultsDirectoryAbsoluteUriLength, string cResizeContent, string dFacesContentDirectory, string dataFullFileName, Face face) : base(string.Empty, string.Empty, dataFullFileName, string.Empty, DateTime.MinValue)
{
string confidence;
@ -130,38 +161,12 @@ public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem, IFaceFileS
string faceRelativePath = string.Concat(requestPath, new Uri(faceFullFileName).AbsoluteUri[rootResultsDirectoryAbsoluteUriLength..]);
string sourceRelativePath = string.Concat(requestPath, new Uri(sourceFullFileName).AbsoluteUri[rootResultsDirectoryAbsoluteUriLength..]);
FileInfo fileInfo = new(sourceFullFileName);
if (face.Populated && !File.Exists(faceFullFileName))
if (face.FaceEncoding is not null && face.Location?.NormalizedPixelPercentage is not null && !File.Exists(faceFullFileName))
Stateless.Methods.IFaceFileSystem.SearchForMissingFile(faceFullFileName, fileInfo: new FileInfo(string.Empty), dataFullFileName);
if (!fileInfo.Exists)
{
sourceSize = 0;
if (face.OutputResolution is null)
{
imageWidth = 0;
imageHeight = 0;
}
else
{
imageWidth = face.OutputResolution.Width;
imageHeight = face.OutputResolution.Height;
}
Stateless.Methods.IFaceFileSystem.SearchForMissingFile(fileInfo.FullName, fileInfo, dataFullFileName);
}
if (fileInfo.Exists)
FileExists(face, faceBottom, faceRight, out imageHeight, out imageWidth, out sourceSize, fileInfo);
else
{
sourceSize = fileInfo.Length;
if (face.OutputResolution is not null)
{
imageWidth = face.OutputResolution.Width;
imageHeight = face.OutputResolution.Height;
}
else
{
System.Drawing.Size size = Stateless.Methods.ImageHelper.GetDimensions(fileInfo.FullName, faceRight, faceBottom);
imageWidth = size.Width;
imageHeight = size.Height;
}
}
FileDoesNotExist(dataFullFileName, face, out imageHeight, out imageWidth, out sourceSize, fileInfo);
_ClassName = "file";
_FaceBottom = faceBottom;
_Confidence = confidence;
@ -176,7 +181,7 @@ public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem, IFaceFileS
_FaceLeft = faceLeft;
_LocationDisplayIndex = locationDisplayIndex;
_LocationIndex = face.LocationIndex;
_Populated = face.Populated;
_Populated = face.FaceEncoding is not null && face.Location?.NormalizedPixelPercentage is not null;
_RelativePath = string.Empty;
_FaceRight = faceRight;
_SourceFullFileName = sourceFullFileName;
@ -187,13 +192,13 @@ public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem, IFaceFileS
_ImageWidth = imageWidth;
}
string IFileSystem.GetDate()
public override string ToString()
{
string result = _LastModified.ToString("MM/dd/yyyy hh:mm:ss tt");
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
string IFaceFileSystem.GetSize()
public string GetSize()
{
string result;
if (_SourceSize is null)
@ -208,19 +213,9 @@ public class FaceFileSystem : FileSystem, Properties.IFaceFileSystem, IFaceFileS
order++;
len /= 1024;
}
result = String.Format("{0:0.##} {1}", len, sizes[order]);
result = string.Format("{0:0.##} {1}", len, sizes[order]);
}
return result;
}
void Stateless.Methods.IFaceFileSystem.TestStatic_SearchForMissingFile(string fullFileName, FileInfo fileInfo, string dataFullFileName) => throw new NotImplementedException();
FaceFileSystem[][] Stateless.Methods.IFaceFileSystem.TestStatic_GetFaceFileSystemCollection(string requestPath, string rootResultsDirectory, (string RootResultsDirectoryAbsoluteUri, string C_ResizeContentDirectory, string D_FacesContentDirectory, string E_DistanceCollectionDirectory) tuple, string selectedFileFullName) => throw new NotImplementedException();
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
}