├── src
└── c#
│ ├── GeneralUpdate.Bowl
│ ├── Common
│ │ └── git.keep
│ ├── bowl.jpeg
│ ├── Applications
│ │ ├── Windows
│ │ │ ├── procdump.exe
│ │ │ ├── procdump64.exe
│ │ │ ├── procdump64a.exe
│ │ │ └── export.bat
│ │ └── Linux
│ │ │ ├── procdump_3.3.0_amd64.deb
│ │ │ ├── procdump-3.3.0-0.cm2.x86_64.rpm
│ │ │ ├── procdump-3.3.0-0.el8.x86_64.rpm
│ │ │ └── install.sh
│ ├── Internal
│ │ ├── CrashJsonContext.cs
│ │ ├── Crash.cs
│ │ └── LinuxSystem.cs
│ ├── Strategys
│ │ ├── IStrategy.cs
│ │ ├── MonitorParameter.cs
│ │ ├── AbstractStrategy.cs
│ │ ├── WindowStrategy.cs
│ │ └── LinuxStrategy.cs
│ └── Bowl.cs
│ ├── GeneralUpdate.Core
│ ├── Common
│ │ └── git.keep
│ ├── GeneralUpdate.ico
│ ├── GeneralUpdate.png
│ ├── Properties
│ │ ├── launchSettings.json
│ │ └── AssemblyInfo.cs
│ ├── Driver
│ │ ├── DriverInfo.cs
│ │ ├── DeleteDriverCommand.cs
│ │ ├── DriverCommand.cs
│ │ ├── DriverProcessor.cs
│ │ ├── RestoreDriverCommand.cs
│ │ ├── InstallDriverCommand.cs
│ │ ├── DriverInformation.cs
│ │ ├── CommandExecutor.cs
│ │ └── BackupDriverCommand.cs
│ ├── Pipeline
│ │ ├── PatchMiddleware.cs
│ │ ├── CompressMiddleware.cs
│ │ ├── HashMiddleware.cs
│ │ └── DriverMiddleware.cs
│ ├── GeneralUpdateOSS.cs
│ └── Strategys
│ │ ├── OSSStrategy.cs
│ │ └── WindowsStrategy.cs
│ ├── GeneralUpdate.ClientCore
│ ├── Common
│ │ └── git.keep
│ ├── GeneralUpdate.ico
│ ├── GeneralUpdate.png
│ ├── GeneralClientBootstrap.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Pipeline
│ │ ├── PatchMiddleware.cs
│ │ ├── CompressMiddleware.cs
│ │ └── HashMiddleware.cs
│ ├── Hubs
│ │ ├── RandomRetryPolicy.cs
│ │ ├── IUpgradeHubService.cs
│ │ └── UpgradeHubService.cs
│ ├── GeneralClientOSS.cs
│ └── Strategys
│ │ ├── WindowsStrategy.cs
│ │ └── LinuxStrategy.cs
│ ├── GeneralUpdate.Common
│ ├── GeneralUpdate128.png
│ ├── Shared
│ │ ├── Object
│ │ │ ├── Enum
│ │ │ │ ├── Format.cs
│ │ │ │ ├── PlatformType.cs
│ │ │ │ ├── ReportType.cs
│ │ │ │ └── AppType.cs
│ │ │ ├── DTO
│ │ │ │ ├── VersionRespDTO.cs
│ │ │ │ └── BaseResponseDTO.cs
│ │ │ ├── ObjectTranslator.cs
│ │ │ ├── Packet.cs
│ │ │ ├── VersionInfo.cs
│ │ │ ├── VersionOSS.cs
│ │ │ ├── GlobalConfigInfoOSS.cs
│ │ │ ├── Configinfo.cs
│ │ │ ├── GlobalConfigInfo.cs
│ │ │ └── ProcessInfo.cs
│ │ ├── Trace
│ │ │ ├── WindowsOutputDebugListener.cs
│ │ │ ├── TextTraceListener.cs
│ │ │ └── GeneralTracer.cs
│ │ └── Service
│ │ │ └── VersionService.cs
│ ├── Internal
│ │ ├── JsonContext
│ │ │ ├── PacketJsonContext.cs
│ │ │ ├── ProcessInfoJsonContext.cs
│ │ │ ├── VersionRespJsonContext.cs
│ │ │ ├── ReportRespJsonContext.cs
│ │ │ ├── GlobalConfigInfoOSSJsonContext.cs
│ │ │ ├── FileNodesJsonContext.cs
│ │ │ ├── VersionOSSJsonContext.cs
│ │ │ └── HttpParameterJsonContext.cs
│ │ ├── Pipeline
│ │ │ ├── IMiddleware.cs
│ │ │ ├── PipelineContext.cs
│ │ │ └── PipelineBuilder.cs
│ │ ├── Exception
│ │ │ └── ExceptionEventArgs.cs
│ │ ├── Bootstrap
│ │ │ ├── Environments.cs
│ │ │ ├── UpdateOptionValue.cs
│ │ │ └── AbstractBootstrap.cs
│ │ ├── Strategy
│ │ │ ├── IStrategy.cs
│ │ │ └── AbstractStrategy.cs
│ │ └── Event
│ │ │ ├── IEventManager.cs
│ │ │ └── EventManager.cs
│ ├── HashAlgorithms
│ │ ├── Sha256HashAlgorithm.cs
│ │ └── HashAlgorithmBase.cs
│ ├── Compress
│ │ ├── ICompressionStrategy.cs
│ │ └── CompressProvider.cs
│ ├── Download
│ │ ├── MultiEventArgs
│ │ │ ├── MutiDownloadCompletedEventArgs.cs
│ │ │ ├── MutiDownloadErrorEventArgs.cs
│ │ │ ├── MutiAllDownloadCompletedEventArgs.cs
│ │ │ └── MutiDownloadStatisticsEventArgs.cs
│ │ └── DownloadManager.cs
│ ├── FileBasic
│ │ ├── ComparisonResult.cs
│ │ ├── FileNode.cs
│ │ ├── BlackListManager.cs
│ │ └── FileTree.cs
│ └── GeneralUpdate.Common.csproj
│ ├── GeneralUpdate.Differential
│ ├── GeneralUpdate.ico
│ ├── GeneralUpdate.png
│ ├── Binary
│ │ ├── IChecksum.cs
│ │ ├── BZip2Constants.cs
│ │ └── StrangeCRC.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── GeneralUpdate.Differential.csproj
│ └── DifferentialCore.cs
│ ├── GeneralUpdate.Client
│ ├── GeneralUpdate.Client.csproj
│ └── Program.cs
│ ├── GeneralUpdate.Upgrad
│ ├── GeneralUpdate.Upgrad.csproj
│ └── Program.cs
│ ├── Generalupdate.CatBowl
│ ├── Generalupdate.CatBowl.csproj
│ └── Program.cs
│ └── GeneralUpdate.sln
├── imgs
├── ui.png
├── 麒麟.png
├── 龙芯.png
├── bowl.jpeg
├── gitee.png
├── linux.png
├── winui.png
├── 统信UOS.png
├── Windows.png
├── contact.png
├── gitcode.jpg
├── github.png
├── toolkit.png
├── ubuntu.png
├── GeneralUpdate.ico
├── GeneralUpdate.png
├── WPFPage_16x.png
├── GeneralUpdate_h.png
├── GeneralUpdate128.png
├── GeneralUpdate_h2.png
├── dot-net-plain-wordmark.png
└── purple-border-gradient-icon.png
├── NuGet.Config
├── .github
└── workflows
│ └── dotnet-ci.yaml
├── git_push.bat
├── .gitattributes
└── .gitignore
/src/c#/GeneralUpdate.Bowl/Common/git.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Common/git.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/Common/git.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/imgs/ui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/ui.png
--------------------------------------------------------------------------------
/imgs/麒麟.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/麒麟.png
--------------------------------------------------------------------------------
/imgs/龙芯.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/龙芯.png
--------------------------------------------------------------------------------
/imgs/bowl.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/bowl.jpeg
--------------------------------------------------------------------------------
/imgs/gitee.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/gitee.png
--------------------------------------------------------------------------------
/imgs/linux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/linux.png
--------------------------------------------------------------------------------
/imgs/winui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/winui.png
--------------------------------------------------------------------------------
/imgs/统信UOS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/统信UOS.png
--------------------------------------------------------------------------------
/imgs/Windows.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/Windows.png
--------------------------------------------------------------------------------
/imgs/contact.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/contact.png
--------------------------------------------------------------------------------
/imgs/gitcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/gitcode.jpg
--------------------------------------------------------------------------------
/imgs/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/github.png
--------------------------------------------------------------------------------
/imgs/toolkit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/toolkit.png
--------------------------------------------------------------------------------
/imgs/ubuntu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/ubuntu.png
--------------------------------------------------------------------------------
/imgs/GeneralUpdate.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/GeneralUpdate.ico
--------------------------------------------------------------------------------
/imgs/GeneralUpdate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/GeneralUpdate.png
--------------------------------------------------------------------------------
/imgs/WPFPage_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/WPFPage_16x.png
--------------------------------------------------------------------------------
/imgs/GeneralUpdate_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/GeneralUpdate_h.png
--------------------------------------------------------------------------------
/imgs/GeneralUpdate128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/GeneralUpdate128.png
--------------------------------------------------------------------------------
/imgs/GeneralUpdate_h2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/GeneralUpdate_h2.png
--------------------------------------------------------------------------------
/imgs/dot-net-plain-wordmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/dot-net-plain-wordmark.png
--------------------------------------------------------------------------------
/imgs/purple-border-gradient-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/imgs/purple-border-gradient-icon.png
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/bowl.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Bowl/bowl.jpeg
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/GeneralUpdate.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Core/GeneralUpdate.ico
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/GeneralUpdate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Core/GeneralUpdate.png
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ico
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.png
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/GeneralUpdate128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Common/GeneralUpdate128.png
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Differential/GeneralUpdate.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Differential/GeneralUpdate.ico
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Differential/GeneralUpdate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Differential/GeneralUpdate.png
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Applications/Windows/procdump.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Bowl/Applications/Windows/procdump.exe
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Applications/Windows/procdump64.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Bowl/Applications/Windows/procdump64.exe
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Applications/Windows/procdump64a.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Bowl/Applications/Windows/procdump64a.exe
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Applications/Linux/procdump_3.3.0_amd64.deb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Bowl/Applications/Linux/procdump_3.3.0_amd64.deb
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/Enum/Format.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Common.Shared.Object
2 | {
3 | public class Format
4 | {
5 | public const string ZIP = ".zip";
6 | }
7 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Applications/Linux/procdump-3.3.0-0.cm2.x86_64.rpm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Bowl/Applications/Linux/procdump-3.3.0-0.cm2.x86_64.rpm
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Applications/Linux/procdump-3.3.0-0.el8.x86_64.rpm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneralLibrary/GeneralUpdate/HEAD/src/c#/GeneralUpdate.Bowl/Applications/Linux/procdump-3.3.0-0.el8.x86_64.rpm
--------------------------------------------------------------------------------
/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/DTO/VersionRespDTO.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace GeneralUpdate.Common.Shared.Object;
4 | public class VersionRespDTO : BaseResponseDTO>;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/Enum/PlatformType.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Common.Shared.Object.Enum;
2 |
3 | public class PlatformType
4 | {
5 | public const int Windows = 1;
6 |
7 | public const int Linux = 2;
8 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Internal/CrashJsonContext.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json.Serialization;
2 |
3 | namespace GeneralUpdate.Bowl.Internal;
4 |
5 | [JsonSerializable(typeof(Crash))]
6 | internal partial class CrashJsonContext : JsonSerializerContext;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Strategys/IStrategy.cs:
--------------------------------------------------------------------------------
1 | using GeneralUpdate.Bowl.Internal;
2 |
3 | namespace GeneralUpdate.Bowl.Strategys;
4 |
5 | internal interface IStrategy
6 | {
7 | void Launch();
8 |
9 | void SetParameter(MonitorParameter parameter);
10 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/Enum/ReportType.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Common.Shared.Object.Enum;
2 |
3 | public class ReportType
4 | {
5 | public const int None = 0;
6 |
7 | public const int Success = 2;
8 |
9 | public const int Failure = 3;
10 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/JsonContext/PacketJsonContext.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json.Serialization;
2 | using GeneralUpdate.Common.Shared.Object;
3 |
4 | namespace GeneralUpdate.Common.Internal.JsonContext;
5 |
6 | [JsonSerializable(typeof(Packet))]
7 | public partial class PacketJsonContext : JsonSerializerContext;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/HashAlgorithms/Sha256HashAlgorithm.cs:
--------------------------------------------------------------------------------
1 | using System.Security.Cryptography;
2 |
3 | namespace GeneralUpdate.Common.HashAlgorithms
4 | {
5 | public class Sha256HashAlgorithm : HashAlgorithmBase
6 | {
7 | protected override HashAlgorithm GetHashAlgorithm() => SHA256.Create();
8 | }
9 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/JsonContext/ProcessInfoJsonContext.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json.Serialization;
2 | using GeneralUpdate.Common.Shared.Object;
3 |
4 | namespace GeneralUpdate.Common.Internal.JsonContext;
5 |
6 | [JsonSerializable(typeof(ProcessInfo))]
7 | public partial class ProcessInfoJsonContext : JsonSerializerContext;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/ObjectTranslator.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Common.Shared.Object;
2 |
3 | public sealed class ObjectTranslator
4 | {
5 | public static string GetPacketHash(object version) =>
6 | !GeneralTracer.IsTracingEnabled() ? string.Empty : $"[PacketHash]:{(version as VersionInfo).Hash} ";
7 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Internal/Crash.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using GeneralUpdate.Bowl.Strategys;
3 |
4 | namespace GeneralUpdate.Bowl.Internal;
5 |
6 | internal class Crash
7 | {
8 | public MonitorParameter Parameter { get; set; }
9 |
10 | public List ProcdumpOutPutLines { get; set; }
11 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/JsonContext/VersionRespJsonContext.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json.Serialization;
2 | using GeneralUpdate.Common.Shared.Object;
3 |
4 | namespace GeneralUpdate.Common.Internal.JsonContext;
5 |
6 | [JsonSerializable(typeof(VersionRespDTO))]
7 | public partial class VersionRespJsonContext : JsonSerializerContext;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/JsonContext/ReportRespJsonContext.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json.Serialization;
2 | using GeneralUpdate.Common.Shared.Object;
3 |
4 | namespace GeneralUpdate.Common.Internal.JsonContext;
5 |
6 | [JsonSerializable(typeof(BaseResponseDTO))]
7 | public partial class ReportRespJsonContext : JsonSerializerContext;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Pipeline/IMiddleware.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace GeneralUpdate.Common.Internal.Pipeline
4 | {
5 | ///
6 | /// Pipeline middleware.
7 | ///
8 | public interface IMiddleware
9 | {
10 | Task InvokeAsync(PipelineContext context);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/JsonContext/GlobalConfigInfoOSSJsonContext.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json.Serialization;
2 | using GeneralUpdate.Common.Shared.Object;
3 |
4 | namespace GeneralUpdate.Common.Internal.JsonContext;
5 |
6 | [JsonSerializable(typeof(GlobalConfigInfoOSS))]
7 | public partial class GlobalConfigInfoOSSJsonContext : JsonSerializerContext;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/JsonContext/FileNodesJsonContext.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text.Json.Serialization;
3 | using GeneralUpdate.Common.FileBasic;
4 |
5 | namespace GeneralUpdate.Common.Internal.JsonContext;
6 |
7 | [JsonSerializable(typeof(List))]
8 | public partial class FileNodesJsonContext : JsonSerializerContext;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Exception/ExceptionEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace GeneralUpdate.Common.Internal;
4 |
5 | public class ExceptionEventArgs(Exception? exception = null, string? message = null) : EventArgs
6 | {
7 | public Exception Exception { get; private set; } = exception;
8 | public string Message { get; private set; } = message;
9 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/JsonContext/VersionOSSJsonContext.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text.Json.Serialization;
3 | using GeneralUpdate.Common.Shared.Object;
4 |
5 | namespace GeneralUpdate.Common.Internal.JsonContext;
6 |
7 | [JsonSerializable(typeof(List))]
8 | public partial class VersionOSSJsonContext : JsonSerializerContext;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Internal/LinuxSystem.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Bowl.Internal;
2 |
3 | internal class LinuxSystem
4 | {
5 | internal string Name { get; set; }
6 |
7 | internal string Version { get; set; }
8 |
9 | internal LinuxSystem(string name, string version)
10 | {
11 | Name = name;
12 | Version = version;
13 | }
14 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Compress/ICompressionStrategy.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace GeneralUpdate.Common.Compress;
4 |
5 | public interface ICompressionStrategy
6 | {
7 | void Compress(string sourcePath, string destinationPath, bool includeRootDirectory, Encoding encoding);
8 | void Decompress(string archivePath, string destinationPath, Encoding encoding);
9 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "GeneralUpdate.Core": {
4 | "commandName": "Project",
5 | "launchBrowser": true,
6 | "environmentVariables": {
7 | "ASPNETCORE_ENVIRONMENT": "Development"
8 | },
9 | "applicationUrl": "https://localhost:65348;http://localhost:65359"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Differential/Binary/IChecksum.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Differential.Binary
2 | {
3 | public interface IChecksum
4 | {
5 | long Value { get; }
6 |
7 | void Reset();
8 |
9 | void Update(int value);
10 |
11 | void Update(byte[] buffer);
12 |
13 | void Update(byte[] buffer, int offset, int count);
14 | }
15 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "GeneralUpdate.ClientCore": {
4 | "commandName": "Project",
5 | "launchBrowser": true,
6 | "environmentVariables": {
7 | "ASPNETCORE_ENVIRONMENT": "Development"
8 | },
9 | "applicationUrl": "https://localhost:65352;http://localhost:65362"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Differential/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "GeneralUpdate.Differential": {
4 | "commandName": "Project",
5 | "launchBrowser": true,
6 | "environmentVariables": {
7 | "ASPNETCORE_ENVIRONMENT": "Development"
8 | },
9 | "applicationUrl": "https://localhost:65354;http://localhost:65360"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Download/MultiEventArgs/MutiDownloadCompletedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace GeneralUpdate.Common.Download
4 | {
5 | public class MultiDownloadCompletedEventArgs(object version, bool isComplated) : EventArgs
6 | {
7 | public object Version { get; private set; } = version;
8 |
9 | public bool IsComplated { get; private set; } = isComplated;
10 | }
11 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/Enum/AppType.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Common.Shared.Object
2 | {
3 | public class AppType
4 | {
5 | ///
6 | /// main program
7 | ///
8 | public const int ClientApp = 1;
9 |
10 | ///
11 | /// upgrade program.
12 | ///
13 | public const int UpgradeApp = 2;
14 | }
15 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Driver/DriverInfo.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Core.Driver;
2 |
3 | public class DriverInfo
4 | {
5 | public string PublishedName { get; set; }
6 | public string OriginalName { get; set; }
7 | public string Provider { get; set; }
8 | public string ClassName { get; set; }
9 | public string ClassGUID { get; set; }
10 | public string Version { get; set; }
11 | public string Signer { get; set; }
12 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/DTO/BaseResponseDTO.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json.Serialization;
2 |
3 | namespace GeneralUpdate.Common.Shared.Object
4 | {
5 | public class BaseResponseDTO
6 | {
7 | [JsonPropertyName("code")]
8 | public int Code { get; set; }
9 |
10 | [JsonPropertyName("body")]
11 | public TBody Body { get; set; }
12 |
13 | [JsonPropertyName("message")]
14 | public string Message { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/.github/workflows/dotnet-ci.yaml:
--------------------------------------------------------------------------------
1 | name: dotnet-ci
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build:
7 | runs-on: windows-latest
8 |
9 | steps:
10 | - uses: actions/checkout@v3
11 | - name: Setup .NET SDK
12 | uses: actions/setup-dotnet@v2
13 | with:
14 | dotnet-version: '9.0.x'
15 | - name: Restore dependencies
16 | run: dotnet restore ./src/c#/GeneralUpdate.sln
17 | - name: build
18 | run: dotnet build ./src/c#/GeneralUpdate.sln -c Release
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | enable
7 | enable
8 | default
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Download/MultiEventArgs/MutiDownloadErrorEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace GeneralUpdate.Common.Download
4 | {
5 | public class MultiDownloadErrorEventArgs : EventArgs
6 | {
7 | public MultiDownloadErrorEventArgs(Exception exception, object version)
8 | {
9 | Exception = exception;
10 | Version = version;
11 | }
12 |
13 | public Exception Exception { get; set; }
14 |
15 | public object Version { get; set; }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/JsonContext/HttpParameterJsonContext.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text.Json.Serialization;
3 |
4 | namespace GeneralUpdate.Common.Internal.JsonContext;
5 |
6 | [JsonSerializable(typeof(bool))]
7 | [JsonSerializable(typeof(bool?))]
8 | [JsonSerializable(typeof(int))]
9 | [JsonSerializable(typeof(int?))]
10 | [JsonSerializable(typeof(string))]
11 | [JsonSerializable(typeof(Dictionary))]
12 | public partial class HttpParameterJsonContext: JsonSerializerContext;
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Pipeline/PatchMiddleware.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using GeneralUpdate.Common.Internal.Pipeline;
3 | using GeneralUpdate.Differential;
4 |
5 | namespace GeneralUpdate.Core.Pipeline;
6 |
7 | public class PatchMiddleware : IMiddleware
8 | {
9 | public async Task InvokeAsync(PipelineContext context)
10 | {
11 | var sourcePath = context.Get("SourcePath");
12 | var targetPath = context.Get("PatchPath");
13 | await DifferentialCore.Instance?.Dirty(sourcePath, targetPath);
14 | }
15 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/Pipeline/PatchMiddleware.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using GeneralUpdate.Common.Internal.Pipeline;
3 | using GeneralUpdate.Differential;
4 |
5 | namespace GeneralUpdate.ClientCore.Pipeline;
6 |
7 | public class PatchMiddleware : IMiddleware
8 | {
9 | public async Task InvokeAsync(PipelineContext context)
10 | {
11 | var sourcePath = context.Get("SourcePath");
12 | var targetPath = context.Get("PatchPath");
13 | await DifferentialCore.Instance.Dirty(sourcePath, targetPath);
14 | }
15 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Upgrad/GeneralUpdate.Upgrad.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | enable
7 | enable
8 | default
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | all
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Download/MultiEventArgs/MutiAllDownloadCompletedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace GeneralUpdate.Common.Download
5 | {
6 | public class MultiAllDownloadCompletedEventArgs : EventArgs
7 | {
8 | public MultiAllDownloadCompletedEventArgs(bool isAllDownloadCompleted, IList<(object, string)> failedVersions)
9 | {
10 | IsAllDownloadCompleted = isAllDownloadCompleted;
11 | FailedVersions = failedVersions;
12 | }
13 |
14 | public bool IsAllDownloadCompleted { get; set; }
15 |
16 | public IList> FailedVersions { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Driver/DeleteDriverCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace GeneralUpdate.Core.Driver;
4 |
5 | public class DeleteDriverCommand(DriverInformation information) : DriverCommand
6 | {
7 | public override void Execute()
8 | {
9 | //Before installing the driver, delete the driver that has been installed on the local system. Otherwise, an exception may occur.
10 | foreach (var driver in information.Drivers)
11 | {
12 | var command = new StringBuilder("/c pnputil /delete-driver ")
13 | .Append(driver.PublishedName)
14 | .ToString();
15 | CommandExecutor.ExecuteCommand(command);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/Hubs/RandomRetryPolicy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.AspNetCore.SignalR.Client;
3 |
4 | namespace GeneralUpdate.ClientCore.Hubs;
5 |
6 | public class RandomRetryPolicy : IRetryPolicy
7 | {
8 | private readonly Random _random = new();
9 |
10 | public TimeSpan? NextRetryDelay(RetryContext retryContext)
11 | {
12 | // If we've been reconnecting for less than 60 seconds so far,
13 | // wait between 0 and 10 seconds before the next reconnect attempt.
14 | if (retryContext.ElapsedTime < TimeSpan.FromSeconds(60))
15 | return TimeSpan.FromSeconds(_random.NextDouble() * 10);
16 | // If we've been reconnecting for more than 60 seconds so far, stop reconnecting.
17 | return null;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Download/MultiEventArgs/MutiDownloadStatisticsEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace GeneralUpdate.Common.Download;
4 |
5 | public class MultiDownloadStatisticsEventArgs(object version
6 | , TimeSpan remaining
7 | , string speed
8 | , long totalBytes
9 | , long bytesReceived
10 | , double progressPercentage) : EventArgs
11 | {
12 | public object Version { get; private set; } = version;
13 |
14 | public TimeSpan Remaining { get; private set; } = remaining;
15 |
16 | public string Speed { get; private set; } = speed;
17 |
18 | public long TotalBytesToReceive { get; private set; } = totalBytes;
19 |
20 | public long BytesReceived { get; private set; } = bytesReceived;
21 |
22 | public double ProgressPercentage { get; private set; } = progressPercentage;
23 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Bootstrap/Environments.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace GeneralUpdate.Common.Internal.Bootstrap;
4 |
5 | public static class Environments
6 | {
7 | public static void SetEnvironmentVariable(string key, string value)
8 | {
9 | var filePath = Path.Combine(Path.GetTempPath(), $"{key}.txt");
10 | File.WriteAllText(filePath, value);
11 | }
12 |
13 | public static string GetEnvironmentVariable(string key)
14 | {
15 | var filePath = Path.Combine(Path.GetTempPath(), $"{key}.txt");
16 | if (!File.Exists(filePath))
17 | return string.Empty;
18 |
19 | var content = File.ReadAllText(filePath);
20 | File.SetAttributes(filePath, FileAttributes.Normal);
21 | File.Delete(filePath);
22 | return content;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Driver/DriverCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Linq;
4 | using GeneralUpdate.Common.FileBasic;
5 |
6 | namespace GeneralUpdate.Core.Driver
7 | {
8 | public abstract class DriverCommand
9 | {
10 | public abstract void Execute();
11 |
12 | ///
13 | /// Search for driver files.
14 | ///
15 | ///
16 | ///
17 | protected static IEnumerable SearchDrivers(string patchPath, string fileExtension)
18 | {
19 | var files = StorageManager.GetAllFiles(patchPath, BlackListManager.Instance.SkipDirectorys.ToList());
20 | return files.Where(x => x.FullName.EndsWith(fileExtension)).ToList();
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/c#/Generalupdate.CatBowl/Generalupdate.CatBowl.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/git_push.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | git remote -v
4 |
5 | set /p commitmessage=Git commit message:
6 |
7 | git add .
8 |
9 | git commit -m "%commitMessage%"
10 |
11 | echo Pushing to default remote repository...
12 | git push
13 | if %errorlevel% neq 0 (
14 | echo Failed to push to default remote repository.
15 | pause
16 | exit /b %errorlevel%
17 | )
18 |
19 | echo Pushing to upstream remote on 'master' branch...
20 | git push upstream master
21 | if %errorlevel% neq 0 (
22 | echo Failed to push to upstream remote on 'main' branch.
23 | pause
24 | exit /b %errorlevel%
25 | )
26 |
27 | echo Pushing to 'upstream_gitcode' remote on 'master' branch...
28 | git push upstream_gitcode master
29 | if %errorlevel% neq 0 (
30 | echo Failed to push to 'upstream_gitcode' remote on 'main' branch.
31 | pause
32 | exit /b %errorlevel%
33 | )
34 |
35 | echo All pushes completed successfully.
36 | pause
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Strategy/IStrategy.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using GeneralUpdate.Common.Shared.Object;
3 |
4 | namespace GeneralUpdate.Common.Internal.Strategy
5 | {
6 | ///
7 | /// Update the strategy, if you need to extend it, you need to inherit this interface.
8 | ///
9 | public interface IStrategy
10 | {
11 | ///
12 | /// Execution strategy.
13 | ///
14 | void Execute();
15 |
16 | ///
17 | /// After the update is complete.
18 | ///
19 | void StartApp();
20 |
21 | ///
22 | /// Execution strategy.
23 | ///
24 | Task ExecuteAsync();
25 |
26 | ///
27 | /// Create a strategy.
28 | ///
29 | void Create(GlobalConfigInfo parameter);
30 | }
31 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Pipeline/CompressMiddleware.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using System.Threading.Tasks;
3 | using GeneralUpdate.Common.Compress;
4 | using GeneralUpdate.Common.Internal.Pipeline;
5 |
6 | namespace GeneralUpdate.Core.Pipeline;
7 |
8 | public class CompressMiddleware : IMiddleware
9 | {
10 | public Task InvokeAsync(PipelineContext context)
11 | {
12 | return Task.Run(() =>
13 | {
14 | var format = context.Get("Format");
15 | var sourcePath = context.Get("ZipFilePath");
16 | var patchPath = context.Get("PatchPath");
17 | var encoding = context.Get("Encoding");
18 | var appPath = context.Get("SourcePath");
19 | var patchEnabled = context.Get("PatchEnabled");
20 |
21 | CompressProvider.Decompress(format, sourcePath,patchEnabled == false ? appPath : patchPath, encoding);
22 | });
23 | }
24 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Applications/Windows/export.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | setlocal
3 |
4 | if "%~1"=="" (
5 | echo Please provide the export path as the first parameter.
6 | exit /b 1
7 | )
8 |
9 | set exportDir=%~1
10 |
11 | if not exist "%exportDir%" (
12 | mkdir "%exportDir%"
13 | )
14 |
15 | set outputFile=%exportDir%\driverInfo.txt
16 |
17 | :: 导出驱动信息
18 | driverquery /v /fo table > "%outputFile%"
19 | echo %outputFile% Export successfully.
20 |
21 | :: 导出系统信息
22 | set systemInfoFile=%exportDir%\systeminfo.txt
23 | systeminfo > "%systemInfoFile%"
24 | echo %systemInfoFile% Export successfully.
25 |
26 | :: 获取当前日期
27 | for /f "tokens=1-4 delims=/- " %%i in ('date /t') do (
28 | set yyyy=%%i
29 | set mm=%%j
30 | set dd=%%k
31 | )
32 |
33 | :: 设置日志文件名
34 | set logFile=%exportDir%\systemlog.evtx
35 |
36 | :: 导出系统日志
37 | wevtutil epl System "%logFile%" /q:"*[System[TimeCreated[timediff(@SystemTime) <= 86400000]]]"
38 | echo %logFile% Export successfully.
39 |
40 | endlocal
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/Pipeline/CompressMiddleware.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using System.Threading.Tasks;
3 | using GeneralUpdate.Common.Compress;
4 | using GeneralUpdate.Common.Internal.Pipeline;
5 |
6 | namespace GeneralUpdate.ClientCore.Pipeline;
7 |
8 | public class CompressMiddleware : IMiddleware
9 | {
10 | public Task InvokeAsync(PipelineContext? context)
11 | {
12 | return Task.Run(() =>
13 | {
14 | var format = context.Get("Format");
15 | var sourcePath = context.Get("ZipFilePath");
16 | var patchPath = context.Get("PatchPath");
17 | var encoding = context.Get("Encoding");
18 | var appPath = context.Get("SourcePath");
19 | var patchEnabled = context.Get("PatchEnabled");
20 |
21 | CompressProvider.Decompress(format, sourcePath,patchEnabled == false ? appPath : patchPath, encoding);
22 | });
23 | }
24 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Bootstrap/UpdateOptionValue.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Common.Internal.Bootstrap
2 | {
3 | public abstract class UpdateOptionValue
4 | {
5 | public abstract UpdateOption Option { get; }
6 |
7 | public abstract bool Set(IUpdateConfiguration config);
8 |
9 | public abstract object GetValue();
10 | }
11 |
12 | public sealed class UpdateOptionValue : UpdateOptionValue
13 | {
14 | public override UpdateOption Option { get; }
15 | private readonly T value;
16 |
17 | public UpdateOptionValue(UpdateOption option, T value)
18 | {
19 | this.Option = option;
20 | this.value = value;
21 | }
22 |
23 | public override object GetValue() => this.value;
24 |
25 | public override bool Set(IUpdateConfiguration config) => config.SetOption(this.Option, this.value);
26 |
27 | public override string ToString() => this.value.ToString();
28 | }
29 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Pipeline/PipelineContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 |
4 | namespace GeneralUpdate.Common.Internal.Pipeline;
5 |
6 | public class PipelineContext
7 | {
8 | private ConcurrentDictionary _context = new();
9 |
10 | public TValue? Get(string key)
11 | {
12 | if (_context.TryGetValue(key, out var value))
13 | {
14 | return value is TValue typedValue ? typedValue : default;
15 | }
16 | return default;
17 | }
18 |
19 | public void Add(string key, TValue? value)
20 | {
21 | if (string.IsNullOrWhiteSpace(key))
22 | {
23 | throw new ArgumentException("Key cannot be null or whitespace.", nameof(key));
24 | }
25 |
26 | _context[key] = value;
27 | }
28 |
29 | public bool Remove(string key) => _context.TryRemove(key, out _);
30 |
31 | public bool ContainsKey(string key) => _context.ContainsKey(key);
32 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Driver/DriverProcessor.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace GeneralUpdate.Core.Driver
5 | {
6 | ///
7 | /// Handle all drive-related.
8 | ///
9 | public class DriverProcessor
10 | {
11 | private readonly List _commands = new ();
12 |
13 | public void AddCommand(DriverCommand command) => _commands.Add(command);
14 |
15 | ///
16 | /// Execute all driver-related commands.
17 | ///
18 | public void ProcessCommands()
19 | {
20 | if (!_commands.Any()) return;
21 |
22 | /*
23 | * This section describes the PnPUtil command.
24 | * https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/pnputil-command-syntax
25 | */
26 | foreach (var command in _commands)
27 | {
28 | command.Execute();
29 | }
30 | _commands.Clear();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Pipeline/HashMiddleware.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Security.Cryptography;
3 | using System.Threading.Tasks;
4 | using GeneralUpdate.Common.HashAlgorithms;
5 | using GeneralUpdate.Common.Internal.Pipeline;
6 |
7 | namespace GeneralUpdate.Core.Pipeline;
8 |
9 | public class HashMiddleware : IMiddleware
10 | {
11 | public async Task InvokeAsync(PipelineContext context)
12 | {
13 | var path = context.Get("ZipFilePath");
14 | var hash = context.Get("Hash");
15 | var isVerify = await VerifyFileHash(path, hash);
16 | if (!isVerify) throw new CryptographicException("Hash verification failed !");
17 | }
18 |
19 | private Task VerifyFileHash(string path, string hash)
20 | {
21 | return Task.Run(() =>
22 | {
23 | var hashAlgorithm = new Sha256HashAlgorithm();
24 | var hashSha256 = hashAlgorithm.ComputeHash(path);
25 | return string.Equals(hash, hashSha256, StringComparison.OrdinalIgnoreCase);
26 | });
27 | }
28 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/Pipeline/HashMiddleware.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Security.Cryptography;
3 | using System.Threading.Tasks;
4 | using GeneralUpdate.Common.HashAlgorithms;
5 | using GeneralUpdate.Common.Internal.Pipeline;
6 |
7 | namespace GeneralUpdate.ClientCore.Pipeline;
8 |
9 | public class HashMiddleware : IMiddleware
10 | {
11 | public async Task InvokeAsync(PipelineContext context)
12 | {
13 | var path = context.Get("ZipFilePath");
14 | var hash = context.Get("Hash");
15 | var isVerify = await VerifyFileHash(path, hash);
16 | if (!isVerify) throw new CryptographicException("Hash verification failed .");
17 | }
18 |
19 | private Task VerifyFileHash(string path, string hash)
20 | {
21 | return Task.Run(() =>
22 | {
23 | var hashAlgorithm = new Sha256HashAlgorithm();
24 | var hashSha256 = hashAlgorithm.ComputeHash(path);
25 | return string.Equals(hash, hashSha256, StringComparison.OrdinalIgnoreCase);
26 | });
27 | }
28 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/Packet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.Json.Serialization;
3 |
4 | namespace GeneralUpdate.Common.Shared.Object;
5 |
6 | ///
7 | /// Currently used only for upgrade push.
8 | ///
9 | public class Packet
10 | {
11 | [JsonPropertyName("Name")]
12 | public string? Name { get; set; }
13 |
14 | [JsonPropertyName("Hash")]
15 | public string Hash { get; set; }
16 |
17 | [JsonPropertyName("ReleaseDate")]
18 | public DateTime? ReleaseDate { get; set; }
19 |
20 | [JsonPropertyName("Url")]
21 | public string? Url { get; set; }
22 |
23 | [JsonPropertyName("Version")]
24 | public string? Version { get; set; }
25 |
26 | [JsonPropertyName("AppType")]
27 | public int? AppType { get; set; }
28 |
29 | [JsonPropertyName("Platform")]
30 | public int? Platform { get; set; }
31 |
32 | [JsonPropertyName("ProductId")]
33 | public string? ProductId { get; set; }
34 |
35 | [JsonPropertyName("IsForcibly")]
36 | public bool? IsForcibly { get; set; }
37 |
38 | [JsonPropertyName("IsFreeze")]
39 | public bool? IsFreeze { get; set; }
40 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Strategys/MonitorParameter.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Bowl.Strategys;
2 |
3 | public class MonitorParameter
4 | {
5 | public MonitorParameter() { }
6 |
7 | public string TargetPath { get; set; }
8 |
9 | public string FailDirectory { get; set; }
10 |
11 | public string BackupDirectory { get; set; }
12 |
13 | public string ProcessNameOrId { get; set; }
14 |
15 | public string DumpFileName { get; set; }
16 |
17 | public string FailFileName { get; set; }
18 |
19 | internal string InnerArguments { get; set; }
20 |
21 | internal string InnerApp { get; set; }
22 |
23 | ///
24 | /// Upgrade: upgrade mode. This mode is primarily used in conjunction with GeneralUpdate for internal use. Please do not modify it arbitrarily when the default mode is activated.
25 | /// Normal: Normal mode,This mode can be used independently to monitor a single program. If the program crashes, it will export the crash information.
26 | ///
27 | public string WorkModel { get; set; } = "Upgrade";
28 |
29 | public string ExtendedField { get; set; }
30 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/VersionInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.Json.Serialization;
3 |
4 | namespace GeneralUpdate.Common.Shared.Object;
5 |
6 | public class VersionInfo
7 | {
8 | [JsonPropertyName("recordId")]
9 | public int RecordId { get; set; }
10 |
11 | [JsonPropertyName("name")]
12 | public string? Name { get; set; }
13 |
14 | [JsonPropertyName("hash")]
15 | public string? Hash { get; set; }
16 |
17 | [JsonPropertyName("releaseDate")]
18 | public DateTime? ReleaseDate { get; set; }
19 |
20 | [JsonPropertyName("url")]
21 | public string? Url { get; set; }
22 |
23 | [JsonPropertyName("version")]
24 | public string? Version { get; set; }
25 |
26 | [JsonPropertyName("appType")]
27 | public int? AppType { get; set; }
28 |
29 | [JsonPropertyName("platform")]
30 | public int? Platform { get; set; }
31 |
32 | [JsonPropertyName("productId")]
33 | public string? ProductId { get; set; }
34 |
35 | [JsonPropertyName("isForcibly")]
36 | public bool? IsForcibly { get; set; }
37 |
38 | [JsonPropertyName("format")]
39 | public string? Format { get; set; }
40 |
41 | [JsonPropertyName("size")]
42 | public long? Size { get; set; }
43 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Trace/WindowsOutputDebugListener.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace GeneralUpdate.Common.Shared;
6 |
7 | public class WindowsOutputDebugListener : TraceListener
8 | {
9 | ///
10 | /// Does not affect .NET AOT compilation and runtime on the Windows platform, provided that the following conditions are met:
11 | /// The target platform is restricted to Windows (due to the dependency on kernel32.dll);
12 | /// The function declaration is static (not dynamically generated).
13 | /// This syntax is safe in an AOT environment and can properly work with Dbgview.exe to capture logs.
14 | ///
15 | ///
16 | [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
17 | private static extern void OutputDebugString(string lpOutputString);
18 |
19 | public override void Write(string message)
20 | {
21 | if (!string.IsNullOrEmpty(message))
22 | {
23 | OutputDebugString(message);
24 | }
25 | }
26 |
27 | public override void WriteLine(string message)
28 | {
29 | Write($"{message}{Environment.NewLine}");
30 | }
31 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // 有关程序集的一般信息由以下
5 | // 控制。更改这些特性值可修改
6 | // 与程序集关联的信息。
7 | [assembly: AssemblyTitle("GeneralUpdate.Core")]
8 | [assembly: AssemblyDescription("Based on dotnet standard, an automatic upgrade program for c/s application is developed.The core part of the update can be easily used in many projects.")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("juster.zhu WELL-E")]
11 | [assembly: AssemblyProduct("GeneralUpdate.Core")]
12 | [assembly: AssemblyCopyright("Copyright © 2021")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // 将 ComVisible 设置为 false 会使此程序集中的类型
17 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
18 | //请将此类型的 ComVisible 特性设置为 true。
19 | [assembly: ComVisible(false)]
20 |
21 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
22 | [assembly: Guid("35bff228-5ee4-49a6-b721-fb0122e967a0")]
23 |
24 | // 程序集的版本信息由下列四个值组成:
25 | //
26 | // 主版本
27 | // 次版本
28 | // 生成号
29 | // 修订号
30 | //
31 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
32 | //通过使用 "*",如下所示:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("3.6.10.0")]
35 | [assembly: AssemblyFileVersion("3.6.10.0")]
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Compress/CompressProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using GeneralUpdate.Common.Shared.Object;
4 |
5 | namespace GeneralUpdate.Common.Compress;
6 |
7 | public class CompressProvider
8 | {
9 | private static ICompressionStrategy _compressionStrategy;
10 |
11 | private CompressProvider() { }
12 |
13 | public static void Compress(string compressType,string sourcePath, string destinationPath, bool includeRootDirectory, Encoding encoding)
14 | {
15 | _compressionStrategy = GetCompressionStrategy(compressType);
16 | _compressionStrategy.Compress(sourcePath, destinationPath, includeRootDirectory, encoding);
17 | }
18 |
19 | public static void Decompress(string compressType, string archivePath, string destinationPath, Encoding encoding)
20 | {
21 | _compressionStrategy = GetCompressionStrategy(compressType);
22 | _compressionStrategy.Decompress(archivePath, destinationPath, encoding);
23 | }
24 |
25 | private static ICompressionStrategy GetCompressionStrategy(string compressType) => compressType switch
26 | {
27 | Format.ZIP => new ZipCompressionStrategy(),
28 | _ => throw new ArgumentException("Compression format is not supported!")
29 | };
30 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/VersionOSS.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.Json.Serialization;
3 |
4 | namespace GeneralUpdate.Common.Shared.Object
5 | {
6 | ///
7 | /// Version data persistence.
8 | ///
9 | public class VersionOSS
10 | {
11 | ///
12 | /// Update package release time.
13 | ///
14 |
15 | [JsonPropertyName("PubTime")]
16 | public DateTime PubTime { get; set; }
17 |
18 | ///
19 | /// Update package name.
20 | ///
21 | [JsonPropertyName("PacketName")]
22 | public string PacketName { get; set; }
23 |
24 | ///
25 | /// Compare and verify with the downloaded update package.
26 | ///
27 | [JsonPropertyName("Hash")]
28 | public string Hash { get; set; }
29 |
30 | ///
31 | /// The version number.
32 | ///
33 | [JsonPropertyName("Version")]
34 | public string Version { get; set; }
35 |
36 | ///
37 | /// Remote service url address.
38 | ///
39 | [JsonPropertyName("Url")]
40 | public string Url { get; set; }
41 | }
42 | }
--------------------------------------------------------------------------------
/src/c#/Generalupdate.CatBowl/Program.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Text;
3 | using GeneralUpdate.Bowl;
4 | using GeneralUpdate.Bowl.Strategys;
5 |
6 | namespace Generalupdate.CatBowl;
7 |
8 | class Program
9 | {
10 | static void Main(string[] args)
11 | {
12 | var installPath = AppDomain.CurrentDomain.BaseDirectory;
13 | var lastVersion = "1.0.0.3";
14 | var processInfo = new MonitorParameter
15 | {
16 | ProcessNameOrId = "JsonTest.exe",
17 | DumpFileName = $"{lastVersion}_fail.dmp",
18 | FailFileName = $"{lastVersion}_fail.json",
19 | TargetPath = installPath,
20 | FailDirectory = Path.Combine(installPath, "fail", lastVersion),
21 | BackupDirectory = Path.Combine(installPath, lastVersion),
22 | WorkModel = "Normal"
23 | };
24 | Bowl.Launch(processInfo);
25 |
26 | /*var source = @"D:\packet\release";
27 | var target = @"D:\packet\1.zip";
28 | CompressProvider.Compress(Format.ZIP,source,target, false, Encoding.UTF8);
29 | CompressProvider.Decompress(Format.ZIP,target,source, Encoding.UTF8);
30 | Console.WriteLine($"Done {File.Exists(target)}");*/
31 |
32 | Console.Read();
33 | }
34 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfoOSS.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.Json.Serialization;
3 |
4 | namespace GeneralUpdate.Common.Shared.Object
5 | {
6 | public class GlobalConfigInfoOSS
7 | {
8 | [JsonPropertyName("Url")]
9 | public string Url { get; set; }
10 |
11 | [JsonPropertyName("AppName")]
12 | public string AppName { get; set; }
13 |
14 | [JsonPropertyName("CurrentVersion")]
15 | public string CurrentVersion { get; set; }
16 |
17 | [JsonPropertyName("VersionFileName")]
18 | public string VersionFileName { get; set; }
19 |
20 | [JsonPropertyName("Encoding")]
21 | public string Encoding { get; set; }
22 |
23 | public GlobalConfigInfoOSS()
24 | {
25 | }
26 |
27 | public GlobalConfigInfoOSS(string url, string appName, string currentVersion, string versionFileName)
28 | {
29 | Url = url ?? throw new ArgumentNullException(nameof(url));
30 | AppName = appName ?? throw new ArgumentNullException(nameof(appName));
31 | CurrentVersion = currentVersion ?? throw new ArgumentNullException(nameof(currentVersion));
32 | VersionFileName = versionFileName ?? "versions.json";
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Applications/Linux/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # 获取脚本的实际名称
4 | SCRIPT_NAME=$(basename "\$0")
5 |
6 | # 检查是否提供了参数
7 | if [ "$#" -ne 1 ]; then
8 | echo "Usage: $SCRIPT_NAME "
9 | exit 1
10 | fi
11 |
12 | PACKAGE_FILE=\$1
13 |
14 | # 检查文件类型并安装
15 | if [[ "$PACKAGE_FILE" == *.rpm ]]; then
16 | if command -v rpm &> /dev/null; then
17 | sudo rpm -ivh "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using rpm"; exit 1; }
18 | elif command -v dnf &> /dev/null; then
19 | sudo dnf install -y "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using dnf"; exit 1; }
20 | elif command -v yum &> /dev/null; then
21 | sudo yum install -y "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using yum"; exit 1; }
22 | else
23 | echo "RPM package manager not found."
24 | exit 1
25 | fi
26 | elif [[ "$PACKAGE_FILE" == *.deb ]]; then
27 | if command -v dpkg &> /dev/null; then
28 | sudo dpkg -i "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using dpkg"; exit 1; }
29 | sudo apt-get install -f -y || { echo "Failed to fix dependencies"; exit 1; }
30 | else
31 | echo "DEB package manager not found."
32 | exit 1
33 | fi
34 | else
35 | echo "Unsupported package format."
36 | exit 1
37 | fi
38 |
39 | echo "Installation of $PACKAGE_FILE completed."
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/FileBasic/ComparisonResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace GeneralUpdate.Common.FileBasic;
4 |
5 | ///
6 | /// Result of a comparison between two directories.
7 | ///
8 | public class ComparisonResult
9 | {
10 | private List _leftNodes;
11 | private List _rightNodes;
12 | private List _differentNodes;
13 |
14 | public ComparisonResult()
15 | {
16 | _leftNodes = new List();
17 | _rightNodes = new List();
18 | _differentNodes = new List();
19 | }
20 |
21 | ///
22 | /// List of files that are unique to A.
23 | ///
24 | public IReadOnlyList LeftNodes => _leftNodes.AsReadOnly();
25 |
26 | ///
27 | /// List of files that are unique to B.
28 | ///
29 | public IReadOnlyList RightNodes => _rightNodes.AsReadOnly();
30 |
31 | ///
32 | /// List of files that are different between A and B.
33 | ///
34 | public IReadOnlyList DifferentNodes => _differentNodes.AsReadOnly();
35 |
36 | public void AddToLeft(IEnumerable files) => _leftNodes.AddRange(files);
37 |
38 | public void AddToRight(IEnumerable files) => _rightNodes.AddRange(files);
39 |
40 | public void AddDifferent(IEnumerable files) => _differentNodes.AddRange(files);
41 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/HashAlgorithms/HashAlgorithmBase.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Security.Cryptography;
3 | using System.Text;
4 |
5 | namespace GeneralUpdate.Common.HashAlgorithms
6 | {
7 | public abstract class HashAlgorithmBase
8 | {
9 | public string ComputeHash(string fileName)
10 | {
11 | if (!System.IO.File.Exists(fileName))
12 | throw new FileNotFoundException(nameof(fileName));
13 |
14 | using var hashAlgorithm = GetHashAlgorithm();
15 | using var file = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
16 | var dataArray = hashAlgorithm.ComputeHash(file);
17 | var stringBuilder = new StringBuilder();
18 | for (int i = 0; i < dataArray.Length; i++)
19 | {
20 | stringBuilder.Append(dataArray[i].ToString("x2"));
21 | }
22 | return stringBuilder.ToString();
23 | }
24 |
25 | public byte[] ComputeHashBytes(string fileName)
26 | {
27 | if (!File.Exists(fileName))
28 | throw new FileNotFoundException(nameof(fileName));
29 |
30 | using var hashAlgorithm = GetHashAlgorithm();
31 | using var file = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
32 | return hashAlgorithm.ComputeHash(file);
33 | }
34 |
35 | protected abstract HashAlgorithm GetHashAlgorithm();
36 | }
37 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Pipeline/PipelineBuilder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Immutable;
3 | using System.Threading.Tasks;
4 |
5 | namespace GeneralUpdate.Common.Internal.Pipeline
6 | {
7 | ///
8 | /// Pipeline builder.
9 | ///
10 | public sealed class PipelineBuilder(PipelineContext context)
11 | {
12 | ///
13 | /// LIFO,Last In First Out.
14 | ///
15 | private ImmutableStack _middlewareStack = ImmutableStack.Empty;
16 |
17 | public PipelineBuilder UseMiddleware() where TMiddleware : IMiddleware, new()
18 | {
19 | var middleware = new TMiddleware();
20 | _middlewareStack = _middlewareStack.Push(middleware);
21 | return this;
22 | }
23 |
24 | public PipelineBuilder UseMiddlewareIf(bool? condition)
25 | where TMiddleware : IMiddleware, new()
26 | {
27 | if (condition is null or false)
28 | return this;
29 |
30 | var middleware = new TMiddleware();
31 | _middlewareStack = _middlewareStack.Push(middleware);
32 | return this;
33 | }
34 |
35 | public async Task Build()
36 | {
37 | foreach (var middleware in _middlewareStack)
38 | {
39 | await middleware.InvokeAsync(context);
40 | }
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Event/IEventManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace GeneralUpdate.Common.Internal.Event
4 | {
5 | ///
6 | /// Event manager interface.
7 | ///
8 | public interface IEventManager
9 | {
10 | ///
11 | /// Adding Event Listeners.
12 | ///
13 | /// Generic delegate.
14 | /// New delegate that needs to be injected.
15 | void AddListener(TDelegate newDelegate) where TDelegate : Delegate;
16 |
17 | ///
18 | /// Removing Event Listening.
19 | ///
20 | /// Generic delegate.
21 | /// Need to remove an existing delegate.
22 | void RemoveListener(TDelegate oldDelegate) where TDelegate : Delegate;
23 |
24 | ///
25 | /// Triggers notifications of the same event type based on the listening event type.
26 | ///
27 | /// generic delegate.
28 | /// Event handler.
29 | /// Event args.
30 | void Dispatch(object sender, EventArgs eventArgs) where TDelegate : Delegate;
31 |
32 | ///
33 | /// Remove all injected delegates.
34 | ///
35 | void Clear();
36 | }
37 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Strategy/AbstractStrategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Runtime.InteropServices;
5 | using System.Threading.Tasks;
6 | using GeneralUpdate.Common.FileBasic;
7 | using GeneralUpdate.Common.Shared.Object;
8 |
9 | namespace GeneralUpdate.Common.Internal.Strategy
10 | {
11 | public abstract class AbstractStrategy : IStrategy
12 | {
13 | protected const string Patchs = "patchs";
14 |
15 | public virtual void Execute() => throw new NotImplementedException();
16 |
17 | public virtual void StartApp() => throw new NotImplementedException();
18 |
19 | public virtual Task ExecuteAsync() => throw new NotImplementedException();
20 |
21 | public virtual void Create(GlobalConfigInfo parameter) => throw new NotImplementedException();
22 |
23 | protected static void OpenBrowser(string url)
24 | {
25 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
26 | {
27 | Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true });
28 | return;
29 | }
30 |
31 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
32 | {
33 | Process.Start("xdg-open", url);
34 | return;
35 | }
36 |
37 | throw new PlatformNotSupportedException("Unsupported OS platform");
38 | }
39 |
40 | protected static void Clear(string path)
41 | {
42 | if (Directory.Exists(path))
43 | StorageManager.DeleteDirectory(path);
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Driver/RestoreDriverCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Text;
4 | using GeneralUpdate.Common.FileBasic;
5 |
6 | namespace GeneralUpdate.Core.Driver
7 | {
8 | public class RestoreDriverCommand(DriverInformation information)
9 | {
10 | public void Execute()
11 | {
12 | try
13 | {
14 | var backupFiles = StorageManager.GetAllFiles(information.OutPutDirectory, BlackListManager.Instance.SkipDirectorys.ToList());
15 | var fileExtension = information.DriverFileExtension;
16 | var drivers = backupFiles.Where(x => x.FullName.EndsWith(fileExtension)).ToList();
17 |
18 | foreach (var driver in drivers)
19 | {
20 | try
21 | {
22 | //Install all drivers in the specified directory, and if the installation fails, restore all the drivers in the backup directory.
23 | var command = new StringBuilder("/c pnputil /add-driver ")
24 | .Append(driver.FullName)
25 | .Append(" /install")
26 | .ToString();
27 | CommandExecutor.ExecuteCommand(command);
28 | }
29 | catch (Exception e)
30 | {
31 | throw new ApplicationException($"Failed to execute install command for {driver.FullName}, error: {e.Message} !");
32 | }
33 | }
34 | }
35 | catch
36 | {
37 | throw new ApplicationException($"Failed to execute restore command for {information.OutPutDirectory}");
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Pipeline/DriverMiddleware.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using GeneralUpdate.Common.Internal.Pipeline;
4 | using GeneralUpdate.Core.Driver;
5 |
6 | namespace GeneralUpdate.Core.Pipeline;
7 |
8 | ///
9 | /// Driver update.
10 | /// Use for Windows Vista/Windows 7/Windows 8/Windows 8.1/Windows 10/Windows 11/Windows Server 2008.
11 | ///
12 | public class DriverMiddleware : IMiddleware
13 | {
14 | private const string FileExtension = ".inf";
15 |
16 | public Task InvokeAsync(PipelineContext context)
17 | {
18 | return Task.Run(() =>
19 | {
20 | var outPutPath = context.Get("DriverOutPut");
21 | if (string.IsNullOrWhiteSpace(outPutPath))
22 | return;
23 |
24 | var patchPath = context.Get("PatchPath");
25 | if (string.IsNullOrWhiteSpace(patchPath))
26 | return;
27 |
28 | var fieldMappings = context.Get>("FieldMappings");
29 | if (fieldMappings == null || fieldMappings.Count == 0)
30 | return;
31 |
32 | var information = new DriverInformation.Builder()
33 | .SetDriverFileExtension(FileExtension)
34 | .SetOutPutDirectory(outPutPath)
35 | .SetDriverDirectory(patchPath)
36 | .SetFieldMappings(fieldMappings)
37 | .Build();
38 |
39 | var processor = new DriverProcessor();
40 | processor.AddCommand(new BackupDriverCommand(information));
41 | processor.AddCommand(new DeleteDriverCommand(information));
42 | processor.AddCommand(new InstallDriverCommand(information));
43 | processor.ProcessCommands();
44 | });
45 | }
46 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Strategys/AbstractStrategy.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using GeneralUpdate.Common.FileBasic;
5 |
6 | namespace GeneralUpdate.Bowl.Strategys;
7 |
8 | internal abstract class AbstractStrategy : IStrategy
9 | {
10 | protected MonitorParameter _parameter;
11 | protected List OutputList = new ();
12 |
13 | public void SetParameter(MonitorParameter parameter) => _parameter = parameter;
14 |
15 | public virtual void Launch()
16 | {
17 | Startup(_parameter.InnerApp, _parameter.InnerArguments);
18 | }
19 |
20 | private void Startup(string appName, string arguments)
21 | {
22 | if (Directory.Exists(_parameter.FailDirectory))
23 | {
24 | StorageManager.DeleteDirectory(_parameter.FailDirectory);
25 | }
26 | Directory.CreateDirectory(_parameter.FailDirectory);
27 |
28 | var startInfo = new ProcessStartInfo
29 | {
30 | FileName = appName,
31 | Arguments = arguments,
32 | RedirectStandardOutput = true,
33 | RedirectStandardError = true,
34 | UseShellExecute = false,
35 | CreateNoWindow = true
36 | };
37 |
38 | var process = new Process { StartInfo = startInfo };
39 | process.OutputDataReceived += OutputHandler;
40 | process.ErrorDataReceived += OutputHandler;
41 | process.Start();
42 | process.BeginOutputReadLine();
43 | process.BeginErrorReadLine();
44 | process.WaitForExit(1000 * 10);
45 | }
46 |
47 | private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
48 | {
49 | var data = outLine.Data;
50 | if (!string.IsNullOrEmpty(data))
51 | OutputList.Add(data);
52 | }
53 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | GeneralUpdate.ico
6 | GeneralUpdate.png
7 | https://github.com/JusterZhu/GeneralUpdate
8 | The binary differential update function is provided, but the configuration file update function is reserved.
9 | JusterZhu
10 | 9.4.7
11 | https://github.com/GeneralLibrary/GeneralUpdate
12 | Copyright © 2025 JusterZhu. All rights reserved.
13 | default
14 | enable
15 | GeneralUpdate.Differential
16 | https://github.com/GeneralLibrary/GeneralUpdate?tab=MIT-1-ov-file#readme
17 | public
18 | upgrade,update
19 | The binary differential update function is provided, but the configuration file update function is reserved.
20 | true
21 | true
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | True
31 |
32 |
33 |
34 |
35 |
36 |
37 | True
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Trace/TextTraceListener.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Collections.Concurrent;
5 | using System.Threading;
6 |
7 | public class TextTraceListener : TraceListener, IDisposable
8 | {
9 | private readonly string _filePath;
10 | private readonly BlockingCollection _messageQueue;
11 | private readonly Thread _loggingThread;
12 | private volatile bool _isDisposed;
13 |
14 | public TextTraceListener(string filePath)
15 | {
16 | _filePath = filePath;
17 | _messageQueue = new BlockingCollection();
18 | _loggingThread = new Thread(ProcessQueue);
19 | _loggingThread.IsBackground = true;
20 | _loggingThread.Start();
21 | }
22 |
23 | public override void Write(string? message)
24 | {
25 | QueueMessage(message);
26 | }
27 |
28 | public override void WriteLine(string? message)
29 | {
30 | QueueMessage(message + Environment.NewLine);
31 | }
32 |
33 | private void QueueMessage(string? message)
34 | {
35 | if (!_isDisposed && message != null)
36 | {
37 | _messageQueue.Add(message);
38 | }
39 | }
40 |
41 | private void ProcessQueue()
42 | {
43 | foreach (var message in _messageQueue.GetConsumingEnumerable())
44 | {
45 | using (var fileStream = new FileStream(_filePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
46 | using (var writer = new StreamWriter(fileStream))
47 | {
48 | writer.Write(message);
49 | }
50 | }
51 | }
52 |
53 | public void Dispose()
54 | {
55 | if (!_isDisposed)
56 | {
57 | _isDisposed = true;
58 | _messageQueue.CompleteAdding();
59 | _loggingThread.Join();
60 | _messageQueue.Dispose();
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Driver/InstallDriverCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 |
5 | namespace GeneralUpdate.Core.Driver
6 | {
7 | ///
8 | /// Install the new driver, and if the installation fails, the backup is automatically restored.
9 | ///
10 | public class InstallDriverCommand(DriverInformation information) : DriverCommand
11 | {
12 | public override void Execute()
13 | {
14 | foreach (var driver in information.Drivers)
15 | {
16 | try
17 | {
18 | /*
19 | * 1.It is best to ensure that the installed file is OEM INF, otherwise PnPUtil may indicate that non-OEM INF cannot perform the current operation.
20 | *
21 | * 2.Before installation, you need to delete the previously installed driver, otherwise PnPUtil will prompt 259 to exit the code.
22 | * (On Windows, an ExitCode value of 259 (STILL_ACTIVE) means that the process is still running)
23 | * If you do not remove the previous installation 259 prompt will give you a misleading impression of what is running.
24 | */
25 | var path = Path.Combine(information.DriverDirectory, driver.OriginalName);
26 | var command = new StringBuilder("/c pnputil /add-driver ")
27 | .Append(path)
28 | .Append(" /install")
29 | .ToString();
30 | CommandExecutor.ExecuteCommand(command);
31 | }
32 | catch (Exception ex)
33 | {
34 | //restore all the drivers in the backup directory.
35 | new RestoreDriverCommand(information).Execute();
36 | throw new ApplicationException($"Failed to execute driver command: {ex.Message}, details: {ex} !");
37 | }
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/GeneralUpdate.Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | default
5 | enable
6 | netstandard2.0
7 | GeneralUpdate.Common
8 | JusterZhu
9 | The infrastructure required to support all components is necessary, and this nuget package is essential.
10 | Copyright © 2025 JusterZhu. All rights reserved.
11 | https://github.com/GeneralLibrary/GeneralUpdate
12 | https://github.com/GeneralLibrary/GeneralUpdate?tab=MIT-1-ov-file#readme
13 | GeneralUpdate128.png
14 | https://github.com/GeneralLibrary/GeneralUpdate
15 | public
16 | upgrade,update
17 | The infrastructure required to support all components is necessary, and this nuget package is essential.
18 | true
19 | 9.4.7
20 | true
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | True
32 |
33 | GeneralUpdate.ico
34 |
35 |
36 | True
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/GeneralUpdateOSS.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.Json;
3 | using System.Threading.Tasks;
4 | using GeneralUpdate.Common.Internal.Bootstrap;
5 | using GeneralUpdate.Common.Internal.JsonContext;
6 | using GeneralUpdate.Common.Shared;
7 | using GeneralUpdate.Common.Shared.Object;
8 | using GeneralUpdate.Core.Strategys;
9 |
10 | namespace GeneralUpdate.Core
11 | {
12 | public sealed class GeneralUpdateOSS
13 | {
14 | private GeneralUpdateOSS() { }
15 |
16 | #region Public Methods
17 |
18 | ///
19 | /// Starting an OSS update for windows,Linux,mac platform.
20 | ///
21 | ///
22 | public static async Task Start()=> await BaseStart();
23 |
24 | #endregion Public Methods
25 |
26 | #region Private Methods
27 |
28 | ///
29 | /// The underlying update method.
30 | ///
31 | private static async Task BaseStart()
32 | {
33 | try
34 | {
35 | GeneralTracer.Debug("Starting OSS upgrade mode.");
36 | var json = Environments.GetEnvironmentVariable("GlobalConfigInfoOSS");
37 | if (string.IsNullOrWhiteSpace(json))
38 | return;
39 |
40 | var parameter = JsonSerializer.Deserialize(json,
41 | GlobalConfigInfoOSSJsonContext.Default.GlobalConfigInfoOSS);
42 | var strategy = new OSSStrategy();
43 | strategy.Create(parameter);
44 | await strategy.ExecuteAsync();
45 | }
46 | catch (Exception exception)
47 | {
48 | GeneralTracer.Error("The BaseStart method in the GeneralUpdateOSS class throws an exception.",
49 | exception);
50 | throw exception;
51 | }
52 | finally
53 | {
54 | GeneralTracer.Dispose();
55 | }
56 | }
57 |
58 | #endregion Private Methods
59 | }
60 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/Hubs/IUpgradeHubService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 |
4 | namespace GeneralUpdate.ClientCore.Hubs;
5 |
6 | public interface IUpgradeHubService
7 | {
8 | ///
9 | /// Add a listener to receive upgrade information pushed from the server.
10 | ///
11 | /// string : group name , string : received message content.
12 | public void AddListenerReceive(Action receiveMessageCallback);
13 |
14 | ///
15 | /// Add a listener to receive online and offline notifications.
16 | ///
17 | /// string : Offline or online information.
18 | public void AddListenerOnline(Action onlineMessageCallback);
19 |
20 | ///
21 | /// Add a listener to receive reconnection notifications.
22 | ///
23 | /// string? : Reconnection information.
24 | public void AddListenerReconnected(Func? reconnectedCallback);
25 |
26 | ///
27 | /// Add a listener to receive disconnection notifications.
28 | ///
29 | /// Exception? : Offline exception information.
30 | public void AddListenerClosed(Func closeCallback);
31 |
32 | ///
33 | /// Start subscribing to upgrade push notifications, and the content of the notifications should be agreed upon independently (it is recommended to use JSON data format).
34 | ///
35 | public Task StartAsync();
36 |
37 | ///
38 | /// When closing the connection, any ongoing message processing will be completed, but no new messages will be accepted.
39 | /// This should be called before the application closes or goes to sleep, so it can reconnect when it resumes next time.
40 | ///
41 | public Task StopAsync();
42 |
43 | ///
44 | /// The Hub instance will be completely disposed of and cannot be used for reconnection.
45 | ///
46 | public Task DisposeAsync();
47 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Bowl/Bowl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Runtime.InteropServices;
4 | using System.Text.Json;
5 | using GeneralUpdate.Bowl.Strategys;
6 | using GeneralUpdate.Common.Internal.Bootstrap;
7 | using GeneralUpdate.Common.Internal.JsonContext;
8 | using GeneralUpdate.Common.Shared.Object;
9 |
10 | namespace GeneralUpdate.Bowl;
11 |
12 | ///
13 | /// Surveillance Main Program.
14 | ///
15 | public sealed class Bowl
16 | {
17 | private static IStrategy? _strategy;
18 |
19 | private Bowl() { }
20 |
21 | private static void CreateStrategy()
22 | {
23 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
24 | _strategy = new WindowStrategy();
25 |
26 | if (_strategy == null)
27 | throw new PlatformNotSupportedException("Unsupported operating system");
28 | }
29 |
30 | public static void Launch(MonitorParameter? monitorParameter = null)
31 | {
32 | monitorParameter ??= CreateParameter();
33 | CreateStrategy();
34 | _strategy?.SetParameter(monitorParameter);
35 | _strategy?.Launch();
36 | }
37 |
38 | private static MonitorParameter CreateParameter()
39 | {
40 | var json = Environments.GetEnvironmentVariable("ProcessInfo");
41 | if(string.IsNullOrWhiteSpace(json))
42 | throw new ArgumentNullException("ProcessInfo environment variable not set !");
43 |
44 | var processInfo = JsonSerializer.Deserialize(json, ProcessInfoJsonContext.Default.ProcessInfo);
45 | if(processInfo == null)
46 | throw new ArgumentNullException("ProcessInfo json deserialize fail!");
47 |
48 | return new MonitorParameter
49 | {
50 | ProcessNameOrId = processInfo.AppName,
51 | DumpFileName = $"{processInfo.LastVersion}_fail.dmp",
52 | FailFileName = $"{processInfo.LastVersion}_fail.json",
53 | TargetPath = processInfo.InstallPath,
54 | FailDirectory = Path.Combine(processInfo.InstallPath, "fail", processInfo.LastVersion),
55 | BackupDirectory = Path.Combine(processInfo.InstallPath, processInfo.LastVersion),
56 | ExtendedField = processInfo.LastVersion
57 | };
58 | }
59 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Bootstrap/AbstractBootstrap.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Concurrent;
2 | using System.Diagnostics;
3 | using System.Threading.Tasks;
4 | using GeneralUpdate.Common.Internal.Strategy;
5 | using GeneralUpdate.Common.Shared;
6 | using GeneralUpdate.Common.Shared.Object;
7 |
8 | namespace GeneralUpdate.Common.Internal.Bootstrap
9 | {
10 | public abstract class AbstractBootstrap
11 | where TBootstrap : AbstractBootstrap
12 | where TStrategy : IStrategy
13 | {
14 | private readonly ConcurrentDictionary _options;
15 |
16 | protected internal AbstractBootstrap() =>
17 | _options = new ConcurrentDictionary();
18 |
19 | ///
20 | /// Launch async udpate.
21 | ///
22 | ///
23 | public abstract Task LaunchAsync();
24 |
25 | protected abstract void ExecuteStrategy();
26 |
27 | protected abstract Task ExecuteStrategyAsync();
28 |
29 | protected abstract TBootstrap StrategyFactory();
30 |
31 | ///
32 | /// Setting update configuration.
33 | ///
34 | ///
35 | /// Configuration Action Enumeration.
36 | /// Value
37 | ///
38 | public TBootstrap Option(UpdateOption option, T value)
39 | {
40 | if (value == null)
41 | {
42 | _options.TryRemove(option, out _);
43 | }
44 | else
45 | {
46 | _options[option] = new UpdateOptionValue(option, value);
47 | }
48 | return (TBootstrap)this;
49 | }
50 |
51 | protected T? GetOption(UpdateOption? option)
52 | {
53 | try
54 | {
55 | Debug.Assert(option != null && _options.Count != 0);
56 | var val = _options[option];
57 | if (val != null) return (T)val.GetValue();
58 | return default;
59 | }
60 | catch
61 | {
62 | return default;
63 | }
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Driver/DriverInformation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace GeneralUpdate.Core.Driver
5 | {
6 | ///
7 | /// Driver information object.
8 | ///
9 | public class DriverInformation
10 | {
11 | public Dictionary FieldMappings { get; private set; }
12 |
13 | public string DriverFileExtension { get; private set; }
14 |
15 | ///
16 | /// All driver backup directories.
17 | ///
18 | public string OutPutDirectory { get; private set; }
19 |
20 | public string DriverDirectory { get; private set; }
21 |
22 | ///
23 | /// A collection of driver files to be backed up.
24 | ///
25 | public IEnumerable Drivers { get; set; }
26 |
27 | private DriverInformation()
28 | { }
29 |
30 | public class Builder
31 | {
32 | private DriverInformation _information = new ();
33 |
34 | public Builder SetDriverFileExtension(string fileExtension)
35 | {
36 | _information.DriverFileExtension = fileExtension;
37 | return this;
38 | }
39 |
40 | public Builder SetOutPutDirectory(string outPutDirectory)
41 | {
42 | _information.OutPutDirectory = outPutDirectory;
43 | return this;
44 | }
45 |
46 | public Builder SetDriverDirectory(string driverDirectory)
47 | {
48 | _information.DriverDirectory = driverDirectory;
49 | return this;
50 | }
51 |
52 | public Builder SetFieldMappings(Dictionary fieldMappings)
53 | {
54 | _information.FieldMappings = fieldMappings;
55 | return this;
56 | }
57 |
58 | public DriverInformation Build()
59 | {
60 | if (string.IsNullOrWhiteSpace(_information.OutPutDirectory) ||
61 | string.IsNullOrWhiteSpace(_information.DriverFileExtension))
62 | {
63 | throw new ArgumentNullException("Cannot create DriverInformation, not all fields are set.");
64 | }
65 |
66 | return _information;
67 | }
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Core/Driver/CommandExecutor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using GeneralUpdate.Common.Shared;
4 |
5 | namespace GeneralUpdate.Core.Driver
6 | {
7 | ///
8 | /// When the process starts, PnPUtil is used to execute driver processing commands.
9 | ///
10 | public class CommandExecutor
11 | {
12 | private CommandExecutor()
13 | { }
14 |
15 | public static void ExecuteCommand(string command)
16 | {
17 | /*
18 | *
19 | *Problems may occur, including:
20 | Permission issues: PnPUtil requires administrator rights to run. If you try to run it without the proper permissions, the backup or restore may fail.
21 | Driver compatibility: Although the backed up drivers work properly at backup time, if the operating system is upgraded, the backed up drivers may no longer be compatible with the new operating system version.
22 | Hardware problems: If the hardware device fails or the hardware configuration changes, the backup driver may not work properly.
23 |
24 | To minimize these risks, the following measures are recommended:
25 | Before doing anything, create a system restore point so that it can be restored to its previous state if something goes wrong.
26 | Update the driver regularly to ensure that the driver is compatible with the current operating system version.
27 | If possible, use pre-tested drivers that are proven to work.
28 | *
29 | */
30 | var processStartInfo = new ProcessStartInfo
31 | {
32 | WindowStyle = ProcessWindowStyle.Hidden,
33 | FileName = "cmd.exe",
34 | Arguments = command,
35 | UseShellExecute = false,
36 | RedirectStandardOutput = true,
37 | RedirectStandardError = true,
38 | Verb = "runas"
39 | };
40 |
41 | var process = new Process();
42 | try
43 | {
44 | process.StartInfo = processStartInfo;
45 | process.Start();
46 | process.WaitForExit();
47 |
48 | var output = process.StandardOutput.ReadToEnd();
49 | GeneralTracer.Info(output);
50 |
51 | var error = process.StandardError.ReadToEnd();
52 | if (!string.IsNullOrEmpty(error))
53 | {
54 | GeneralTracer.Error(error);
55 | }
56 |
57 | if (process.ExitCode != 0)
58 | throw new ApplicationException($"Operation failed code: {process.ExitCode}");
59 | }
60 | finally
61 | {
62 | process.Dispose();
63 | }
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Download/DownloadManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading.Tasks;
4 | using System.Collections.Immutable;
5 | using System.Diagnostics;
6 | using System.Linq;
7 |
8 | namespace GeneralUpdate.Common.Download
9 | {
10 | public class DownloadManager(string path, string format, int timeOut)
11 | {
12 | #region Private Members
13 |
14 | private readonly ImmutableList.Builder _downloadTasksBuilder = ImmutableList.Create().ToBuilder();
15 | private ImmutableList _downloadTasks;
16 |
17 | #endregion Private Members
18 |
19 | #region Public Properties
20 |
21 | public List<(object, string)> FailedVersions { get; } = new();
22 |
23 | public string Path => path;
24 |
25 | public string Format => format;
26 |
27 | public int TimeOut => timeOut;
28 |
29 | private ImmutableList DownloadTasks => _downloadTasks ?? _downloadTasksBuilder.ToImmutable();
30 |
31 | public event EventHandler MultiAllDownloadCompleted;
32 | public event EventHandler MultiDownloadCompleted;
33 | public event EventHandler MultiDownloadError;
34 | public event EventHandler MultiDownloadStatistics;
35 |
36 | #endregion Public Properties
37 |
38 | #region Public Methods
39 |
40 | public async Task LaunchTasksAsync()
41 | {
42 | try
43 | {
44 | var downloadTasks = DownloadTasks.Select(task => task.LaunchAsync()).ToList();
45 | await Task.WhenAll(downloadTasks);
46 | MultiAllDownloadCompleted?.Invoke(this, new MultiAllDownloadCompletedEventArgs(true, FailedVersions));
47 | }
48 | catch (Exception ex)
49 | {
50 | MultiAllDownloadCompleted?.Invoke(this, new MultiAllDownloadCompletedEventArgs(false, FailedVersions));
51 | throw new Exception($"Download manager error: {ex.Message}", ex);
52 | }
53 | }
54 |
55 | public void OnMultiDownloadStatistics(object sender, MultiDownloadStatisticsEventArgs e)
56 | => MultiDownloadStatistics?.Invoke(this, e);
57 |
58 | public void OnMultiAsyncCompleted(object sender, MultiDownloadCompletedEventArgs e)
59 | => MultiDownloadCompleted?.Invoke(this, e);
60 |
61 | public void OnMultiDownloadError(object sender, MultiDownloadErrorEventArgs e)
62 | {
63 | MultiDownloadError?.Invoke(this, e);
64 | FailedVersions.Add((e.Version, e.Exception.Message));
65 | }
66 |
67 | public void Add(DownloadTask task)
68 | {
69 | Debug.Assert(task != null);
70 | if (!_downloadTasksBuilder.Contains(task))
71 | {
72 | _downloadTasksBuilder.Add(task);
73 | }
74 | }
75 |
76 | #endregion Public Methods
77 | }
78 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.ClientCore/Hubs/UpgradeHubService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using GeneralUpdate.Common.Shared;
4 | using GeneralUpdate.Common.Internal.JsonContext;
5 | using Microsoft.AspNetCore.SignalR;
6 | using Microsoft.AspNetCore.SignalR.Client;
7 | using Microsoft.Extensions.DependencyInjection;
8 |
9 | namespace GeneralUpdate.ClientCore.Hubs;
10 |
11 | ///
12 | /// Upgrade the push notification service.
13 | ///
14 | /// Subscription address, for example: http://127.0.0.1/UpgradeHub
15 | /// ID4 authentication token string.
16 | /// Parameters to be sent to the server upon connection (recommended as a JSON string).
17 | public class UpgradeHubService : IUpgradeHubService
18 | {
19 | private const string Onlineflag = "Online";
20 | private const string ReceiveMessageflag = "ReceiveMessage";
21 | private HubConnection? _connection;
22 |
23 | public UpgradeHubService(string url, string? token = null, string? appkey = null)
24 | => _connection = BuildHubConnection(url, token, appkey);
25 |
26 | private HubConnection BuildHubConnection(string url, string? token = null, string? appkey = null)
27 | {
28 | var builder = new HubConnectionBuilder()
29 | .WithUrl(url, config =>
30 | {
31 | if (!string.IsNullOrWhiteSpace(token))
32 | config.AccessTokenProvider = () => Task.FromResult(token);
33 |
34 | if (!string.IsNullOrWhiteSpace(appkey))
35 | config.Headers.Add("appkey", appkey);
36 | }).WithAutomaticReconnect(new RandomRetryPolicy());
37 | builder.Services.Configure(o =>
38 | {
39 | o.PayloadSerializerOptions.TypeInfoResolverChain.Insert(0, PacketJsonContext.Default);
40 | });
41 | return builder.Build();
42 | }
43 |
44 | public void AddListenerReceive(Action receiveMessageCallback)
45 | => _connection?.On(ReceiveMessageflag, receiveMessageCallback);
46 |
47 | public void AddListenerOnline(Action onlineMessageCallback)
48 | => _connection?.On(Onlineflag, onlineMessageCallback);
49 |
50 | public void AddListenerReconnected(Func? reconnectedCallback)
51 | => _connection!.Reconnected += reconnectedCallback;
52 |
53 | public void AddListenerClosed(Func closeCallback)
54 | => _connection!.Closed += closeCallback;
55 |
56 | public async Task StartAsync()
57 | {
58 | try
59 | {
60 | await _connection!.StartAsync();
61 | }
62 | catch (Exception e)
63 | {
64 | GeneralTracer.Error("The StartAsync method in the UpgradeHubService class throws an exception." , e);
65 | }
66 | }
67 |
68 | public async Task StopAsync()
69 | {
70 | try
71 | {
72 | await _connection!.StopAsync();
73 | }
74 | catch (Exception e)
75 | {
76 | GeneralTracer.Error("The StopAsync method in the UpgradeHubService class throws an exception." , e);
77 | }
78 | }
79 |
80 | public async Task DisposeAsync()
81 | {
82 | try
83 | {
84 | await _connection!.DisposeAsync();
85 | }
86 | catch (Exception e)
87 | {
88 | GeneralTracer.Error("The DisposeAsync method in the UpgradeHubService class throws an exception." , e);
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/FileBasic/FileNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace GeneralUpdate.Common.FileBasic;
4 |
5 | public class FileNode
6 | {
7 | #region Public Properties
8 |
9 | public long Id { get; set; }
10 |
11 | public string Name { get; set; }
12 |
13 | public string FullName { get; set; }
14 |
15 | public string Path { get; set; }
16 |
17 | public string Hash { get; set; }
18 |
19 | public FileNode Left { get; set; }
20 |
21 | public FileNode Right { get; set; }
22 |
23 | public int LeftType { get; set; }
24 |
25 | public int RightType { get; set; }
26 |
27 | public string RelativePath { get; set; }
28 |
29 | #endregion Public Properties
30 |
31 | #region Constructors
32 |
33 | public FileNode()
34 | {
35 | }
36 |
37 | public FileNode(int id)
38 | {
39 | Id = id;
40 | }
41 |
42 | #endregion Constructors
43 |
44 | #region Public Methods
45 |
46 | public void Add(FileNode node)
47 | {
48 | if (node == null) return;
49 |
50 | if (node.Id < Id)
51 | {
52 | if (Left == null)
53 | {
54 | Left = node;
55 | }
56 | else
57 | {
58 | Left.Add(node);
59 | }
60 | }
61 | else
62 | {
63 | if (Right == null)
64 | {
65 | Right = node;
66 | }
67 | else
68 | {
69 | Right.Add(node);
70 | }
71 | }
72 | }
73 |
74 | public void InfixOrder()
75 | {
76 | if (Left != null)
77 | {
78 | Left.InfixOrder();
79 | }
80 |
81 | if (Right != null)
82 | {
83 | Right.InfixOrder();
84 | }
85 | }
86 |
87 | public FileNode Search(long id)
88 | {
89 | if (id == Id)
90 | {
91 | return this;
92 | }
93 | else if (id < Id)
94 | {
95 | if (Left == null) return null;
96 | return Left.Search(id);
97 | }
98 | else
99 | {
100 | if (Right == null) return null;
101 | return Right.Search(id);
102 | }
103 | }
104 |
105 | ///
106 | /// Find the parent node of the node that you want to delete.
107 | ///
108 | ///
109 | ///
110 | public FileNode SearchParent(long id)
111 | {
112 | if (Left != null && Left.Id == id || Right != null && Right.Id == id)
113 | {
114 | return this;
115 | }
116 | else
117 | {
118 | if (id < Id && Left != null)
119 | {
120 | return Left.SearchParent(id);
121 | }
122 | else if (id >= Id && Right != null)
123 | {
124 | return Right.SearchParent(id);
125 | }
126 | else
127 | {
128 | return null;
129 | }
130 | }
131 | }
132 |
133 | ///
134 | /// Compare tree nodes equally by Hash and file names.
135 | ///
136 | ///
137 | ///
138 | public override bool Equals(object obj)
139 | {
140 | if (obj == null) return false;
141 | var tempNode = obj as FileNode;
142 | if (tempNode == null) throw new ArgumentException(nameof(tempNode));
143 | return string.Equals(Hash, tempNode.Hash, StringComparison.OrdinalIgnoreCase) &&
144 | string.Equals(Name, tempNode.Name, StringComparison.OrdinalIgnoreCase);
145 | }
146 |
147 | public override int GetHashCode() => base.GetHashCode();
148 |
149 | #endregion Public Methods
150 | }
151 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/Configinfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace GeneralUpdate.Common.Shared.Object
5 | {
6 | ///
7 | /// Global update parameters.
8 | ///
9 | public class Configinfo
10 | {
11 | ///
12 | /// Update check api address.
13 | ///
14 | public string UpdateUrl { get; set; }
15 |
16 | ///
17 | /// API address for reporting update status.
18 | ///
19 | public string ReportUrl { get; set; }
20 |
21 | ///
22 | /// Need to start the name of the app.
23 | ///
24 | public string AppName { get; set; }
25 |
26 | ///
27 | /// The name of the main application, without .exe.
28 | ///
29 | public string MainAppName { get; set; }
30 |
31 | ///
32 | /// Update log web address.
33 | ///
34 | public string UpdateLogUrl { get; set; }
35 |
36 | ///
37 | /// application key
38 | ///
39 | public string AppSecretKey { get; set; }
40 |
41 | ///
42 | /// Client current version.
43 | ///
44 | public string ClientVersion { get; set; }
45 |
46 | ///
47 | /// Upgrade Client current version.
48 | ///
49 | public string UpgradeClientVersion { get; set; }
50 |
51 | ///
52 | /// installation path (for update file logic).
53 | ///
54 | public string InstallPath { get; set; }
55 |
56 | ///
57 | /// Files in the blacklist will skip the update.
58 | ///
59 | public List BlackFiles { get; set; }
60 |
61 | ///
62 | /// File formats in the blacklist will skip the update.
63 | ///
64 | public List BlackFormats { get; set; }
65 |
66 | ///
67 | /// SkipDirectorys
68 | ///
69 | public List SkipDirectorys { get; set; }
70 |
71 | ///
72 | /// Product ID.
73 | ///
74 | public string ProductId { get; set; }
75 |
76 | public string Bowl { get; set; }
77 |
78 | public string Scheme { get; set; }
79 |
80 | public string Token { get; set; }
81 |
82 | ///
83 | /// Script to grant permissions to a specified file on Linux
84 | ///
85 | public string Script { get; set; }
86 |
87 | public void Validate()
88 | {
89 | if (string.IsNullOrWhiteSpace(UpdateUrl) || !Uri.IsWellFormedUriString(UpdateUrl, UriKind.Absolute))
90 | throw new ArgumentException("Invalid UpdateUrl");
91 |
92 | if (!string.IsNullOrWhiteSpace(UpdateLogUrl) && !Uri.IsWellFormedUriString(UpdateLogUrl, UriKind.Absolute))
93 | throw new ArgumentException("Invalid UpdateLogUrl");
94 |
95 | if (string.IsNullOrWhiteSpace(AppName))
96 | throw new ArgumentException("AppName cannot be empty");
97 |
98 | if (string.IsNullOrWhiteSpace(MainAppName))
99 | throw new ArgumentException("MainAppName cannot be empty");
100 |
101 | if (string.IsNullOrWhiteSpace(AppSecretKey))
102 | throw new ArgumentException("AppSecretKey cannot be empty");
103 |
104 | if (string.IsNullOrWhiteSpace(ClientVersion))
105 | throw new ArgumentException("ClientVersion cannot be empty");
106 |
107 | if (string.IsNullOrWhiteSpace(InstallPath))
108 | throw new ArgumentException("InstallPath cannot be empty");
109 | }
110 | }
111 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 | [Dd]ebug/
11 | [Dd]ebugPublic/
12 | [Rr]elease/
13 | [Rr]eleases/
14 | x64/
15 | x86/
16 | build/
17 | bld/
18 | [Bb]in/
19 | [Oo]bj/
20 | *.vs/
21 |
22 | # Roslyn cache directories
23 | *.ide/
24 |
25 | # MSTest test Results
26 | [Tt]est[Rr]esult*/
27 | [Bb]uild[Ll]og.*
28 |
29 | #NUNIT
30 | *.VisualState.xml
31 | TestResult.xml
32 |
33 | # Build Results of an ATL Project
34 | [Dd]ebugPS/
35 | [Rr]eleasePS/
36 | dlldata.c
37 |
38 | *_i.c
39 | *_p.c
40 | *_i.h
41 | *.ilk
42 | *.meta
43 | *.obj
44 | *.pch
45 | *.pdb
46 | *.pgc
47 | *.pgd
48 | *.rsp
49 | *.sbr
50 | *.tlb
51 | *.tli
52 | *.tlh
53 | *.tmp
54 | *.tmp_proj
55 | *.log
56 | *.vspscc
57 | *.vssscc
58 | .builds
59 | *.pidb
60 | *.svclog
61 | *.scc
62 |
63 | # Chutzpah Test files
64 | _Chutzpah*
65 |
66 | # Visual C++ cache files
67 | ipch/
68 | *.aps
69 | *.ncb
70 | *.opensdf
71 | *.sdf
72 | *.cachefile
73 |
74 | # Visual Studio profiler
75 | *.psess
76 | *.vsp
77 | *.vspx
78 |
79 | # TFS 2012 Local Workspace
80 | $tf/
81 |
82 | # Guidance Automation Toolkit
83 | *.gpState
84 |
85 | # ReSharper is a .NET coding add-in
86 | _ReSharper*/
87 | *.[Rr]e[Ss]harper
88 | *.DotSettings.user
89 |
90 | # JustCode is a .NET coding addin-in
91 | .JustCode
92 |
93 | # TeamCity is a build add-in
94 | _TeamCity*
95 |
96 | # DotCover is a Code Coverage Tool
97 | *.dotCover
98 |
99 | # NCrunch
100 | _NCrunch_*
101 | .*crunch*.local.xml
102 |
103 | # MightyMoose
104 | *.mm.*
105 | AutoTest.Net/
106 |
107 | # Web workbench (sass)
108 | .sass-cache/
109 |
110 | # Installshield output folder
111 | [Ee]xpress/
112 |
113 | # DocProject is a documentation generator add-in
114 | DocProject/buildhelp/
115 | DocProject/Help/*.HxT
116 | DocProject/Help/*.HxC
117 | DocProject/Help/*.hhc
118 | DocProject/Help/*.hhk
119 | DocProject/Help/*.hhp
120 | DocProject/Help/Html2
121 | DocProject/Help/html
122 |
123 | # Click-Once directory
124 | publish/
125 |
126 | # Publish Web Output
127 | *.[Pp]ublish.xml
128 | *.azurePubxml
129 | # TODO: Comment the next line if you want to checkin your web deploy settings
130 | # but database connection strings (with potential passwords) will be unencrypted
131 | *.pubxml
132 | *.publishproj
133 |
134 | # NuGet Packages
135 | *.nupkg
136 | # The packages folder can be ignored because of Package Restore
137 | **/packages/*
138 | # except build/, which is used as an MSBuild target.
139 | !**/packages/build/
140 | # If using the old MSBuild-Integrated Package Restore, uncomment this:
141 | #!**/packages/repositories.config
142 |
143 | # Windows Azure Build Output
144 | csx/
145 | *.build.csdef
146 |
147 | # Windows Store app package directory
148 | AppPackages/
149 |
150 | # Others
151 | sql/
152 | *.Cache
153 | ClientBin/
154 | [Ss]tyle[Cc]op.*
155 | ~$*
156 | *~
157 | *.dbmdl
158 | *.dbproj.schemaview
159 | *.pfx
160 | *.publishsettings
161 | node_modules/
162 |
163 | # RIA/Silverlight projects
164 | Generated_Code/
165 |
166 | # Backup & report files from converting an old project file
167 | # to a newer Visual Studio version. Backup files are not needed,
168 | # because we have git ;-)
169 | _UpgradeReport_Files/
170 | Backup*/
171 | UpgradeLog*.XML
172 | UpgradeLog*.htm
173 |
174 | # SQL Server files
175 | *.mdf
176 | *.ldf
177 |
178 | # Business Intelligence projects
179 | *.rdl.data
180 | *.bim.layout
181 | *.bim_*.settings
182 |
183 | # Microsoft Fakes
184 | FakesAssemblies/
185 |
186 | # SVN Repo
187 | .svn/
188 | *.vsidx
189 | *.v2
190 | *.lock
191 | *.txt
192 | *.v3
193 | *.v5
194 | src/c\#/.vs
195 | src/c\#/.idea
196 | src/c\#/global.json
197 |
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/FileBasic/BlackListManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Linq;
4 | using GeneralUpdate.Common.Shared.Object;
5 |
6 | namespace GeneralUpdate.Common.FileBasic;
7 |
8 | public class BlackListManager
9 | {
10 | private static readonly object LockObject = new object();
11 | private static BlackListManager? _instance;
12 |
13 | private static readonly List _blackFileFormats =
14 | [
15 | ".patch",
16 | Format.ZIP,
17 | ".rar",
18 | ".tar",
19 | ".json",
20 | ".pdb"
21 | ];
22 |
23 | private static readonly List _blackFiles =
24 | [
25 | "Microsoft.Bcl.AsyncInterfaces.dll",
26 | "System.Collections.Immutable.dll",
27 | "System.IO.Pipelines.dll",
28 | "System.Text.Encodings.Web.dll",
29 | "System.Text.Json.dll"
30 | ];
31 |
32 | private static readonly List _skipDirectorys = ["app-", "fail"];
33 |
34 | private BlackListManager() { }
35 |
36 | public static BlackListManager? Instance
37 | {
38 | get
39 | {
40 | if (_instance == null)
41 | {
42 | lock (LockObject)
43 | {
44 | if (_instance == null)
45 | {
46 | _instance = new BlackListManager();
47 | }
48 | }
49 | }
50 |
51 | return _instance;
52 | }
53 | }
54 |
55 | public IReadOnlyList BlackFileFormats => _blackFileFormats.AsReadOnly();
56 | public IReadOnlyList BlackFiles => _blackFiles.AsReadOnly();
57 |
58 | public IReadOnlyList SkipDirectorys = _skipDirectorys.AsReadOnly();
59 |
60 | public void AddBlackFileFormats(List? formats)
61 | {
62 | if (formats == null)
63 | return;
64 |
65 | foreach (var format in formats)
66 | {
67 | AddBlackFileFormat(format);
68 | }
69 | }
70 |
71 | public void AddBlackFileFormat(string format)
72 | {
73 | if (string.IsNullOrWhiteSpace(format))
74 | return;
75 |
76 | if (!_blackFileFormats.Contains(format))
77 | {
78 | _blackFileFormats.Add(format);
79 | }
80 | }
81 |
82 | public void AddBlackFiles(List? fileNames)
83 | {
84 | if (fileNames == null)
85 | return;
86 |
87 | foreach (var fileName in fileNames)
88 | {
89 | AddBlackFile(fileName);
90 | }
91 | }
92 |
93 | public void AddBlackFile(string fileName)
94 | {
95 | if (string.IsNullOrWhiteSpace(fileName))
96 | return;
97 |
98 | if (!_blackFiles.Contains(fileName))
99 | {
100 | _blackFiles.Add(fileName);
101 | }
102 | }
103 |
104 | public void AddSkipDirectorys(List? directorys)
105 | {
106 | if (directorys == null)
107 | return;
108 |
109 | foreach (var directory in directorys)
110 | {
111 | AddSkipDirectory(directory);
112 | }
113 | }
114 |
115 | public void AddSkipDirectory(string directory)
116 | {
117 | if (string.IsNullOrWhiteSpace(directory))
118 | return;
119 |
120 | if (!_skipDirectorys.Contains(directory))
121 | {
122 | _skipDirectorys.Add(directory);
123 | }
124 | }
125 |
126 | public bool IsBlacklisted(string relativeFilePath)
127 | {
128 | var fileName = Path.GetFileName(relativeFilePath);
129 | var fileExtension = Path.GetExtension(relativeFilePath);
130 |
131 | return _blackFiles.Contains(fileName) || _blackFileFormats.Contains(fileExtension);
132 | }
133 |
134 | public bool IsSkipDirectory(string directory)
135 | {
136 | return _skipDirectorys.Any(directory.Contains);
137 | }
138 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Differential/Binary/BZip2Constants.cs:
--------------------------------------------------------------------------------
1 | namespace GeneralUpdate.Differential.Binary
2 | {
3 | internal sealed class BZip2Constants
4 | {
5 | public const int BaseBlockSize = 100000;
6 |
7 | public const int MaximumAlphaSize = 258;
8 |
9 | public const int MaximumCodeLength = 23;
10 |
11 | public const int RunA = 0;
12 |
13 | public const int RunB = 1;
14 |
15 | public const int GroupCount = 6;
16 |
17 | public const int GroupSize = 50;
18 |
19 | public const int NumberOfIterations = 4;
20 |
21 | public const int MaximumSelectors = 18002;
22 |
23 | public const int OvershootBytes = 20;
24 |
25 | public static readonly int[] RandomNumbers = new int[512]
26 | {
27 | 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
28 | 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
29 | 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
30 | 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
31 | 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
32 | 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
33 | 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
34 | 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
35 | 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
36 | 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
37 | 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
38 | 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
39 | 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
40 | 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
41 | 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
42 | 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
43 | 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
44 | 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
45 | 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
46 | 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
47 | 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
48 | 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
49 | 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
50 | 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
51 | 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
52 | 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
53 | 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
54 | 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
55 | 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
56 | 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
57 | 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
58 | 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
59 | 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
60 | 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
61 | 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
62 | 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
63 | 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
64 | 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
65 | 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
66 | 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
67 | 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
68 | 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
69 | 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
70 | 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
71 | 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
72 | 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
73 | 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
74 | 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
75 | 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
76 | 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
77 | 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
78 | 936, 638
79 | };
80 |
81 | private BZip2Constants()
82 | {
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text;
3 |
4 | namespace GeneralUpdate.Common.Shared.Object;
5 |
6 | public class GlobalConfigInfo
7 | {
8 | ///
9 | /// Update check api address.
10 | ///
11 | public string UpdateUrl { get; set; }
12 |
13 | ///
14 | /// API address for reporting update status.
15 | ///
16 | public string ReportUrl { get; set; }
17 |
18 | ///
19 | /// Need to start the name of the app.
20 | ///
21 | public string AppName { get; set; }
22 |
23 | ///
24 | /// The name of the main application, without .exe.
25 | ///
26 | public string MainAppName { get; set; }
27 |
28 | ///
29 | /// Update package file format(Defult format is Zip).
30 | ///
31 | public string Format { get; set; }
32 |
33 | ///
34 | /// Whether an update is required to upgrade the application.
35 | ///
36 | public bool IsUpgradeUpdate { get; set; }
37 |
38 | ///
39 | /// Whether the main application needs to be updated.
40 | ///
41 | public bool IsMainUpdate { get; set; }
42 |
43 | ///
44 | /// Update log web address.
45 | ///
46 | public string UpdateLogUrl { get; set; }
47 |
48 | ///
49 | /// Version information that needs to be updated.
50 | ///
51 | public List UpdateVersions { get; set; }
52 |
53 | ///
54 | /// The encoding format for file operations.
55 | ///
56 | public Encoding Encoding { get; set; }
57 |
58 | ///
59 | /// Time-out event for file download.
60 | ///
61 | public int DownloadTimeOut { get; set; }
62 |
63 | ///
64 | /// application key
65 | ///
66 | public string AppSecretKey { get; set; }
67 |
68 | ///
69 | /// Client current version.
70 | ///
71 | public string ClientVersion { get; set; }
72 |
73 | ///
74 | /// Upgrade Client current version.
75 | ///
76 | public string UpgradeClientVersion { get; set; }
77 |
78 | ///
79 | /// The main program latest version.
80 | ///
81 | public string LastVersion { get; set; }
82 |
83 | ///
84 | /// installation path (for update file logic).
85 | ///
86 | public string InstallPath { get; set; }
87 |
88 | ///
89 | /// Download file temporary storage path (for update file logic).
90 | ///
91 | public string TempPath { get; set; }
92 |
93 | ///
94 | /// Configuration parameters for upgrading the terminal program.
95 | ///
96 | public string ProcessInfo { get; set; }
97 |
98 | ///
99 | /// Files in the blacklist will skip the update.
100 | ///
101 | public List BlackFiles { get; set; }
102 |
103 | ///
104 | /// File formats in the blacklist will skip the update.
105 | ///
106 | public List BlackFormats { get; set; }
107 |
108 | ///
109 | /// SkipDirectorys
110 | ///
111 | public List SkipDirectorys { get; set; }
112 |
113 | ///
114 | /// Whether to enable the driver upgrade function.
115 | ///
116 | public bool? DriveEnabled { get; set; }
117 |
118 | public bool? PatchEnabled { get; set; }
119 |
120 | public string ProductId { get; set; }
121 |
122 | public Dictionary FieldMappings { get; set; }
123 |
124 | public string BackupDirectory { get; set; }
125 |
126 | public string Bowl { get; set; }
127 |
128 | public string Scheme { get; set; }
129 |
130 | public string Token { get; set; }
131 |
132 | ///
133 | /// Script to grant permissions to a specified file on Linux
134 | ///
135 | public string Script { get; set; }
136 | }
--------------------------------------------------------------------------------
/src/c#/GeneralUpdate.Common/Internal/Event/EventManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using GeneralUpdate.Common.Shared;
5 |
6 | namespace GeneralUpdate.Common.Internal.Event
7 | {
8 | public class EventManager : IDisposable
9 | {
10 | private static readonly object _lockObj = new();
11 | private static EventManager _instance;
12 | private Dictionary _dicDelegates = new();
13 | private bool _disposed = false;
14 |
15 | private EventManager() { }
16 |
17 | public static EventManager Instance
18 | {
19 | get
20 | {
21 | if (_instance == null)
22 | {
23 | lock (_lockObj)
24 | {
25 | if (_instance == null)
26 | _instance = new EventManager();
27 | }
28 | }
29 | return _instance;
30 | }
31 | }
32 |
33 | public void AddListener(Action