2026-06-02 18:45:14 +08:00
|
|
|
using Avalonia;
|
2026-06-15 10:28:16 +08:00
|
|
|
using Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services;
|
2026-06-02 18:45:14 +08:00
|
|
|
using Serilog;
|
2026-06-02 17:41:53 +08:00
|
|
|
using System;
|
2026-06-02 18:45:14 +08:00
|
|
|
using System.IO;
|
2026-06-15 10:46:27 +08:00
|
|
|
using System.Threading;
|
2026-06-02 17:41:53 +08:00
|
|
|
|
|
|
|
|
namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance
|
|
|
|
|
{
|
|
|
|
|
internal sealed class Program
|
|
|
|
|
{
|
2026-06-15 10:46:27 +08:00
|
|
|
private const string SingleInstanceMutexName = @"Global\FootwearSlipResistancePerformance";
|
|
|
|
|
|
2026-06-02 17:41:53 +08:00
|
|
|
[STAThread]
|
2026-06-02 18:45:14 +08:00
|
|
|
public static int Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
ConfigureLogging();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2026-06-15 10:28:16 +08:00
|
|
|
if (args.Length == 2 && string.Equals(args[0], MachineLicenseService.InstallArgument, StringComparison.Ordinal))
|
|
|
|
|
{
|
|
|
|
|
return MachineLicenseService.RunElevatedInstall(args[1]);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-15 10:46:27 +08:00
|
|
|
using var singleInstanceMutex = new Mutex(
|
|
|
|
|
initiallyOwned: true,
|
|
|
|
|
SingleInstanceMutexName,
|
|
|
|
|
out var isFirstInstance);
|
|
|
|
|
if (!isFirstInstance)
|
|
|
|
|
{
|
|
|
|
|
Log.Warning("检测到鞋类整鞋防滑性能试验程序已在运行,本次启动已取消");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-02 18:45:14 +08:00
|
|
|
Log.Information("鞋类整鞋防滑性能试验程序启动");
|
|
|
|
|
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log.Fatal(ex, "程序发生致命异常并退出");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Log.Information("鞋类整鞋防滑性能试验程序退出");
|
|
|
|
|
Log.CloseAndFlush();
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-06-02 17:41:53 +08:00
|
|
|
|
|
|
|
|
public static AppBuilder BuildAvaloniaApp()
|
|
|
|
|
=> AppBuilder.Configure<App>()
|
|
|
|
|
.UsePlatformDetect()
|
|
|
|
|
#if DEBUG
|
|
|
|
|
.WithDeveloperTools()
|
|
|
|
|
#endif
|
|
|
|
|
.WithInterFont()
|
|
|
|
|
.LogToTrace();
|
2026-06-02 18:45:14 +08:00
|
|
|
|
|
|
|
|
private static void ConfigureLogging()
|
|
|
|
|
{
|
|
|
|
|
var logDirectory = Path.Combine(
|
|
|
|
|
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
|
|
|
|
"FootwearSlipResistance",
|
|
|
|
|
"Logs");
|
|
|
|
|
Directory.CreateDirectory(logDirectory);
|
|
|
|
|
|
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
|
|
|
.MinimumLevel.Debug()
|
|
|
|
|
.WriteTo.File(
|
|
|
|
|
Path.Combine(logDirectory, "app-.log"),
|
|
|
|
|
rollingInterval: RollingInterval.Day,
|
|
|
|
|
retainedFileCountLimit: 30,
|
|
|
|
|
fileSizeLimitBytes: 20 * 1024 * 1024,
|
|
|
|
|
rollOnFileSizeLimit: true,
|
|
|
|
|
shared: true,
|
|
|
|
|
flushToDiskInterval: TimeSpan.FromSeconds(1),
|
|
|
|
|
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}")
|
|
|
|
|
.CreateLogger();
|
|
|
|
|
}
|
2026-06-02 17:41:53 +08:00
|
|
|
}
|
|
|
|
|
}
|