Server version query update
parent
099fa90e24
commit
e9b4201a22
|
@ -1,4 +1,5 @@
|
||||||
using MediatR;
|
using MediatR;
|
||||||
|
using NetworkResurrector.Server.PublishedLanguage.Dto;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -9,17 +10,15 @@ namespace NetworkResurrector.Server.Application.Queries
|
||||||
{
|
{
|
||||||
public class GetSystemVersion
|
public class GetSystemVersion
|
||||||
{
|
{
|
||||||
public class Query : IRequest<Model> { }
|
public class Query : IRequest<ServiceVersion> { }
|
||||||
|
|
||||||
public record Model(string Version, DateTime LastUpdateDate);
|
public class QueryHandler : IRequestHandler<Query, ServiceVersion>
|
||||||
|
|
||||||
public class QueryHandler : IRequestHandler<Query, Model>
|
|
||||||
{
|
{
|
||||||
public QueryHandler()
|
public QueryHandler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Model> Handle(Query request, CancellationToken cancellationToken)
|
public async Task<ServiceVersion> Handle(Query request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var version = Environment.GetEnvironmentVariable("APP_VERSION");
|
var version = Environment.GetEnvironmentVariable("APP_VERSION");
|
||||||
var appDate = Environment.GetEnvironmentVariable("APP_DATE");
|
var appDate = Environment.GetEnvironmentVariable("APP_DATE");
|
||||||
|
@ -27,13 +26,13 @@ namespace NetworkResurrector.Server.Application.Queries
|
||||||
if (string.IsNullOrEmpty(version))
|
if (string.IsNullOrEmpty(version))
|
||||||
version = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
version = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||||
|
|
||||||
if (!DateTime.TryParse(appDate, out var lastUpdateDate))
|
if (!DateTime.TryParse(appDate, out var lastReleaseDate))
|
||||||
{
|
{
|
||||||
var location = Assembly.GetExecutingAssembly().Location;
|
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);
|
return await Task.FromResult(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NetworkResurrector.Server.PublishedLanguage.Dto
|
||||||
|
{
|
||||||
|
public record ServiceVersion(string Version, DateTime LastReleaseDate);
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
<RepositoryUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</RepositoryUrl>
|
<RepositoryUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</RepositoryUrl>
|
||||||
<RepositoryType>Git</RepositoryType>
|
<RepositoryType>Git</RepositoryType>
|
||||||
<PackageProjectUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</PackageProjectUrl>
|
<PackageProjectUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</PackageProjectUrl>
|
||||||
<Version>1.1.0</Version>
|
<Version>1.1.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
internal struct ApiRoutes
|
internal struct ApiRoutes
|
||||||
{
|
{
|
||||||
public const string
|
public const string
|
||||||
|
SystemVersion = "system/version",
|
||||||
Wake = "resurrector/wake",
|
Wake = "resurrector/wake",
|
||||||
Ping = "resurrector/ping",
|
Ping = "resurrector/ping",
|
||||||
Shutdown = "resurrector/shutdown";
|
Shutdown = "resurrector/shutdown";
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<PackageProjectUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</PackageProjectUrl>
|
<PackageProjectUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</RepositoryUrl>
|
<RepositoryUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</RepositoryUrl>
|
||||||
<RepositoryType>Git</RepositoryType>
|
<RepositoryType>Git</RepositoryType>
|
||||||
<Version>1.1.0</Version>
|
<Version>1.1.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -15,7 +15,10 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsPackageVersion)" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsPackageVersion)" />
|
||||||
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
|
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
|
||||||
<PackageReference Include="Netmash.Extensions.Http" Version="1.0.0" />
|
<PackageReference Include="Netmash.Extensions.Http" Version="1.0.0" />
|
||||||
<PackageReference Include="NetworkResurrector.Server.PublishedLanguage" Version="1.1.0" />
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\NetworkResurrector.Server.PublishedLanguage\NetworkResurrector.Server.PublishedLanguage.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Netmash.Extensions.Http;
|
using Netmash.Extensions.Http;
|
||||||
using NetworkResurrector.Server.PublishedLanguage.Commands;
|
using NetworkResurrector.Server.PublishedLanguage.Commands;
|
||||||
|
using NetworkResurrector.Server.PublishedLanguage.Dto;
|
||||||
using NetworkResurrector.Server.PublishedLanguage.Events;
|
using NetworkResurrector.Server.PublishedLanguage.Events;
|
||||||
using NetworkResurrector.Server.Wrapper.Constants;
|
using NetworkResurrector.Server.Wrapper.Constants;
|
||||||
using NetworkResurrector.Server.Wrapper.Models;
|
using NetworkResurrector.Server.Wrapper.Models;
|
||||||
|
@ -29,6 +30,12 @@ namespace NetworkResurrector.Server.Wrapper.Services
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ServiceVersion> GetServiceVersion()
|
||||||
|
{
|
||||||
|
var result = await _httpClient.ExecuteGetRequest<ServiceVersion>(ApiRoutes.SystemVersion);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<MachineWaked> Wake(string macAddress)
|
public async Task<MachineWaked> Wake(string macAddress)
|
||||||
{
|
{
|
||||||
var body = new WakeMachine() { MacAddress = macAddress };
|
var body = new WakeMachine() { MacAddress = macAddress };
|
||||||
|
|
Loading…
Reference in New Issue