diff --git a/COMETwebapp/COMETwebapp.csproj b/COMETwebapp/COMETwebapp.csproj index 2af80b85..17b5a943 100644 --- a/COMETwebapp/COMETwebapp.csproj +++ b/COMETwebapp/COMETwebapp.csproj @@ -2,7 +2,7 @@ net9.0 - 6.2.0 + 6.2.1 CDP4-COMET WEB A web application that implements ECSS-E-TM-10-25 Starion Group S.A. @@ -17,6 +17,14 @@ true + + + + + + + + diff --git a/COMETwebapp/Extensions/ServiceCollectionExtensions.cs b/COMETwebapp/Extensions/ServiceCollectionExtensions.cs index 467669c0..4d62b661 100644 --- a/COMETwebapp/Extensions/ServiceCollectionExtensions.cs +++ b/COMETwebapp/Extensions/ServiceCollectionExtensions.cs @@ -25,6 +25,7 @@ namespace COMETwebapp.Extensions { using COMETwebapp.Model.Viewer; + using COMETwebapp.Resources; using COMETwebapp.Services.Interoperability; using COMETwebapp.Services.ShowHideDeprecatedThingsService; using COMETwebapp.Services.SubscriptionService; @@ -34,34 +35,34 @@ namespace COMETwebapp.Extensions using COMETwebapp.ViewModels.Components.EngineeringModel; using COMETwebapp.ViewModels.Components.EngineeringModel.CommonFileStore; using COMETwebapp.ViewModels.Components.EngineeringModel.DomainFileStore; + using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore; + using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileHandler; + using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileRevisionHandler; + using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FolderHandler; using COMETwebapp.ViewModels.Components.EngineeringModel.Options; using COMETwebapp.ViewModels.Components.EngineeringModel.Publications; - using COMETwebapp.ViewModels.Components.SiteDirectory.DomainsOfExpertise; using COMETwebapp.ViewModels.Components.ModelDashboard; using COMETwebapp.ViewModels.Components.ModelDashboard.ParameterValues; using COMETwebapp.ViewModels.Components.ModelEditor; + using COMETwebapp.ViewModels.Components.ModelEditor.CopySettings; using COMETwebapp.ViewModels.Components.ParameterEditor; + using COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor; + using COMETwebapp.ViewModels.Components.ReferenceData; using COMETwebapp.ViewModels.Components.ReferenceData.Categories; using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales; using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementUnits; using COMETwebapp.ViewModels.Components.ReferenceData.ParameterTypes; + using COMETwebapp.ViewModels.Components.SiteDirectory; + using COMETwebapp.ViewModels.Components.SiteDirectory.DomainsOfExpertise; using COMETwebapp.ViewModels.Components.SiteDirectory.EngineeringModels; using COMETwebapp.ViewModels.Components.SiteDirectory.Organizations; using COMETwebapp.ViewModels.Components.SiteDirectory.Roles; + using COMETwebapp.ViewModels.Components.SiteDirectory.UserManagement; using COMETwebapp.ViewModels.Components.SubscriptionDashboard; using COMETwebapp.ViewModels.Components.SystemRepresentation; - using COMETwebapp.ViewModels.Components.SiteDirectory.UserManagement; using COMETwebapp.ViewModels.Components.Viewer; - using COMETwebapp.ViewModels.Shared.TopMenuEntry; - using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore; - using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileHandler; - using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileRevisionHandler; - using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FolderHandler; - using COMETwebapp.ViewModels.Components.ModelEditor.CopySettings; - using COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor; - using COMETwebapp.ViewModels.Components.ReferenceData; using COMETwebapp.ViewModels.Pages; - using COMETwebapp.ViewModels.Components.SiteDirectory; + using COMETwebapp.ViewModels.Shared.TopMenuEntry; /// /// Extension class for the @@ -74,6 +75,7 @@ public static class ServiceCollectionExtensions /// The public static void RegisterServices(this IServiceCollection serviceCollection) { + serviceCollection.AddSingleton(); serviceCollection.AddScoped(); serviceCollection.AddScoped(); serviceCollection.AddScoped(); diff --git a/COMETwebapp/Program.cs b/COMETwebapp/Program.cs index 412eaea6..ef7fa09b 100644 --- a/COMETwebapp/Program.cs +++ b/COMETwebapp/Program.cs @@ -24,17 +24,19 @@ namespace COMETwebapp { + using System; using System.Diagnostics.CodeAnalysis; using System.Reflection; using COMET.Web.Common.Extensions; - + using COMETwebapp.Extensions; using COMETwebapp.Model; + using COMETwebapp.Resources; using COMETwebapp.Shared; using COMETwebapp.Shared.SideBarEntry; using COMETwebapp.Shared.TopMenuEntry; - + using Serilog; /// @@ -46,8 +48,10 @@ public class Program /// /// Point of entry of the application /// - public static async Task Main(string[] args) + public static async Task Main(string[] args) { + Console.Title = "CDP4-COMET WEB"; + var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorPages(); @@ -73,13 +77,38 @@ public static async Task Main(string[] args) }); var app = builder.Build(); - app.UseStaticFiles(); - app.UseRouting(); - app.MapBlazorHub(); - app.MapFallbackToPage("/_Host"); - await app.Services.InitializeCdp4CometCommonServices(); - await app.RunAsync(); + var logger = app.Services.GetService>(); + + try + { + var resourceLoader = app.Services.GetService(); + + logger.LogInformation(resourceLoader.QueryLogo()); + + logger.LogInformation("################################################################"); + + logger.LogInformation("Starting CDP4-COMET WEB v{version}", resourceLoader.QueryVersion()); + + app.UseStaticFiles(); + app.UseRouting(); + app.MapBlazorHub(); + app.MapFallbackToPage("/_Host"); + + await app.Services.InitializeCdp4CometCommonServices(); + + logger.LogInformation("CDP4-COMET WEB is running and accepting connections"); + + await app.RunAsync(); + + logger.LogInformation("Terminated CDP4-COMET WEB cleanly"); + return 0; + } + catch (Exception e) + { + logger.LogCritical(e, "An unhandled exception occurred during startup-bootstrapping"); + return -1; + } } } } diff --git a/COMETwebapp/Resources/IResourceLoader.cs b/COMETwebapp/Resources/IResourceLoader.cs new file mode 100644 index 00000000..470d2f11 --- /dev/null +++ b/COMETwebapp/Resources/IResourceLoader.cs @@ -0,0 +1,62 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2025 Starion Group S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Théate Antoine +// +// This file is part of CDP4-COMET WEB Community Edition +// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. +// +// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace COMETwebapp.Resources +{ + using System; + using System.Collections.Generic; + + /// + /// Defnition of the interface used to load (embedded) resources + /// + public interface IResourceLoader + { + /// + /// Load an embedded resource + /// + /// + /// The path of the embedded resource + /// + /// + /// a string containing the contents of the embedded resource + /// + string LoadEmbeddedResource(string path); + + /// + /// queries the version number from the executing assembly + /// + /// + /// a string representation of the version of the application + /// + string QueryVersion(); + + /// + /// Queries the logo with version info from the embedded resources + /// + /// + /// the logo + /// + string QueryLogo(); + } +} diff --git a/COMETwebapp/Resources/ResourceLoader.cs b/COMETwebapp/Resources/ResourceLoader.cs new file mode 100644 index 00000000..df892196 --- /dev/null +++ b/COMETwebapp/Resources/ResourceLoader.cs @@ -0,0 +1,123 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2025 Starion Group S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine +// +// This file is part of CDP4-COMET WEB Community Edition +// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. +// +// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace COMETwebapp.Resources +{ + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.IO; + using System.Reflection; + using System.Resources; + + /// + /// Class responsible for loading embedded resources. + /// + public class ResourceLoader : IResourceLoader + { + /// + /// Load an embedded resource + /// + /// + /// The path of the embedded resource + /// + /// + /// a string containing the contents of the embedded resource + /// + public string LoadEmbeddedResource(string path) + { + var assembly = Assembly.GetExecutingAssembly(); + + using var stream = assembly.GetManifestResourceStream(path); + + using var reader = new StreamReader(stream ?? throw new MissingManifestResourceException()); + + return reader.ReadToEnd(); + } + + /// + /// queries the version number from the executing assembly + /// + /// + /// a string representation of the version of the application + /// + public string QueryVersion() + { + var assembly = Assembly.GetExecutingAssembly(); + + return this.GetAssemblyVersion(assembly); + } + + /// + /// Gets the version number of an + /// + /// The + /// The version number of the + private string GetAssemblyVersion(Assembly assembly) + { + var infoVersion = assembly.GetCustomAttribute(); + + if (infoVersion != null) + { + var plusIndex = infoVersion.InformationalVersion.IndexOf('+'); + + if (plusIndex != -1) + { + return infoVersion.InformationalVersion.Substring(0, plusIndex); + } + } + + var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); + var productVersion = fileVersionInfo.ProductVersion; + + if (productVersion != null) + { + var plusIndex = productVersion.IndexOf('+'); + + if (plusIndex != -1) + { + return productVersion.Substring(0, plusIndex); + } + } + + return productVersion ?? "unknown"; + } + + /// + /// Queries the logo with version info from the embedded resources + /// + /// + /// the logo + /// + public string QueryLogo() + { + var version = this.QueryVersion(); + + var logo = this.LoadEmbeddedResource("COMETwebapp.Resources.ascii-art.txt") + .Replace("COMETWebVersion", version); + + return logo; + } + } +} diff --git a/COMETwebapp/Resources/ascii-art.txt b/COMETwebapp/Resources/ascii-art.txt new file mode 100644 index 00000000..3363c117 --- /dev/null +++ b/COMETwebapp/Resources/ascii-art.txt @@ -0,0 +1,12 @@ + + + ██████╗██████╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ███╗ ███╗███████╗████████╗ + ██╔════╝██╔══██╗██╔══██╗██║ ██║ ██╔════╝██╔═══██╗████╗ ████║██╔════╝╚══██╔══╝ + ██║ ██║ ██║██████╔╝███████║█████╗██║ ██║ ██║██╔████╔██║█████╗ ██║ + ██║ ██║ ██║██╔═══╝ ╚════██║╚════╝██║ ██║ ██║██║╚██╔╝██║██╔══╝ ██║ + ╚██████╗██████╔╝██║ ██║ ╚██████╗╚██████╔╝██║ ╚═╝ ██║███████╗ ██║ + ╚═════╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ + + copyright 2015-2025 STARION Group S.A. https://www.stariongroup.eu + email: info@stariongroup.eu + CDP4-COMET WEB version: COMETWebVersion diff --git a/COMETwebapp/appsettings.json b/COMETwebapp/appsettings.json index 295df06c..1e8b55a1 100644 --- a/COMETwebapp/appsettings.json +++ b/COMETwebapp/appsettings.json @@ -1,5 +1,12 @@ { "AllowedHosts": "*", + "Kestrel": { + "Endpoints": { + "Http": { + "Url": "http://*:8080" + } + } + }, "StringTablePath": "wwwroot/DefaultTextConfiguration.json", "MaxUploadFileSizeInMb": 500, "ServerConfiguration": {