Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion COMETwebapp/COMETwebapp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Version>6.2.0</Version>
<Version>6.2.1</Version>
<Title>CDP4-COMET WEB</Title>
<Description>A web application that implements ECSS-E-TM-10-25</Description>
<Company>Starion Group S.A.</Company>
Expand All @@ -17,6 +17,14 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\ascii-art.txt" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\ascii-art.txt" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AntDesign" Version="1.2.0" />
<PackageReference Include="BlazorStrap" Version="5.2.103.250102" />
Expand Down
24 changes: 13 additions & 11 deletions COMETwebapp/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/// <summary>
/// Extension class for the <see cref="IServiceCollection" />
Expand All @@ -74,6 +75,7 @@ public static class ServiceCollectionExtensions
/// <param name="serviceCollection">The <see cref="IServiceCollection" /></param>
public static void RegisterServices(this IServiceCollection serviceCollection)
{
serviceCollection.AddSingleton<IResourceLoader, ResourceLoader>();
serviceCollection.AddScoped<ISubscriptionService, SubscriptionService>();
serviceCollection.AddScoped<IShowHideDeprecatedThingsService, ShowHideDeprecatedThingsService>();
serviceCollection.AddScoped<ISceneSettings, SceneSettings>();
Expand Down
47 changes: 38 additions & 9 deletions COMETwebapp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
Expand All @@ -46,8 +48,10 @@ public class Program
/// <summary>
/// Point of entry of the application
/// </summary>
public static async Task Main(string[] args)
public static async Task<int> Main(string[] args)
{
Console.Title = "CDP4-COMET WEB";

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorPages();
Expand All @@ -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<ILogger<Program>>();

try
{
var resourceLoader = app.Services.GetService<IResourceLoader>();

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;
}
}
}
}
62 changes: 62 additions & 0 deletions COMETwebapp/Resources/IResourceLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IResourceLoader.cs" company="Starion Group S.A.">
// 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 <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Resources
{
using System;
using System.Collections.Generic;

/// <summary>
/// Defnition of the interface used to load (embedded) resources
/// </summary>
public interface IResourceLoader
{
/// <summary>
/// Load an embedded resource
/// </summary>
/// <param name="path">
/// The path of the embedded resource
/// </param>
/// <returns>
/// a string containing the contents of the embedded resource
/// </returns>
string LoadEmbeddedResource(string path);

/// <summary>
/// queries the version number from the executing assembly
/// </summary>
/// <returns>
/// a string representation of the version of the application
/// </returns>
string QueryVersion();

/// <summary>
/// Queries the logo with version info from the embedded resources
/// </summary>
/// <returns>
/// the logo
/// </returns>
string QueryLogo();
}
}
123 changes: 123 additions & 0 deletions COMETwebapp/Resources/ResourceLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ResourceLoader.cs" company="Starion Group S.A.">
// 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 <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Resources
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;

/// <summary>
/// Class responsible for loading embedded resources.
/// </summary>
public class ResourceLoader : IResourceLoader
{
/// <summary>
/// Load an embedded resource
/// </summary>
/// <param name="path">
/// The path of the embedded resource
/// </param>
/// <returns>
/// a string containing the contents of the embedded resource
/// </returns>
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();
}

/// <summary>
/// queries the version number from the executing assembly
/// </summary>
/// <returns>
/// a string representation of the version of the application
/// </returns>
public string QueryVersion()
{
var assembly = Assembly.GetExecutingAssembly();

return this.GetAssemblyVersion(assembly);
}

/// <summary>
/// Gets the version number of an <see cref="Assembly"/>
/// </summary>
/// <param name="assembly">The <see cref="Assembly"/></param>
/// <returns>The version number of the <see cref="Assembly"/></returns>
private string GetAssemblyVersion(Assembly assembly)
{
var infoVersion = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();

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";
}

/// <summary>
/// Queries the logo with version info from the embedded resources
/// </summary>
/// <returns>
/// the logo
/// </returns>
public string QueryLogo()
{
var version = this.QueryVersion();

var logo = this.LoadEmbeddedResource("COMETwebapp.Resources.ascii-art.txt")
.Replace("COMETWebVersion", version);

return logo;
}
}
}
12 changes: 12 additions & 0 deletions COMETwebapp/Resources/ascii-art.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


██████╗██████╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ███╗ ███╗███████╗████████╗
██╔════╝██╔══██╗██╔══██╗██║ ██║ ██╔════╝██╔═══██╗████╗ ████║██╔════╝╚══██╔══╝
██║ ██║ ██║██████╔╝███████║█████╗██║ ██║ ██║██╔████╔██║█████╗ ██║
██║ ██║ ██║██╔═══╝ ╚════██║╚════╝██║ ██║ ██║██║╚██╔╝██║██╔══╝ ██║
╚██████╗██████╔╝██║ ██║ ╚██████╗╚██████╔╝██║ ╚═╝ ██║███████╗ ██║
╚═════╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝

copyright 2015-2025 STARION Group S.A. https://www.stariongroup.eu
email: [email protected]
CDP4-COMET WEB version: COMETWebVersion
7 changes: 7 additions & 0 deletions COMETwebapp/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://*:8080"
}
}
},
"StringTablePath": "wwwroot/DefaultTextConfiguration.json",
"MaxUploadFileSizeInMb": 500,
"ServerConfiguration": {
Expand Down
Loading