diff --git a/imgs/bowl.jpeg b/imgs/bowl.jpeg
new file mode 100644
index 00000000..b099e216
Binary files /dev/null and b/imgs/bowl.jpeg differ
diff --git a/src/c#/GeneralUpdate.Bowl.Test/GeneralUpdate.Bowl.Test.csproj b/src/c#/GeneralUpdate.Bowl.Test/GeneralUpdate.Bowl.Test.csproj
new file mode 100644
index 00000000..085bdddf
--- /dev/null
+++ b/src/c#/GeneralUpdate.Bowl.Test/GeneralUpdate.Bowl.Test.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/c#/GeneralUpdate.Bowl.Test/UnitTest1.cs b/src/c#/GeneralUpdate.Bowl.Test/UnitTest1.cs
new file mode 100644
index 00000000..c76c89cc
--- /dev/null
+++ b/src/c#/GeneralUpdate.Bowl.Test/UnitTest1.cs
@@ -0,0 +1,9 @@
+namespace GeneralUpdate.Bowl.Test;
+
+public class UnitTest1
+{
+ [Fact]
+ public void Test1()
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/c#/GeneralUpdate.Bowl/Bowl.cs b/src/c#/GeneralUpdate.Bowl/Bowl.cs
index fc828ebb..25d84697 100644
--- a/src/c#/GeneralUpdate.Bowl/Bowl.cs
+++ b/src/c#/GeneralUpdate.Bowl/Bowl.cs
@@ -4,7 +4,10 @@
namespace GeneralUpdate.Bowl;
-public class Bowl
+///
+/// Surveillance Main Program.
+///
+public sealed class Bowl
{
private IStrategy _strategy;
@@ -14,7 +17,7 @@ public Bowl(MonitorParameter parameter = null)
_strategy!.SetParameter(parameter);
}
- private void CreateStrategy()
+ private Bowl CreateStrategy()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
@@ -24,6 +27,11 @@ private void CreateStrategy()
{
_strategy = new LinuxStrategy();
}
+
+ if (_strategy == null)
+ throw new PlatformNotSupportedException("Unsupported operating system");
+
+ return this;
}
public Bowl SetParameter(MonitorParameter parameter)
@@ -35,5 +43,9 @@ public Bowl SetParameter(MonitorParameter parameter)
return this;
}
- public void Launch() => _strategy.Launch();
+ public Bowl Launch()
+ {
+ _strategy.Launch();
+ return this;
+ }
}
\ No newline at end of file
diff --git a/src/c#/GeneralUpdate.Bowl/Strategys/AbstractStrategy.cs b/src/c#/GeneralUpdate.Bowl/Strategys/AbstractStrategy.cs
index dcf8f275..9b06b153 100644
--- a/src/c#/GeneralUpdate.Bowl/Strategys/AbstractStrategy.cs
+++ b/src/c#/GeneralUpdate.Bowl/Strategys/AbstractStrategy.cs
@@ -11,7 +11,8 @@ public abstract class AbstractStrategy : IStrategy
private readonly IReadOnlyList _sensitiveCharacter = new List
{
"Exit",
- "exit"
+ "exit",
+ "EXIT"
};
public virtual void Launch()
diff --git a/src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs b/src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs
index 64f300c5..bb1c93bf 100644
--- a/src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs
+++ b/src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs
@@ -8,14 +8,16 @@ namespace GeneralUpdate.Bowl.Strategys;
public class LinuxStrategy : AbstractStrategy
{
- /*procdump-3.3.0-0.cm2.x86_64.rpm:
- 适合系统:此RPM包可能适用于基于CentOS或RHEL的某些派生版本,具体来说是CM2版本。CM2通常指的是ClearOS 7.x或类似的社区维护版本。
- procdump-3.3.0-0.el8.x86_64.rpm:
- 适合系统:此RPM包适用于Red Hat Enterprise Linux 8 (RHEL 8)、CentOS 8及其他基于RHEL 8的发行版。
- procdump_3.3.0_amd64.deb:
- 适合系统:此DEB包适用于Debian及其衍生发行版,如Ubuntu,适用于64位系统(amd64架构)。*/
+ /*procdump-3.3.0-0.cm2.x86_64.rpm:
+ Compatible Systems: This RPM package may be suitable for certain CentOS or RHEL-based derivatives, specifically the CM2 version. CM2 typically refers to ClearOS 7.x or similar community-maintained versions.
+
+ procdump-3.3.0-0.el8.x86_64.rpm:
+ Compatible Systems: This RPM package is suitable for Red Hat Enterprise Linux 8 (RHEL 8), CentOS 8, and other RHEL 8-based distributions.
+
+ procdump_3.3.0_amd64.deb:
+ Compatible Systems: This DEB package is suitable for Debian and its derivatives, such as Ubuntu, for 64-bit systems (amd64 architecture).*/
- private IReadOnlyList procdump_amd64 = new List { "Ubuntu", "Debian" };
+ private IReadOnlyList _rocdumpAmd64 = new List { "Ubuntu", "Debian" };
private IReadOnlyList procdump_el8_x86_64 = new List { "Red Hat", "CentOS", "Fedora" };
private IReadOnlyList procdump_cm2_x86_64 = new List { "ClearOS" };
@@ -64,9 +66,9 @@ private void Install()
private string GetPacketName()
{
- string packageFileName = string.Empty;
- LinuxSystem system = GetSystem();
- if (procdump_amd64.Contains(system.Name))
+ var packageFileName = string.Empty;
+ var system = GetSystem();
+ if (_rocdumpAmd64.Contains(system.Name))
{
packageFileName = $"procdump_3.3.0_amd64.deb";
}
@@ -105,9 +107,7 @@ private LinuxSystem GetSystem()
return new LinuxSystem(distro, version);
}
- else
- {
- throw new FileNotFoundException("Cannot determine the Linux distribution. The /etc/os-release file does not exist.");
- }
+
+ throw new FileNotFoundException("Cannot determine the Linux distribution. The /etc/os-release file does not exist.");
}
}
\ No newline at end of file
diff --git a/src/c#/GeneralUpdate.Client.Test/GeneralUpdate.Client.Test.csproj b/src/c#/GeneralUpdate.Client.Test/GeneralUpdate.Client.Test.csproj
new file mode 100644
index 00000000..085bdddf
--- /dev/null
+++ b/src/c#/GeneralUpdate.Client.Test/GeneralUpdate.Client.Test.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/c#/GeneralUpdate.Client.Test/UnitTest1.cs b/src/c#/GeneralUpdate.Client.Test/UnitTest1.cs
new file mode 100644
index 00000000..a34ba46c
--- /dev/null
+++ b/src/c#/GeneralUpdate.Client.Test/UnitTest1.cs
@@ -0,0 +1,9 @@
+namespace GeneralUpdate.Client.Test;
+
+public class UnitTest1
+{
+ [Fact]
+ public void Test1()
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/c#/GeneralUpdate.Client/MySample.cs b/src/c#/GeneralUpdate.Client/MySample.cs
deleted file mode 100644
index d602edbc..00000000
--- a/src/c#/GeneralUpdate.Client/MySample.cs
+++ /dev/null
@@ -1,322 +0,0 @@
-using GeneralUpdate.ClientCore;
-using GeneralUpdate.Core.Bootstrap;
-using GeneralUpdate.Core.Domain.Entity;
-using GeneralUpdate.Core.Domain.Enum;
-using GeneralUpdate.Core.Driver;
-using GeneralUpdate.Core.Events.CommonArgs;
-using GeneralUpdate.Core.Events.MultiEventArgs;
-using GeneralUpdate.Core.Strategys.PlatformWindows;
-using GeneralUpdate.Differential;
-using System.Diagnostics;
-using System.Text;
-
-namespace GeneralUpdate.Client
-{
- internal class MySample
- {
- #region 推送功能
-
- private const string baseUrl = @"http://127.0.0.1:5000";
- private const string hubName = "versionhub";
-
- internal MySample()
- {
- //Receive sample code pushed by the server
- //VersionHub.Instance.Subscribe($"{baseUrl}/{hubName}", "TESTNAME", new Action(GetMessage));
- }
-
- //Receive sample code pushed by the server
- private async void GetMessage(string msg)
- {
- var isUpdate = true;
- if (isUpdate) Upgrade();
- }
-
- #endregion 推送功能
-
- #region 常规更新
-
- public async Task Upgrade()
- {
- //Task.Run(async () =>
- //{
- // var url = "http://192.168.50.203";
- // var appName = "GeneralUpdate.Client";
- // var version = "1.0.0.0";
- // var versionFileName = "version.json";
- // ParamsOSS @params = new ParamsOSS(url, appName, version, versionFileName);
- // await GeneralClientOSS.Start(@params);
- //});
-
- //ClientStrategy该更新策略将完成1.自动升级组件自更新 2.启动更新组件 3.配置好ClientParameter无需再像之前的版本写args数组进程通讯了。
- //generalClientBootstrap.Config(baseUrl, "B8A7FADD-386C-46B0-B283-C9F963420C7C").
- var configinfo = GetWindowsConfigInfo();
- var generalClientBootstrap = await new GeneralClientBootstrap()
- //单个或多个更新包下载通知事件
- .AddListenerMultiDownloadProgress(OnMultiDownloadProgressChanged)
- //单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件
- .AddListenerMultiDownloadStatistics(OnMultiDownloadStatistics)
- //单个或多个更新包下载完成
- .AddListenerMultiDownloadCompleted(OnMultiDownloadCompleted)
- //完成所有的下载任务通知
- .AddListenerMultiAllDownloadCompleted(OnMultiAllDownloadCompleted)
- //下载过程出现的异常通知
- .AddListenerMultiDownloadError(OnMultiDownloadError)
- //整个更新过程出现的任何问题都会通过这个事件通知
- .AddListenerException(OnException)
- .Config(configinfo)
- .Option(UpdateOption.DownloadTimeOut, 60)
- .Option(UpdateOption.Encoding, Encoding.Default)
- .Option(UpdateOption.Format, Format.ZIP)
- //开启驱动更新
- //.Option(UpdateOption.Drive, true)
- //开启遗言功能,需要部署GeneralUpdate.SystemService Windows服务。
- .Option(UpdateOption.WillMessage, true)
- .Strategy()
- //注入一个func让用户决定是否跳过本次更新,如果是强制更新则不生效
- //.SetCustomSkipOption(ShowCustomOption)
- //注入一个自定义方法集合,该集合会在更新启动前执行。执行自定义方法列表如果出现任何异常,将通过异常订阅通知。(推荐在更新之前检查当前软件环境)
- //.AddCustomOption(new List>() { () => Check1(), () => Check2() })
- //默认黑名单文件: { "Newtonsoft.Json.dll" } 默认黑名单文件扩展名: { ".patch", ".7z", ".zip", ".rar", ".tar" , ".json" }
- //如果不需要扩展,需要重新传入黑名单集合来覆盖。
- //.SetBlacklist(GetBlackFiles(), GetBlackFormats())
- .LaunchTaskAsync();
- }
-
- private bool Check1() => true;
-
- private bool Check2() => true;
-
- private List GetBlackFiles()
- {
- var blackFiles = new List();
- blackFiles.Add("MainApp");
- return blackFiles;
- }
-
- private List GetBlackFormats()
- {
- var blackFormats = new List();
- blackFormats.Add(".zip");
- return blackFormats;
- }
-
- ///
- /// 获取Windows平台所需的配置参数
- ///
- ///
- private Configinfo GetWindowsConfigInfo()
- {
- //该对象用于主程序客户端与更新组件进程之间交互用的对象
- var config = new Configinfo();
- //本机的客户端程序应用地址
- config.InstallPath = @"D:\packet\source";
- //更新公告网页
- config.UpdateLogUrl = "https://www.baidu.com/";
- //客户端当前版本号
- config.ClientVersion = "1.1.1.1";
- //客户端类型:1.主程序客户端 2.更新组件
- config.AppType = AppType.UpgradeApp;
- //指定应用密钥,用于区分客户端应用
- config.AppSecretKey = "B8A7FADD-386C-46B0-B283-C9F963420C7C";
- //更新组件更新包下载地址
- config.UpdateUrl = $"{baseUrl}/versions/{config.AppType}/{config.ClientVersion}/{config.AppSecretKey}";
- //更新程序exe名称
- config.AppName = "GeneralUpdate.Core";
- //主程序客户端exe名称
- config.MainAppName = "GeneralUpdate.ClientCore";
- //主程序信息
- var mainVersion = "1.1.1.1";
- //主程序客户端更新包下载地址
- config.MainUpdateUrl = $"{baseUrl}/versions/{AppType.ClientApp}/{mainVersion}/{config.AppSecretKey}";
- return config;
- }
-
- ///
- /// 获取Android平台所需要的参数
- ///
- ///
- private Configinfo GetAndroidConfigInfo()
- {
- var config = new Configinfo();
- config.InstallPath = System.Threading.Thread.GetDomain().BaseDirectory;
- //主程序客户端当前版本号
- config.ClientVersion = "1.0.0.0"; //VersionTracking.Default.CurrentVersion.ToString();
- config.AppType = AppType.ClientApp;
- config.AppSecretKey = "41A54379-C7D6-4920-8768-21A3468572E5";
- //主程序客户端exe名称
- config.MainAppName = "GeneralUpdate.ClientCore";
- //主程序信息
- var mainVersion = "1.1.1.1";
- config.MainUpdateUrl = $"{baseUrl}/versions/{AppType.ClientApp}/{mainVersion}/{config.AppSecretKey}";
- return config;
- }
-
- ///
- /// 让用户决定是否跳过本次更新
- ///
- ///
- private async Task ShowCustomOption()
- {
- return await Task.FromResult(true);
- }
-
- private void OnMultiDownloadStatistics(object sender, MultiDownloadStatisticsEventArgs e)
- {
- //e.Remaining 剩余下载时间
- //e.Speed 下载速度
- //e.Version 当前下载的版本信息
- }
-
- private void OnMultiDownloadProgressChanged(object sender, MultiDownloadProgressChangedEventArgs e)
- {
- //e.TotalBytesToReceive 当前更新包需要下载的总大小
- //e.ProgressValue 当前进度值
- //e.ProgressPercentage 当前进度的百分比
- //e.Version 当前下载的版本信息
- //e.Type 当前正在执行的操作 1.ProgressType.Check 检查版本信息中 2.ProgressType.Donwload 正在下载当前版本 3. ProgressType.Updatefile 更新当前版本 4. ProgressType.Done更新完成 5.ProgressType.Fail 更新失败
- //e.BytesReceived 已下载大小
- DispatchMessage($"{e.ProgressPercentage}%");
- //MyProgressBar.ProgressTo(e.ProgressValue, 100, Easing.Default);
- }
-
- private void OnException(object sender, ExceptionEventArgs e)
- {
- //DispatchMessage(e.Exception.Message);
- }
-
- private void OnMultiAllDownloadCompleted(object sender, MultiAllDownloadCompletedEventArgs e)
- {
- //e.FailedVersions; 如果出现下载失败则会把下载错误的版本、错误原因统计到该集合当中。
- DispatchMessage($"Is all download completed {e.IsAllDownloadCompleted}.");
- }
-
- private void OnMultiDownloadCompleted(object sender, MultiDownloadCompletedEventArgs e)
- {
- var info = e.Version as VersionInfo;
- DispatchMessage($"{info.Name} download completed.");
- }
-
- private void OnMultiDownloadError(object sender, MultiDownloadErrorEventArgs e)
- {
- var info = e.Version as VersionInfo;
- DispatchMessage($"{info.Name} error!");
- }
-
- private void DispatchMessage(string message)
- {
- }
-
- #endregion 常规更新
-
- #region 测试二进制更新包整理
-
- public async Task TestDifferentialClean()
- {
- var path1 = "D:\\packet\\source";
- var path2 = "D:\\packet\\target";
- var path3 = "D:\\packet\\patchs";
- await DifferentialCore.Instance.Clean(path1, path2, path3);
- }
-
- public async Task TestDifferentialDirty()
- {
- var path1 = "D:\\packet\\source";
- var path2 = "D:\\packet\\patchs";
- await DifferentialCore.Instance.Dirty(path1, path2);
- }
-
- #endregion 测试二进制更新包整理
-
- #region 测试驱动功能
-
- public void TestDrive()
- {
- var path1 = "D:\\packet\\source";
- var path2 = "D:\\packet\\target";
-
- var drivers = GetAllDriverDirectories(path1);
-
- var information = new DriverInformation.Builder()
- .SetInstallDirectory(path1)
- .SetOutPutDirectory(path2)
- .SetDriverNames(drivers)
- .Build();
-
- var processor = new DriverProcessor();
- processor.AddCommand(new BackupDriverCommand(information));
- processor.AddCommand(new DeleteDriverCommand(information));
- processor.AddCommand(new InstallDriverCommand(information));
- processor.ProcessCommands();
- }
-
- ///
- /// Identifies all folders containing driver files in the specified directory and returns the directory collection.
- ///
- ///
- ///
- private List GetAllDriverDirectories(string path)
- {
- var driverDirectories = new HashSet();
- try
- {
- foreach (string filePath in Directory.GetFiles(path))
- {
- if (IsDriverFile(filePath))
- driverDirectories.Add(filePath);
- }
-
- foreach (string directory in Directory.GetDirectories(path))
- {
- driverDirectories.UnionWith(GetAllDriverDirectories(directory));
- }
- }
- catch (UnauthorizedAccessException)
- {
- Trace.WriteLine("No access directory:" + path);
- }
- catch (PathTooLongException)
- {
- Trace.WriteLine("Path overlength:" + path);
- }
-
- return new List(driverDirectories);
- }
-
- ///
- /// Match the driver installation boot file.
- ///
- ///
- ///
- private bool IsDriverFile(string filePath) =>
- string.Equals(Path.GetExtension(filePath), ".inf", StringComparison.OrdinalIgnoreCase);
-
- #endregion 测试驱动功能
-
- #region 文件管理测试
-
- public void TestFileProvider()
- {
- var sourcePath = "D:\\packet\\source";
- var targetPath = "D:\\packet\\target";
- var resultPath = "D:\\packet\\patchs";
-
- //FileProvider fileProvider = new FileProvider();
- //var list = fileProvider.ExecuteOperation(sourcePath, targetPath,new List(), new List());
- //foreach (var item in list) {
- // Console.WriteLine(item);
- //}
- //Console.WriteLine("total" + list.Count());
- //Console.WriteLine("--------------------------------------");
- //FileProvider fileProvider1 = new FileProvider();
- //var list1 = fileProvider1.ExecuteOperation(targetPath, sourcePath, new List(), new List());
- //foreach (var item in list1)
- //{
- // Console.WriteLine(item);
- //}
- //Console.WriteLine("total" + list1.Count());
- }
-
- #endregion 文件管理测试
- }
-}
\ No newline at end of file
diff --git a/src/c#/GeneralUpdate.Client/Program.cs b/src/c#/GeneralUpdate.Client/Program.cs
index 1b9dd51c..dc9b8f2b 100644
--- a/src/c#/GeneralUpdate.Client/Program.cs
+++ b/src/c#/GeneralUpdate.Client/Program.cs
@@ -1,28 +1,104 @@
-namespace GeneralUpdate.Client
+using System.Diagnostics;
+using System.Text;
+using GeneralUpdate.ClientCore;
+using GeneralUpdate.Common.Download;
+using GeneralUpdate.Common.Internal;
+using GeneralUpdate.Common.Internal.Bootstrap;
+using GeneralUpdate.Common.Shared.Object;
+
+namespace GeneralUpdate.Client
{
- internal class Program
+ internal class Progra
{
private static void Main(string[] args)
{
- MySample sample = new MySample();
- sample.TestFileProvider();
- //Task.Run(async() =>
- //{
- // //415eed05eb310f480d1e4d15516fa00e484ddb9f416908b217f17b782ded2030
- // //var zip1 = @"D:\github_project\WpfClient\WebApi\UpdateFiles\WpfClient_1_24.1.5.1218.zip";
- // //94bd3d806d39cd1b8813298ec0637c7f377658e766845a06cc50917306cb4ad9
- // //var zip2 = @"D:\github_project\WpfClient\WebApi\UpdateFiles\WpfClient_1_24.1.5.1224.zip";
-
- // //var hashAlgorithm = new Sha256HashAlgorithm();
- // //var hashSha256 = hashAlgorithm.ComputeHash(zip1);
- // //var hashSha2561 = hashAlgorithm.ComputeHash(zip2);
-
- // MySample sample = new MySample();
- // //await sample.TestDifferentialClean();
- // //await sample.TestDifferentialDirty();
- // await sample.Upgrade();
- //});
+ /*Task.Run(async () =>
+ {
+ var source = @"D:\packet\app";
+ var target = @"D:\packet\release";
+ var patch = @"D:\packet\patch";
+
+ await DifferentialCore.Instance?.Clean(source, target, patch);
+ await DifferentialCore.Instance?.Dirty(source, patch);
+ });*/
+
+ Task.Run(async () =>
+ {
+ Console.WriteLine("主程序启动辣!!!!");
+ await Task.Delay(3000);
+
+ var configinfo = new Configinfo();
+ //configinfo.UpdateLogUrl = "https://www.baidu.com";
+ configinfo.ReportUrl = "http://127.0.0.1:5008/Upgrade/Report";
+ configinfo.UpdateUrl = "http://127.0.0.1:5008/Upgrade/Verification";
+
+ configinfo.AppName = "GeneralUpdate.Upgrad.exe";
+ configinfo.MainAppName = "GeneralUpdate.Client.exe";
+ configinfo.InstallPath = Thread.GetDomain().BaseDirectory;
+
+ //当前客户端的版本号
+ configinfo.ClientVersion = "1.0.0.0";
+ //当前升级端的版本号
+ configinfo.UpgradeClientVersion = "1.0.0.0";
+
+ //平台
+ configinfo.Platform = 1;
+ //产品id
+ configinfo.ProductId = "a77c9df5-45f8-4ee9-b3ad-b9431ce0b51c";
+ //应用密钥
+ configinfo.AppSecretKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ _ = new GeneralClientBootstrap()//单个或多个更新包下载通知事件
+ .AddListenerMultiDownloadProgress(OnMultiDownloadProgressChanged)
+ //单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件
+ .AddListenerMultiDownloadStatistics(OnMultiDownloadStatistics)
+ //单个或多个更新包下载完成
+ .AddListenerMultiDownloadCompleted(OnMultiDownloadCompleted)
+ //完成所有的下载任务通知
+ .AddListenerMultiAllDownloadCompleted(OnMultiAllDownloadCompleted)
+ //下载过程出现的异常通知
+ .AddListenerMultiDownloadError(OnMultiDownloadError)
+ //整个更新过程出现的任何问题都会通过这个事件通知
+ .AddListenerException(OnException)
+ .SetConfig(configinfo)
+ .Option(UpdateOption.DownloadTimeOut, 60)
+ .Option(UpdateOption.Encoding, Encoding.UTF8)
+ .Option(UpdateOption.Format, Format.ZIP)
+ .LaunchAsync();
+ });
+
Console.Read();
}
+
+ private static void OnMultiDownloadError(object arg1, MultiDownloadErrorEventArgs arg2)
+ {
+ Debug.WriteLine(arg2.Exception);
+ }
+
+ private static void OnMultiAllDownloadCompleted(object arg1, MultiAllDownloadCompletedEventArgs arg2)
+ {
+ Debug.WriteLine(arg2.IsAllDownloadCompleted);
+ }
+
+ private static void OnMultiDownloadCompleted(object arg1, MultiDownloadCompletedEventArgs arg2)
+ {
+ var v = arg2.Version as VersionInfo;
+ Debug.WriteLine(v.Version);
+ }
+
+ private static void OnMultiDownloadStatistics(object arg1, MultiDownloadStatisticsEventArgs arg2)
+ {
+ Debug.WriteLine(arg2.Speed);
+ }
+
+ private static void OnMultiDownloadProgressChanged(object arg1, MultiDownloadProgressChangedEventArgs arg2)
+ {
+ Debug.WriteLine(arg2.ProgressValue);
+ }
+
+ private static void OnException(object arg1, ExceptionEventArgs arg2)
+ {
+ Debug.WriteLine(arg2.Exception);
+ }
}
}
\ No newline at end of file
diff --git a/src/c#/GeneralUpdate.ClientCore/Bootstrap/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Bootstrap/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/CustomAwaiter/.gitkeep b/src/c#/GeneralUpdate.ClientCore/CustomAwaiter/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Differential/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Differential/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Differential/Binary/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Differential/Binary/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Differential/ContentProvider/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Differential/ContentProvider/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Differential/GStream/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Differential/GStream/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Domain/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Domain/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Domain/DTO/Assembler/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Domain/DTO/Assembler/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Domain/Entity/Assembler/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Domain/Entity/Assembler/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Domain/Enum/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Domain/Enum/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Domain/PO/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Domain/PO/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Domain/PO/Assembler/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Domain/PO/Assembler/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Domain/Service/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Domain/Service/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Domain/VO/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Domain/VO/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Download/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Download/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Driver/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Driver/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Events/CommonArgs/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Events/CommonArgs/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Events/MultiEventArgs/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Events/MultiEventArgs/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Exceptions/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Exceptions/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Exceptions/CustomArgs/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Exceptions/CustomArgs/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/Exceptions/CustomException/.gitkeep b/src/c#/GeneralUpdate.ClientCore/Exceptions/CustomException/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
index 11bded52..fe14f11e 100644
--- a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
+++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
@@ -1,271 +1,370 @@
-using GeneralUpdate.Core.Bootstrap;
-using GeneralUpdate.Core.Domain.DTO.Assembler;
-using GeneralUpdate.Core.Domain.Entity;
-using GeneralUpdate.Core.Domain.Entity.Assembler;
-using GeneralUpdate.Core.Domain.Enum;
-using GeneralUpdate.Core.Domain.Service;
-using GeneralUpdate.Core.Exceptions.CustomArgs;
-using GeneralUpdate.Core.Exceptions.CustomException;
-using GeneralUpdate.Core.Strategys;
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.IO;
using System.Linq;
-using System.Reflection;
-using System.Security;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Text.Json;
using System.Threading.Tasks;
+using GeneralUpdate.ClientCore.Strategys;
+using GeneralUpdate.Common.FileBasic;
+using GeneralUpdate.Common.Download;
+using GeneralUpdate.Common.Internal;
+using GeneralUpdate.Common.Internal.Bootstrap;
+using GeneralUpdate.Common.Internal.Event;
+using GeneralUpdate.Common.Internal.Strategy;
+using GeneralUpdate.Common.Shared.Object;
+using GeneralUpdate.Common.Shared.Service;
-namespace GeneralUpdate.ClientCore
+namespace GeneralUpdate.ClientCore;
+
+///
+/// This component is used only for client application bootstrapping classes.
+///
+public class GeneralClientBootstrap : AbstractBootstrap
{
///
- /// This component is used only for client application bootstrapping classes.
+ /// All update actions of the core object for automatic upgrades will be related to the packet object.
///
- public class GeneralClientBootstrap : AbstractBootstrap
- {
- private Func _customSkipOption;
- private Func> _customSkipTaskOption;
+ private GlobalConfigInfo? _configinfo;
+ private IStrategy? _strategy;
+ private Func? _customSkipOption;
+ private readonly List> _customOptions = new();
+
+ #region Public Methods
- private List> _customOptions;
- private List>> _customTaskOptions;
+ ///
+ /// Main function for booting the update startup.
+ ///
+ ///
+ public override async Task LaunchAsync()
+ {
+ ExecuteCustomOptions();
+ ClearEnvironmentVariable();
+ await ExecuteWorkflowAsync();
+ return this;
+ }
- public GeneralClientBootstrap() : base()
+ ///
+ /// Configure server address (Recommended Windows,Linux,Mac).
+ ///
+ /// Remote server address.
+ /// The updater name does not need to contain an extension.
+ ///
+ /// Parameter initialization is abnormal.
+ public GeneralClientBootstrap SetConfig(Configinfo configInfo)
+ {
+ Debug.Assert(configInfo != null, "configInfo should not be null");
+ configInfo?.Validate();
+ _configinfo = new GlobalConfigInfo
{
- _customOptions = new List>();
- _customTaskOptions = new List>>();
- }
+ AppName = configInfo.AppName,
+ MainAppName = configInfo.MainAppName,
+ ClientVersion = configInfo.ClientVersion,
+ InstallPath = configInfo.InstallPath,
+ UpdateLogUrl = configInfo.UpdateLogUrl,
+ UpdateUrl = configInfo.UpdateUrl,
+ ReportUrl = configInfo.ReportUrl,
+ AppSecretKey = configInfo.AppSecretKey,
+ BlackFormats = configInfo.BlackFormats,
+ BlackFiles = configInfo.BlackFiles,
+ Platform = configInfo.Platform,
+ ProductId = configInfo.ProductId,
+ UpgradeClientVersion = configInfo.UpgradeClientVersion
+ };
+ return this;
+ }
- #region Public Methods
+ ///
+ /// Let the user decide whether to update in the state of non-mandatory update.
+ ///
+ ///
+ /// Custom function ,Custom actions to let users decide whether to update. true update false do not
+ /// update .
+ ///
+ ///
+ public GeneralClientBootstrap SetCustomSkipOption(Func func)
+ {
+ Debug.Assert(func != null);
+ _customSkipOption = func;
+ return this;
+ }
- ///
- /// Start the update.
- ///
- ///
- public override GeneralClientBootstrap LaunchAsync()
- {
- Task.Run(() => BaseLaunch());
- return this;
- }
+ ///
+ /// Add an asynchronous custom operation.
+ /// In theory, any custom operation can be done. It is recommended to register the environment check method to ensure
+ /// that there are normal dependencies and environments after the update is completed.
+ ///
+ ///
+ ///
+ ///
+ public GeneralClientBootstrap AddCustomOption(List> funcs)
+ {
+ Debug.Assert(funcs != null && funcs.Any());
+ _customOptions.AddRange(funcs);
+ return this;
+ }
- ///
- /// Start the update.
- ///
- ///
- public Task LaunchTaskAsync() => BaseLaunch();
+ public GeneralClientBootstrap AddListenerMultiAllDownloadCompleted(
+ Action