Compare commits

...

10 Commits

Author SHA1 Message Date
Tudor Stanciu a70123f778 APP_DATE env in dockerfile 2023-03-27 02:53:31 +03:00
Tudor Stanciu cda20f5e3d release notes 2023-03-27 02:07:45 +03:00
Tudor Stanciu ec6aef42ea release notes 2023-03-27 00:29:06 +03:00
Tudor Stanciu 1724a9d0cc release notes changes 2023-03-26 21:35:04 +03:00
Tudor Stanciu fb98358dbb release notes changes 2023-03-26 21:32:55 +03:00
Tudor Stanciu 81f50b7bde New methods have been added to the API for reading the system version and release notes. 2023-03-25 12:54:38 +02:00
Tudor Stanciu 4449b79ff9 IResurrectorService + GetServiceVersion 2023-03-25 03:01:51 +02:00
Tudor Stanciu e9b4201a22 Server version query update 2023-03-25 02:58:55 +02:00
Tudor Stanciu 099fa90e24 Added missing release notes 2023-03-25 02:00:01 +02:00
Tudor Stanciu a206d72a93 added date tag in release notes 2023-03-25 01:36:13 +02:00
15 changed files with 244 additions and 31 deletions

View File

@ -1,7 +1,7 @@
<Project>
<Import Project="dependencies.props" />
<PropertyGroup>
<Version>1.1.3</Version>
<Version>1.2.3</Version>
<Authors>Tudor Stanciu</Authors>
<Company>STA</Company>
<PackageTags>NetworkResurrector</PackageTags>

View File

@ -2,35 +2,70 @@
<ReleaseNotes>
<Note>
<Version>1.0.0</Version>
<Date>2020-11-28 18:15</Date>
<Content>
System initialization
Simple .net core 3.1 console application that serve as an REST API through witch a user can execute wake or shutdown commands on machines from his network.
Has been added Wake on LAN support and "wake" route in the API controller.
</Content>
</Note>
<Note>
<Version>1.0.1</Version>
<Date>2020-11-29 22:14</Date>
<Content>
Has been added "ping" and "shutdown" support. Routes with same names have also been added to the controller.
New functionalities added
Added support for "ping" and "shutdown". Routes with the same names have also been added to the controller.
</Content>
</Note>
<Note>
<Version>1.0.2</Version>
<Date>2020-12-20 23:00</Date>
<Content>
Changes in the system structure
Replaced Swagger and MediatR implementations with inhouse nuget packages.
Integration with Tuitio.
</Content>
</Note>
<Note>
<Version>1.0.3</Version>
<Date>2022-01-03 08:52</Date>
<Content>
Added NetworkResurrector.Agent service
Upgrade all services to net5.0
NetworkResurrector.Agent is a service that will be installed on a host machine with the scope to execute operations like shutdown, restart, etc directly.
The system will be able to execute these operations in multiple ways. This is just the first one and all of them are handled by the NetworkResurrector.Api. For example, if the user wants to shutdown a clean Windows machine, he can use the agent and configure the API to call it, but in case of a proxmox machine, the API can be configured to execute a http request directly to the OS with the shutdown action (without the need for the agent).
</Content>
Added NetworkResurrector.Agent service
Upgrade all services to net5.0
NetworkResurrector.Agent is a service that will be installed on a host machine with the scope to execute operations like shutdown, restart, etc directly.
The system will be able to execute these operations in multiple ways. This is just the first one and all of them are handled by the NetworkResurrector.Api. For example, if the user wants to shutdown a clean Windows machine, he can use the agent and configure the API to call it, but in case of a proxmox machine, the API can be configured to execute a http request directly to the OS with the shutdown action (without the need for the agent).
</Content>
</Note>
<Note>
<Version>1.0.4</Version>
<Date>2022-01-14 01:22</Date>
<Content>
NetworkResurrector.Agent improvements
• Multiple operations were implemented in the agent: Shutdown, Restart, Sleep, LockLogout and Cancel. The "Cancel" action can cancel one of the previously operations programmed with a delay.
• Added NetworkResurrector.Agent.Wrapper nuget package. It provides an easy and efficient method for a developer to connect another system written in .NET to this agent.
</Content>
</Note>
<Note>
<Version>1.0.5</Version>
<Date>2022-01-18 21:43</Date>
<Content>
NetworkResurrector.Server.Wrapper nuget package
• Added NetworkResurrector.Server.Wrapper nuget package. It provides an easy and efficient method for a developer to connect another system written in .NET to NetworkResurrector.Server.
• Added logic where the http headers from the caller's request are automatically passed to the request sent to this server.
</Content>
</Note>
<Note>
<Version>1.0.6</Version>
<Date>2022-06-19 08:18</Date>
<Content>
Implemented Netmash.Infrastructure.DatabaseMigration
• Through this nuget package, support was added for the automatic running of new sql scripts at system startup.
• The current sql scripts have been corrected or updated to meet the migrator rules.
</Content>
</Note>
<Note>
<Version>1.0.7</Version>
<Date>2022-11-30 23:21</Date>
<Content>
Code cleanup and refactoring
• Preparing to make the project open source on my Gitea instance.
@ -40,6 +75,7 @@
</Note>
<Note>
<Version>1.1.0</Version>
<Date>2023-01-29 00:31</Date>
<Content>
Massive improvements
• .NET 6 upgrade
@ -47,31 +83,82 @@
• Added Seq logging
• Added messaging and published notifications from command handlers
• Refactoring and code cleanup
• Added README.md file
</Content>
• Added README.md file
</Content>
</Note>
<Note>
<Version>1.1.1</Version>
<Date>2023-02-02 19:03</Date>
<Content>
Retouches after the last upgrade
• Nuget packages upgrade
• Small fixes
</Content>
</Content>
</Note>
<Note>
<Version>1.1.2</Version>
<Date>2023-02-04 11:14</Date>
<Content>
Tuitio latest updates
• Tuitio nuget packages upgrade
• Tuitio configuration changes
</Content>
• Many frontend developments
• Tuitio client NPM package integration: @flare/tuitio-react-client
• Added license file
• Login with enter key
</Content>
</Note>
<Note>
<Version>1.1.3</Version>
<Date>2023-03-18 02:49</Date>
<Content>
Tuitio latest changes
• Account logout method and the latest changes published by Tuitio were implemented
• Netmash.Security.Authentication.Tuitio nuget package upgrade
</Content>
</Content>
</Note>
<Note>
<Version>1.2.0</Version>
<Date>2023-03-19 14:56</Date>
<Content>
Massive frontend developments
• Complete UI refactoring
• A complete menu has been added to the application.
• The theme and the switch between dark and light mode have been implemented.
• Axios upgrade.
• The ugly and useless stepper has been removed from the machines page.
</Content>
</Note>
<Note>
<Version>1.2.1</Version>
<Date>2023-03-19 20:11</Date>
<Content>
Frontend developments
• Added sensitive info toggle.
• Apply mask on sensitive information.
• Mask machine logs.
</Content>
</Note>
<Note>
<Version>1.2.2</Version>
<Date>2023-03-19 23:14</Date>
<Content>
Added user profile page
• The data on the page is extracted from the Tuitio token.
</Content>
</Note>
<Note>
<Version>1.2.3</Version>
<Date>2023-03-25 02:26</Date>
<Content>
Important developments in frontend
• Machines view modes
• New menu entries: About, Administration and System
• About page. It contains information about the system and the release notes.
• New methods have been added to the API for reading the system version and release notes.
• Release notes area
• Timeline area
• Settings page redesign
</Content>
</Note>
</ReleaseNotes>

View File

@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="NBB.Messaging.Abstractions" Version="$(NBBPackageVersion)" />
<PackageReference Include="NetworkResurrector.Agent.Wrapper" Version="1.1.0" />
<PackageReference Include="NetworkResurrector.Server.Wrapper" Version="1.1.0" />
<PackageReference Include="NetworkResurrector.Server.Wrapper" Version="1.1.1" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,71 @@
using MediatR;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
namespace NetworkResurrector.Api.Application.Queries
{
public class GetReleaseNotes
{
public class Query : IRequest<Model[]>
{
public Query() { }
}
public record Model(string Version, DateTime Date, string[] Notes);
public class QueryHandler : IRequestHandler<Query, Model[]>
{
public QueryHandler() { }
public async Task<Model[]> Handle(Query request, CancellationToken cancellationToken)
{
var x = Directory.GetCurrentDirectory();
Console.WriteLine(x);
var releaseNotes = new XmlDocument();
releaseNotes.Load("ReleaseNotes.xml");
var rows = releaseNotes.DocumentElement.SelectNodes("Note");
var result = new List<Model>();
foreach (XmlNode node in rows)
{
var version = node.SelectSingleNode("Version").InnerText;
var date = GetReleaseDateUtc(node.SelectSingleNode("Date").InnerText);
var notes = ParseContent(node.SelectSingleNode("Content").InnerText);
result.Add(new Model(version, date, notes));
}
return await Task.FromResult(result.ToArray());
}
private string[] ParseContent(string text)
{
var lines = text
.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)
.Where(z => !string.IsNullOrWhiteSpace(z))
.ToArray();
for (int i = 0; i < lines.Count(); i++)
{
lines[i] = lines[i].TrimStart().TrimEnd();
}
return lines;
}
private DateTime GetReleaseDateUtc(string date)
{
var datetime = Convert.ToDateTime(date);
var utcDatetime = TimeZoneInfo.ConvertTimeToUtc(datetime, TimeZoneInfo.Local);
return utcDatetime;
}
}
}
}

View File

@ -1,4 +1,5 @@
using MediatR;
using NetworkResurrector.Server.Wrapper.Services;
using System;
using System.IO;
using System.Reflection;
@ -11,15 +12,38 @@ namespace NetworkResurrector.Api.Application.Queries
{
public class Query : IRequest<Model> { }
public record Model(string Version, DateTime LastUpdateDate);
public class Model
{
public ServiceVersion Api { get; set; }
public ServiceVersion Server { get; set; }
}
public record ServiceVersion(string Version, DateTime LastReleaseDate);
public class QueryHandler : IRequestHandler<Query, Model>
{
public QueryHandler()
private readonly IResurrectorService _resurrectorService;
public QueryHandler(IResurrectorService resurrectorService)
{
_resurrectorService=resurrectorService;
}
public async Task<Model> Handle(Query request, CancellationToken cancellationToken)
{
var serverVersion = await _resurrectorService.GetServiceVersion();
var apiVersion = GetApiVersion();
var result = new Model
{
Api = apiVersion,
Server = new ServiceVersion(serverVersion.Version, serverVersion.LastReleaseDate)
};
return result;
}
private ServiceVersion GetApiVersion()
{
var version = Environment.GetEnvironmentVariable("APP_VERSION");
var appDate = Environment.GetEnvironmentVariable("APP_DATE");
@ -27,14 +51,14 @@ namespace NetworkResurrector.Api.Application.Queries
if (string.IsNullOrEmpty(version))
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;
lastUpdateDate = File.GetLastWriteTime(location);
lastReleaseDate = File.GetLastWriteTime(location);
}
var result = new Model(version, lastUpdateDate);
return await Task.FromResult(result);
var result = new ServiceVersion(version, lastReleaseDate);
return result;
}
}
}

View File

@ -32,5 +32,12 @@ namespace NetworkResurrector.Api.Controllers
var result = await _mediator.Send(query);
return Ok(result);
}
[HttpGet("release-notes")]
public async Task<IActionResult> GetReleaseNotes([FromRoute] GetReleaseNotes.Query query)
{
var result = await _mediator.Send(query);
return Ok(result);
}
}
}

View File

@ -33,6 +33,8 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ARG APP_VERSION=0.0.0.0
ENV APP_VERSION=${APP_VERSION}
ARG APP_DATE="-"
ENV APP_DATE=${APP_DATE}
#Workaround to lower the TLS level in container for old sql server version
RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf

View File

@ -5,6 +5,10 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<Content Include="..\..\..\ReleaseNotes.xml" Link="ReleaseNotes.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.4" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="$(MicrosoftExtensionsPackageVersion)" />

View File

@ -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<Model> { }
public class Query : IRequest<ServiceVersion> { }
public record Model(string Version, DateTime LastUpdateDate);
public class QueryHandler : IRequestHandler<Query, Model>
public class QueryHandler : IRequestHandler<Query, ServiceVersion>
{
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 appDate = Environment.GetEnvironmentVariable("APP_DATE");
@ -27,13 +26,13 @@ namespace NetworkResurrector.Server.Application.Queries
if (string.IsNullOrEmpty(version))
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;
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);
}
}

View File

@ -0,0 +1,6 @@
using System;
namespace NetworkResurrector.Server.PublishedLanguage.Dto
{
public record ServiceVersion(string Version, DateTime LastReleaseDate);
}

View File

@ -6,7 +6,7 @@
<RepositoryUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageProjectUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</PackageProjectUrl>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
</PropertyGroup>
<ItemGroup>

View File

@ -3,6 +3,7 @@
internal struct ApiRoutes
{
public const string
SystemVersion = "system/version",
Wake = "resurrector/wake",
Ping = "resurrector/ping",
Shutdown = "resurrector/shutdown";

View File

@ -6,7 +6,7 @@
<PackageProjectUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</PackageProjectUrl>
<RepositoryUrl>https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
</PropertyGroup>
<ItemGroup>
@ -15,7 +15,10 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
<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>
</Project>

View File

@ -1,10 +1,12 @@
using NetworkResurrector.Server.PublishedLanguage.Events;
using NetworkResurrector.Server.PublishedLanguage.Dto;
using NetworkResurrector.Server.PublishedLanguage.Events;
using System.Threading.Tasks;
namespace NetworkResurrector.Server.Wrapper.Services
{
public interface IResurrectorService
{
Task<ServiceVersion> GetServiceVersion();
Task<MachineWaked> Wake(string macAddress);
Task<MachinePinged> Ping(string ipAddressOrMachineName);
Task<MachineShutdown> Shutdown(string ipAddressOrMachineName);

View File

@ -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<ServiceVersion> GetServiceVersion()
{
var result = await _httpClient.ExecuteGetRequest<ServiceVersion>(ApiRoutes.SystemVersion);
return result;
}
public async Task<MachineWaked> Wake(string macAddress)
{
var body = new WakeMachine() { MacAddress = macAddress };