From 5b961e5b18d2e5d7ef96d5246e0acccab8afafd2 Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Mon, 22 Sep 2025 23:13:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D1=91=D1=81=20Ab?= =?UTF-8?q?stractions=20=D0=B2=20=D0=B4=D1=80=D1=83=D0=B3=D0=BE=D0=B9=20na?= =?UTF-8?q?mespace=20=D0=B8=20=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IPlugin.cs | 2 +- .../ModeusScheduleRequestDTO.cs | 2 +- .../SfeduSchedule.Abstractions.csproj | 0 SfeduSchedule.Plugin.Sample/Plugin.cs | 2 +- .../SfeduSchedule.Plugin.Sample.csproj | 4 +--- SfeduSchedule.sln | 2 +- SfeduSchedule/Controllers/ScheduleController.cs | 3 ++- SfeduSchedule/Playwright/MicrosoftLoginHelper.cs | 2 +- SfeduSchedule/PluginLoader.cs | 4 ++-- SfeduSchedule/Program.cs | 8 +++++++- SfeduSchedule/Services/ModeusService.cs | 6 +++--- SfeduSchedule/SfeduSchedule.csproj | 2 +- 12 files changed, 21 insertions(+), 16 deletions(-) rename {SfeduSchedule.Plugin.Abstractions => SfeduSchedule.Abstractions}/IPlugin.cs (91%) rename {SfeduSchedule.Plugin.Abstractions => SfeduSchedule.Abstractions}/ModeusScheduleRequestDTO.cs (98%) rename SfeduSchedule.Plugin.Abstractions/SfeduSchedule.Plugin.Abstractions.csproj => SfeduSchedule.Abstractions/SfeduSchedule.Abstractions.csproj (100%) diff --git a/SfeduSchedule.Plugin.Abstractions/IPlugin.cs b/SfeduSchedule.Abstractions/IPlugin.cs similarity index 91% rename from SfeduSchedule.Plugin.Abstractions/IPlugin.cs rename to SfeduSchedule.Abstractions/IPlugin.cs index ef08039..4f5325c 100644 --- a/SfeduSchedule.Plugin.Abstractions/IPlugin.cs +++ b/SfeduSchedule.Abstractions/IPlugin.cs @@ -1,4 +1,4 @@ -namespace SfeduSchedule.Plugin.Abstractions; +namespace SfeduSchedule.Abstractions; // Базовый контракт плагина (общий для хоста и плагинов) public interface IPlugin diff --git a/SfeduSchedule.Plugin.Abstractions/ModeusScheduleRequestDTO.cs b/SfeduSchedule.Abstractions/ModeusScheduleRequestDTO.cs similarity index 98% rename from SfeduSchedule.Plugin.Abstractions/ModeusScheduleRequestDTO.cs rename to SfeduSchedule.Abstractions/ModeusScheduleRequestDTO.cs index 4f2b582..acc06bf 100644 --- a/SfeduSchedule.Plugin.Abstractions/ModeusScheduleRequestDTO.cs +++ b/SfeduSchedule.Abstractions/ModeusScheduleRequestDTO.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace SfeduSchedule.Plugin.Abstractions; +namespace SfeduSchedule.Abstractions; /// /// DTO для запроса расписания в Modeus. diff --git a/SfeduSchedule.Plugin.Abstractions/SfeduSchedule.Plugin.Abstractions.csproj b/SfeduSchedule.Abstractions/SfeduSchedule.Abstractions.csproj similarity index 100% rename from SfeduSchedule.Plugin.Abstractions/SfeduSchedule.Plugin.Abstractions.csproj rename to SfeduSchedule.Abstractions/SfeduSchedule.Abstractions.csproj diff --git a/SfeduSchedule.Plugin.Sample/Plugin.cs b/SfeduSchedule.Plugin.Sample/Plugin.cs index 64cc96e..1761fb1 100644 --- a/SfeduSchedule.Plugin.Sample/Plugin.cs +++ b/SfeduSchedule.Plugin.Sample/Plugin.cs @@ -1,5 +1,5 @@ using Microsoft.AspNetCore.Mvc; -using SfeduSchedule.Plugin.Abstractions; +using SfeduSchedule.Abstractions; namespace SfeduSchedule.Plugin.Sample; diff --git a/SfeduSchedule.Plugin.Sample/SfeduSchedule.Plugin.Sample.csproj b/SfeduSchedule.Plugin.Sample/SfeduSchedule.Plugin.Sample.csproj index 0a44fa7..dc7d7eb 100644 --- a/SfeduSchedule.Plugin.Sample/SfeduSchedule.Plugin.Sample.csproj +++ b/SfeduSchedule.Plugin.Sample/SfeduSchedule.Plugin.Sample.csproj @@ -12,9 +12,7 @@ - - - + diff --git a/SfeduSchedule.sln b/SfeduSchedule.sln index 35476ce..c832b11 100644 --- a/SfeduSchedule.sln +++ b/SfeduSchedule.sln @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule", "SfeduSchedule\SfeduSchedule.csproj", "{57B088A7-D7E2-4B5D-82A4-A3070A78A3E4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule.Plugin.Abstractions", "SfeduSchedule.Plugin.Abstractions\SfeduSchedule.Plugin.Abstractions.csproj", "{B2E8DAD7-7373-4155-B230-4E53DFC04445}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule.Abstractions", "SfeduSchedule.Abstractions\SfeduSchedule.Abstractions.csproj", "{B2E8DAD7-7373-4155-B230-4E53DFC04445}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule.Plugin.Sample", "SfeduSchedule.Plugin.Sample\SfeduSchedule.Plugin.Sample.csproj", "{B2B6D730-46AE-40ED-815F-81176FB4E545}" EndProject diff --git a/SfeduSchedule/Controllers/ScheduleController.cs b/SfeduSchedule/Controllers/ScheduleController.cs index a02d05d..87a6b26 100644 --- a/SfeduSchedule/Controllers/ScheduleController.cs +++ b/SfeduSchedule/Controllers/ScheduleController.cs @@ -3,7 +3,7 @@ using System.Text.Json; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.RateLimiting; -using SfeduSchedule.Plugin.Abstractions; +using SfeduSchedule.Abstractions; using SfeduSchedule.Services; namespace SfeduSchedule.Controllers @@ -71,6 +71,7 @@ namespace SfeduSchedule.Controllers /// Неавторизованный [HttpGet] [Authorize(AuthenticationSchemes = "ApiKey")] + [DisableRateLimiting] [Route("getguid")] public async Task GetGuid(string fullname) { diff --git a/SfeduSchedule/Playwright/MicrosoftLoginHelper.cs b/SfeduSchedule/Playwright/MicrosoftLoginHelper.cs index 31e14d9..41a6fb3 100644 --- a/SfeduSchedule/Playwright/MicrosoftLoginHelper.cs +++ b/SfeduSchedule/Playwright/MicrosoftLoginHelper.cs @@ -65,4 +65,4 @@ public static class MicrosoftLoginHelper if (Regex.IsMatch(currentHost, "login\\.(microsoftonline|live)\\.com", RegexOptions.IgnoreCase)) throw new Exception("Авторизация не завершена: остались на странице Microsoft Login"); } -} +} \ No newline at end of file diff --git a/SfeduSchedule/PluginLoader.cs b/SfeduSchedule/PluginLoader.cs index e5ac290..17c5822 100644 --- a/SfeduSchedule/PluginLoader.cs +++ b/SfeduSchedule/PluginLoader.cs @@ -1,6 +1,6 @@ using System.Reflection; using System.Runtime.Loader; -using SfeduSchedule.Plugin.Abstractions; +using SfeduSchedule.Abstractions; namespace SfeduSchedule; @@ -50,7 +50,7 @@ public sealed class PluginLoadContext : AssemblyLoadContext } // Разрешаем управляемые зависимости плагина из его папки. - // Возвращаем null, чтобы отдать решение в Default ALC для общих сборок (например, SfeduSchedule.Plugin.Abstractions). + // Возвращаем null, чтобы отдать решение в Default ALC для общих сборок (например, SfeduSchedule.Abstractions). protected override Assembly? Load(AssemblyName assemblyName) { var path = _resolver.ResolveAssemblyToPath(assemblyName); diff --git a/SfeduSchedule/Program.cs b/SfeduSchedule/Program.cs index b1b13f6..9b0790f 100644 --- a/SfeduSchedule/Program.cs +++ b/SfeduSchedule/Program.cs @@ -18,6 +18,12 @@ string? tgChatId = configuration["TG_CHAT_ID"]; string? tgToken = configuration["TG_TOKEN"]; string updateJwtCron = configuration["UPDATE_JWT_CRON"] ?? "0 0 4 ? * *"; +// Если не указана TZ, ставим Europe/Moscow +if (string.IsNullOrEmpty(configuration["TZ"])) +{ + configuration["TZ"] = "Europe/Moscow"; +} + int permitLimit = int.TryParse(configuration["PERMIT_LIMIT"], out var parsedPermitLimit) ? parsedPermitLimit : 40; int timeLimit = int.TryParse(configuration["TIME_LIMIT"], out var parsedTimeLimit) ? parsedTimeLimit : 10; @@ -96,7 +102,7 @@ builder.Services.AddSwaggerGen(options => var mainXmlPath = Path.Combine(AppContext.BaseDirectory, mainXmlFile); options.IncludeXmlComments(mainXmlPath); - var pluginXmlFile = "SfeduSchedule.Plugin.Abstractions.xml"; + var pluginXmlFile = "SfeduSchedule.Abstractions.xml"; var pluginXmlPath = Path.Combine(AppContext.BaseDirectory, pluginXmlFile); options.IncludeXmlComments(pluginXmlPath); diff --git a/SfeduSchedule/Services/ModeusService.cs b/SfeduSchedule/Services/ModeusService.cs index 91e55b3..e33dbae 100644 --- a/SfeduSchedule/Services/ModeusService.cs +++ b/SfeduSchedule/Services/ModeusService.cs @@ -1,6 +1,6 @@ using System.Text.Json; using Microsoft.Net.Http.Headers; -using SfeduSchedule.Plugin.Abstractions; +using SfeduSchedule.Abstractions; namespace SfeduSchedule.Services { @@ -20,9 +20,9 @@ namespace SfeduSchedule.Services _httpClient.DefaultRequestHeaders.Add(HeaderNames.Authorization, $"Bearer {token}"); } - public async Task GetScheduleAsync(ModeusScheduleRequest msr, string TZ = "Europe/Moscow") + public async Task GetScheduleAsync(ModeusScheduleRequest msr) { - var request = new HttpRequestMessage(HttpMethod.Post, $"schedule-calendar-v2/api/calendar/events/search?tz={TZ}"); + var request = new HttpRequestMessage(HttpMethod.Post, $"schedule-calendar-v2/api/calendar/events/search?tz={_configuration["TZ"]!}"); request.Content = new StringContent(JsonSerializer.Serialize(msr, GlobalVariables.jsonSerializerOptions), System.Text.Encoding.UTF8, "application/json"); var response = await _httpClient.SendAsync(request); _logger.LogInformation("GetScheduleAsync: Ответ получен: {StatusCode}", response.StatusCode); diff --git a/SfeduSchedule/SfeduSchedule.csproj b/SfeduSchedule/SfeduSchedule.csproj index 3acf5e8..1c16d82 100644 --- a/SfeduSchedule/SfeduSchedule.csproj +++ b/SfeduSchedule/SfeduSchedule.csproj @@ -18,7 +18,7 @@ - +