добавлено чтение с 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

BIN
Data/limits.db Normal file

Binary file not shown.

View File

@@ -23,9 +23,7 @@
th,
td,
form,
h2,
h3,
img {
h2 {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
@@ -38,7 +36,6 @@
</style>
<body>
<table border="1">
<caption>
<h2>Расчет размеров поковки</h2>
@@ -191,10 +188,10 @@
</thead>
</table>
<br>
<h3>Результат без пробы</h3>
<h2>Результат без пробы</h2>
<p class="aligncenter"><img src="/images/Result_WithoutBlank.png" alt="Результат без пробы"></p>
<br>
<h3>Результат с пробой</h3>
<h2>Результат с пробой</h2>
<p class="aligncenter"><img src="/images/Result_WithBlank.png" alt="Результат с пробой"></p>
</body>

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)
{

View File

@@ -7,11 +7,6 @@ builder.Services.AddRazorPages(options =>
options.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute());
});
builder.WebHost.ConfigureKestrel(serverOptions =>
{
serverOptions.ListenAnyIP(5146);
});
var app = builder.Build();
app.MapRazorPages();
app.UseStaticFiles();

View File

@@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.7" />
<PackageReference Include="System.Drawing.Common" Version="9.0.7" />
</ItemGroup>