This commit is contained in:
@@ -28,6 +28,8 @@ namespace Elwig {
|
||||
public static bool ForceShutdown { get; private set; } = false;
|
||||
|
||||
private readonly DispatcherTimer _autoUpdateTimer = new() { Interval = TimeSpan.FromHours(1) };
|
||||
private readonly DispatcherTimer _autoBackupTimer = new() { Interval = TimeSpan.FromHours(1) };
|
||||
private DatabaseBackupService? _databaseBackupService;
|
||||
public readonly SerialPortWatcher SerialPortWatcher = new();
|
||||
|
||||
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Elwig");
|
||||
@@ -101,6 +103,13 @@ namespace Elwig {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.DatabaseBackup) {
|
||||
_databaseBackupService = new DatabaseBackupService(Config.DatabaseFile);
|
||||
await _databaseBackupService.RunIfNeededAsync();
|
||||
_autoBackupTimer.Tick += OnAutoBackupTimer;
|
||||
_autoBackupTimer.Start();
|
||||
}
|
||||
|
||||
LastChanged = CurrentLastWrite;
|
||||
ContextTimer.Start();
|
||||
|
||||
@@ -191,6 +200,7 @@ namespace Elwig {
|
||||
}
|
||||
|
||||
private async void Application_Exit(object sender, ExitEventArgs evt) {
|
||||
_autoBackupTimer.Stop();
|
||||
SerialPortWatcher.Dispose();
|
||||
foreach (var s in EventScales) {
|
||||
s.Dispose();
|
||||
@@ -198,6 +208,12 @@ namespace Elwig {
|
||||
await Pdf.Cleanup();
|
||||
}
|
||||
|
||||
private async void OnAutoBackupTimer(object? sender, EventArgs evt) {
|
||||
if (_databaseBackupService != null) {
|
||||
await _databaseBackupService.RunIfNeededAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetBranch(Branch b) {
|
||||
SetBranch((b.ZwstId, b.Name, b.PostalDest?.AtPlz?.Plz, b.PostalDest?.AtPlz?.Ort.Name, b.Address, b.PhoneNr, b.FaxNr, b.MobileNr));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user