feat: massive rework

1) GSS2.Core:
- strip prefixes in GSS2.Core.Analysis.AmineContent namespace class names
- add IEnumerable<double>.Variance extension
- remake analysis + update database so not needed to store all every file, calibration data also stored in database, also currently capturing images stored in system temporary directory and rewriting every time
2) GSS.UI.Core: AsyncImageRecordViewModel make zoom and pans public
3) GSS:
- remove image-storage-clear command
- remove ResultsView and ResultsViewModel, results presented in analysis
- rework calibration views
- add analysis views
- add text and number fields editors view
- add confirmation view on danger buttons
This commit is contained in:
2026-05-13 12:56:32 +03:00
parent ec95eef375
commit 3cc4d21947
63 changed files with 4359 additions and 3961 deletions
-110
View File
@@ -1,110 +0,0 @@
using Microsoft.Extensions.Logging;
namespace GSS2.Core.Hardware;
public class ImageStorageService
{
private readonly ILogger<ImageStorageService> _logger;
private readonly DirectoryInfo _rootDirectory;
public ImageStorageService(ILogger<ImageStorageService> logger, DirectoryInfo rootDirectory)
{
_logger = logger;
_logger.LogInformation("Initialization");
_rootDirectory = rootDirectory;
if (!_rootDirectory.Exists)
{
_rootDirectory.Create();
_logger.LogInformation("Created directory: {}", _rootDirectory.FullName);
}
_logger.LogInformation("Initialized");
}
public async Task<string> SaveAsync(Stream fileStream, string extension, string subDirectory, CancellationToken ct = default)
{
var fileName = GenerateFileName(extension);
var fullPath = GetFullPath(fileName, subDirectory);
System.Diagnostics.Debug.Assert(fullPath is not null);
var directory = Path.GetDirectoryName(fullPath)!;
Directory.CreateDirectory(directory);
await using var file = new FileStream(
fullPath,
FileMode.CreateNew,
FileAccess.Write,
FileShare.None,
81920,
useAsync: true);
await fileStream.CopyToAsync(file, ct);
_logger.LogInformation("File saved: {FileName}", fileName);
return fileName;
}
public Stream OpenRead(string fileName, string? subDirectory = null)
{
var fullPath = GetFullPath(fileName, subDirectory);
if (fullPath is null)
throw new FileNotFoundException(null, fullPath);
return new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read);
}
public bool Delete(string fileName, string? subDirectory = null)
{
var fullPath = GetFullPath(fileName, subDirectory);
if (fullPath is null)
throw new FileNotFoundException(null, fullPath);
if (!File.Exists(fullPath))
return false;
File.Delete(fullPath);
_logger.LogInformation("File removed: {}", fileName);
var parentDirectory = Directory.GetParent(fullPath);
if (parentDirectory?.GetFiles().Count() == 0)
{
parentDirectory.Delete();
_logger.LogInformation("Empty directory removed: {}", parentDirectory.Name);
}
return true;
}
private string GenerateFileName(string extension)
{
var guid = Guid.NewGuid().ToString("N");
return $"{guid}{extension}";
}
public string? GetFullPath(string fileName, string? subDirectory = null)
{
var level1 = fileName.Substring(0, 2);
var level2 = fileName.Substring(2, 2);
if (subDirectory is not null)
return Path.Combine(_rootDirectory.FullName, subDirectory, level1, level2, fileName);
return ListFiles()
.FirstOrDefault(f => Path.GetFileName(f) == fileName);
}
public List<string> ListFiles(string? subDirectory = null)
{
if (subDirectory is not null)
return Directory.GetDirectories(Path.Join(_rootDirectory.FullName, subDirectory))
.SelectMany(Directory.GetDirectories)
.SelectMany(Directory.GetFiles)
.ToList();
return Directory.GetDirectories(_rootDirectory.FullName)
.Select(Path.GetFileName)
.SelectMany(ListFiles)
.ToList();
}
}
+72
View File
@@ -0,0 +1,72 @@
using System.Device.I2c;
using Microsoft.Extensions.Logging;
using GSS2.Core.Abstractions;
using System.Diagnostics;
namespace GSS2.Core.Hardware;
[Obsolete("Not implemented")]
public class UsbService : IDisposable
{
private bool _disposedValue;
private readonly ILogger<UsbService> _logger;
private readonly Process _monitor;
public UsbService(ILogger<UsbService> logger)
{
_logger = logger;
_logger.LogInformation("Инициализация");
_monitor = new Process();
_monitor.StartInfo = new ProcessStartInfo()
{
FileName = "udisksctl",
Arguments = "monitor",
RedirectStandardOutput = true,
RedirectStandardError = true
};
_monitor.OutputDataReceived += MonitorDataReceived;
_monitor.ErrorDataReceived += MonitorDataReceived;
_monitor.Exited += (s, ea) => _logger.LogWarning("Монитор udisksctl отключен");
if (_monitor.Start())
_logger.LogInformation("Монитор udisksctl запущен");
else
_logger.LogError("Не удалось запустить монитор udisksctl");
_monitor.BeginOutputReadLine();
_monitor.BeginErrorReadLine();
_logger.LogInformation("Инициализировано");
}
private void MonitorDataReceived(object sender, DataReceivedEventArgs ea)
{
if (ea.Data is null)
return;
_logger.LogInformation("Data rec {}", ea.Data);
}
protected virtual void Dispose(bool disposing)
{
if (!_disposedValue)
{
if (disposing)
{
try
{
_monitor.Close();
}
catch { }
}
_disposedValue = true;
}
}
void IDisposable.Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}