Compare commits

...

24 Commits

Author SHA1 Message Date
3f9a11b17d build: update ref
All checks were successful
Build and Deploy Docker Container / build-and-deploy (push) Successful in 2m8s
2025-09-04 18:44:47 +03:00
f95d8d3420 build: update ref
All checks were successful
Build and Deploy Docker Container / build-and-deploy (push) Successful in 2m49s
2025-09-04 00:02:06 +03:00
e439183645 feat: add OpenTelemetry support for monitoring
All checks were successful
Build and Deploy Docker Container / build-and-deploy (push) Successful in 4m21s
2025-08-05 16:57:45 +03:00
785ab935c6 build: remove code analyze build 2025-08-05 16:56:38 +03:00
f45f846b37 fix: add properties 2025-08-05 16:38:07 +03:00
46046d589e feat: switching to logging via OpenTelemetry 2025-08-05 15:47:35 +03:00
802acad570 build: update ref 2025-08-05 12:55:22 +03:00
dd4d3397eb build: set localhost hosting 2025-08-05 12:44:04 +03:00
3d92d1b72d build: remove code analyze 2025-08-05 12:43:34 +03:00
c550967ecc fix: ExcelPackage.License instead ExcelPackage.LicenseContext
Some checks failed
.NET Test Pipeline / build (push) Failing after 6s
Build and Deploy Docker Container / build-and-deploy (push) Successful in 2m7s
2025-05-16 10:49:23 +03:00
38bba2aab2 fix: obsolete excel package
Some checks failed
.NET Test Pipeline / build (push) Failing after 6s
Build and Deploy Docker Container / build-and-deploy (push) Successful in 2m15s
2025-05-16 02:13:26 +03:00
104a1cff41 build: update ref
Some checks failed
.NET Test Pipeline / build (push) Failing after 22s
Build and Deploy Docker Container / build-and-deploy (push) Failing after 2m16s
2025-05-16 02:07:30 +03:00
95692a6a1f build: update ref
All checks were successful
.NET Test Pipeline / build (push) Successful in 2m5s
Build and Deploy Docker Container / build-and-deploy (push) Successful in 2m55s
2025-03-11 09:37:58 +03:00
13eb3c0033 fix: remove convert universal time
All checks were successful
.NET Test Pipeline / build (push) Successful in 1m23s
Build and Deploy Docker Container / build-and-deploy (push) Successful in 1m30s
2025-02-14 17:47:56 +03:00
f6d1543108 docs: fix code character
Some checks failed
.NET Test Pipeline / build (push) Has been cancelled
Build and Deploy Docker Container / build-and-deploy (push) Has been cancelled
Signed-off-by: Polianin Nikita <wesser@noreply.git.winsomnia.net>
2025-02-13 16:40:33 +03:00
a4721c9739 build: add configuration Release
All checks were successful
Build and Deploy Docker Container / build-and-deploy (push) Successful in 1m47s
.NET Test Pipeline / build (push) Successful in 1m51s
Signed-off-by: Polianin Nikita <wesser@noreply.git.winsomnia.net>
2025-02-12 09:35:55 +03:00
46bbc34956 refactor: fix error WHITESPACE and FINALNEWLINE
All checks were successful
.NET Test Pipeline / build (pull_request) Successful in 1m37s
.NET Test Pipeline / build (push) Successful in 1m33s
Build and Deploy Docker Container / build-and-deploy (push) Successful in 2m18s
2025-02-11 17:13:13 +03:00
047ccfa754 fix: correct calculate next occurrence
Some checks failed
.NET Test Pipeline / build (pull_request) Failing after 44s
2025-02-11 16:35:56 +03:00
b0d9a67c1c refacotr: clean code 2025-02-11 15:36:55 +03:00
3eb043b24c build: fix code style with CRLF
Some checks failed
.NET Test Pipeline / build (pull_request) Failing after 42s
2025-02-11 15:29:43 +03:00
4cd476764d build: fix secrets
Some checks failed
.NET Test Pipeline / build (pull_request) Failing after 43s
2025-02-11 15:25:47 +03:00
90b4662dda Release 1.0.0
Some checks failed
.NET Test Pipeline / build (pull_request) Failing after 8s
2025-02-11 15:16:51 +03:00
e7edc79ebc build: instead build run analyze 2025-02-11 15:04:38 +03:00
aabeed0aa5 feat: add backend version to swagger 2025-02-10 16:07:51 +03:00
47 changed files with 218 additions and 223 deletions

View File

@@ -12,7 +12,7 @@ indent_style = space
tab_width = 4
# Предпочтения для новых строк
end_of_line = crlf
end_of_line = unset
insert_final_newline = false
#### Действия кода .NET ####
@@ -244,7 +244,7 @@ dotnet_naming_style.begins_with_i.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
end_of_line = unset
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion

View File

@@ -1,29 +0,0 @@
name: .NET Test Pipeline
on:
pull_request:
push:
branches:
[master, 'release/*']
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build the solution
run: dotnet build --configuration Release
- name: Run tests
run: dotnet test --configuration Release --no-build --no-restore --verbosity normal

View File

@@ -3,7 +3,7 @@
on:
push:
branches:
[master, 'release/*']
[master]
jobs:
build-and-deploy:
@@ -24,7 +24,7 @@ jobs:
- name: Build and push Docker image
run: |
docker build --build-arg NUGET_USERNAME=${{ secrets.NUGET_USERNAME }} --build-arg NUGET_PASSWORD=${{ secrets.NUGET_PASSWORD }} -t ${{ secrets.DOCKER_USERNAME }}/mirea-backend:latest .
docker build --build-arg NUGET_USERNAME=${{ secrets.NUGET_USERNAME }} --build-arg NUGET_PASSWORD=${{ secrets.NUGET_PASSWORD }} --build-arg NUGET_ADDRESS=${{ secrets.NUGET_ADDRESS }} -t ${{ secrets.DOCKER_USERNAME }}/mirea-backend:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/mirea-backend:latest
- name: Start ssh-agent
@@ -64,7 +64,7 @@ jobs:
docker pull $DOCKER_IMAGE &&
docker stop mirea-backend || true &&
docker rm mirea-backend || true &&
docker run -d --name mirea-backend -p 8085:8080 \
docker run -d --name mirea-backend -p 127.0.0.1:8085:8080 \
--restart=on-failure:10 \
-v mirea-data:/data \
-e PATH_TO_SAVE=$PATH_TO_SAVE \

View File

@@ -1,13 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Winsomnia</Company>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.3.0</AssemblyVersion>
<FileVersion>1.0.3.0</FileVersion>
<AssemblyName>Mirea.Api.Dto</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>

View File

@@ -19,4 +19,4 @@ public enum OAuthProvider
/// OAuth provider for Mail.ru.
/// </summary>
MailRu
}
}

View File

@@ -29,4 +29,4 @@ public class PasswordPolicy
/// Gets or sets a value indicating whether at least one special character is required in the password.
/// </summary>
public bool RequireSpecialCharacter { get; set; }
}
}

View File

@@ -14,4 +14,4 @@ public enum TwoFactorAuthentication
/// TOTP (Time-based One-Time Password) is required for additional verification.
/// </summary>
TotpRequired,
}
}

View File

@@ -24,15 +24,16 @@ public class LoggingRequest
public string? LogFilePath { get; set; }
/// <summary>
/// Gets or sets the API key for integrating with Seq, a log aggregation service.
/// If provided, logs will be sent to a Seq server using this API key.
/// Gets or sets the endpoint URL for the OpenTelemetry Collector.
/// This property specifies the OTLP endpoint to which logs will be sent.
/// </summary>
public string? ApiKeySeq { get; set; }
public string? OpenTelemetryEndpoint { get; set; }
/// <summary>
/// Gets or sets the server URL for the Seq logging service.
/// This property specifies the Seq server endpoint to which logs will be sent.
/// If <see cref="ApiKeySeq"/> is provided, logs will be sent to this server.
/// Gets or sets the logical service name used for OpenTelemetry logging.
/// This name will be attached to log entries as the "service.name" resource attribute,
/// allowing logs to be grouped and filtered by service in backends like Loki or Grafana.
/// </summary>
public string? ApiServerSeq { get; set; }
public string? OpenTelemetryServiceName { get; set; }
}

View File

@@ -27,4 +27,4 @@ public class CreateUserRequest
[Required]
[MinLength(2)]
public required string Password { get; set; }
}
}

View File

@@ -34,4 +34,4 @@ public class ScheduleRequest
/// Gets or sets an array of lesson type IDs.
/// </summary>
public int[]? LessonType { get; set; } = null;
}
}

View File

@@ -28,4 +28,4 @@ public class CampusDetailsResponse
/// Gets or sets the address of the campus (optional).
/// </summary>
public string? Address { get; set; }
}
}

View File

@@ -114,4 +114,4 @@ public class ScheduleResponse
/// Gets or sets the links to online meetings for the schedule entry.
/// </summary>
public required IEnumerable<string?> LinkToMeet { get; set; }
}
}

View File

@@ -12,11 +12,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Elements of the solution",
.env = .env
.gitattributes = .gitattributes
.gitignore = .gitignore
.gitea\workflows\deploy-stage.yaml = .gitea\workflows\deploy-stage.yaml
Directory.Build.props = Directory.Build.props
Dockerfile = Dockerfile
LICENSE.txt = LICENSE.txt
README.md = README.md
.gitea\workflows\test.yaml = .gitea\workflows\test.yaml
.github\workflows\release-version.yml = .github\workflows\release-version.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiDto", "ApiDto\ApiDto.csproj", "{0335FA36-E137-453F-853B-916674C168FE}"

14
Directory.Build.props Normal file
View File

@@ -0,0 +1,14 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Company>Winsomnia</Company>
<Version>1.1.0</Version>
<AssemblyVersion>1.1.3.0</AssemblyVersion>
<FileVersion>1.1.3.0</FileVersion>
</PropertyGroup>
</Project>

View File

@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
LABEL company="Winsomnia"
LABEL maintainer.name="Wesser" maintainer.email="support@winsomnia.net"
WORKDIR /app
@@ -13,10 +13,14 @@ COPY . .
ARG NUGET_USERNAME
ARG NUGET_PASSWORD
ARG NUGET_ADDRESS
ENV NUGET_USERNAME=$NUGET_USERNAME
ENV NUGET_PASSWORD=$NUGET_PASSWORD
ENV NUGET_ADDRESS=$NUGET_ADDRESS
RUN dotnet restore ./Backend.sln --configfile nuget.config
RUN dotnet nuget add source --name="Winsomnia" --username ${NUGET_USERNAME} --store-password-in-clear-text --password ${NUGET_PASSWORD} ${NUGET_ADDRESS}
RUN dotnet restore ./Backend.sln
WORKDIR /app
WORKDIR /src
RUN dotnet publish ./Endpoint/Endpoint.csproj -c Release --self-contained false -p:PublishSingleFile=false -o /app

View File

@@ -16,4 +16,4 @@ public static class CronUpdateSkipConverter
}).ToList();
public static List<ScheduleSettings.CronUpdateSkip> ConvertFromDto(this IEnumerable<Dto.Common.CronUpdateSkip> pairPeriod) =>
pairPeriod.Select(x => x.Get()).ToList();
}
}

View File

@@ -11,4 +11,4 @@ public static class PairPeriodTimeConverter
public static Dictionary<int, ScheduleSettings.PairPeriodTime> ConvertFromDto(this IDictionary<int, Dto.Common.PairPeriodTime> pairPeriod) =>
pairPeriod.ToDictionary(kvp => kvp.Key, kvp => new ScheduleSettings.PairPeriodTime(kvp.Value.Start, kvp.Value.End));
}
}

View File

@@ -45,32 +45,31 @@ public static class CronUpdateSkipService
if (depth <= 0)
return [];
currentDate ??= DateOnly.FromDateTime(DateTime.Now);
DateTimeOffset nextRunTime = currentDate.Value.ToDateTime(TimeOnly.FromDateTime(DateTime.Now));
DateTimeOffset nextRunTime = (currentDate?.ToDateTime(TimeOnly.MinValue) ?? DateTime.Now);
List<DateTimeOffset> result = [];
do
{
var lastSkip = data.FilterDateEntry(nextRunTime.DateTime).LastOrDefault();
var lastSkippedEntry = data.FilterDateEntry(nextRunTime.DateTime).LastOrDefault();
if (lastSkip is { Start: not null, End: not null })
nextRunTime = new DateTimeOffset(lastSkip.End.Value.AddDays(1), new TimeOnly(0, 0, 0), TimeSpan.Zero);
else if (lastSkip.Date.HasValue)
nextRunTime = new DateTimeOffset(lastSkip.Date.Value.AddDays(1), new TimeOnly(0, 0, 0), TimeSpan.Zero);
if (lastSkippedEntry is { Start: not null, End: not null })
nextRunTime = lastSkippedEntry.End.Value.ToDateTime(TimeOnly.MinValue).AddDays(1);
else if (lastSkippedEntry.Date.HasValue)
nextRunTime = lastSkippedEntry.Date.Value.ToDateTime(TimeOnly.MinValue).AddDays(1);
var next = expression.GetNextOccurrence(nextRunTime.ToUniversalTime(), TimeZoneInfo.Local);
var nextOccurrence = expression.GetNextOccurrence(nextRunTime.AddMinutes(-1), TimeZoneInfo.Local);
if (!next.HasValue)
if (!nextOccurrence.HasValue)
return result;
nextRunTime = next.Value;
if (data.FilterDateEntry(nextRunTime.DateTime).Any())
if (data.FilterDateEntry(nextOccurrence.Value.DateTime).Count != 0)
{
nextRunTime = nextOccurrence.Value.AddDays(1);
continue;
}
result.Add(nextRunTime);
nextRunTime = nextRunTime.AddMinutes(1);
result.Add(nextOccurrence.Value);
nextRunTime = nextOccurrence.Value.AddMinutes(1);
} while (result.Count < depth);

View File

@@ -64,4 +64,4 @@ public static class JwtConfiguration
};
});
}
}
}

View File

@@ -8,7 +8,7 @@ using Serilog.Context;
using Serilog.Events;
using Serilog.Filters;
using Serilog.Formatting.Compact;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -46,9 +46,18 @@ public static class LoggerConfiguration
rollingInterval: RollingInterval.Day);
}
if (generalConfig != null && !string.IsNullOrEmpty(generalConfig.ApiServerSeq) &&
Uri.TryCreate(generalConfig.ApiServerSeq, UriKind.Absolute, out var _))
configuration.WriteTo.Seq(generalConfig.ApiServerSeq, apiKey: generalConfig.ApiKeySeq);
if (!string.IsNullOrEmpty(generalConfig?.OpenTelemetryEndpoint)
&& !string.IsNullOrEmpty(generalConfig.OpenTelemetryServiceName))
configuration.WriteTo.OpenTelemetry(options =>
{
options.Endpoint = generalConfig.OpenTelemetryEndpoint;
options.Protocol = Serilog.Sinks.OpenTelemetry.OtlpProtocol.Grpc;
options.ResourceAttributes = new Dictionary<string, object>
{
["service.name"] = generalConfig.OpenTelemetryServiceName,
["deployment.environment"] = context.HostingEnvironment.EnvironmentName
};
});
configuration
.MinimumLevel.Override("Microsoft.AspNetCore.Hosting", LogEventLevel.Warning)
@@ -99,4 +108,4 @@ public static class LoggerConfiguration
};
});
}
}
}

View File

@@ -2,4 +2,4 @@
public interface ISaveSettings
{
void SaveSetting();
}
}

View File

@@ -9,13 +9,13 @@ public class LogSettings : IIsConfigured
public bool EnableLogToFile { get; set; }
public string? LogFilePath { get; set; }
public string? LogFileName { get; set; }
public string? ApiKeySeq { get; set; }
public string? ApiServerSeq { get; set; }
public string? OpenTelemetryEndpoint { get; set; }
public string? OpenTelemetryServiceName { get; set; }
public bool IsConfigured()
{
return !EnableLogToFile ||
!string.IsNullOrEmpty(LogFilePath) &&
!string.IsNullOrEmpty(LogFileName);
return !EnableLogToFile
|| !string.IsNullOrEmpty(LogFilePath)
&& !string.IsNullOrEmpty(LogFileName);
}
}

View File

@@ -4,6 +4,8 @@ using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Diagnostics;
using System.Reflection;
namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions;
@@ -19,7 +21,7 @@ public class ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) :
{
var info = new OpenApiInfo()
{
Title = "MIREA Schedule Web API",
Title = $"MIREA Schedule Web API ({FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion})",
Version = description.ApiVersion.ToString(),
Description = "This API provides a convenient interface for retrieving data stored in the database. " +
"Special attention was paid to the lightweight and easy transfer of all necessary data. Made by the Winsomnia team.",

View File

@@ -23,6 +23,7 @@ using Mirea.Api.Security.Services;
using MySqlConnector;
using Npgsql;
using Serilog;
using Serilog.Sinks.OpenTelemetry;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
@@ -434,26 +435,32 @@ public class SetupController(
}
};
if (!string.IsNullOrEmpty(request?.ApiServerSeq))
if (!string.IsNullOrEmpty(request?.OpenTelemetryEndpoint)
&& !string.IsNullOrEmpty(request.OpenTelemetryServiceName))
{
settings.ApiServerSeq = request.ApiServerSeq;
settings.ApiKeySeq = request.ApiKeySeq;
settings.OpenTelemetryEndpoint = request.OpenTelemetryEndpoint;
settings.OpenTelemetryServiceName = request.OpenTelemetryServiceName;
try
{
Log.Logger = new LoggerConfiguration()
.WriteTo.Seq(settings.ApiServerSeq, apiKey: settings.ApiKeySeq)
using var innerLogger = new LoggerConfiguration()
.WriteTo.OpenTelemetry(options =>
{
options.Endpoint = settings.OpenTelemetryEndpoint;
options.Protocol = OtlpProtocol.Grpc;
options.ResourceAttributes = new Dictionary<string, object>
{
["service.name"] = settings.OpenTelemetryServiceName,
["deployment.environment"] = "test"
};
})
.CreateLogger();
Log.Warning("Testing configuration Seq.");
innerLogger.Warning("🚀 Testing OpenTelemetry log delivery.");
}
catch
catch (Exception ex)
{
// ignoring
}
finally
{
Log.CloseAndFlush();
Console.WriteLine("Error sending log to OTEL Collector: " + ex.Message);
}
}
@@ -477,8 +484,8 @@ public class SetupController(
EnableLogToFile = settings.EnableLogToFile,
LogFileName = settings.LogFileName,
LogFilePath = settings.LogFilePath,
ApiKeySeq = settings.ApiKeySeq,
ApiServerSeq = settings.ApiServerSeq
OpenTelemetryEndpoint = settings.OpenTelemetryEndpoint,
OpenTelemetryServiceName = settings.OpenTelemetryServiceName
});
return true;

View File

@@ -315,4 +315,4 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
return Ok(password);
}
}
}

View File

@@ -203,10 +203,10 @@ public class ScheduleController(ILogger<ScheduleController> logger, IOptionsSnap
{
try
{
using var scope = scopeFactory.CreateScope();
using var scope = scopeFactory.CreateScope();
var sync = (ScheduleSynchronizer)ActivatorUtilities.GetServiceOrCreateInstance(scope.ServiceProvider, typeof(ScheduleSynchronizer));
await sync.StartSync(filePaths, CancellationToken.None);
await sync.StartSync(filePaths, CancellationToken.None);
}
catch (Exception ex)
{

View File

@@ -52,7 +52,7 @@ public class ImportController(IMediator mediator, IOptionsSnapshot<GeneralConfig
LessonTypeIds = request.LessonType
})).Schedules.ToList();
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
ExcelPackage.License.SetNonCommercialOrganization("Winsomnia");
using var package = new ExcelPackage();
var worksheet = package.Workbook.Worksheets.Add("Расписание");

View File

@@ -1,24 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Winsomnia</Company>
<Version>1.0-rc7</Version>
<AssemblyVersion>1.0.2.7</AssemblyVersion>
<FileVersion>1.0.2.7</FileVersion>
<AssemblyName>Mirea.Api.Endpoint</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<OutputType>Exe</OutputType>
<InvariantGlobalization>false</InvariantGlobalization>
<UserSecretsId>65cea060-88bf-4e35-9cfb-18fc996a8f05</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
<SignAssembly>False</SignAssembly>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DocumentationFile>docs.xml</DocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
<ItemGroup>
@@ -26,49 +16,67 @@
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.System" Version="9.0.0" />
<PackageReference Include="Cronos" Version="0.9.0" />
<PackageReference Include="EPPlus" Version="7.5.3" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.12" />
<PackageReference Include="Microsoft.Build.Framework" Version="17.12.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1">
<PackageReference Include="Cronos" Version="0.11.1" />
<PackageReference Include="EPPlus" Version="8.1.0" />
<PackageReference Include="EPPlus.System.Drawing" Version="8.1.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.12.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.19" />
<PackageReference Include="Microsoft.Bcl.Cryptography" Version="9.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.1">
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.3.1" />
<PackageReference Include="Mirea.Tools.Schedule.Parser" Version="1.2.5" />
<PackageReference Include="Mirea.Tools.Schedule.WebParser" Version="1.0.6" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.8" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.14.0" />
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="9.0.8" />
<PackageReference Include="Mirea.Tools.Schedule.Parser" Version="1.2.8" />
<PackageReference Include="Mirea.Tools.Schedule.WebParser" Version="1.0.7" />
<PackageReference Include="OpenTelemetry" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
<PackageReference Include="QRCoder" Version="1.6.0" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" />
<PackageReference Include="StackExchange.Redis" Version="2.8.24" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageReference Include="System.CodeDom" Version="[8.0.0, 9.0.0)" />
<PackageReference Include="System.Composition" Version="[8.0.0, 9.0.0)" />
<PackageReference Include="System.Composition.AttributedModel" Version="9.0.1" />
<PackageReference Include="System.Composition.Convention" Version="9.0.1" />
<PackageReference Include="System.Composition.Hosting" Version="9.0.1" />
<PackageReference Include="System.Composition.Runtime" Version="9.0.1" />
<PackageReference Include="System.Composition.TypedParts" Version="9.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.1" />
<PackageReference Include="System.Drawing.Common" Version="9.0.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.1" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="9.0.1" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="9.0.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.1" />
<PackageReference Include="System.Threading.Channels" Version="[8.0.0, 9.0.0)" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="9.103.7" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.8" />
<PackageReference Include="Serilog.Sinks.OpenTelemetry" Version="4.2.0" />
<PackageReference Include="StackExchange.Redis" Version="2.9.11" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="9.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="9.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="9.0.4" />
<PackageReference Include="System.Composition" Version="9.0.8" />
<PackageReference Include="System.Composition.AttributedModel" Version="9.0.8" />
<PackageReference Include="System.Composition.Convention" Version="9.0.8" />
<PackageReference Include="System.Composition.Hosting" Version="9.0.8" />
<PackageReference Include="System.Composition.Runtime" Version="9.0.8" />
<PackageReference Include="System.Composition.TypedParts" Version="9.0.8" />
<PackageReference Include="System.Diagnostics.EventLog" Version="9.0.8" />
<PackageReference Include="System.Formats.Asn1" Version="9.0.8" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.14.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="9.0.8" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="9.0.8" />
<PackageReference Include="System.Text.Json" Version="9.0.8" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="9.103.9.3" />
</ItemGroup>
<ItemGroup>

View File

@@ -19,7 +19,12 @@ using Mirea.Api.Endpoint.Configuration.Model;
using Mirea.Api.Endpoint.Configuration.Validation;
using Mirea.Api.Endpoint.Configuration.Validation.Validators;
using Mirea.Api.Security.Services;
using OfficeOpenXml;
using OpenTelemetry.Exporter;
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using System;
using System.Collections.Generic;
using System.IO;
namespace Mirea.Api.Endpoint;
@@ -117,6 +122,34 @@ public class Program
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(PathBuilder.Combine("DataProtection")));
builder.Host.ConfigureServices((context, services) =>
{
var config = context.Configuration.Get<GeneralConfig>()?.LogSettings;
if (string.IsNullOrEmpty(config?.OpenTelemetryEndpoint)
|| string.IsNullOrEmpty(config.OpenTelemetryServiceName))
return;
services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics
.AddAspNetCoreInstrumentation()
.AddRuntimeInstrumentation()
.SetResourceBuilder(ResourceBuilder.CreateDefault()
.AddService(serviceName: config.OpenTelemetryServiceName)
.AddAttributes([
new KeyValuePair<string, object>("deployment.environment", context.HostingEnvironment.EnvironmentName),
new KeyValuePair<string, object>("host.name", Environment.MachineName)
]))
.AddOtlpExporter(options =>
{
options.Endpoint = new Uri(config.OpenTelemetryEndpoint);
options.Protocol = OtlpExportProtocol.Grpc;
});
});
});
var app = builder.Build();
app.UseForwardedHeaders();
@@ -158,6 +191,8 @@ public class Program
app.MapControllers();
ExcelPackage.License.SetNonCommercialOrganization("Winsomnia");
app.Run();
}
}

View File

@@ -86,12 +86,11 @@ To set up the `redirect URL` when registering and logging in using OAuth 2, use
**Where:**
- `{schema}` is the protocol you are using (`http` or `https').
- `{domain}` is your domain (for example, `mydomain.com ` or IP address).
- `{portString}` is a port string that is only needed if your application is running on a nonstandard port (for
- `{schema}` is the protocol you are using (`http` or `https`).
- `{domain}` is your domain (for example, `mydomain.com` or IP address).
- `{portString}` is a port string that is only needed if your application is running on a non-standard port (for
example, `:8080`). If you use standard ports (`80` for `http` and `443` for `https`), this parameter can be omitted.
- `{ACTUAL_SUB_PATH}` is the path to your API that you specify in the settings. If it ends with `/api', then don't add `
/api` at the end of the URL.
- `{ACTUAL_SUB_PATH}` is the path to your API that you specify in the settings. If it ends with `/api`, then don't add `/api` at the end of the URL.
**Examples:**

View File

@@ -13,4 +13,4 @@ public interface ICacheService
Task<T?> GetAsync<T>(string key, CancellationToken cancellationToken = default);
Task RemoveAsync(string key, CancellationToken cancellationToken = default);
}
}

View File

@@ -26,4 +26,4 @@ public class CookieOptions
internal void DropCookie(HttpContext context, string name) =>
SetCookie(context, name, "", DateTimeOffset.MinValue);
}
}

View File

@@ -1,13 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Winsomnia</Company>
<Version>1.1.3</Version>
<AssemblyVersion>1.1.3.3</AssemblyVersion>
<FileVersion>1.1.3.3</FileVersion>
<AssemblyName>Mirea.Api.Security</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<OutputType>Library</OutputType>
@@ -15,10 +8,9 @@
<ItemGroup>
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.8" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="System.Memory" Version="4.6.0" />
</ItemGroup>
</Project>

View File

@@ -1,22 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Winsomnia</Company>
<Version>1.0.3</Version>
<AssemblyVersion>1.0.3.3</AssemblyVersion>
<FileVersion>1.0.3.3</FileVersion>
<AssemblyName>Mirea.Api.DataAccess.Application</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.11.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
<PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageReference Include="FluentValidation" Version="12.0.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.0.0" />
<PackageReference Include="MediatR" Version="13.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.8" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,13 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Winsomnia</Company>
<Version>1.0.1</Version>
<AssemblyVersion>1.0.3.1</AssemblyVersion>
<FileVersion>1.0.3.1</FileVersion>
<AssemblyName>Mirea.Api.DataAccess.Domain</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
</PropertyGroup>

View File

@@ -386,4 +386,4 @@ namespace MysqlMigrations.Migrations
name: "Campus");
}
}
}
}

View File

@@ -80,4 +80,4 @@ namespace MysqlMigrations.Migrations
onDelete: ReferentialAction.SetNull);
}
}
}
}

View File

@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<BaseOutputPath>..\..\Persistence\bin\</BaseOutputPath>
</PropertyGroup>

View File

@@ -362,4 +362,4 @@ namespace PsqlMigrations.Migrations
name: "Campus");
}
}
}
}

View File

@@ -46,4 +46,4 @@ namespace PsqlMigrations.Migrations
onDelete: ReferentialAction.SetNull);
}
}
}
}

View File

@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<BaseOutputPath>..\..\Persistence\bin\</BaseOutputPath>
</PropertyGroup>

View File

@@ -361,4 +361,4 @@ namespace SqliteMigrations.Migrations
name: "Campus");
}
}
}
}

View File

@@ -46,4 +46,4 @@ namespace SqliteMigrations.Migrations
onDelete: ReferentialAction.SetNull);
}
}
}
}

View File

@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<BaseOutputPath>..\..\Persistence\bin\</BaseOutputPath>
</PropertyGroup>

View File

@@ -19,4 +19,4 @@ public static class ModelBuilderExtensions
var applyConcreteMethod = applyGenericMethod.MakeGenericMethod(entityType);
applyConcreteMethod.Invoke(modelBuilder, [configuration]);
}
}
}

View File

@@ -1,13 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Winsomnia</Company>
<Version>1.0.3</Version>
<AssemblyVersion>1.0.3.3</AssemblyVersion>
<FileVersion>1.0.3.3</FileVersion>
<AssemblyName>Mirea.Api.DataAccess.Persistence</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
</PropertyGroup>
@@ -16,14 +9,9 @@
<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.Sqlite" Version="9.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.1" />
<PackageReference Include="MySqlConnector" Version="2.4.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.2.efcore.9.0.0" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="winsomnia.net" value="https://git.winsomnia.net/api/packages/Winsomnia/nuget/index.json" />
</packageSources>
<packageSourceCredentials>
<winsomnia.net>
<add key="Username" value="%NUGET_USERNAME%" />
<add key="ClearTextPassword" value="%NUGET_PASSWORD%" />
</winsomnia.net>
</packageSourceCredentials>
</configuration>