Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fa78a55
создан
Matosik Feb 17, 2026
1ae7749
генерация данных через Bogus
Matosik Mar 11, 2026
6fb6c55
Создан нормальный генератор моделей, который относит модели к их прои…
Matosik Mar 11, 2026
1b19de4
веб сервер
Matosik Mar 12, 2026
f182de1
изменен README под 1 ЛР
Matosik Mar 13, 2026
e82dee3
Вроде всё готово
Matosik Mar 15, 2026
f96b71b
Нормальные логи
Matosik Mar 15, 2026
7af635e
sfdlhkj
Matosik Mar 16, 2026
4de7479
Написаны Unit тесты
Matosik Mar 16, 2026
839686a
Удалены ненужные дерективы using
Matosik Mar 16, 2026
13d2baa
Добавлены описания
Matosik Mar 16, 2026
5170a8d
значение ttl вынесено в appsetting.json
Matosik Mar 17, 2026
0197853
удален ненужный файл
Matosik Mar 17, 2026
990c578
delete string.Empty и добавлены описание описания(даже описания исклю…
Matosik Mar 18, 2026
08d75a0
Удален не используемый класс остался только Dto. Надеюсь это никого н…
Matosik Mar 18, 2026
ab5a2c8
написан primary constructor
Matosik Mar 18, 2026
9a94c4f
Seed => Id
Matosik Mar 18, 2026
975f080
Удалены ненужные закомиченые исключения и один файл = один класс
Matosik Mar 18, 2026
688ed74
лучший способ получать файл с производителями и моделями
Matosik Mar 18, 2026
34c5ec2
Меньше пустых строк
Matosik Mar 18, 2026
b0651bb
VehicleModelGenerator теперь не генератор а просто закрузчик данных д…
Matosik Mar 18, 2026
47f9b8f
JsonSerializerOptions вынесен в статическое поле
Matosik Mar 18, 2026
47fb48c
теперь data не может быть null так как выбросится исключение
Matosik Mar 18, 2026
1c1e4d2
Убрал лишнюю проверку
Matosik Mar 18, 2026
f49ba5e
primary конструктор
Matosik Mar 18, 2026
f1a7125
Удалено то чего быть не должно
Matosik Mar 18, 2026
50be3f3
порт вынесен в appsetting.json
Matosik Mar 18, 2026
d5767dd
primary constructor
Matosik Mar 18, 2026
c6b4c9b
страшная табуляция превратилась в шедевр искусства
Matosik Mar 18, 2026
3fc2ba7
Понижена гарантия валидации данных
Matosik Mar 18, 2026
7ddadc5
вынес адрес клиента в appsetting.json
Matosik Mar 18, 2026
0a0badb
ждем
Matosik Mar 18, 2026
46b43a6
Удален ненужный проект
Matosik Mar 19, 2026
f00be80
Asp => Server
Matosik Mar 19, 2026
850282c
Aspire.StackExchange.Redis.DistributedCaching
Matosik Mar 19, 2026
c1ddc10
cleanup code
Matosik Mar 19, 2026
ccfb2bb
fix
Matosik Mar 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Aspire.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var builder = DistributedApplication.CreateBuilder(args);
var redis = builder.AddRedis("cache").WithRedisInsight();

var back = builder.AddProject<Projects.Server>("back")
.WithReference(redis)
.WaitFor(redis);

builder.AddProject<Projects.Client_Wasm>("front")
.WaitFor(back);
builder.Build().Run();
23 changes: 23 additions & 0 deletions Aspire.AppHost/Aspire.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>332a680f-f1c5-49c8-a258-12e527af6b5e</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.2" />
<PackageReference Include="Aspire.Hosting.Redis" Version="13.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Server\Server.csproj" />
<ProjectReference Include="..\Client.Wasm\Client.Wasm.csproj" />
</ItemGroup>

</Project>
29 changes: 29 additions & 0 deletions Aspire.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17077;http://localhost:15131",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21228",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22147"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15131",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19273",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20035"
}
}
}
}
8 changes: 8 additions & 0 deletions Aspire.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions Aspire.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
22 changes: 22 additions & 0 deletions Aspire.ServiceDefaults/Aspire.ServiceDefaults.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.9.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.5.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
</ItemGroup>

</Project>
126 changes: 126 additions & 0 deletions Aspire.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

namespace Microsoft.Extensions.Hosting;

// Adds common Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
public static class Extensions
{
private const string HealthEndpointPath = "/health";
private const string AlivenessEndpointPath = "/alive";

public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.ConfigureOpenTelemetry();

builder.AddDefaultHealthChecks();

builder.Services.AddServiceDiscovery();

builder.Services.ConfigureHttpClientDefaults(http =>
{
// Turn on resilience by default
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
// {
// options.AllowedSchemes = ["https"];
// });

return builder;
}

public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Logging.AddOpenTelemetry(logging =>
{
logging.IncludeFormattedMessage = true;
logging.IncludeScopes = true;
});

builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
})
.WithTracing(tracing =>
{
tracing.AddSource(builder.Environment.ApplicationName)
.AddAspNetCoreInstrumentation(tracing =>
// Exclude health check requests from tracing
tracing.Filter = context =>
!context.Request.Path.StartsWithSegments(HealthEndpointPath)
&& !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
)
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
});

builder.AddOpenTelemetryExporters();

return builder;
}

private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);

if (useOtlpExporter)
{
builder.Services.AddOpenTelemetry().UseOtlpExporter();
}

// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
//{
// builder.Services.AddOpenTelemetry()
// .UseAzureMonitor();
//}

return builder;
}

public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

return builder;
}

public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
// Adding health checks endpoints to applications in non-development environments has security implications.
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks(HealthEndpointPath);

// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
});
}

return app;
}
}
2 changes: 1 addition & 1 deletion Client.Wasm/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</Router>
51 changes: 36 additions & 15 deletions Client.Wasm/Components/DataCard.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@inject IConfiguration Configuration
@using System.Diagnostics;
@inject IConfiguration Configuration
@inject HttpClient Client

<CardDeck>
Expand All @@ -7,30 +8,33 @@
<Heading Size="HeadingSize.Is5"><Icon Name="IconName.Table" /> Характеристики текущего объекта</Heading>
</CardHeader>
<CardBody>
<Table Bordered >
<Table Bordered>
<TableHeader ThemeContrast="ThemeContrast.Light">
<TableRow>
<TableRow>
<TableHeaderCell>#</TableHeaderCell>
<TableHeaderCell>Характеристика</TableHeaderCell>
<TableHeaderCell>Значение</TableHeaderCell>
</TableRow>
</TableRow>
</TableHeader>


<TableBody>
@if(Value is null)
@if (Value is null)
{
<TableRow>
<TableRowCell>1</TableRowCell>
<TableRowCell>нет данных</TableRowCell>
<TableRowCell>нет данных</TableRowCell>
<TableRowCell>-1</TableRowCell>
<TableRowCell>not found</TableRowCell>
<TableRowCell>not found</TableRowCell>
</TableRow>

}
else
{
var array = Value.ToArray();
foreach (var property in array)
{
<TableRow>
<TableRowCell>@(Array.IndexOf(array, property)+1)</TableRowCell>
<TableRowCell>@(Array.IndexOf(array, property) + 1)</TableRowCell>
<TableRowCell>@property.Key</TableRowCell>
<TableRowCell>@property.Value?.ToString()</TableRowCell>
</TableRow>
Expand All @@ -40,7 +44,7 @@
</Table>
</CardBody>
</Card>

<Card Margin="Margin.Is3.OnY">
<CardHeader>
<Heading Size="HeadingSize.Is5"><Icon Name="IconName.Send" /> Запросить новый объект</Heading>
Expand All @@ -51,24 +55,41 @@
<Text>Идентификатор нового объекта:</Text>
</Column>
<Column ColumnSize="ColumnSize.Is4">
<NumericEdit TValue="int" @bind-Value="@Id"/>
<NumericEdit TValue="int" @bind-Value="@Id" />
</Column>
<Column ColumnSize="ColumnSize.Is4">
<Button Clicked=RequestNewData Color="Color.Primary">Запросить данные <Icon Name="IconName.ArrowRight" /></Button>
</Column>
</Row>
</CardBody>
<p> Время запроса: @_requestTimeMs</p>
</Card>
</CardDeck>

@code {
private long _requestTimeMs;
private JsonObject? Value { get; set; }
private int Id { get; set; }
private string? ErrorMessage { get; set; }

private async Task RequestNewData()
{
var baseAddress = Configuration["BaseAddress"] ?? throw new KeyNotFoundException("Конфигурация клиента не содержит параметра BaseAddress");
Value = await Client.GetFromJsonAsync<JsonObject>($"{baseAddress}?id={Id}", new JsonSerializerOptions { });
StateHasChanged();
try
{
ErrorMessage = null;

var url = "contracts/vehicle";
url += $"?id={Id}";

var stopwatch = Stopwatch.StartNew();
Value = await Client.GetFromJsonAsync<JsonObject>(url);
stopwatch.Stop();
_requestTimeMs = stopwatch.ElapsedMilliseconds;

}
catch (Exception ex)
{
ErrorMessage = $"Ошибка запроса: {ex.Message}";
}
}
}
}
10 changes: 5 additions & 5 deletions Client.Wasm/Components/StudentCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
</CardHeader>
<CardBody>
<UnorderedList Unstyled>
<UnorderedListItem>Номер <Strong>№X "Название лабораторной"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№Х "Название варианта"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Фамилией Именем 65ХХ</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://puginarug.com/">Ссылка на форк</Link></UnorderedListItem>
<UnorderedListItem>Номер <Strong>№1 "Название лабораторной"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№3 "Транспортное средство"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Богачевым Матвеем 6511</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://github.com/Matosik/cloud-development">Ссылка на форк</Link></UnorderedListItem>
</UnorderedList>
</CardBody>
</Card>
</Card>
2 changes: 1 addition & 1 deletion Client.Wasm/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
@Body
</article>
</main>
</div>
</div>
8 changes: 6 additions & 2 deletions Client.Wasm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
var baseAddress = builder.Configuration["BaseAddress"]
?? throw new InvalidOperationException("BaseAddress is not configured.");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) });

builder.Services.AddBlazorise(options => { options.Immediate = true; })
.AddBootstrapProviders()
.AddFontAwesomeIcons();

await builder.Build().RunAsync();
await builder.Build().RunAsync();
Loading