Change Init Users
This commit is contained in:
+72
@@ -84,6 +84,78 @@ namespace SafeBagDE70
|
||||
System.Windows.MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
private static void LoadConfig2()
|
||||
{
|
||||
try
|
||||
{
|
||||
AppData.CurrentVersion = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
VKeyboard.Listen<System.Windows.Controls.TextBox>(e => e.Text);
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
InitLogger(configuration);
|
||||
AppData.CDMPort = configuration["SerialPort:CDMPort"];
|
||||
AppData.SensorPort = configuration["SerialPort:SensorPort"];
|
||||
AppData.BaseURL = configuration["Device:BaseURL"];
|
||||
AppData.TenantId = int.Parse("0" + configuration["Device:TenantId"]);
|
||||
var maxNotes = int.Parse("0" + configuration["CDM:MaxNotes"]);
|
||||
if (maxNotes > 0)
|
||||
AppData.MaxNotes = maxNotes;
|
||||
|
||||
StateMachineConfig = new StateMachineConfig();
|
||||
configuration.GetSection("StateMachine").Bind(StateMachineConfig);
|
||||
Log.Information("START APP");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Windows.MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
private static void InitLogger(IConfigurationRoot configuration)
|
||||
{
|
||||
var logPath = configuration["Serilog:WriteTo:0:Args:path"];
|
||||
var rollingIntervalSetting = configuration["Serilog:WriteTo:0:Args:rollingInterval"];
|
||||
|
||||
// Ensure the path is relative to the application's directory
|
||||
var resolvedLogPath = Path.IsPathRooted(logPath)
|
||||
? logPath
|
||||
: Path.Combine(AppDomain.CurrentDomain.BaseDirectory, logPath);
|
||||
|
||||
// Parse the rollingInterval from string to enum
|
||||
RollingInterval rollingInterval = Enum.TryParse(rollingIntervalSetting, out RollingInterval interval)
|
||||
? interval
|
||||
: RollingInterval.Day; // Default to 'Day' if parsing fails
|
||||
|
||||
// Ensure the directory exists
|
||||
var logDirectory = Path.GetDirectoryName(resolvedLogPath);
|
||||
if (!Directory.Exists(logDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(logDirectory);
|
||||
}
|
||||
|
||||
// Configure Serilog to write logs to the resolved log path
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.WriteTo.File(
|
||||
path: resolvedLogPath,
|
||||
rollingInterval: rollingInterval
|
||||
)
|
||||
.WriteTo.Sink(new RealTimeLogSink())
|
||||
.CreateLogger();
|
||||
|
||||
try
|
||||
{
|
||||
Log.Information("Application Starting...");
|
||||
// Your application code here
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "Application failed to start.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
private void LoadDualScreens()
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user