добавлено чтение с db

This commit is contained in:
2026-01-18 14:42:32 +04:00
parent 16718ba551
commit faf209f946
5 changed files with 34 additions and 15 deletions

View File

@@ -1,10 +1,9 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.Sqlite;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;
public class ResultsModel : PageModel
{
@@ -205,6 +204,33 @@ public class ResultsModel : PageModel
ResultImage("Result_WithBlank", mDisk_nom_2_O, mDisk_max_2_O, _dd, d_BilletWithBlank, limit6, _H, H_BilletWithBlank, _D, D_BilletWithBlank, limit4);
}
public (int Delta, int Tolerance) SearchLimit(double D, double H)
{
using var connection = new SqliteConnection("Data Source=tolerances.db");
connection.Open();
var command = connection.CreateCommand();
command.CommandText = @"
SELECT Delta, Tolerance
FROM Tolerances
WHERE @height > HeightFrom
AND @height <= HeightTo
AND @diameter > DiameterFrom
AND @diameter <= DiameterTo
LIMIT 1";
command.Parameters.AddWithValue("@height", H);
command.Parameters.AddWithValue("@diameter", D);
using var reader = command.ExecuteReader();
if (reader.Read())
{
return (reader.GetInt32(0), reader.GetInt32(1));
}
return (-1, -1);
}
/*
private (int, int) SearchLimit(double D, double H)
{
// Диапазоны высоты H
@@ -291,7 +317,7 @@ public class ResultsModel : PageModel
return limits[hIndex, dIndex];
}
*/
private string ResultImage(string imageName, double weightNom, double weightMax, double d, double d_Billet,
double limit5, double H, double H_Billet, double D, double D_Billet, double limit3)
{