diff --git a/Pilz.Updating.Administration.GUI/Pilz.Updating.Administration.GUI.csproj b/Pilz.Updating.Administration.GUI/Pilz.Updating.Administration.GUI.csproj
index 806a0cf..7ca2ba0 100644
--- a/Pilz.Updating.Administration.GUI/Pilz.Updating.Administration.GUI.csproj
+++ b/Pilz.Updating.Administration.GUI/Pilz.Updating.Administration.GUI.csproj
@@ -46,19 +46,15 @@
TRACE;RelMono
-
+
+
- 2022.3.1109
+ 2023.1.117
-
-
- ..\Shared Libs\Pilz.Cryptography.dll
-
-
@@ -220,8 +216,8 @@
-
-
+
+
diff --git a/Pilz.Updating.Administration/Pilz.Updating.Administration.csproj b/Pilz.Updating.Administration/Pilz.Updating.Administration.csproj
index f989bb4..e6c51af 100644
--- a/Pilz.Updating.Administration/Pilz.Updating.Administration.csproj
+++ b/Pilz.Updating.Administration/Pilz.Updating.Administration.csproj
@@ -37,17 +37,18 @@
MinimumRecommendedRules.ruleset
TRACE;RelMono
+
+ True
+ 1.yyyy.Mdd.Hmm
+ 1.2023.914.854
+
+
-
-
- ..\Shared Libs\Pilz.Cryptography.dll
-
-
@@ -101,11 +102,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/Pilz.Updating.Administration/UpdateInstaller/ZipPackageFileNameDefinations.cs b/Pilz.Updating.Administration/UpdateInstaller/PackageFileNameDefinations.cs
similarity index 87%
rename from Pilz.Updating.Administration/UpdateInstaller/ZipPackageFileNameDefinations.cs
rename to Pilz.Updating.Administration/UpdateInstaller/PackageFileNameDefinations.cs
index 5f4d166..5ac38f7 100644
--- a/Pilz.Updating.Administration/UpdateInstaller/ZipPackageFileNameDefinations.cs
+++ b/Pilz.Updating.Administration/UpdateInstaller/PackageFileNameDefinations.cs
@@ -1,5 +1,4 @@
-
-namespace Pilz.Updating.UpdateInstaller
+namespace Pilz.Updating.UpdateInstaller
{
public static class PackageFileNameDefinations
{
diff --git a/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj b/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj
index 9d984be..b7e06a8 100644
--- a/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj
+++ b/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj
@@ -40,14 +40,16 @@
True
+ 1.yyyy.Mdd.Hmm
+ 1.2023.914.854
+
-
- 2022.3.1109
+ 2023.1.117
@@ -97,11 +99,6 @@
Settings.settings
True
-
- UpdatingClientGuiLangRes.de.resx
- True
- True
-
True
True
@@ -133,8 +130,7 @@
Designer
- ResXFileCodeGenerator
- UpdatingClientGuiLangRes.de.Designer.cs
+
Pilz.Updating.Client.GUI
@@ -160,10 +156,9 @@
-
-
-
+
+
diff --git a/Pilz.Updating.Client.GUI/SimpleActionDialog.cs b/Pilz.Updating.Client.GUI/SimpleActionDialog.cs
index e8ed9c4..c427e11 100644
--- a/Pilz.Updating.Client.GUI/SimpleActionDialog.cs
+++ b/Pilz.Updating.Client.GUI/SimpleActionDialog.cs
@@ -12,66 +12,20 @@ namespace Pilz.Updating.Client.GUI
public void SetCurrentState(UpdateStatus curAction)
{
- SetCurrentStateInternal(curAction, -1);
- }
-
- public void SetCurrentState(UpdateStatus curAction, int progress)
- {
- SetCurrentStateInternal(curAction, progress);
- }
-
- private void SetCurrentStateInternal(UpdateStatus curAction, int progress)
- {
- var progressText = string.Empty;
-
- switch (curAction)
+ string progressText = curAction switch
{
- case UpdateStatus.Waiting:
- {
- progressText = UpdatingClientGuiLangRes.SimpleActions_Waiting;
- break;
- }
+ UpdateStatus.Waiting => UpdatingClientGuiLangRes.SimpleActions_Waiting,
+ UpdateStatus.Searching => UpdatingClientGuiLangRes.SimpleActions_Searching,
+ UpdateStatus.DownloadingPackage => UpdatingClientGuiLangRes.SimpleActions_DownloadingPackage,
+ UpdateStatus.DownloadingInstaller => UpdatingClientGuiLangRes.SimpleActions_DownloadingInstaller,
+ UpdateStatus.StartingInstaller => UpdatingClientGuiLangRes.SimpleActions_StartingInstaller,
+ _ => string.Empty,
+ };
- case UpdateStatus.Searching:
- {
- progressText = UpdatingClientGuiLangRes.SimpleActions_Searching;
- break;
- }
-
- case UpdateStatus.DownloadingInstaller:
- {
- progressText = UpdatingClientGuiLangRes.SimpleActions_DownloadingInstaller;
- break;
- }
-
- case UpdateStatus.DownloadingPackage:
- {
- progressText = UpdatingClientGuiLangRes.SimpleActions_DownloadingPackage;
- break;
- }
-
- case UpdateStatus.StartingInstaller:
- {
- progressText = UpdatingClientGuiLangRes.SimpleActions_DownloadingInstaller;
- break;
- }
- }
-
- if (progress == -1)
- {
- radProgressBar1.Visible = false;
- radWaitingBar1.Text = progressText;
- radWaitingBar1.BringToFront();
- radWaitingBar1.StartWaiting();
- }
- else
- {
- radWaitingBar1.StopWaiting();
- radProgressBar1.Text = progressText + $" ({progress}%)";
- radProgressBar1.Value1 = progress;
- radProgressBar1.BringToFront();
- radProgressBar1.Visible = true;
- }
+ radProgressBar1.Visible = false;
+ radWaitingBar1.Text = progressText;
+ radWaitingBar1.BringToFront();
+ radWaitingBar1.StartWaiting();
}
}
}
\ No newline at end of file
diff --git a/Pilz.Updating.Client.GUI/UpdateClientGUI.cs b/Pilz.Updating.Client.GUI/UpdateClientGUI.cs
index 6344987..54e8bea 100644
--- a/Pilz.Updating.Client.GUI/UpdateClientGUI.cs
+++ b/Pilz.Updating.Client.GUI/UpdateClientGUI.cs
@@ -7,6 +7,7 @@ using Microsoft.VisualBasic.CompilerServices;
using global::Pilz.Updating.Client.GUI.My.Resources;
using System;
using Telerik.WinControls;
+using System.Threading.Tasks;
namespace Pilz.Updating.Client.GUI
{
@@ -59,13 +60,7 @@ namespace Pilz.Updating.Client.GUI
public bool UseHiddenSearch { get; set; } = false;
- private Image MyAppIcon
- {
- get
- {
- return Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location).ToBitmap();
- }
- }
+ private static Image MyAppIcon => Icon.ExtractAssociatedIcon(IO.Extensions.GetExecutablePath()).ToBitmap();
// C o n s t r u c t o r s
@@ -76,10 +71,10 @@ namespace Pilz.Updating.Client.GUI
// F e a t u r e s
- public void UpdateInteractive(Form parentForm)
+ public async Task UpdateInteractive(Form parentForm)
{
this.parentForm = parentForm;
- UpdateClient.UpdateInteractiveAsync();
+ await UpdateClient.UpdateInteractive();
}
private void EndUpdating()
@@ -88,7 +83,7 @@ namespace Pilz.Updating.Client.GUI
UpdateClient = null;
}
- private void MyUpdateClient_UpdateStatusChanged(UpdateStatus newStatus, int progress)
+ private void MyUpdateClient_UpdateStatusChanged(UpdateStatus newStatus)
{
bool useGui = false;
if (!(newStatus == UpdateStatus.Searching && UseHiddenSearch))
@@ -106,7 +101,7 @@ namespace Pilz.Updating.Client.GUI
}));
}
- curProgressDialog?.Invoke(new Action(() => curProgressDialog.SetCurrentState(newStatus, progress)));
+ curProgressDialog?.Invoke(new Action(() => curProgressDialog.SetCurrentState(newStatus)));
}
private void MyUpdateClient_DownloadingUpdate(UpdatePackageInfo pkg, CancelEventArgs e)
diff --git a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.Designer.cs b/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.Designer.cs
index 2213f31..6006532 100644
--- a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.Designer.cs
+++ b/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.Designer.cs
@@ -105,6 +105,15 @@ namespace Pilz.Updating.Client.GUI {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Starting Installer ... ähnelt.
+ ///
+ internal static string SimpleActions_StartingInstaller {
+ get {
+ return ResourceManager.GetString("SimpleActions_StartingInstaller", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Waiting ... ähnelt.
///
diff --git a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.de.Designer.cs b/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.de.Designer.cs
deleted file mode 100644
index e02abfc..0000000
--- a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.de.Designer.cs
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.de.resx b/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.de.resx
index e6173a6..aa8d1ba 100644
--- a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.de.resx
+++ b/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.de.resx
@@ -132,6 +132,9 @@
Nach Updates suchen ...
+
+ Starte Installer ...
+
Warten ...
diff --git a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.resx b/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.resx
index fa845c6..983a953 100644
--- a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.resx
+++ b/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.resx
@@ -132,6 +132,9 @@
Searching for Updates ...
+
+ Starting Installer ...
+
Waiting ...
diff --git a/Pilz.Updating.Client/Pilz.Updating.Client.csproj b/Pilz.Updating.Client/Pilz.Updating.Client.csproj
index d201b3e..65069f3 100644
--- a/Pilz.Updating.Client/Pilz.Updating.Client.csproj
+++ b/Pilz.Updating.Client/Pilz.Updating.Client.csproj
@@ -39,6 +39,8 @@
True
+ 1.yyyy.Mdd.Hmm
+ 1.2023.914.854
@@ -94,10 +96,11 @@
+
-
+
diff --git a/Pilz.Updating.Client/UpdateClient.cs b/Pilz.Updating.Client/UpdateClient.cs
index e0cb6e0..f86fb5a 100644
--- a/Pilz.Updating.Client/UpdateClient.cs
+++ b/Pilz.Updating.Client/UpdateClient.cs
@@ -5,8 +5,10 @@ using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Compression;
+using System.IO.Pipes;
using System.Linq;
using System.Net;
+using System.Net.Http;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.VisualBasic.CompilerServices;
@@ -21,7 +23,7 @@ namespace Pilz.Updating
public event UpdateStatusChangedEventHandler UpdateStatusChanged;
- public delegate void UpdateStatusChangedEventHandler(UpdateStatus newStatus, int progress);
+ public delegate void UpdateStatusChangedEventHandler(UpdateStatus newStatus);
public event DownloadingUpdateEventHandler DownloadingUpdate;
@@ -46,7 +48,7 @@ namespace Pilz.Updating
// P r o p e r t i e s
- public WebClient WebClient { get; private set; } = new WebClient();
+ public HttpClient WebClient { get; private set; } = new();
public string UpdateUrl { get; private set; }
public ApplicationVersion CurrentVersion { get; private set; }
public Channels MinimumChannel { get; private set; }
@@ -69,7 +71,6 @@ namespace Pilz.Updating
UpdateUrl = updateUrl;
CurrentVersion = currentVersion;
MinimumChannel = (Channels)Math.Max((int)minimumChannel, (int)currentVersion.Channel);
- WebClient.DownloadProgressChanged += WebClient_DownloadProgressChanged;
}
// E v e n t M e t h o d s
@@ -88,70 +89,48 @@ namespace Pilz.Updating
return e.Cancel;
}
- // W e b C l i e n t E v e n t s
-
- private void WebClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
- {
- RaiseUpdateStatusChanged(curDownloadingStatus, e.ProgressPercentage);
- }
-
// U p d a t e R o u t i n e s
- public Task UpdateInteractiveAsync()
+ public async Task UpdateInteractive()
{
- return Task.Run(UpdateInteractive);
- }
-
- public void UpdateInteractive()
- {
- var latestVersion = CheckForUpdate();
+ var latestVersion = await CheckForUpdate();
if (latestVersion is null)
- {
NoUpdatesFound?.Invoke();
- }
else
- {
- UpdateInteractive(latestVersion);
- }
+ await UpdateInteractive(latestVersion);
}
- public void UpdateInteractive(UpdatePackageInfo package)
+ public async Task UpdateInteractive(UpdatePackageInfo package)
{
- if (!RaiseDownloadingUpdate(package) && DownloadPackage(package))
+ if (!RaiseDownloadingUpdate(package) && await DownloadPackageAsync(package))
{
if (!RaiseInstallingUpdate(package))
- {
- InstallPackage(package);
- }
+ await InstallPackage(package);
}
}
- public void RaiseUpdateStatusChanged(UpdateStatus newStatus, int progress = -1)
+ public void RaiseUpdateStatusChanged(UpdateStatus newStatus)
{
- UpdateStatusChanged?.Invoke(newStatus, progress);
+ UpdateStatusChanged?.Invoke(newStatus);
}
// F e a t u r e s
- public UpdateInfo GetUpdateInfo()
+ public async Task GetUpdateInfo()
{
- string str = WebClient.DownloadString(UpdateUrl);
+ string str = await WebClient.GetStringAsync(UpdateUrl);
var info = UpdateInfo.Parse(str);
return info;
}
- public UpdatePackageInfo CheckForUpdate()
+ public async Task CheckForUpdate()
{
RaiseUpdateStatusChanged(UpdateStatus.Searching);
- UpdateInfo = GetUpdateInfo();
- if (UpdateInfo is object)
- {
+ UpdateInfo = await GetUpdateInfo();
+ if (UpdateInfo is not null)
return CheckForUpdate(UpdateInfo);
- }
else
- {
return null;
- }
}
public UpdatePackageInfo CheckForUpdate(UpdateInfo updateInfo)
@@ -172,7 +151,7 @@ namespace Pilz.Updating
return foundPkgInfo;
}
- public bool DownloadPackage(UpdatePackageInfo package)
+ public async Task DownloadPackageAsync(UpdatePackageInfo package)
{
curDownloadingStatus = UpdateStatus.DownloadingPackage;
RaiseUpdateStatusChanged(curDownloadingStatus);
@@ -183,14 +162,14 @@ namespace Pilz.Updating
{
// Ensure existing and empty directory for the Zip File
if (dir.Exists)
- {
dir.Delete(true);
- }
dir.Create();
// Download zip package
- WebClient.DownloadFile(package.Packagelink, zipPath);
+ using var zipFile = new FileStream(zipPath, FileMode.Create, FileAccess.ReadWrite);
+ using var zipStream = await WebClient.GetStreamAsync(package.Packagelink);
+ await zipStream.CopyToAsync(zipFile);
// Remember path to package directory
dicPackagePaths.Add(package, dirPath);
@@ -203,7 +182,7 @@ namespace Pilz.Updating
return true;
}
- private FileInfo DownloadUpdateInstaller()
+ private async Task DownloadUpdateInstaller()
{
curDownloadingStatus = UpdateStatus.DownloadingInstaller;
RaiseUpdateStatusChanged(curDownloadingStatus);
@@ -211,17 +190,19 @@ namespace Pilz.Updating
// Ensure update installer path is empty
var installerDirPath = new DirectoryInfo(Path.Combine(MyPaths.GetMyAppDataPath(), "UpdateInstallerTool"));
if (installerDirPath.Exists)
- {
installerDirPath.Delete(true);
- }
- Task.Delay(100);
+ await Task.Delay(100);
installerDirPath.Create();
- Task.Delay(100);
+ await Task.Delay(100);
// Download update installer zip
- string installerZipPath = Path.Combine(installerDirPath.FullName, "UpdatenInstaller.zip");
- WebClient.DownloadFile(UpdateInfo.UpdateInstallerLink, installerZipPath);
+ var installerZipPath = Path.Combine(installerDirPath.FullName, "UpdatenInstaller.zip");
+ using (var installerZipFile = new FileStream(installerZipPath, FileMode.Create, FileAccess.ReadWrite))
+ {
+ using var installerZipStream = await WebClient.GetStreamAsync(UpdateInfo.UpdateInstallerLink);
+ await installerZipStream.CopyToAsync(installerZipFile);
+ }
// Extract update installer
var installerExtractPath = installerDirPath.CreateSubdirectory("extracted");
@@ -262,26 +243,24 @@ namespace Pilz.Updating
UpdateInstallerStarted?.Invoke();
}
- public bool InstallPackage(UpdatePackageInfo package)
+ public async Task InstallPackage(UpdatePackageInfo package)
{
- string packagePath = null;
- bool hasDownloaded = dicPackagePaths.TryGetValue(package, out packagePath);
- if (hasDownloaded)
+ if (dicPackagePaths.TryGetValue(package, out var packagePath))
{
// Download update installer
- var installerPath = DownloadUpdateInstaller();
+ var installerPath = await DownloadUpdateInstaller();
// Start update installer
StartUpdateInstaller(packagePath, installerPath.FullName);
// Close Host Application
if (AutoCloseHostApplication)
- {
Environment.Exit(Environment.ExitCode);
- }
+
+ return true;
}
- return hasDownloaded;
+ return false;
}
}
}
\ No newline at end of file
diff --git a/Pilz.Updating.GUIBase/Pilz.Updating.GUIBase.csproj b/Pilz.Updating.GUIBase/Pilz.Updating.GUIBase.csproj
index 344d33d..cd5c6ee 100644
--- a/Pilz.Updating.GUIBase/Pilz.Updating.GUIBase.csproj
+++ b/Pilz.Updating.GUIBase/Pilz.Updating.GUIBase.csproj
@@ -38,6 +38,8 @@
True
+ 1.yyyy.Mdd.Hmm
+ 1.2023.914.854
diff --git a/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj b/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj
index ae37da7..035a4d2 100644
--- a/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj
+++ b/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj
@@ -51,7 +51,7 @@
- 2022.3.1109
+ 2023.1.117
@@ -148,7 +148,7 @@
-
+
diff --git a/Pilz.Updating/Pilz.Updating.csproj b/Pilz.Updating/Pilz.Updating.csproj
index c6fae79..bd3530c 100644
--- a/Pilz.Updating/Pilz.Updating.csproj
+++ b/Pilz.Updating/Pilz.Updating.csproj
@@ -39,6 +39,8 @@
True
+ 1.yyyy.Mdd.Hmm
+ 1.2023.914.854
@@ -92,7 +94,7 @@
-
+