2025-08-21 18:16:21 -05:00
|
|
|
|
using LANCommander.Launcher.Services;
|
2024-08-07 18:48:13 -05:00
|
|
|
|
using LANCommander.Launcher.Services.Extensions;
|
2024-06-05 01:21:31 -05:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2024-06-12 23:20:31 -05:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2024-06-05 01:21:31 -05:00
|
|
|
|
using Photino.Blazor;
|
|
|
|
|
|
using Photino.Blazor.CustomWindow.Extensions;
|
2024-06-11 02:05:15 -05:00
|
|
|
|
using Photino.NET;
|
2024-09-11 00:24:34 -05:00
|
|
|
|
using Serilog;
|
2025-06-15 20:01:17 +02:00
|
|
|
|
using Serilog.Events;
|
2024-09-25 20:27:23 -05:00
|
|
|
|
using Serilog.Extensions.Logging;
|
2024-06-11 02:05:15 -05:00
|
|
|
|
using System.Runtime.InteropServices;
|
2024-06-08 02:58:18 -05:00
|
|
|
|
using System.Web;
|
2025-08-24 20:29:31 -05:00
|
|
|
|
using LANCommander.Launcher.Startup;
|
2024-05-09 20:44:40 -05:00
|
|
|
|
|
2024-08-04 17:53:19 -05:00
|
|
|
|
namespace LANCommander.Launcher
|
2024-05-09 20:44:40 -05:00
|
|
|
|
{
|
2024-06-05 01:21:31 -05:00
|
|
|
|
class Program
|
2024-05-09 20:44:40 -05:00
|
|
|
|
{
|
2024-06-05 01:21:31 -05:00
|
|
|
|
[STAThread]
|
2024-08-07 01:20:31 -05:00
|
|
|
|
static void Main(string[] args)
|
2024-05-09 20:44:40 -05:00
|
|
|
|
{
|
2024-09-11 00:24:34 -05:00
|
|
|
|
var settings = SettingService.GetSettings();
|
|
|
|
|
|
|
2025-06-15 20:01:17 +02:00
|
|
|
|
// Map the Microsoft.Extensions.Logging.LogLevel to Serilog.LogEventLevel.
|
|
|
|
|
|
var serilogLogLevel = MapLogLevel(settings.Debug.LoggingLevel);
|
|
|
|
|
|
|
2024-09-11 00:24:34 -05:00
|
|
|
|
using var Logger = new LoggerConfiguration()
|
2025-06-15 20:01:17 +02:00
|
|
|
|
.MinimumLevel.Is(serilogLogLevel)
|
|
|
|
|
|
.MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning)
|
|
|
|
|
|
.MinimumLevel.Override("Microsoft.AspNetCore.Components", LogEventLevel.Warning)
|
|
|
|
|
|
.MinimumLevel.Override("AntDesign", LogEventLevel.Warning)
|
2024-09-11 02:05:24 -05:00
|
|
|
|
.Enrich.WithProperty("Application", typeof(Program).Assembly.GetName().Name)
|
2024-09-11 00:24:34 -05:00
|
|
|
|
.WriteTo.File(Path.Combine(settings.Debug.LoggingPath, "log-.txt"), rollingInterval: settings.Debug.LoggingArchivePeriod)
|
2024-09-11 02:05:24 -05:00
|
|
|
|
#if DEBUG
|
|
|
|
|
|
.WriteTo.Seq("http://localhost:5341")
|
|
|
|
|
|
#endif
|
2024-09-11 00:24:34 -05:00
|
|
|
|
.CreateLogger();
|
|
|
|
|
|
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
|
var localizationService = new LocalizationService();
|
|
|
|
|
|
Logger?.Information(localizationService.GetString("StartingUpLauncher", UpdateService.GetCurrentVersion()));
|
|
|
|
|
|
Logger?.Debug(localizationService.GetString("LoadingSettingsFromFile"));
|
2024-07-28 17:41:43 -05:00
|
|
|
|
|
2024-06-05 01:21:31 -05:00
|
|
|
|
var builder = PhotinoBlazorAppBuilder.CreateDefault(args);
|
2024-05-09 20:44:40 -05:00
|
|
|
|
|
2025-08-24 20:29:31 -05:00
|
|
|
|
builder.AddSettings();
|
|
|
|
|
|
builder.AddLogging();
|
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
|
builder.AddAspire();
|
|
|
|
|
|
#endif
|
2025-08-06 19:37:11 -05:00
|
|
|
|
|
2024-08-06 18:24:44 -05:00
|
|
|
|
builder.RootComponents.Add<App>("app");
|
2025-08-06 19:37:11 -05:00
|
|
|
|
|
2024-08-06 18:24:44 -05:00
|
|
|
|
builder.Services.AddCustomWindow();
|
|
|
|
|
|
builder.Services.AddAntDesign();
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
|
builder.Services.AddSingleton<LocalizationService>();
|
2024-09-25 20:27:23 -05:00
|
|
|
|
builder.Services.AddLANCommander(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
options.ServerAddress = settings.Authentication.ServerAddress;
|
|
|
|
|
|
options.Logger = new SerilogLoggerFactory(Logger).CreateLogger<SDK.Client>();
|
|
|
|
|
|
});
|
2024-05-09 20:44:40 -05:00
|
|
|
|
|
2024-07-28 17:41:43 -05:00
|
|
|
|
#region Build Application
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
|
Logger?.Debug(localizationService.GetString("BuildingApplication"));
|
2024-07-28 17:41:43 -05:00
|
|
|
|
|
2024-05-21 20:51:09 -05:00
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
2025-08-24 20:29:31 -05:00
|
|
|
|
app
|
|
|
|
|
|
.RegisterMainWindow()
|
|
|
|
|
|
.RegisterMediaHandler()
|
|
|
|
|
|
.RegisterChatWindow()
|
|
|
|
|
|
.RestoreWindowPosition();
|
2024-09-17 19:48:23 -05:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-06-05 01:21:31 -05:00
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += (sender, error) =>
|
|
|
|
|
|
{
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
|
app.MainWindow.ShowMessage(localizationService.GetString("FatalException"), error.ExceptionObject.ToString());
|
2024-06-05 01:21:31 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
2024-09-18 20:40:41 -05:00
|
|
|
|
app.Services.InitializeLANCommander();
|
2025-08-21 18:16:21 -05:00
|
|
|
|
|
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
|
|
|
SystemService.RegisterCustomScheme();
|
2024-05-21 20:51:09 -05:00
|
|
|
|
|
2025-08-24 20:29:31 -05:00
|
|
|
|
if (!app.ParseCommandLine(args))
|
2024-08-06 18:24:44 -05:00
|
|
|
|
{
|
|
|
|
|
|
settings.LaunchCount++;
|
|
|
|
|
|
|
|
|
|
|
|
SettingService.SaveSettings(settings);
|
2024-07-28 18:32:45 -05:00
|
|
|
|
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
|
Logger?.Debug(localizationService.GetString("StartingApplication"));
|
2024-07-28 18:32:45 -05:00
|
|
|
|
|
2024-08-06 18:24:44 -05:00
|
|
|
|
app.Run();
|
2024-07-08 17:46:58 -05:00
|
|
|
|
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
|
Logger?.Debug(localizationService.GetString("ClosingApplication"));
|
2024-08-06 18:24:44 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-17 19:48:23 -05:00
|
|
|
|
|
|
|
|
|
|
|
2025-06-15 20:01:17 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Maps Microsoft.Extensions.Logging.LogLevel to Serilog.Events.LogEventLevel.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private static LogEventLevel MapLogLevel(LogLevel level)
|
|
|
|
|
|
{
|
|
|
|
|
|
return level switch
|
|
|
|
|
|
{
|
|
|
|
|
|
LogLevel.Trace => LogEventLevel.Verbose,
|
|
|
|
|
|
LogLevel.Debug => LogEventLevel.Debug,
|
|
|
|
|
|
LogLevel.Information => LogEventLevel.Information,
|
|
|
|
|
|
LogLevel.Warning => LogEventLevel.Warning,
|
|
|
|
|
|
LogLevel.Error => LogEventLevel.Error,
|
|
|
|
|
|
LogLevel.Critical => LogEventLevel.Fatal,
|
|
|
|
|
|
// LogLevel.None indicates logging should be disabled.
|
|
|
|
|
|
// Serilog does not have a direct "Off" level so you might choose to
|
|
|
|
|
|
// either bypass logging configuration or set it high enough to ignore messages.
|
|
|
|
|
|
LogLevel.None => LogEventLevel.Fatal,
|
|
|
|
|
|
_ => LogEventLevel.Information
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2024-05-09 20:44:40 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|