diff --git a/src/c#/GeneralUpdate.Api/Program.cs b/src/c#/GeneralUpdate.Api/Program.cs index 35a851f2abe33130c2f82595c8aa751d9aea9e54..6e8fa59b5c50bb87a4d586d39b38c7c65875a94a 100644 --- a/src/c#/GeneralUpdate.Api/Program.cs +++ b/src/c#/GeneralUpdate.Api/Program.cs @@ -36,7 +36,7 @@ var app = builder.Build(); app.MapGet("/versions/{clientType}/{clientVersion}/{clientAppKey}", (int clientType, string clientVersion, string clientAppKey, IUpdateService updateService) => { var versions = new List(); - var hash = "9bf414990a67e74f11752d03f49b15d8";//生成好的更新包文件的MD5码,因为返回给客户端的时候需要同这个来验证是否可用 + var hash = "415eed05eb310f480d1e4d15516fa00e484ddb9f416908b217f17b782ded2030";//生成好的更新包文件的MD5码,因为返回给客户端的时候需要同这个来验证是否可用 var pubTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(); string version = null; if (clientType == AppType.ClientApp) @@ -48,10 +48,10 @@ app.MapGet("/versions/{clientType}/{clientVersion}/{clientAppKey}", (int clientT else if (clientType == AppType.UpgradeApp) { //upgrad - //version = "0.0.0.0"; - version = "9.9.9.9"; //这里设置为9是让程序认为需要更新 + version = "0.0.0.0"; + //version = "9.9.9.9"; //这里设置为9是让程序认为需要更新 } - var url = $"http://192.168.50.203/update.zip";//更新包的下载地址 + var url = $"http://127.0.0.1/WpfClient_1_24.1.5.1218.zip";//更新包的下载地址 var name = "update"; versions.Add(new VersionDTO(hash, pubTime, version, url, name)); return updateService.Update(clientType, clientVersion, version, clientAppKey, GetAppSecretKey(), false, versions); diff --git a/src/c#/GeneralUpdate.Client/MySample.cs b/src/c#/GeneralUpdate.Client/MySample.cs index 64fc8ab778ae73951f1fe990d11f216dc8a062a9..0488921f7368c0a4bea873650dbb0271d2659027 100644 --- a/src/c#/GeneralUpdate.Client/MySample.cs +++ b/src/c#/GeneralUpdate.Client/MySample.cs @@ -19,7 +19,7 @@ namespace GeneralUpdate.Client { #region 鎺ㄩ佸姛鑳 - private const string baseUrl = @"http://localhost:5051"; + private const string baseUrl = @"http://127.0.0.1:5001"; private const string hubName = "versionhub"; internal MySample() @@ -119,7 +119,7 @@ namespace GeneralUpdate.Client //瀹㈡埛绔綋鍓嶇増鏈彿 config.ClientVersion = "1.1.1.1"; //瀹㈡埛绔被鍨嬶細1.涓荤▼搴忓鎴风 2.鏇存柊缁勪欢 - config.AppType = AppType.ClientApp; + config.AppType = AppType.UpgradeApp; //鎸囧畾搴旂敤瀵嗛挜锛岀敤浜庡尯鍒嗗鎴风搴旂敤 config.AppSecretKey = "B8A7FADD-386C-46B0-B283-C9F963420C7C"; //鏇存柊缁勪欢鏇存柊鍖呬笅杞藉湴鍧 diff --git a/src/c#/GeneralUpdate.Client/Program.cs b/src/c#/GeneralUpdate.Client/Program.cs index d2b508002b83f039405c8ee7431fc128eea881a3..99480e10585b091829fbb35cf7bf2fdddfc2dd87 100644 --- a/src/c#/GeneralUpdate.Client/Program.cs +++ b/src/c#/GeneralUpdate.Client/Program.cs @@ -1,4 +1,6 @@ -锘縩amespace GeneralUpdate.Client +锘縰sing GeneralUpdate.Core.HashAlgorithms; + +namespace GeneralUpdate.Client { internal class Program { @@ -6,6 +8,15 @@ { Task.Run(async() => { + //415eed05eb310f480d1e4d15516fa00e484ddb9f416908b217f17b782ded2030 + //var zip1 = @"D:\github_project\WpfClient\WebApi\UpdateFiles\WpfClient_1_24.1.5.1218.zip"; + //94bd3d806d39cd1b8813298ec0637c7f377658e766845a06cc50917306cb4ad9 + //var zip2 = @"D:\github_project\WpfClient\WebApi\UpdateFiles\WpfClient_1_24.1.5.1224.zip"; + + //var hashAlgorithm = new Sha256HashAlgorithm(); + //var hashSha256 = hashAlgorithm.ComputeHash(zip1); + //var hashSha2561 = hashAlgorithm.ComputeHash(zip2); + MySample sample = new MySample(); //await sample.TestDifferentialClean(); //await sample.TestDifferentialDirty(); diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj b/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj index 2dc1fd226f3d70d28cecbfc09fd7ddedbe854a38..523523f88d0c808a2bc04c2718cf1fc0a041850c 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj +++ b/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj @@ -127,6 +127,7 @@ + diff --git a/src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs b/src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs index 5a06c2b3a66dc7c96b4c94def7b87fb0d3206fd2..2062880ed895d41ad842ca40208ca32cbf40092b 100644 --- a/src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs +++ b/src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs @@ -166,35 +166,17 @@ namespace GeneralUpdate.Core.Bootstrap #region Callback event. - public TBootstrap AddListenerMultiAllDownloadCompleted(Action callbackAction) - { - return AddListener(callbackAction); - } + public TBootstrap AddListenerMultiAllDownloadCompleted(Action callbackAction)=> AddListener(callbackAction); - public TBootstrap AddListenerMultiDownloadProgress(Action callbackAction) - { - return AddListener(callbackAction); - } + public TBootstrap AddListenerMultiDownloadProgress(Action callbackAction)=> AddListener(callbackAction); - public TBootstrap AddListenerMultiDownloadCompleted(Action callbackAction) - { - return AddListener(callbackAction); - } + public TBootstrap AddListenerMultiDownloadCompleted(Action callbackAction)=> AddListener(callbackAction); - public TBootstrap AddListenerMultiDownloadError(Action callbackAction) - { - return AddListener(callbackAction); - } + public TBootstrap AddListenerMultiDownloadError(Action callbackAction)=> AddListener(callbackAction); - public TBootstrap AddListenerMultiDownloadStatistics(Action callbackAction) - { - return AddListener(callbackAction); - } + public TBootstrap AddListenerMultiDownloadStatistics(Action callbackAction)=> AddListener(callbackAction); - public TBootstrap AddListenerException(Action callbackAction) - { - return AddListener(callbackAction); - } + public TBootstrap AddListenerException(Action callbackAction)=> AddListener(callbackAction); protected TBootstrap AddListener(Action callbackAction) where TArgs : EventArgs { diff --git a/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs b/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs index 95c7cdbbaf7807061b3c31e7bf60a5dcb27071d5..088cd354e6aed7549a78557b7efdb9ce9b07d21b 100644 --- a/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs +++ b/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs @@ -1,5 +1,6 @@ 锘縰sing GeneralUpdate.Core.Exceptions.CustomArgs; using System; +using System.IO; namespace GeneralUpdate.Core.Exceptions { @@ -10,11 +11,9 @@ namespace GeneralUpdate.Core.Exceptions #region Common - public static void ThrowIfNull(object obj) - { - if (obj == null) - Throw("Parameter cannot be null"); - } + public static void ThrowFileNotFound(string file) => Throw($"File cannot be accessed {file}!"); + + public static void ThrowIfNull()=> Throw("Parameter cannot be null"); /// /// Checks if an object is empty and throws an exception if it is diff --git a/src/c#/GeneralUpdate.Core/HashAlgorithms/HashAlgorithmBase.cs b/src/c#/GeneralUpdate.Core/HashAlgorithms/HashAlgorithmBase.cs index bd75ad69fc5ea58d4f9436524caa963249080f64..09ed6b71e200a730cf74d6ac61ad62bf69496379 100644 --- a/src/c#/GeneralUpdate.Core/HashAlgorithms/HashAlgorithmBase.cs +++ b/src/c#/GeneralUpdate.Core/HashAlgorithms/HashAlgorithmBase.cs @@ -1,4 +1,5 @@ -锘縰sing System.IO; +锘縰sing GeneralUpdate.Core.Exceptions; +using System.IO; using System.Security.Cryptography; using System.Text; @@ -8,6 +9,9 @@ namespace GeneralUpdate.Core.HashAlgorithms { public string ComputeHash(string fileName) { + if (!File.Exists(fileName)) + ThrowExceptionUtility.ThrowFileNotFound(fileName); + using (var hashAlgorithm = GetHashAlgorithm()) { using (var file = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) diff --git a/src/c#/GeneralUpdate.Differential/Exceptions/.gitkeep b/src/c#/GeneralUpdate.Differential/Exceptions/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/c#/GeneralUpdate.Differential/Exceptions/CustomArgs/.gitkeep b/src/c#/GeneralUpdate.Differential/Exceptions/CustomArgs/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/c#/GeneralUpdate.Differential/Exceptions/CustomException/.gitkeep b/src/c#/GeneralUpdate.Differential/Exceptions/CustomException/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj b/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj index f9a76f981cd9268e823bba6601f42910fbadc79b..b39690182ab1d593e1c8b63cad920c0cfeaeacb5 100644 --- a/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj +++ b/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj @@ -16,6 +16,9 @@ + + + @@ -25,6 +28,13 @@ + + + + + + +