From e9b4201a2209a8f7939b0dd1b4dcb7efeda962f5 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sat, 25 Mar 2023 02:58:55 +0200 Subject: [PATCH] Server version query update --- .../Queries/GetServiceVersion.cs | 15 +++++++-------- .../Dto/ServiceVersion.cs | 6 ++++++ ...orkResurrector.Server.PublishedLanguage.csproj | 2 +- .../Constants/ApiRoutes.cs | 1 + .../NetworkResurrector.Server.Wrapper.csproj | 7 +++++-- .../Services/ResurrectorService.cs | 7 +++++++ 6 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 src/server/NetworkResurrector.Server.PublishedLanguage/Dto/ServiceVersion.cs diff --git a/src/server/NetworkResurrector.Server.Application/Queries/GetServiceVersion.cs b/src/server/NetworkResurrector.Server.Application/Queries/GetServiceVersion.cs index a8476e6..304ad29 100644 --- a/src/server/NetworkResurrector.Server.Application/Queries/GetServiceVersion.cs +++ b/src/server/NetworkResurrector.Server.Application/Queries/GetServiceVersion.cs @@ -1,4 +1,5 @@ using MediatR; +using NetworkResurrector.Server.PublishedLanguage.Dto; using System; using System.IO; using System.Reflection; @@ -9,17 +10,15 @@ namespace NetworkResurrector.Server.Application.Queries { public class GetSystemVersion { - public class Query : IRequest { } + public class Query : IRequest { } - public record Model(string Version, DateTime LastUpdateDate); - - public class QueryHandler : IRequestHandler + public class QueryHandler : IRequestHandler { public QueryHandler() { } - public async Task Handle(Query request, CancellationToken cancellationToken) + public async Task Handle(Query request, CancellationToken cancellationToken) { var version = Environment.GetEnvironmentVariable("APP_VERSION"); var appDate = Environment.GetEnvironmentVariable("APP_DATE"); @@ -27,13 +26,13 @@ namespace NetworkResurrector.Server.Application.Queries if (string.IsNullOrEmpty(version)) version = Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion; - if (!DateTime.TryParse(appDate, out var lastUpdateDate)) + if (!DateTime.TryParse(appDate, out var lastReleaseDate)) { var location = Assembly.GetExecutingAssembly().Location; - lastUpdateDate = File.GetLastWriteTime(location); + lastReleaseDate = File.GetLastWriteTime(location); } - var result = new Model(version, lastUpdateDate); + var result = new ServiceVersion(version, lastReleaseDate); return await Task.FromResult(result); } } diff --git a/src/server/NetworkResurrector.Server.PublishedLanguage/Dto/ServiceVersion.cs b/src/server/NetworkResurrector.Server.PublishedLanguage/Dto/ServiceVersion.cs new file mode 100644 index 0000000..b4c74b1 --- /dev/null +++ b/src/server/NetworkResurrector.Server.PublishedLanguage/Dto/ServiceVersion.cs @@ -0,0 +1,6 @@ +using System; + +namespace NetworkResurrector.Server.PublishedLanguage.Dto +{ + public record ServiceVersion(string Version, DateTime LastReleaseDate); +} diff --git a/src/server/NetworkResurrector.Server.PublishedLanguage/NetworkResurrector.Server.PublishedLanguage.csproj b/src/server/NetworkResurrector.Server.PublishedLanguage/NetworkResurrector.Server.PublishedLanguage.csproj index d708ec9..09d50d9 100644 --- a/src/server/NetworkResurrector.Server.PublishedLanguage/NetworkResurrector.Server.PublishedLanguage.csproj +++ b/src/server/NetworkResurrector.Server.PublishedLanguage/NetworkResurrector.Server.PublishedLanguage.csproj @@ -6,7 +6,7 @@ https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector Git https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector - 1.1.0 + 1.1.1 diff --git a/src/server/NetworkResurrector.Server.Wrapper/Constants/ApiRoutes.cs b/src/server/NetworkResurrector.Server.Wrapper/Constants/ApiRoutes.cs index 52d4810..91c8ca6 100644 --- a/src/server/NetworkResurrector.Server.Wrapper/Constants/ApiRoutes.cs +++ b/src/server/NetworkResurrector.Server.Wrapper/Constants/ApiRoutes.cs @@ -3,6 +3,7 @@ internal struct ApiRoutes { public const string + SystemVersion = "system/version", Wake = "resurrector/wake", Ping = "resurrector/ping", Shutdown = "resurrector/shutdown"; diff --git a/src/server/NetworkResurrector.Server.Wrapper/NetworkResurrector.Server.Wrapper.csproj b/src/server/NetworkResurrector.Server.Wrapper/NetworkResurrector.Server.Wrapper.csproj index 4a23d4a..b8e9a0f 100644 --- a/src/server/NetworkResurrector.Server.Wrapper/NetworkResurrector.Server.Wrapper.csproj +++ b/src/server/NetworkResurrector.Server.Wrapper/NetworkResurrector.Server.Wrapper.csproj @@ -6,7 +6,7 @@ https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector Git - 1.1.0 + 1.1.1 @@ -15,7 +15,10 @@ - + + + + diff --git a/src/server/NetworkResurrector.Server.Wrapper/Services/ResurrectorService.cs b/src/server/NetworkResurrector.Server.Wrapper/Services/ResurrectorService.cs index d7787eb..93d3159 100644 --- a/src/server/NetworkResurrector.Server.Wrapper/Services/ResurrectorService.cs +++ b/src/server/NetworkResurrector.Server.Wrapper/Services/ResurrectorService.cs @@ -1,5 +1,6 @@ using Netmash.Extensions.Http; using NetworkResurrector.Server.PublishedLanguage.Commands; +using NetworkResurrector.Server.PublishedLanguage.Dto; using NetworkResurrector.Server.PublishedLanguage.Events; using NetworkResurrector.Server.Wrapper.Constants; using NetworkResurrector.Server.Wrapper.Models; @@ -29,6 +30,12 @@ namespace NetworkResurrector.Server.Wrapper.Services _httpClient = httpClient; } + public async Task GetServiceVersion() + { + var result = await _httpClient.ExecuteGetRequest(ApiRoutes.SystemVersion); + return result; + } + public async Task Wake(string macAddress) { var body = new WakeMachine() { MacAddress = macAddress };