Перенёс Abstractions в другой namespace и небольшие улучшения
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
namespace SfeduSchedule.Plugin.Abstractions;
|
namespace SfeduSchedule.Abstractions;
|
||||||
|
|
||||||
// Базовый контракт плагина (общий для хоста и плагинов)
|
// Базовый контракт плагина (общий для хоста и плагинов)
|
||||||
public interface IPlugin
|
public interface IPlugin
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace SfeduSchedule.Plugin.Abstractions;
|
namespace SfeduSchedule.Abstractions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DTO для запроса расписания в Modeus.
|
/// DTO для запроса расписания в Modeus.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SfeduSchedule.Plugin.Abstractions;
|
using SfeduSchedule.Abstractions;
|
||||||
|
|
||||||
namespace SfeduSchedule.Plugin.Sample;
|
namespace SfeduSchedule.Plugin.Sample;
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Даёт доступ к Microsoft.AspNetCore.* (ControllerBase и т.п.) -->
|
<ProjectReference Include="..\SfeduSchedule.Abstractions\SfeduSchedule.Abstractions.csproj" />
|
||||||
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
|
|
||||||
<ProjectReference Include="..\SfeduSchedule.Plugin.Abstractions\SfeduSchedule.Plugin.Abstractions.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule", "SfeduSchedule\SfeduSchedule.csproj", "{57B088A7-D7E2-4B5D-82A4-A3070A78A3E4}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule", "SfeduSchedule\SfeduSchedule.csproj", "{57B088A7-D7E2-4B5D-82A4-A3070A78A3E4}"
|
||||||
EndProject
|
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
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule.Plugin.Sample", "SfeduSchedule.Plugin.Sample\SfeduSchedule.Plugin.Sample.csproj", "{B2B6D730-46AE-40ED-815F-81176FB4E545}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule.Plugin.Sample", "SfeduSchedule.Plugin.Sample\SfeduSchedule.Plugin.Sample.csproj", "{B2B6D730-46AE-40ED-815F-81176FB4E545}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Text.Json;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.RateLimiting;
|
using Microsoft.AspNetCore.RateLimiting;
|
||||||
using SfeduSchedule.Plugin.Abstractions;
|
using SfeduSchedule.Abstractions;
|
||||||
using SfeduSchedule.Services;
|
using SfeduSchedule.Services;
|
||||||
|
|
||||||
namespace SfeduSchedule.Controllers
|
namespace SfeduSchedule.Controllers
|
||||||
@@ -71,6 +71,7 @@ namespace SfeduSchedule.Controllers
|
|||||||
/// <response code="401">Неавторизованный</response>
|
/// <response code="401">Неавторизованный</response>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize(AuthenticationSchemes = "ApiKey")]
|
[Authorize(AuthenticationSchemes = "ApiKey")]
|
||||||
|
[DisableRateLimiting]
|
||||||
[Route("getguid")]
|
[Route("getguid")]
|
||||||
public async Task<IActionResult> GetGuid(string fullname)
|
public async Task<IActionResult> GetGuid(string fullname)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.Loader;
|
using System.Runtime.Loader;
|
||||||
using SfeduSchedule.Plugin.Abstractions;
|
using SfeduSchedule.Abstractions;
|
||||||
|
|
||||||
namespace SfeduSchedule;
|
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)
|
protected override Assembly? Load(AssemblyName assemblyName)
|
||||||
{
|
{
|
||||||
var path = _resolver.ResolveAssemblyToPath(assemblyName);
|
var path = _resolver.ResolveAssemblyToPath(assemblyName);
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ string? tgChatId = configuration["TG_CHAT_ID"];
|
|||||||
string? tgToken = configuration["TG_TOKEN"];
|
string? tgToken = configuration["TG_TOKEN"];
|
||||||
string updateJwtCron = configuration["UPDATE_JWT_CRON"] ?? "0 0 4 ? * *";
|
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 permitLimit = int.TryParse(configuration["PERMIT_LIMIT"], out var parsedPermitLimit) ? parsedPermitLimit : 40;
|
||||||
int timeLimit = int.TryParse(configuration["TIME_LIMIT"], out var parsedTimeLimit) ? parsedTimeLimit : 10;
|
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);
|
var mainXmlPath = Path.Combine(AppContext.BaseDirectory, mainXmlFile);
|
||||||
options.IncludeXmlComments(mainXmlPath);
|
options.IncludeXmlComments(mainXmlPath);
|
||||||
|
|
||||||
var pluginXmlFile = "SfeduSchedule.Plugin.Abstractions.xml";
|
var pluginXmlFile = "SfeduSchedule.Abstractions.xml";
|
||||||
var pluginXmlPath = Path.Combine(AppContext.BaseDirectory, pluginXmlFile);
|
var pluginXmlPath = Path.Combine(AppContext.BaseDirectory, pluginXmlFile);
|
||||||
options.IncludeXmlComments(pluginXmlPath);
|
options.IncludeXmlComments(pluginXmlPath);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
using SfeduSchedule.Plugin.Abstractions;
|
using SfeduSchedule.Abstractions;
|
||||||
|
|
||||||
namespace SfeduSchedule.Services
|
namespace SfeduSchedule.Services
|
||||||
{
|
{
|
||||||
@@ -20,9 +20,9 @@ namespace SfeduSchedule.Services
|
|||||||
_httpClient.DefaultRequestHeaders.Add(HeaderNames.Authorization, $"Bearer {token}");
|
_httpClient.DefaultRequestHeaders.Add(HeaderNames.Authorization, $"Bearer {token}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string?> GetScheduleAsync(ModeusScheduleRequest msr, string TZ = "Europe/Moscow")
|
public async Task<string?> 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");
|
request.Content = new StringContent(JsonSerializer.Serialize(msr, GlobalVariables.jsonSerializerOptions), System.Text.Encoding.UTF8, "application/json");
|
||||||
var response = await _httpClient.SendAsync(request);
|
var response = await _httpClient.SendAsync(request);
|
||||||
_logger.LogInformation("GetScheduleAsync: Ответ получен: {StatusCode}", response.StatusCode);
|
_logger.LogInformation("GetScheduleAsync: Ответ получен: {StatusCode}", response.StatusCode);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SfeduSchedule.Plugin.Abstractions\SfeduSchedule.Plugin.Abstractions.csproj" />
|
<ProjectReference Include="..\SfeduSchedule.Abstractions\SfeduSchedule.Abstractions.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user