Rework updating process a bit
Test / Run tests (push) Successful in 13s

This commit is contained in:
2026-08-12 15:01:59 +02:00
parent 4e82f164c9
commit 2dee3a9ae9
8 changed files with 72 additions and 96 deletions
+2 -2
View File
@@ -4,7 +4,7 @@
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
Title="Update verfügbar - Anlagensteuerung Pamhagen"
Height="220" Width="460"
Height="220" Width="480"
Closed="OnClosed">
<Grid Margin="20">
<Grid.RowDefinitions>
@@ -18,7 +18,7 @@
Version <Run x:Name="VersionText" FontWeight="Bold">0.0.0</Run> ist verfügbar.<LineBreak/>
Soll das Update heruntergeladen und installiert werden?<LineBreak/>
(ca. <Run x:Name="SizeText">0</Run> MB)<LineBreak/><LineBreak/>
<Run FontWeight="Bold">Hinweis:</Run> Die Anlagensteuerung wird zur Installation geschlossen.
<Run FontWeight="Bold">Hinweis:</Run> Die Anlagensteuerung wird für die Installation geschlossen.
</TextBlock>
<StackPanel x:Name="DownloadPanel" Grid.Row="0" VerticalAlignment="Center" Visibility="Collapsed">
+10 -14
View File
@@ -1,17 +1,18 @@
using PamhagenSysCtrl.Helpers;
using System.IO;
using System.Windows;
namespace PamhagenSysCtrl.Dialogs {
public partial class UpdateDialog : Window {
private readonly UpdateInstaller Installer;
private readonly string Url;
private readonly CancellationTokenSource Cancellation = new();
public UpdateDialog(UpdateInstaller installer) {
Installer = installer;
public UpdateDialog(string version, string url, long size) {
Url = url;
InitializeComponent();
VersionText.Text = installer.Version.ToString();
SizeText.Text = Math.Ceiling(installer.Size / 1024d / 1024d).ToString("N0");
VersionText.Text = version;
SizeText.Text = Math.Ceiling(size / 1024d / 1024d).ToString("N0");
}
private void OnClosed(object? sender, EventArgs evt) {
@@ -26,20 +27,15 @@ namespace PamhagenSysCtrl.Dialogs {
try {
var progress = new Progress<double>(value => DownloadProgress.Value = value * 100);
var fileName = await UpdateService.DownloadInstallerAsync(Installer, App.TempPath, progress, Cancellation.Token);
var filename = Path.Combine(App.TempPath, $"PamhagenSysCtrl-{VersionText.Text}.msi");
await UpdateService.DownloadInstaller(Url, filename, progress, Cancellation.Token);
StatusText.Text = "Installer wird gestartet...";
UpdateService.StartInstaller(fileName);
UpdateService.StartInstaller(filename);
DialogResult = true;
} catch (OperationCanceledException) {
// Closing the dialog cancels an active download.
} catch (Exception exc) {
MessageBox.Show(
this,
$"Das Update konnte nicht installiert werden:\n\n{exc.Message}",
"Update installieren",
MessageBoxButton.OK,
MessageBoxImage.Error
);
MessageBox.Show($"Das Update konnte nicht installiert werden:\n\n{exc.Message}", "Update installieren", MessageBoxButton.OK, MessageBoxImage.Error);
Description.Visibility = Visibility.Visible;
DownloadPanel.Visibility = Visibility.Collapsed;
InstallButton.IsEnabled = true;