Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 30 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
8 changes: 4 additions & 4 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>№14 "Медицинский пациeнт"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Степановым Дмитрием 6511</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://github.com/negniy/cloud-development.git">Ссылка на форк</Link></UnorderedListItem>
</UnorderedList>
</CardBody>
</Card>
12 changes: 6 additions & 6 deletions Client.Wasm/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5127",
"applicationUrl": "http://localhost:5128",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7282;http://localhost:5127",
"applicationUrl": "https://localhost:7283;http://localhost:5128",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
4 changes: 2 additions & 2 deletions Client.Wasm/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}
},
"AllowedHosts": "*",
"BaseAddress": ""
}
"BaseAddress": "http://localhost:5000/patient"
}
38 changes: 37 additions & 1 deletion CloudDevelopment.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36811.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Wasm", "Client.Wasm\Client.Wasm.csproj", "{AE7EEA74-2FE0-136F-D797-854FD87E022A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client.Wasm", "Client.Wasm\Client.Wasm.csproj", "{AE7EEA74-2FE0-136F-D797-854FD87E022A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatientApp.Generator", "GeneratorService\PatientApp.Generator.csproj", "{DB627DDE-E411-4B5B-9FE3-15F9A8EC1491}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatientApp.AppHost", "Patient\Patient.AppHost\PatientApp.AppHost.csproj", "{03605D0F-0E69-461D-9417-32DD06B53E23}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatientApp.ServiceDefaults", "Patient\Patient.ServiceDefaults\PatientApp.ServiceDefaults.csproj", "{DA24CCA7-7B4A-871C-985C-DBE0FA1F7524}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatientApp.Gateway", "Gateway\PatientApp.Gateway.csproj", "{AB6410EA-A027-B523-756F-6E77D0CA6F6B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventSink2", "EventSink2\EventSink2.csproj", "{49DE02D1-F38B-4E25-AA05-51120A4D9AEC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{1F9349B8-0B98-4B35-9CFE-39A2D1854DD9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +27,30 @@ Global
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.Build.0 = Release|Any CPU
{DB627DDE-E411-4B5B-9FE3-15F9A8EC1491}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB627DDE-E411-4B5B-9FE3-15F9A8EC1491}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB627DDE-E411-4B5B-9FE3-15F9A8EC1491}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB627DDE-E411-4B5B-9FE3-15F9A8EC1491}.Release|Any CPU.Build.0 = Release|Any CPU
{03605D0F-0E69-461D-9417-32DD06B53E23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03605D0F-0E69-461D-9417-32DD06B53E23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03605D0F-0E69-461D-9417-32DD06B53E23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03605D0F-0E69-461D-9417-32DD06B53E23}.Release|Any CPU.Build.0 = Release|Any CPU
{DA24CCA7-7B4A-871C-985C-DBE0FA1F7524}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA24CCA7-7B4A-871C-985C-DBE0FA1F7524}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA24CCA7-7B4A-871C-985C-DBE0FA1F7524}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA24CCA7-7B4A-871C-985C-DBE0FA1F7524}.Release|Any CPU.Build.0 = Release|Any CPU
{AB6410EA-A027-B523-756F-6E77D0CA6F6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB6410EA-A027-B523-756F-6E77D0CA6F6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB6410EA-A027-B523-756F-6E77D0CA6F6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB6410EA-A027-B523-756F-6E77D0CA6F6B}.Release|Any CPU.Build.0 = Release|Any CPU
{49DE02D1-F38B-4E25-AA05-51120A4D9AEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49DE02D1-F38B-4E25-AA05-51120A4D9AEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49DE02D1-F38B-4E25-AA05-51120A4D9AEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49DE02D1-F38B-4E25-AA05-51120A4D9AEC}.Release|Any CPU.Build.0 = Release|Any CPU
{1F9349B8-0B98-4B35-9CFE-39A2D1854DD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F9349B8-0B98-4B35-9CFE-39A2D1854DD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F9349B8-0B98-4B35-9CFE-39A2D1854DD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F9349B8-0B98-4B35-9CFE-39A2D1854DD9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
44 changes: 44 additions & 0 deletions EventSink1/Controllers/S3StorageController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using EventSink1.Storage;
using Microsoft.AspNetCore.Mvc;
using System.Text;
using System.Text.Json.Nodes;

namespace EventSink1.Controllers;

[ApiController]
[Route("api/s3")]
public class S3StorageController(IS3Service s3Service, ILogger<S3StorageController> logger) : ControllerBase
{
[HttpGet]
public async Task<ActionResult<List<string>>> ListFiles()
{
logger.LogInformation("Получен запрос списка файлов");
try
{
var list = await s3Service.GetFileList();
logger.LogInformation("Найдено файлов: {count}", list.Count);
return Ok(list);
}
catch (Exception ex)
{
logger.LogError(ex, "Ошибка при получении списка файлов");
return BadRequest(ex.Message);
}
}

[HttpGet("{key}")]
public async Task<ActionResult<JsonNode>> GetFile(string key)
{
logger.LogInformation("Запрошен файл: {key}", key);
try
{
var node = await s3Service.DownloadFile(key);
return Ok(node);
}
catch (Exception ex)
{
logger.LogError(ex, "Ошибка при скачивании файла {key}", key);
return BadRequest(ex.Message);
}
}
}
46 changes: 46 additions & 0 deletions EventSink1/Controllers/SnsSubscriberController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Amazon.SimpleNotificationService.Util;
using EventSink1.Storage;
using Microsoft.AspNetCore.Mvc;
using System.Text;

namespace EventSink1.Controllers;

[ApiController]
[Route("api/sns")]
public class SnsSubscriberController(IS3Service s3Service, ILogger<SnsSubscriberController> logger) : ControllerBase
{
[HttpPost]
public async Task<IActionResult> ReceiveMessage()
{
logger.LogInformation("SNS webhook вызван");

try
{
using var reader = new StreamReader(Request.Body, Encoding.UTF8);
var jsonContent = await reader.ReadToEndAsync();

var snsMessage = Message.ParseMessage(jsonContent);

if (snsMessage.Type == "SubscriptionConfirmation")
{
logger.LogInformation("Получено подтверждение подписки");
using var httpClient = new HttpClient();
var response = await httpClient.GetAsync(snsMessage.SubscribeURL);
logger.LogInformation("Подписка подтверждена: {status}", response.StatusCode);
return Ok();
}

if (snsMessage.Type == "Notification")
{
await s3Service.UploadFile(snsMessage.MessageText);
logger.LogInformation("Сообщение успешно сохранено в S3");
}
}
catch (Exception ex)
{
logger.LogError(ex, "Ошибка при обработке SNS сообщения");
}

return Ok();
}
}
25 changes: 25 additions & 0 deletions EventSink1/EventSink1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>29d94b31-07bf-4de9-b545-da17884e78db</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="4.0.23.3" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="4.0.2.33" />
<PackageReference Include="LocalStack.Aspire.Hosting" Version="13.1.0" />
<PackageReference Include="LocalStack.Client" Version="2.0.0" />
<PackageReference Include="LocalStack.Client.Extensions" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Patient\Patient.ServiceDefaults\PatientApp.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
33 changes: 33 additions & 0 deletions EventSink1/Messaging/SnsSubscriptionService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Amazon.SimpleNotificationService;
using Amazon.SimpleNotificationService.Model;
using System.Net;

namespace EventSink1.Messaging;

public class SnsSubscriptionService(IAmazonSimpleNotificationService snsClient, IConfiguration configuration, ILogger<SnsSubscriptionService> logger)
{
private readonly string _topicArn = configuration["AWS:Resources:SNSTopicArn"]
?? throw new KeyNotFoundException("SNSTopicArn not found in configuration");

public async Task SubscribeEndpoint()
{
logger.LogInformation("Отправка запроса на подписку к {topic}", _topicArn);

var endpoint = configuration["AWS:Resources:SNSUrl"] ?? "http://localhost:4566";

var request = new SubscribeRequest
{
TopicArn = _topicArn,
Protocol = "http",
Endpoint = $"{endpoint}/api/sns", // вебхук
ReturnSubscriptionArn = true
};

var response = await snsClient.SubscribeAsync(request);

if (response.HttpStatusCode == HttpStatusCode.OK)
logger.LogInformation("Запрос на подписку отправлен успешно. Ожидаем подтверждения.");
else
logger.LogError("Ошибка подписки на SNS");
}
}
29 changes: 29 additions & 0 deletions EventSink1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using EventSink1;
using LocalStack.Client.Extensions;
using PatientApp.ServiceDefaults;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();

builder.Services.AddLocalStack(builder.Configuration);

builder.AddConsumer();
builder.AddS3();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

await app.UseConsumer();
await app.UseS3();

app.MapControllers();
app.Run();
41 changes: 41 additions & 0 deletions EventSink1/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5142"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7160;http://localhost:5142"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:8673",
"sslPort": 44331
}
}
}
11 changes: 11 additions & 0 deletions EventSink1/Storage/IS3Service.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Text.Json.Nodes;

namespace EventSink1.Storage;

public interface IS3Service
{
public Task EnsureBucketExists();
public Task UploadFile(string jsonContent);
public Task<List<string>> GetFileList();
public Task<JsonNode> DownloadFile(string key);
}
Loading
Loading