0
0

Compare commits

..

No commits in common. "c13f4ddda1ec917c8957db2bcc397c5bc80c39fe" and "a9ce0c1785ce7c220ff953db7a21cf33535c6d26" have entirely different histories.

59 changed files with 179 additions and 168 deletions

View File

@ -41,4 +41,11 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: gitea.cebotari.ru/chebser/rhsolutions-api:latest
tags: gitea.cebotari.ru/chebser/rhsolutions-api:latest
- name: Build database
uses: docker/build-push-action@v5
with:
context: Database
file: Database/Dockerfile
push: true
tags: gitea.cebotari.ru/chebser/rhsolutions-db:latest

6
Database/Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM postgres:16.1-alpine AS build
ADD ./*.sql /docker-entrypoint-initdb.d
RUN chmod 644 /docker-entrypoint-initdb.d/*.sql
EXPOSE 5432
ENTRYPOINT [ "docker-entrypoint.sh" ]
CMD [ "postgres" ]

View File

@ -1,7 +1,6 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build
WORKDIR /source
COPY . .
RUN dotnet restore
RUN dotnet publish --property:OutputPath=/app
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled

View File

@ -2,13 +2,13 @@ using Microsoft.Extensions.DependencyInjection;
namespace RhSolutions.Api.Tests;
public abstract class ProductParsersTests
public abstract class ProductQueryModifierTests
{
public void Invoke(string productType, string query, string expected)
{
var modifier = TestServiceCollection.ServiceProvider?.GetRequiredKeyedService<IProductParser>(productType);
var modifier = TestServiceCollection.ServiceProvider?.GetRequiredKeyedService<IProductMLModifier>(productType);
string actual = string.Empty;
Assert.That(modifier?.TryParse(query, out actual), Is.True);
Assert.That(modifier?.TryQueryModify(query, out actual), Is.True);
Assert.That(actual, Is.EqualTo(expected));
}
}

View File

@ -1,7 +1,7 @@
namespace RhSolutions.Api.Tests;
public class RautitanFittingsTests : ProductParsersTests
public class RautitanFittingsTests : ProductQueryModifierTests
{
[TestCase("Гильза 16", "Монтажная гильза 16")]
[TestCase("Пресс-втулка 20", "Монтажная гильза 20")]

View File

@ -1,7 +1,7 @@
namespace RhSolutions.Api.Tests;
public class RautitanPipesTests : ProductParsersTests
public class RautitanPipesTests : ProductQueryModifierTests
{
[TestCase("Унив.труба RAUTITAN flex 16x2,2, бухта 100м", "Труба Flex 16x2,2 бухта")]
[TestCase("Труба flex 16", "Труба Flex 16x2,2 бухта")]

View File

@ -23,7 +23,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RhSolutions.Parsers\RhSolutions.Parsers.csproj" />
<ProjectReference Include="..\RhSolutions.MLModifiers\RhSolutions.MLModifiers.csproj" />
</ItemGroup>
</Project>

View File

@ -11,7 +11,7 @@ public class TestServiceCollection
public void CreateProvider()
{
var collection = new ServiceCollection();
collection.AddProductParsers();
collection.AddModifiers();
ServiceProvider = collection.BuildServiceProvider();
}

View File

@ -0,0 +1,2 @@
global using NUnit.Framework;
global using RhSolutions.MLModifiers;

View File

@ -5,9 +5,9 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.Api", "RhSolutions.Api\RhSolutions.Api.csproj", "{6AACEC90-0811-418D-8505-EB142A2B2AFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.Parsers", "RhSolutions.Parsers\RhSolutions.Parsers.csproj", "{C00C3DAB-275B-416D-BB66-4CB144441B18}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.Api.Tests", "RhSolutions.Api.Tests\RhSolutions.Api.Tests.csproj", "{E49F46C4-5F07-4055-AE8B-700AA6FC35FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.Parsers.Tests", "RhSolutions.Parsers.Tests\RhSolutions.Parsers.Tests.csproj", "{5AD110C3-A08C-459F-9CB1-198E75A955EE}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.MLModifiers", "RhSolutions.MLModifiers\RhSolutions.MLModifiers.csproj", "{50A53BB3-1F9D-4F19-90DB-BCB4D49FF9FE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -22,13 +22,13 @@ Global
{6AACEC90-0811-418D-8505-EB142A2B2AFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AACEC90-0811-418D-8505-EB142A2B2AFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AACEC90-0811-418D-8505-EB142A2B2AFA}.Release|Any CPU.Build.0 = Release|Any CPU
{C00C3DAB-275B-416D-BB66-4CB144441B18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C00C3DAB-275B-416D-BB66-4CB144441B18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C00C3DAB-275B-416D-BB66-4CB144441B18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C00C3DAB-275B-416D-BB66-4CB144441B18}.Release|Any CPU.Build.0 = Release|Any CPU
{5AD110C3-A08C-459F-9CB1-198E75A955EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AD110C3-A08C-459F-9CB1-198E75A955EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AD110C3-A08C-459F-9CB1-198E75A955EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AD110C3-A08C-459F-9CB1-198E75A955EE}.Release|Any CPU.Build.0 = Release|Any CPU
{E49F46C4-5F07-4055-AE8B-700AA6FC35FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E49F46C4-5F07-4055-AE8B-700AA6FC35FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E49F46C4-5F07-4055-AE8B-700AA6FC35FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E49F46C4-5F07-4055-AE8B-700AA6FC35FD}.Release|Any CPU.Build.0 = Release|Any CPU
{50A53BB3-1F9D-4F19-90DB-BCB4D49FF9FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50A53BB3-1F9D-4F19-90DB-BCB4D49FF9FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50A53BB3-1F9D-4F19-90DB-BCB4D49FF9FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50A53BB3-1F9D-4F19-90DB-BCB4D49FF9FE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Http.Extensions;
using RhSolutions.Api.Services;
using RhSolutions.Parsers;
using RhSolutions.MLModifiers;
namespace RhSolutions.Api.Middleware;
@ -8,7 +8,7 @@ public class QueryModifier
{
private RequestDelegate _next;
private IServiceProvider _provider;
private IProductParser? _modifier;
private IProductMLModifier? _modifier;
public QueryModifier(RequestDelegate nextDelegate, IServiceProvider provider)
{
@ -21,15 +21,15 @@ public class QueryModifier
if (context.Request.Method == HttpMethods.Get
&& context.Request.Path == "/api/search")
{
string input = context.Request.Query["query"].ToString();
var productType = typePredicter.GetPredictedProductType(input);
_modifier = _provider.GetRequiredKeyedService<IProductParser>(productType);
string query = context.Request.Query["query"].ToString();
var productType = typePredicter.GetPredictedProductType(query);
_modifier = _provider.GetRequiredKeyedService<IProductMLModifier>(productType);
if (_modifier == null) return;
if (_modifier.TryParse(input, out var output))
if (_modifier.TryQueryModify(query, out var modified))
{
QueryBuilder qb = new()
{
{"query", output}
{"query", modified}
};
context.Request.QueryString = qb.ToQueryString();
}

View File

@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore;
using RhSolutions.Models;
using RhSolutions.Api.Services;
using RhSolutions.Api.Middleware;
using RhSolutions.Parsers;
using RhSolutions.MLModifiers;
using Microsoft.OpenApi.Models;
using System.Reflection;
using Microsoft.AspNetCore.Identity;
@ -32,7 +32,7 @@ builder.Services.AddIdentity<IdentityUser, IdentityRole>()
builder.Services.AddScoped<IPricelistParser, ClosedXMLParser>()
.AddScoped<IProductTypePredicter, ProductTypePredicter>();
builder.Services.AddProductParsers();
builder.Services.AddModifiers();
builder.Services.AddControllers();
builder.Services.AddSwaggerGen(options =>
{

View File

@ -34,7 +34,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RhSolutions.Parsers\RhSolutions.Parsers.csproj" />
<ProjectReference Include="..\RhSolutions.MLModifiers\RhSolutions.MLModifiers.csproj" />
</ItemGroup>
</Project>

View File

@ -1,10 +1,10 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
public abstract class Adapter : DrinkingWaterHeatingFitting
{
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
Match diameter = _diameter.Match(input);

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Переходник на наружную резьбу")]
[MLModifierKey("Переходник на наружную резьбу")]
public class AdapterExternal : Adapter
{
protected override string _title => "Переходник с наружной резьбой";

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Переходник на внутреннюю резьбу")]
[MLModifierKey("Переходник на внутреннюю резьбу")]
public class AdapterInternal : Adapter
{
protected override string _title => "Переходник с внутренней резьбой -угольник-переходник";

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Переходник с накидной гайкой")]
[MLModifierKey("Переходник с накидной гайкой")]
public class AdapterScrewcap : Adapter
{
protected override string _title => "Переходник с накидной гайкой";

View File

@ -1,10 +1,10 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Фиксатор поворота отопление")]
[MLModifierKey("Фиксатор поворота отопление")]
public class BendFormerHeating : DrinkingWaterHeatingFitting
{
protected override string _title => "Фиксатор поворота";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,11 +1,11 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Фиксатор поворота водоснабжение")]
[MLModifierKey("Фиксатор поворота водоснабжение")]
public class BendFormerSanitary : DrinkingWaterHeatingFitting
{
protected override string _title => "Фиксатор поворота с кольцами";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,8 +1,8 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Трубка Г-образная")]
[MLModifierKey("Трубка Г-образная")]
public class ConnectionBend : DrinkingWaterHeatingFitting
{
private static readonly int[] lengths = [250, 500, 1000];
@ -10,7 +10,7 @@ public class ConnectionBend : DrinkingWaterHeatingFitting
new(@"([\b\D]|^)?(?<Diameter>16|20|25)(\D+|.*15.*)(?<Length>\b\d{3,4})([\b\D]|$)");
protected override string _title => "Трубка Г-образная";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var match = _pattern.Match(input);

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Трубка Т-образная")]
[MLModifierKey("Трубка Т-образная")]
public class ConnectionTee : ConnectionBend
{
protected override string _title => "Трубка Т-образная";

View File

@ -1,11 +1,11 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Муфта соединительная")]
[MLModifierKey("Муфта соединительная")]
public class Coupling : DrinkingWaterHeatingFitting
{
protected override string _title => "Муфта соединительная";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diametersMatches = _diameter.Matches(input);

View File

@ -1,8 +1,8 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
public abstract class DrinkingWaterHeatingFitting : IProductParser
public abstract class DrinkingWaterHeatingFitting : IProductMLModifier
{
protected static readonly Regex _diameter =
new(@"([\b\D]|^)?(?<Diameter>16|20|25|32|40|50|63)([\b\D]|$)");
@ -13,7 +13,7 @@ public abstract class DrinkingWaterHeatingFitting : IProductParser
protected virtual string _title { get; } = string.Empty;
public virtual bool TryParse(string input, out string output)
public virtual bool TryQueryModify(string input, out string output)
{
var match = _diameter.Match(input);
if (match.Success)

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Заглушка труб RAUTITAN")]
[MLModifierKey("Заглушка труб RAUTITAN")]
public class DummyPlug : DrinkingWaterHeatingFitting
{
protected override string _title => "Заглушка для полимерн. трубы";

View File

@ -1,11 +1,11 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Угольник RAUTITAN")]
[MLModifierKey("Угольник RAUTITAN")]
public class Elbow : DrinkingWaterHeatingFitting
{
protected override string _title { get; } = "Угольник -PLATINUM";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,10 +1,10 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
public abstract class Eurocone : DrinkingWaterHeatingFitting
{
protected virtual Dictionary<string, string> _titles { get; } = new();
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,11 +1,11 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Переходник на евроконус")]
[MLModifierKey("Переходник на евроконус")]
public class EuroconeAdapter : DrinkingWaterHeatingFitting
{
protected override string _title => "Переходник на евроконус";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,9 +1,9 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Резьбозажимное для трубки")]
[MLModifierKey("Резьбозажимное для трубки")]
public class EuroconeConnectionBend : DrinkingWaterHeatingFitting
{
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = "Резьбозажимное соединение для металлической трубки G 3/4 -15";
return true;

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Резьбозажимное flex")]
[MLModifierKey("Резьбозажимное flex")]
public class EuroconeFlex : Eurocone
{
protected override Dictionary<string, string> _titles => new()

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Резьбозажимное stabil")]
[MLModifierKey("Резьбозажимное stabil")]
public class EuroconeStabil : Eurocone
{
protected override Dictionary<string, string> _titles => new()

View File

@ -1,8 +1,8 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Коллектор G1")]
[MLModifierKey("Коллектор G1")]
public class ManifoldG1 : DrinkingWaterHeatingFitting
{
private static readonly Regex _portsCount =
@ -10,7 +10,7 @@ public class ManifoldG1 : DrinkingWaterHeatingFitting
protected override string _title => "Распределительный коллектор G1";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
var match = _portsCount.Match(input);
if (match.Success)

View File

@ -1,15 +1,15 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Коллектор HLV")]
[MLModifierKey("Коллектор HLV")]
public class ManifoldHLV : DrinkingWaterHeatingFitting
{ private static readonly Regex _portsCount =
new(@"\s(?<Ports>\d{1,2})\s");
protected override string _title => "Распределительный коллектор HLV";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
var match = _portsCount.Match(input);
if (match.Success)

View File

@ -1,9 +1,9 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Ниппель")]
[MLModifierKey("Ниппель")]
public class Nippel : DrinkingWaterHeatingFitting
{
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = "К-т двух резьбозажим. нипелей с нар.резьбой 1/2х3/4";
return true;

View File

@ -1,11 +1,11 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Гофротруба RAUTITAN")]
[MLModifierKey("Гофротруба RAUTITAN")]
public class ProtectivePipe : DrinkingWaterHeatingFitting
{
protected override string _title => "Гофротруба защитн.для ПЭ-трубы";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Угольник с накидной гайкой")]
[MLModifierKey("Угольник с накидной гайкой")]
public class ScrewcapElbow : Adapter
{
protected override string _title => "Угольник-переходник с накидной гайкой";

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Монтажная гильза")]
[MLModifierKey("Монтажная гильза")]
public class Sleeve : DrinkingWaterHeatingFitting
{
protected override string _title => "Монтажная гильза";

View File

@ -1,11 +1,11 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Желоб")]
[MLModifierKey("Желоб")]
public class SupportingClip : DrinkingWaterHeatingFitting
{
protected override string _title => "Фиксирующий желоб для ПЭ-трубы";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,11 +1,11 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Тройник RAUTITAN")]
[MLModifierKey("Тройник RAUTITAN")]
public class TPiece : DrinkingWaterHeatingFitting
{
protected override string _title => "Тройник -PLATINUM";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameters = _diameter.Matches(input)

View File

@ -1,14 +1,14 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Проточный настенный угольник")]
[MLModifierKey("Проточный настенный угольник")]
public class ThreadElbowDoubleWallInternal : DrinkingWaterHeatingFitting
{
protected override string _title => "Проточный настенный угольник";
private Regex _type = new(@"([\b\Wу])(?<Type>длин)([\b\w\.\s])");
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatches = _diameter.Matches(input);

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Угольник с наружной резьбой")]
[MLModifierKey("Угольник с наружной резьбой")]
public class ThreadElbowExternal : Adapter
{
protected override string _title => "Угольник-переходник с наружной резьбой";

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Угольник с внутренней резьбой")]
[MLModifierKey("Угольник с внутренней резьбой")]
public class ThreadElbowInternal : Adapter
{
protected override string _title => "Угольник-переходник с внутренней резьбой";

View File

@ -1,11 +1,11 @@
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Угольник настенный наружный")]
[MLModifierKey("Угольник настенный наружный")]
public class ThreadElbowWallExternal : DrinkingWaterHeatingFitting
{
protected override string _title => "Угольник настенный с наружной резьбой";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,14 +1,14 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Угольник настенный внутренний")]
[MLModifierKey("Угольник настенный внутренний")]
public class ThreadElbowWallInternal : DrinkingWaterHeatingFitting
{
protected override string _title => "Угольник настенный внутр. резьба";
private Regex _type = new(@"([\b\Wу])(?<Type>длин)([\b\w\.\s])");
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,13 +1,13 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Тройник RAUTITAN резьбовой наружный")]
[MLModifierKey("Тройник RAUTITAN резьбовой наружный")]
public class ThreadTPieceExternal : DrinkingWaterHeatingFitting
{
protected override string _title => "Тройник с наружной резьбой";
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
MatchCollection diametersMatches = _diameter.Matches(input);

View File

@ -1,11 +1,11 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
[ParserKey("Тройник RAUTITAN резьбовой внутренний")]
[MLModifierKey("Тройник RAUTITAN резьбовой внутренний")]
public class ThreadTPieceInternal : DrinkingWaterHeatingFitting
{
public override bool TryParse(string input, out string output)
public override bool TryQueryModify(string input, out string output)
{
output = string.Empty;
MatchCollection diametersMatches = _diameter.Matches(input);

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Pipes;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingPipes;
[ParserKey("Black")]
[MLModifierKey("Black")]
public class BlackPipe : DrinkingWaterHeatingPipe
{
protected override string _title => "Black";

View File

@ -1,8 +1,8 @@
using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Pipes;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingPipes;
public abstract class DrinkingWaterHeatingPipe : IProductParser
public abstract class DrinkingWaterHeatingPipe : IProductMLModifier
{
protected static readonly Regex _diameter =
new(@"([\b\D]|^)?(?<Diameter>16|20|25|32|40|50|63)([\b\D]|$)");
@ -28,7 +28,7 @@ public abstract class DrinkingWaterHeatingPipe : IProductParser
["отр"] = "прям.отрезки"
};
public bool TryParse(string input, out string output)
public bool TryQueryModify(string input, out string output)
{
output = string.Empty;
var diameterMatch = _diameter.Match(input);

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Pipes;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingPipes;
[ParserKey("Flex")]
[MLModifierKey("Flex")]
public class FlexPipe : DrinkingWaterHeatingPipe
{
protected override string _title => "Flex";

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Pipes;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingPipes;
[ParserKey("Pink")]
[MLModifierKey("Pink")]
public class PinkPipe : DrinkingWaterHeatingPipe
{
protected override string _title => "Pink+";

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Parsers.Pipes;
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingPipes;
[ParserKey("Stabil")]
[MLModifierKey("Stabil")]
public class StabilPipe : DrinkingWaterHeatingPipe
{
protected override string _title => "Stabil -PLATINUM";

View File

@ -0,0 +1,6 @@
namespace RhSolutions.MLModifiers;
public interface IProductMLModifier
{
public bool TryQueryModify(string query, out string queryModified);
}

View File

@ -0,0 +1,10 @@
namespace RhSolutions.MLModifiers;
public class MLModifierKey : Attribute
{
public string Value { get; private set; }
public MLModifierKey(string value)
{
Value = value;
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
namespace RhSolutions.MLModifiers;
public static class MLModifiersRegistration
{
public static void AddModifiers(this IServiceCollection services)
{
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => p.IsDefined(typeof(MLModifierKey), true));
foreach (Type t in types)
{
string key = GetModifierKey(t);
services.AddKeyedTransient(typeof(IProductMLModifier), key, t);
}
}
private static string GetModifierKey(Type t)
{
return t.GetCustomAttribute<MLModifierKey>()?.Value ?? string.Empty;
}
}

View File

@ -1,2 +0,0 @@
global using NUnit.Framework;
global using RhSolutions.Parsers;

View File

@ -1,6 +0,0 @@
namespace RhSolutions.Parsers;
public interface IProductParser
{
public bool TryParse(string input, out string output);
}

View File

@ -1,10 +0,0 @@
namespace RhSolutions.Parsers;
public class ParserKey : Attribute
{
public string Value { get; private set; }
public ParserKey(string value)
{
Value = value;
}
}

View File

@ -1,25 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
namespace RhSolutions.Parsers;
public static class ParsersRegistration
{
public static void AddProductParsers(this IServiceCollection services)
{
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => p.IsDefined(typeof(ParserKey), true));
foreach (Type t in types)
{
string key = GetParserKey(t);
services.AddKeyedTransient(typeof(IProductParser), key, t);
}
}
private static string GetParserKey(Type t)
{
return t.GetCustomAttribute<ParserKey>()?.Value ?? string.Empty;
}
}

View File

@ -19,7 +19,7 @@ services:
depends_on:
- db
db:
image: postgres:16
build: Database/.
container_name: db
environment:
- POSTGRES_USER=chebser
@ -27,7 +27,6 @@ services:
- POSTGRES_DB=rhsolutions
volumes:
- db-data:/var/lib/postgresql/data
- ./Database:/docker-entrypoint-initdb.d
networks:
- rhsolutions
networks: