diff --git a/src/c#/GeneralUpdate.Api/GeneralUpdate.Api.csproj b/src/c#/GeneralUpdate.Api/GeneralUpdate.Api.csproj deleted file mode 100644 index fd8c7c45d24c49d66ab5e79ad5ee4864602a48a2..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.Api/GeneralUpdate.Api.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - diff --git a/src/c#/GeneralUpdate.Api/Program.cs b/src/c#/GeneralUpdate.Api/Program.cs deleted file mode 100644 index 16c966a513d83e81054358aeb215dd860c0a64c8..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.Api/Program.cs +++ /dev/null @@ -1,108 +0,0 @@ -using GeneralUpdate.AspNetCore.DTO; -using GeneralUpdate.AspNetCore.Hubs; -using GeneralUpdate.AspNetCore.Services; -using GeneralUpdate.Core.Domain.DTO; -using GeneralUpdate.Core.Domain.Enum; -using Microsoft.AspNetCore.SignalR; -using Newtonsoft.Json; - -var builder = WebApplication.CreateBuilder(args); -builder.Services.AddSingleton(); -builder.Services.AddSignalR(); -var app = builder.Build(); - -/** - * Push the latest version information in real time. - */ -//app.MapHub("/versionhub"); - -//app.MapPost("/push", async Task (HttpContext context) => -//{ -// try -// { -// var hubContext = context.RequestServices.GetRequiredService>(); -// await hubContext.SendMessage("TESTNAME", "123"); -// } -// catch (Exception ex) -// { -// return ex.Message; -// } -// return "OK"; -//}); - -/** - * Check if an update is required. - */ -app.MapGet("/versions/{clientType}/{clientVersion}/{clientAppKey}", (int clientType, string clientVersion, string clientAppKey, IUpdateService updateService) => -{ - var versions = new List(); - var hash = "28d10f1fc2a23dd1afe0af40d132b25c72ea56005963f653c27889f03d381c8d";//生成好的更新包文件的MD5码,因为返回给客户端的时候需要同这个来验证是否可用 - var pubTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(); - string version = null; - if (clientType == AppType.ClientApp) - { - //client - //version = "0.0.0.0"; - version = "9.9.9.9";//这里设置为9是让程序认为需要更新 - } - else if (clientType == AppType.UpgradeApp) - { - //upgrad - version = "0.0.0.0"; - //version = "9.9.9.9"; //这里设置为9是让程序认为需要更新 - } - var url = $"http://192.168.1.7/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); -}); - -/** - * Upload update package. - */ -app.MapPost("/upload", async Task (HttpContext context, HttpRequest request) => -{ - var uploadReapDTO = new UploadReapDTO(); - try - { - var contextReq = context.Request; - int.TryParse(contextReq.Form["clientType"], out int clientType); - var version = contextReq.Form["clientType"].ToString(); - var clientAppKey = contextReq.Form["clientAppKey"].ToString(); - var hash = contextReq.Form["hash"].ToString(); - - if (!request.HasFormContentType) throw new Exception("ContentType was not included in the request !"); - var form = await request.ReadFormAsync(); - - var formFile = form.Files["file"]; - if (formFile is null || formFile.Length == 0) throw new ArgumentNullException("Uploaded update package file not found !"); - await using var stream = formFile.OpenReadStream(); - byte[] buffer = new byte[stream.Length]; - stream.Read(buffer, 0, buffer.Length); - //TODO:save to file server. - string localPath = $"E:\\{formFile.FileName}"; - await using var fileStream = new FileStream(localPath, FileMode.CreateNew, FileAccess.Write); - fileStream.Write(buffer, 0, buffer.Length); - - //TODO: data persistence.To mysql , sqlserver.... - - uploadReapDTO.Code = HttpStatus.OK; - uploadReapDTO.Body = "Published successfully."; - uploadReapDTO.Message = RespMessage.RequestSucceeded; - return JsonConvert.SerializeObject(uploadReapDTO); - } - catch (Exception ex) - { - uploadReapDTO.Code = HttpStatus.BAD_REQUEST; - uploadReapDTO.Body = $"Failed to publish ! Because : {ex.Message}"; - uploadReapDTO.Message = RespMessage.RequestFailed; - return JsonConvert.SerializeObject(uploadReapDTO); - } -}); - -app.Run(); - -string GetAppSecretKey() -{ - return "B8A7FADD-386C-46B0-B283-C9F963420C7C"; -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Api/Properties/launchSettings.json b/src/c#/GeneralUpdate.Api/Properties/launchSettings.json deleted file mode 100644 index 8ea702e82de6042f5ebcb464efa91392e29c21a7..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.Api/Properties/launchSettings.json +++ /dev/null @@ -1,30 +0,0 @@ -锘縶 - "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:43557", - "sslPort": 44365 - } - }, - "profiles": { - "GeneralUpdate.Api": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "http://127.0.0.1:5001", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Api/appsettings.Development.json b/src/c#/GeneralUpdate.Api/appsettings.Development.json deleted file mode 100644 index 1b2d3bafd88df424abf0d47e2147edd8358bae7a..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.Api/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Api/appsettings.json b/src/c#/GeneralUpdate.Api/appsettings.json deleted file mode 100644 index ec04bc120fb7f339ce3c5ef898d3db32f7366a0c..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.Api/appsettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*" -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.AspNetCore/DTO/RespMessage.cs b/src/c#/GeneralUpdate.AspNetCore/DTO/RespMessage.cs deleted file mode 100644 index fb89b3e611450616fd480626cfed0164228eac2e..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.AspNetCore/DTO/RespMessage.cs +++ /dev/null @@ -1,13 +0,0 @@ -锘縩amespace GeneralUpdate.AspNetCore.DTO -{ - public class RespMessage - { - public const string RequestSucceeded = "Request succeeded."; - - public const string RequestFailed = "Request failed锛"; - - public const string RequestNone = "No need to update."; - - public const string ServerException = "Server internal exception锛"; - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.AspNetCore/GeneralUpdate.AspNetCore.csproj b/src/c#/GeneralUpdate.AspNetCore/GeneralUpdate.AspNetCore.csproj deleted file mode 100644 index ff68e0369c89c711b549d646a2b611a242bd332e..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.AspNetCore/GeneralUpdate.AspNetCore.csproj +++ /dev/null @@ -1,50 +0,0 @@ -锘 - - - netstandard2.0 - GeneralUpdate.ico - GeneralUpdate.png - False - 1.1.0.0 - 1.1.0.0 - 1.1.1 - https://github.com/WELL-E/AutoUpdater - Copyright 漏 2022 - Provide update information proofreading and download update package services. - juster.zhu - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/c#/GeneralUpdate.AspNetCore/GeneralUpdate.ico b/src/c#/GeneralUpdate.AspNetCore/GeneralUpdate.ico deleted file mode 100644 index 7cb4a86c1bbf84baf7b783ab21b4a7e1cf700455..0000000000000000000000000000000000000000 Binary files a/src/c#/GeneralUpdate.AspNetCore/GeneralUpdate.ico and /dev/null differ diff --git a/src/c#/GeneralUpdate.AspNetCore/Hubs/VersionHub.cs b/src/c#/GeneralUpdate.AspNetCore/Hubs/VersionHub.cs deleted file mode 100644 index 2f79b50014286017c862737c0f0a0ba02d330c5e..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.AspNetCore/Hubs/VersionHub.cs +++ /dev/null @@ -1,91 +0,0 @@ -using GeneralUpdate.Core.Utils; -using Microsoft.AspNetCore.SignalR; -using System; -using System.Threading.Tasks; - -namespace GeneralUpdate.AspNetCore.Hubs -{ - public enum HubStatus - { - Connected = 1, - Disconnected = 2 - } - - public class VersionHub : Hub - { - #region Private Members - - private const string ReceiveMessageflag = "ReceiveMessage"; - private const string SendMessageflag = "SendMessage"; - private const string Onlineflag = "Online"; - private const string GroupName = "VersionGroup"; - - public delegate void ConnectionStatus(HubStatus hubStatus, string message); - - public event ConnectionStatus OnConnectionStatus; - - #endregion Private Members - - #region Public Methods - - public override async Task OnConnectedAsync() - { - await Groups.AddToGroupAsync(Context.ConnectionId, GroupName); - await base.OnConnectedAsync(); - if (OnConnectionStatus != null) OnConnectionStatus(HubStatus.Connected, "The Version hub is connected ."); - } - - public override async Task OnDisconnectedAsync(Exception exception) - { - await Groups.RemoveFromGroupAsync(Context.ConnectionId, GroupName); - await base.OnDisconnectedAsync(exception); - if (OnConnectionStatus != null) OnConnectionStatus(HubStatus.Disconnected, "The Version hub is disconnected !"); - } - - /// - /// Kick client connection from group. - /// - /// client connectionId. - /// - public async Task Remove(string connectionId) - { - if (string.IsNullOrWhiteSpace(connectionId)) - throw new ArgumentNullException($"'VersionHub' The required parameter remove cannot be null !"); - - try - { - await Groups.RemoveFromGroupAsync(connectionId, GroupName); - } - catch (Exception ex) - { - throw new Exception($"'VersionHub' Remove error : {ex.Message} .", ex.InnerException); - } - } - - public Task ThrowException() => throw new HubException("This error will be sent to the client!"); - - #endregion Public Methods - } - - public static class HubProvider - { - private const string GroupName = "VersionGroup"; - private const string ReceiveMessageFlag = "ReceiveMessage"; - - public static async Task SendMessage(this IHubContext hub, string user, string message) - { - if (string.IsNullOrWhiteSpace(user) || string.IsNullOrWhiteSpace(message)) - throw new ArgumentNullException($"'VersionHub' The required parameter send message cannot be null !"); - - try - { - var clientParameter = SerializeUtil.Serialize(message); - await hub.Clients.Groups(GroupName).SendAsync(ReceiveMessageFlag, user, clientParameter); - } - catch (Exception ex) - { - throw new Exception($"'VersionHub' Send message error : {ex.Message} .", ex.InnerException); - } - } - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.AspNetCore/Properties/launchSettings.json b/src/c#/GeneralUpdate.AspNetCore/Properties/launchSettings.json deleted file mode 100644 index 86aa9f96ab0fcb3ef20af74d41e5829a442a56eb..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.AspNetCore/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "GeneralUpdate.AspNetCore": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:65355;http://localhost:65363" - } - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.AspNetCore/Services/GeneralUpdateService.cs b/src/c#/GeneralUpdate.AspNetCore/Services/GeneralUpdateService.cs deleted file mode 100644 index d65c71333964f00b4c0d4c6b7bed9f9d35524b6b..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.AspNetCore/Services/GeneralUpdateService.cs +++ /dev/null @@ -1,73 +0,0 @@ -锘縰sing GeneralUpdate.AspNetCore.DTO; -using GeneralUpdate.Core.Domain.DTO; -using GeneralUpdate.Core.Domain.Enum; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace GeneralUpdate.AspNetCore.Services -{ - public class GeneralUpdateService : IUpdateService - { - /// - /// Update validate. - /// - /// 1:ClientApp 2:UpdateApp - /// The current version number of the client. - /// The latest version number of the server. - /// Do you need to force an update. - /// Each version update (Query the latest version information in the database according to the client version number). - /// - public string Update(int clientType, string clientVersion, string serverLastVersion, string clientAppKey, string appSecretKey, - bool isForce, List versions) - { - ParameterVerification(clientType, clientVersion, serverLastVersion, clientAppKey, appSecretKey, versions); - if (!clientAppKey.Equals(appSecretKey)) throw new Exception("App key does not exist or is incorrect !"); - Version clientLastVersion; - var respDTO = new VersionRespDTO(); - try - { - if (!Version.TryParse(clientVersion, out clientLastVersion)) - { - respDTO.Message = $"{RespMessage.RequestFailed} Wrong version number."; - respDTO.Code = HttpStatus.BAD_REQUEST; - return JsonConvert.SerializeObject(respDTO); - } - var lastVersion = new Version(serverLastVersion); - if (clientLastVersion < lastVersion) - { - respDTO.Body = new VersionBodyDTO() { ClientType = clientType, Versions = versions, IsUpdate = true, IsForcibly = isForce }; - respDTO.Code = HttpStatus.OK; - respDTO.Message = RespMessage.RequestSucceeded; - } - else - { - respDTO.Body = new VersionBodyDTO() { ClientType = clientType, Versions = versions, IsUpdate = false, IsForcibly = false }; - respDTO.Code = HttpStatus.OK; - respDTO.Message = RespMessage.RequestNone; - } - } - catch - { - respDTO.Message = RespMessage.ServerException; - respDTO.Code = HttpStatus.SERVICE_UNAVAILABLE; - } - return JsonConvert.SerializeObject(respDTO); - } - - private void ParameterVerification(int clientType, string clientVersion, string serverLastVersion, string clientAppkey, string appSecretKey, List versions) - { - if (clientType <= 0) throw new Exception(@"'clientType' cannot be less than or equal to 0 !"); - if (string.IsNullOrWhiteSpace(clientVersion)) throw new ArgumentNullException(@"'clientVersion' cannot be null !"); - if (string.IsNullOrWhiteSpace(serverLastVersion)) throw new ArgumentNullException(@"'serverLastVersion' cannot be null !"); - if (versions == null) throw new ArgumentNullException(@"versions cannot be null !"); - if (string.IsNullOrEmpty(clientAppkey) || string.IsNullOrEmpty(appSecretKey)) throw new NullReferenceException("The APP key does not exist !"); - } - - - public string Report(int clientType, string clientVersion, string clientAppkey, string appSecretKey, string meesage, string dumpBase64, string logBase64, Exception exception) => string.Empty; - - - private void ParameterVerification(int clientType, string clientVersion, string clientAppkey, string appSecretKey, string meesage, string dumpBase64, string logBase64, Exception exception) { } - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.AspNetCore/Services/IUpdateService.cs b/src/c#/GeneralUpdate.AspNetCore/Services/IUpdateService.cs deleted file mode 100644 index 7e49511e0b371d2ea57b1382098706e90dba1670..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.AspNetCore/Services/IUpdateService.cs +++ /dev/null @@ -1,38 +0,0 @@ -锘縰sing GeneralUpdate.Core.Domain.DTO; -using System; -using System.Collections.Generic; - -namespace GeneralUpdate.AspNetCore.Services -{ - public interface IUpdateService - { - /// - /// Verify whether the current version of the client needs to be updated. - /// - /// 1:ClientApp 2:UpdateApp - /// Current version of the client - /// The latest version of the server. - /// The appkey agreed by the client and server. - /// Appkey is stored in the database. - /// Whether to force all versions to be updated. - /// - /// Json object. - string Update(int clientType, string clientVersion, string serverLastVersion, string clientAppKey, string appSecretKey, bool isForce, List versions); - - /// - /// When this web api is called at the end of the automatic update, it does not mean that every call is successful. - /// Failure, rollback, and success scenarios will inform the server of the result of the update through this web api. - /// If there is an exception let the decision maker decide whether to fix the problem by pushing the latest version of the update again. - /// - /// 1:ClientApp 2:UpdateApp - /// Current version of the client. - /// The appkey agreed by the client and server. - /// Appkey is stored in the database. - /// The message from the client is used to describe the current situation to the decision maker. - /// If an exception occurs, the dump file is returned. - /// If an exception occurs, the log log is returned - /// If an exception occurs, the object is returned. - /// - string Report(int clientType, string clientVersion, string clientAppkey, string appSecretKey, string meesage, string dumpBase64, string logBase64, Exception exception); - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj b/src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj index 02b2970ff10278dcb097ce4f7b9b4cbc40a59864..94ea81d5b8a99c500de3b09bda23e96227a07b29 100644 --- a/src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj +++ b/src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj @@ -5,6 +5,7 @@ net8.0 enable enable + diff --git a/src/c#/GeneralUpdate.Client/MySample.cs b/src/c#/GeneralUpdate.Client/MySample.cs index 6bc123e64c297fe24f696c491bd9e3878f5cc13c..72e631dacad5fabeb9494c7ffee3973810664778 100644 --- a/src/c#/GeneralUpdate.Client/MySample.cs +++ b/src/c#/GeneralUpdate.Client/MySample.cs @@ -1,20 +1,16 @@ 锘縰sing GeneralUpdate.ClientCore; using GeneralUpdate.Core.Bootstrap; +using GeneralUpdate.Core.ContentProvider; using GeneralUpdate.Core.Domain.Entity; -using GeneralUpdate.Core.Events.MultiEventArgs; -using GeneralUpdate.Core.Strategys.PlatformWindows; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using GeneralUpdate.Core.Domain.Enum; +using GeneralUpdate.Core.Driver; using GeneralUpdate.Core.Events.CommonArgs; +using GeneralUpdate.Core.Events.MultiEventArgs; +using GeneralUpdate.Core.Strategys.PlatformWindows; +using GeneralUpdate.Core.WillMessage; using GeneralUpdate.Differential; -using System.IO; -using GeneralUpdate.Core.Driver; -using Microsoft.VisualBasic; using System.Diagnostics; +using System.Text; namespace GeneralUpdate.Client { @@ -38,7 +34,7 @@ namespace GeneralUpdate.Client if (isUpdate) Upgrade(); } - #endregion + #endregion 鎺ㄩ佸姛鑳 #region 甯歌鏇存柊 @@ -211,14 +207,13 @@ namespace GeneralUpdate.Client private void DispatchMessage(string message) { - } - #endregion + #endregion 甯歌鏇存柊 #region 娴嬭瘯浜岃繘鍒舵洿鏂板寘鏁寸悊 - public async Task TestDifferentialClean() + public async Task TestDifferentialClean() { var path1 = "D:\\packet\\source"; var path2 = "D:\\packet\\target"; @@ -226,14 +221,14 @@ namespace GeneralUpdate.Client await DifferentialCore.Instance.Clean(path1, path2, path3); } - public async Task TestDifferentialDirty() + public async Task TestDifferentialDirty() { var path1 = "D:\\packet\\source"; var path2 = "D:\\packet\\patchs"; await DifferentialCore.Instance.Dirty(path1, path2); } - #endregion + #endregion 娴嬭瘯浜岃繘鍒舵洿鏂板寘鏁寸悊 #region 娴嬭瘯椹卞姩鍔熻兘 @@ -298,6 +293,54 @@ namespace GeneralUpdate.Client private bool IsDriverFile(string filePath) => string.Equals(Path.GetExtension(filePath), ".inf", StringComparison.OrdinalIgnoreCase); - #endregion + #endregion 娴嬭瘯椹卞姩鍔熻兘 + + #region 娴嬭瘯WillMessage + + public void TestWillMessage() + { + var path1 = "D:\\packet\\source"; + var path2 = "D:\\packet\\target"; + var hash = "28d10f1fc2a23dd1afe0af40d132b25c72ea56005963f653c27889f03d381c8d"; + + for (int i = 0; i < 1; i++) + { + var version = "1.0.0." + i; + WillMessageManager.Instance.Backup(path1, path2, version, hash, 1); + } + WillMessageManager.Instance.Builder(); + var obj = WillMessageManager.Instance.GetWillMessage(); + WillMessageManager.Instance.Check(); + WillMessageManager.Instance.Restore(); + //WillMessageManager.Instance.Clear(); + } + + #endregion 娴嬭瘯WillMessage + + #region 鏂囦欢绠$悊娴嬭瘯 + + public void TestFileProvider() + { + var sourcePath = "D:\\packet\\source"; + var targetPath = "D:\\packet\\target"; + var resultPath = "D:\\packet\\patchs"; + + //FileProvider fileProvider = new FileProvider(); + //var list = fileProvider.ExecuteOperation(sourcePath, targetPath,new List(), new List()); + //foreach (var item in list) { + // Console.WriteLine(item); + //} + //Console.WriteLine("total" + list.Count()); + //Console.WriteLine("--------------------------------------"); + //FileProvider fileProvider1 = new FileProvider(); + //var list1 = fileProvider1.ExecuteOperation(targetPath, sourcePath, new List(), new List()); + //foreach (var item in list1) + //{ + // Console.WriteLine(item); + //} + //Console.WriteLine("total" + list1.Count()); + } + + #endregion 鏂囦欢绠$悊娴嬭瘯 } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Client/Program.cs b/src/c#/GeneralUpdate.Client/Program.cs index 99480e10585b091829fbb35cf7bf2fdddfc2dd87..1b9dd51c972a8f7125b322c96aa9cb064d97f72a 100644 --- a/src/c#/GeneralUpdate.Client/Program.cs +++ b/src/c#/GeneralUpdate.Client/Program.cs @@ -1,28 +1,28 @@ -锘縰sing GeneralUpdate.Core.HashAlgorithms; - -namespace GeneralUpdate.Client +锘縩amespace GeneralUpdate.Client { internal class Program { - static void Main(string[] args) + private static void Main(string[] args) { - 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"; + MySample sample = new MySample(); + sample.TestFileProvider(); + //Task.Run(async() => + //{ + // //415eed05eb310f480d1e4d15516fa00e484ddb9f416908b217f17b782ded2030 + // //var zip1 = @"D:\github_project\WpfClient\WebApi\UpdateFiles\WpfClient_1_24.1.5.1218.zip"; + // //94bd3d806d39cd1b8813298ec0637c7f377658e766845a06cc50917306cb4ad9 + // //var zip2 = @"D:\github_project\WpfClient\WebApi\UpdateFiles\WpfClient_1_24.1.5.1224.zip"; - //var hashAlgorithm = new Sha256HashAlgorithm(); - //var hashSha256 = hashAlgorithm.ComputeHash(zip1); - //var hashSha2561 = hashAlgorithm.ComputeHash(zip2); + // //var hashAlgorithm = new Sha256HashAlgorithm(); + // //var hashSha256 = hashAlgorithm.ComputeHash(zip1); + // //var hashSha2561 = hashAlgorithm.ComputeHash(zip2); - MySample sample = new MySample(); - //await sample.TestDifferentialClean(); - //await sample.TestDifferentialDirty(); - await sample.Upgrade(); - }); + // MySample sample = new MySample(); + // //await sample.TestDifferentialClean(); + // //await sample.TestDifferentialDirty(); + // await sample.Upgrade(); + //}); Console.Read(); } } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs index d5d74d58739a3b2fa09bcb215c62fd7c953b391d..da7872627b303c1089ca85909e86cd68dcaae5c2 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs +++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs @@ -158,7 +158,7 @@ namespace GeneralUpdate.ClientCore } /// - /// Add an asynchronous custom operation. + /// Add an asynchronous custom operation. /// In theory, any custom operation can be done. It is recommended to register the environment check method to ensure that there are normal dependencies and environments after the update is completed. /// /// @@ -172,7 +172,7 @@ namespace GeneralUpdate.ClientCore } /// - /// Add a synchronization custom operation. + /// Add a synchronization custom operation. /// In theory, any custom operation can be done. It is recommended to register the environment check method to ensure that there are normal dependencies and environments after the update is completed. /// /// @@ -223,10 +223,10 @@ namespace GeneralUpdate.ClientCore } /// - /// Performs all injected custom operations. + /// Performs all injected custom operations. /// /// - private async Task ExecuteCustomOptions() + private async Task ExecuteCustomOptions() { if (_customTaskOptions.Any()) { @@ -242,7 +242,7 @@ namespace GeneralUpdate.ClientCore foreach (var option in _customOptions) { var isSuccess = option.Invoke(); - if (!isSuccess) + if (!isSuccess) Core.Events.EventManager.Instance.Dispatch>(this, new Core.Events.CommonArgs.ExceptionEventArgs($"{nameof(option)}Execution failure!")); } } @@ -251,7 +251,7 @@ namespace GeneralUpdate.ClientCore /// /// The values passed between processes during previous updates are cleared when the client starts. /// - private void ClearEnvironmentVariable() + private void ClearEnvironmentVariable() { try { @@ -278,7 +278,7 @@ namespace GeneralUpdate.ClientCore foreach (var item in Packet.UpdateVersions) { var msg = willMessage.Message.Peek(); - if (string.Equals(msg.Version, item.Version,StringComparison.OrdinalIgnoreCase)) + if (string.Equals(msg.Version, item.Version, StringComparison.OrdinalIgnoreCase)) { return false; } diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs index fb5af438f60ea570ec7baea88446aefdb7fc0b91..c08f1e5744710b81d59c0769b7dc074fae94a510 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs +++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs @@ -1,7 +1,7 @@ -锘縰sing GeneralUpdate.Core.Domain.Entity; +锘縰sing GeneralUpdate.Core.ContentProvider; +using GeneralUpdate.Core.Domain.Entity; using GeneralUpdate.Core.Domain.Entity.Assembler; using GeneralUpdate.Core.Domain.PO; -using GeneralUpdate.Core.Utils; using System; using System.Collections.Generic; using System.Diagnostics; @@ -32,7 +32,7 @@ namespace GeneralUpdate.ClientCore var versionsFilePath = Path.Combine(basePath, configParams.VersionFileName); DownloadFile(configParams.Url + "/" + configParams.VersionFileName, versionsFilePath); if (!File.Exists(versionsFilePath)) return; - var versions = FileUtil.GetJson>(versionsFilePath); + var versions = FileProvider.GetJson>(versionsFilePath); if (versions == null || versions.Count == 0) return; versions = versions.OrderByDescending(x => x.PubTime).ToList(); var newVersion = versions.First(); @@ -49,7 +49,7 @@ namespace GeneralUpdate.ClientCore GeneralUpdate.Core.Events.EventManager.Instance.Dispatch>(typeof(GeneralClientOSS), new GeneralUpdate.Core.Events.CommonArgs.ExceptionEventArgs(ex)); throw new Exception($"GeneralClientOSS update exception ! {ex.Message}", ex.InnerException); } - finally + finally { Process.GetCurrentProcess().Kill(); } @@ -62,19 +62,19 @@ namespace GeneralUpdate.ClientCore /// /// /// true: Upgrade required , false: No upgrade is required - private static bool IsUpgrade(string clientVersion,string serverVersion) + private static bool IsUpgrade(string clientVersion, string serverVersion) { if (string.IsNullOrWhiteSpace(clientVersion) || string.IsNullOrWhiteSpace(serverVersion)) return false; Version currentClientVersion = null; Version currentServerVersion = null; bool isParseClientVersion = Version.TryParse(clientVersion, out currentClientVersion); bool isParseServerVersion = Version.TryParse(serverVersion, out currentServerVersion); - if(!isParseClientVersion || !isParseServerVersion) return false; + if (!isParseClientVersion || !isParseServerVersion) return false; if (currentClientVersion < currentServerVersion) return true; return false; } - private static void DownloadFile(string url,string path) + private static void DownloadFile(string url, string path) { using (var webClient = new WebClient()) { diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj b/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj index 523523f88d0c808a2bc04c2718cf1fc0a041850c..de6d08b8b4db4e9e2a7dad137a7a1f35c373b269 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj +++ b/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj @@ -32,7 +32,6 @@ - @@ -62,9 +61,9 @@ - + @@ -75,6 +74,13 @@ + + + + + + + @@ -150,17 +156,11 @@ - - - - - - @@ -171,9 +171,6 @@ - - - @@ -203,19 +200,14 @@ - - - - - @@ -244,10 +236,8 @@ - - diff --git a/src/c#/GeneralUpdate.AspNetCore/Utils/.gitkeep b/src/c#/GeneralUpdate.ClientCore/WillMessage/.gitkeep similarity index 100% rename from src/c#/GeneralUpdate.AspNetCore/Utils/.gitkeep rename to src/c#/GeneralUpdate.ClientCore/WillMessage/.gitkeep diff --git a/src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs b/src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs index 9b45207b8c84b9b0beb2f1ad5d27afc0d61cc9c9..081f6ecf9f2beced84a4bd46f79bc2c1144b0a5b 100644 --- a/src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs +++ b/src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs @@ -1,11 +1,11 @@ -锘縰sing GeneralUpdate.Core.Domain.Entity; +锘縰sing GeneralUpdate.Core.ContentProvider; +using GeneralUpdate.Core.Domain.Entity; using GeneralUpdate.Core.Domain.Enum; using GeneralUpdate.Core.Download; using GeneralUpdate.Core.Events; using GeneralUpdate.Core.Events.CommonArgs; using GeneralUpdate.Core.Events.MultiEventArgs; using GeneralUpdate.Core.Strategys; -using GeneralUpdate.Core.Utils; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -62,7 +62,7 @@ namespace GeneralUpdate.Core.Bootstrap Packet.Encoding = GetOption(UpdateOption.Encoding) ?? Encoding.Default; Packet.DownloadTimeOut = GetOption(UpdateOption.DownloadTimeOut); Packet.AppName = $"{Packet.AppName ?? GetOption(UpdateOption.MainApp)}{EXECUTABLE_FILE}"; - Packet.TempPath = $"{FileUtil.GetTempDirectory(Packet.LastVersion)}{Path.DirectorySeparatorChar}"; + Packet.TempPath = $"{FileProvider.GetTempDirectory(Packet.LastVersion)}{Path.DirectorySeparatorChar}"; Packet.DriveEnabled = GetOption(UpdateOption.Drive) ?? false; Packet.WillMessageEnabled = GetOption(UpdateOption.WillMessage) ?? false; var manager = new DownloadManager(Packet.TempPath, Packet.Format, Packet.DownloadTimeOut); @@ -95,7 +95,7 @@ namespace GeneralUpdate.Core.Bootstrap return _strategy; } - protected string GetPlatform()=> _strategy.GetPlatform(); + protected string GetPlatform() => _strategy.GetPlatform(); protected IStrategy ExecuteStrategy() { @@ -173,17 +173,17 @@ namespace GeneralUpdate.Core.Bootstrap #region Callback event. - public TBootstrap AddListenerMultiAllDownloadCompleted(Action callbackAction)=> AddListener(callbackAction); + public TBootstrap AddListenerMultiAllDownloadCompleted(Action callbackAction) => AddListener(callbackAction); - public TBootstrap AddListenerMultiDownloadProgress(Action callbackAction)=> AddListener(callbackAction); + public TBootstrap AddListenerMultiDownloadProgress(Action callbackAction) => AddListener(callbackAction); - public TBootstrap AddListenerMultiDownloadCompleted(Action callbackAction)=> AddListener(callbackAction); + public TBootstrap AddListenerMultiDownloadCompleted(Action callbackAction) => AddListener(callbackAction); - public TBootstrap AddListenerMultiDownloadError(Action callbackAction)=> AddListener(callbackAction); + public TBootstrap AddListenerMultiDownloadError(Action callbackAction) => AddListener(callbackAction); - public TBootstrap AddListenerMultiDownloadStatistics(Action callbackAction)=> AddListener(callbackAction); + public TBootstrap AddListenerMultiDownloadStatistics(Action callbackAction) => AddListener(callbackAction); - public TBootstrap AddListenerException(Action callbackAction)=> AddListener(callbackAction); + public TBootstrap AddListenerException(Action callbackAction) => AddListener(callbackAction); protected TBootstrap AddListener(Action callbackAction) where TArgs : EventArgs { diff --git a/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs b/src/c#/GeneralUpdate.Core/ContentProvider/FileNode.cs similarity index 93% rename from src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs rename to src/c#/GeneralUpdate.Core/ContentProvider/FileNode.cs index bb0851f2176561de9f6075443242cbef5120f73e..b74a0594a2c0936ec4c3f55bc2d98b2699354595 100644 --- a/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs +++ b/src/c#/GeneralUpdate.Core/ContentProvider/FileNode.cs @@ -1,6 +1,6 @@ using System; -namespace GeneralUpdate.Differential.ContentProvider +namespace GeneralUpdate.Core.ContentProvider { public class FileNode { @@ -25,7 +25,7 @@ namespace GeneralUpdate.Differential.ContentProvider public int RightType { get; set; } public string RelativePath { get; set; } - + #endregion Public Properties #region Constructors @@ -138,7 +138,7 @@ namespace GeneralUpdate.Differential.ContentProvider if (obj == null) return false; var tempNode = obj as FileNode; if (tempNode == null) throw new ArgumentException(nameof(tempNode)); - return string.Equals(Hash, tempNode.Hash,StringComparison.OrdinalIgnoreCase) && string.Equals(Name, tempNode.Name,StringComparison.OrdinalIgnoreCase); + return string.Equals(Hash, tempNode.Hash, StringComparison.OrdinalIgnoreCase) && string.Equals(Name, tempNode.Name, StringComparison.OrdinalIgnoreCase); } public override int GetHashCode() => base.GetHashCode(); diff --git a/src/c#/GeneralUpdate.Differential/Common/DirectoryComparer.cs b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Comparer.cs similarity index 77% rename from src/c#/GeneralUpdate.Differential/Common/DirectoryComparer.cs rename to src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Comparer.cs index e08bbc4c4aa78b8b8140997f3a42948b8c6ef8a7..ae8cfcda4da6e2e1c63b1a05f46bbf9aacf02b0e 100644 --- a/src/c#/GeneralUpdate.Differential/Common/DirectoryComparer.cs +++ b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Comparer.cs @@ -3,21 +3,17 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace GeneralUpdate.Differential.Common +namespace GeneralUpdate.Core.ContentProvider { - internal class DirectoryComparer + public partial class FileProvider { - private readonly string _directoryA; - private readonly string _directoryB; + private string _directoryA; + private string _directoryB; - public DirectoryComparer(string directoryA, string directoryB) - { - this._directoryA = directoryA.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; - this._directoryB = directoryB.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; - } - - public List Comparer() + public List Comparer(string directoryA, string directoryB) { + _directoryA = directoryA.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; + _directoryB = directoryB.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; var filesInDirectoryA = new HashSet(GetAllFiles(_directoryA).Select(file => file.Substring(_directoryA.Length)), StringComparer.InvariantCultureIgnoreCase); var missingFilesPath = GetAllFiles(_directoryB).Where(fileB => !filesInDirectoryA.Contains(fileB.Substring(_directoryB.Length))).ToList(); var missingFiles = missingFilesPath.Select(path => new FileInfo(path)).ToList(); diff --git a/src/c#/GeneralUpdate.Differential/Common/Filefilter.cs b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Filter.cs similarity index 83% rename from src/c#/GeneralUpdate.Differential/Common/Filefilter.cs rename to src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Filter.cs index 919a162fccd4b8a845ba67907b4860f7100625fa..ba44771876aecef5a11fa057599bd37277a0bcea 100644 --- a/src/c#/GeneralUpdate.Differential/Common/Filefilter.cs +++ b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Filter.cs @@ -1,11 +1,10 @@ -锘縰sing System.Collections.Generic; +锘縰sing System; +using System.Collections.Generic; +using System.Text; -namespace GeneralUpdate.Differential.Common +namespace GeneralUpdate.Core.ContentProvider { - /// - /// Used to filter out non-updatable file formats during the update process. - /// - public class Filefilter + public partial class FileProvider { private static List _blackFiles, _blackFileFormats; @@ -32,4 +31,4 @@ namespace GeneralUpdate.Differential.Common /// public static List GetBlackFileFormats() => _blackFileFormats ?? new List() { ".patch", ".7z", ".zip", ".rar", ".tar", ".json" }; } -} \ No newline at end of file +} diff --git a/src/c#/GeneralUpdate.Core/Utils/FileUtil.cs b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Manage.cs similarity index 47% rename from src/c#/GeneralUpdate.Core/Utils/FileUtil.cs rename to src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Manage.cs index 482dec9c28ddba80e178c464f27f19837aa67cfa..77fa0b8604e31d3ad9b1f61e2266c4fb139562c2 100644 --- a/src/c#/GeneralUpdate.Core/Utils/FileUtil.cs +++ b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Manage.cs @@ -1,16 +1,17 @@ -锘縰sing Newtonsoft.Json; +锘縰sing GeneralUpdate.Core.Exceptions; +using GeneralUpdate.Core.HashAlgorithms; using System; using System.Collections.Generic; using System.IO; -namespace GeneralUpdate.Core.Utils +namespace GeneralUpdate.Core.ContentProvider { - public static class FileUtil + public partial class FileProvider { public static string GetTempDirectory(string name) { - var path2 = $"generalupdate_{DateTime.Now.ToString("yyyy-MM-dd")}_{name}"; - var tempDir = Path.Combine(Path.GetTempPath(), path2); + var path = $"generalupdate_{DateTime.Now.ToString("yyyy-MM-dd")}_{name}"; + var tempDir = Path.Combine(Path.GetTempPath(), path); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); @@ -18,7 +19,7 @@ namespace GeneralUpdate.Core.Utils return tempDir; } - public static FileInfo[] GetAllFiles(string path) + public static List GetAllfiles(string path) { try { @@ -27,9 +28,9 @@ namespace GeneralUpdate.Core.Utils var tmpDir = new DirectoryInfo(path).GetDirectories(); foreach (var dic in tmpDir) { - files.AddRange(GetAllFiles(dic.FullName)); + files.AddRange(GetAllfiles(dic.FullName)); } - return files.ToArray(); + return files; } catch (Exception) { @@ -37,28 +38,6 @@ namespace GeneralUpdate.Core.Utils } } - public static void CreateJson(string targetPath,string fileName,T obj) - { - if (!Directory.Exists(targetPath)) Directory.CreateDirectory(targetPath); - var fileFullPath = Path.Combine(targetPath,fileName); - if (File.Exists(fileFullPath)) File.Delete(fileFullPath); - var jsonString = JsonConvert.SerializeObject(obj); - File.WriteAllText(fileFullPath, jsonString); - } - - public static T GetJson(string path) - { - if (File.Exists(path)) - { - var json = File.ReadAllText(path); - if (json != null) - { - return JsonConvert.DeserializeObject(json); - } - } - return default(T); - } - /// /// Delete the backup file directory and recursively delete all backup content. /// diff --git a/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Serialization.cs b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Serialization.cs new file mode 100644 index 0000000000000000000000000000000000000000..4a03e465486c88a1c1109194e433d0b68a1d5bb0 --- /dev/null +++ b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider-Serialization.cs @@ -0,0 +1,29 @@ +锘縰sing Newtonsoft.Json; +using System.IO; + +namespace GeneralUpdate.Core.ContentProvider +{ + public partial class FileProvider + { + public static void CreateJson(string targetPath, T obj) + { + if (!Directory.Exists(targetPath)) Directory.CreateDirectory(targetPath); + if (File.Exists(targetPath)) File.Delete(targetPath); + var jsonString = JsonConvert.SerializeObject(obj); + File.WriteAllText(targetPath, jsonString); + } + + public static T GetJson(string path) + { + if (File.Exists(path)) + { + var json = File.ReadAllText(path); + if (json != null) + { + return JsonConvert.DeserializeObject(json); + } + } + return default(T); + } + } +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider.cs similarity index 95% rename from src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs rename to src/c#/GeneralUpdate.Core/ContentProvider/FileProvider.cs index f8a6f8fc61872b2c36a00fa7e67a1304f69b88a3..5a89c1d1c2bd7ca912ee44a55cbc2dc7b5ec6fa7 100644 --- a/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs +++ b/src/c#/GeneralUpdate.Core/ContentProvider/FileProvider.cs @@ -1,5 +1,4 @@ using GeneralUpdate.Core.HashAlgorithms; -using GeneralUpdate.Differential.Common; using System; using System.Collections.Generic; using System.IO; @@ -7,9 +6,9 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -namespace GeneralUpdate.Differential.ContentProvider +namespace GeneralUpdate.Core.ContentProvider { - public class FileProvider + public partial class FileProvider { private long _fileCount = 0; @@ -44,7 +43,7 @@ namespace GeneralUpdate.Differential.ContentProvider /// Except collection public async Task> Except(string leftPath, string rightPath) { - return await Task.Run(() => + return await Task.Run(() => { var leftFileNodes = Read(leftPath); var rightFileNodes = Read(rightPath); @@ -102,7 +101,7 @@ namespace GeneralUpdate.Differential.ContentProvider /// private bool IsMatchBlacklist(string subPath) { - var blackList = Filefilter.GetBlackFiles(); + var blackList = GetBlackFiles(); if (blackList == null) return false; foreach (var file in blackList) { diff --git a/src/c#/GeneralUpdate.Differential/ContentProvider/FileTree.cs b/src/c#/GeneralUpdate.Core/ContentProvider/FileTree.cs similarity index 98% rename from src/c#/GeneralUpdate.Differential/ContentProvider/FileTree.cs rename to src/c#/GeneralUpdate.Core/ContentProvider/FileTree.cs index b77d54f29f8a8c04f9aa98e76025b8149bef962e..31fd7f00fa328858737606f2e1130c1bd5c8136c 100644 --- a/src/c#/GeneralUpdate.Differential/ContentProvider/FileTree.cs +++ b/src/c#/GeneralUpdate.Core/ContentProvider/FileTree.cs @@ -1,7 +1,7 @@ 锘縰sing System.Collections.Generic; using System.Diagnostics; -namespace GeneralUpdate.Differential.ContentProvider +namespace GeneralUpdate.Core.ContentProvider { /// /// Simple file binary tree. diff --git a/src/c#/GeneralUpdate.Core/Domain/Entity/Assembler/ProcessAssembler.cs b/src/c#/GeneralUpdate.Core/Domain/Entity/Assembler/ProcessAssembler.cs index 62a892863ce7dcc63a2da6be800006b05943e86f..39a1c69ab1fc46cb846cb1d2a549ae10ce522215 100644 --- a/src/c#/GeneralUpdate.Core/Domain/Entity/Assembler/ProcessAssembler.cs +++ b/src/c#/GeneralUpdate.Core/Domain/Entity/Assembler/ProcessAssembler.cs @@ -1,5 +1,6 @@ 锘縰sing GeneralUpdate.Core.Utils; using System; +using System.Text; namespace GeneralUpdate.Core.Domain.Entity.Assembler { @@ -27,11 +28,47 @@ namespace GeneralUpdate.Core.Domain.Entity.Assembler packet.ClientVersion = info.CurrentVersion; packet.LastVersion = info.LastVersion; packet.UpdateLogUrl = info.LogUrl; - packet.Encoding = ConvertUtil.ToEncoding(info.CompressEncoding); + packet.Encoding = ToEncoding(info.CompressEncoding); packet.Format = info.CompressFormat; packet.DownloadTimeOut = info.DownloadTimeOut; packet.UpdateVersions = info.UpdateVersions; return packet; } + + private static Encoding ToEncoding(int type) + { + Encoding encoding = Encoding.Default; + switch (type) + { + case 1: + encoding = Encoding.UTF8; + break; + + case 2: + encoding = Encoding.UTF7; + break; + + case 3: + encoding = Encoding.UTF32; + break; + + case 4: + encoding = Encoding.Unicode; + break; + + case 5: + encoding = Encoding.BigEndianUnicode; + break; + + case 6: + encoding = Encoding.ASCII; + break; + + case 7: + encoding = Encoding.Default; + break; + } + return encoding; + } } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Domain/Entity/ProcessInfo.cs b/src/c#/GeneralUpdate.Core/Domain/Entity/ProcessInfo.cs index 9788378bb5f4f135a1c81ed98469f56ac03d8b02..4082dd9f93708c69c4745eb047fbc396365c113e 100644 --- a/src/c#/GeneralUpdate.Core/Domain/Entity/ProcessInfo.cs +++ b/src/c#/GeneralUpdate.Core/Domain/Entity/ProcessInfo.cs @@ -1,6 +1,5 @@ 锘縰sing GeneralUpdate.Core.Domain.DTO; using GeneralUpdate.Core.Domain.DTO.Assembler; -using GeneralUpdate.Core.Utils; using System; using System.Collections.Generic; using System.IO; @@ -22,7 +21,7 @@ namespace GeneralUpdate.Core.Domain.Entity LastVersion = lastVersion ?? throw new ArgumentNullException(nameof(lastVersion)); LogUrl = logUrl; compressEncoding = compressEncoding ?? Encoding.Default; - CompressEncoding = ConvertUtil.ToEncodingType(compressEncoding); + CompressEncoding = ToEncodingType(compressEncoding); CompressFormat = compressFormat; if (downloadTimeOut < 0) throw new ArgumentException("Timeout must be greater than 0 !"); DownloadTimeOut = downloadTimeOut; @@ -31,6 +30,40 @@ namespace GeneralUpdate.Core.Domain.Entity UpdateVersions = VersionAssembler.ToEntitys(updateVersions); } + private int ToEncodingType(Encoding encoding) + { + int type = -1; + if (encoding == Encoding.UTF8) + { + type = 1; + } + else if (encoding == Encoding.UTF7) + { + type = 2; + } + else if (encoding == Encoding.UTF32) + { + type = 3; + } + else if (encoding == Encoding.Unicode) + { + type = 4; + } + else if (encoding == Encoding.BigEndianUnicode) + { + type = 5; + } + else if (encoding == Encoding.ASCII) + { + type = 6; + } + else if (encoding == Encoding.Default) + { + type = 7; + } + return type; + } + /// /// 1:MainApp 2:UpdateApp /// diff --git a/src/c#/GeneralUpdate.Core/Domain/PO/Assembler/VersionAssembler.cs b/src/c#/GeneralUpdate.Core/Domain/PO/Assembler/VersionAssembler.cs index 4b7e0082a5e666e3ce121e18f1f85140efabb73c..57cea11a3d23e52168496d329bc01cf5ac9bd9b3 100644 --- a/src/c#/GeneralUpdate.Core/Domain/PO/Assembler/VersionAssembler.cs +++ b/src/c#/GeneralUpdate.Core/Domain/PO/Assembler/VersionAssembler.cs @@ -20,4 +20,4 @@ namespace GeneralUpdate.Core.Domain.PO.Assembler return new VersionInfo(versionDO.PubTime, versionDO.Name, versionDO.Hash, versionDO.Version, versionDO.Url); } } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Domain/PO/VersionPO.cs b/src/c#/GeneralUpdate.Core/Domain/PO/VersionPO.cs index 43f9161711a72435190f435c1f7a01727b9bab09..bca517a3cee628944ee34477cd381a6d48a91768 100644 --- a/src/c#/GeneralUpdate.Core/Domain/PO/VersionPO.cs +++ b/src/c#/GeneralUpdate.Core/Domain/PO/VersionPO.cs @@ -30,4 +30,4 @@ /// public string Url { get; set; } } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Domain/PO/WillMessagePO.cs b/src/c#/GeneralUpdate.Core/Domain/PO/WillMessagePO.cs index 0daf488c9fabc4db62caea39c7397900b2b1a963..30dca5029e04f2d09ea9855b3a7324737ef78be8 100644 --- a/src/c#/GeneralUpdate.Core/Domain/PO/WillMessagePO.cs +++ b/src/c#/GeneralUpdate.Core/Domain/PO/WillMessagePO.cs @@ -9,17 +9,19 @@ namespace GeneralUpdate.Core.Domain.PO /// Processing has not yet begun. /// NotStarted, + /// /// Processing completed. /// Completed, + /// /// Processing failure. /// Failed } - public class BackupPO + public class BackupPO { public string AppPath { get; set; } @@ -39,7 +41,8 @@ namespace GeneralUpdate.Core.Domain.PO public DateTime CreateTime { get; private set; } public DateTime ChangeTime { get; private set; } - private WillMessagePO() { } + private WillMessagePO() + { } public class Builder { @@ -75,5 +78,4 @@ namespace GeneralUpdate.Core.Domain.PO } } } - -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Domain/Service/VersionService.cs b/src/c#/GeneralUpdate.Core/Domain/Service/VersionService.cs index 6aa13d7d974d6b8878c6f07114c8429b400fc058..3da4cd72bd11c05540a83bd4d5148145b99d1681 100644 --- a/src/c#/GeneralUpdate.Core/Domain/Service/VersionService.cs +++ b/src/c#/GeneralUpdate.Core/Domain/Service/VersionService.cs @@ -1,7 +1,12 @@ 锘縰sing GeneralUpdate.Core.Domain.DTO; using GeneralUpdate.Core.Domain.Enum; -using GeneralUpdate.Core.Utils; +using Newtonsoft.Json; using System; +using System.IO; +using System.Net; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; +using System.Text; using System.Threading.Tasks; namespace GeneralUpdate.Core.Domain.Service @@ -18,11 +23,49 @@ namespace GeneralUpdate.Core.Domain.Service public async Task ValidationVersion(string url) { - var updateResp = await HttpUtil.GetTaskAsync(url); + var updateResp = await GetTaskAsync(url); if (updateResp == null || updateResp.Body == null) throw new ArgumentNullException($"The verification request is abnormal, please check the network or parameter configuration!"); if (updateResp.Code != HttpStatus.OK) throw new Exception($"Request failed , Code :{updateResp.Code}, Message:{updateResp.Message} !"); if (updateResp.Code == HttpStatus.OK) return updateResp; return null; } + + public static async Task GetTaskAsync(string http_url, string header_key = null, string header_value = null) + { + HttpWebResponse response = null; + try + { + ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult); + string httpUri = http_url; + var encoding = Encoding.GetEncoding("utf-8"); + var request = (HttpWebRequest)WebRequest.Create(httpUri); + request.Method = "GET"; + request.Accept = "text/html, application/xhtml+xml, */*"; + request.ContentType = "application/x-www-form-urlencoded"; + request.Timeout = 15000; + if (!string.IsNullOrEmpty(header_key) && !string.IsNullOrEmpty(header_value)) + { + request.Headers[header_key] = header_value; + } + response = (HttpWebResponse)await request.GetResponseAsync(); + if (response.StatusCode != HttpStatusCode.OK) return default(T); + using (var reader = new StreamReader(response.GetResponseStream(), encoding)) + { + var tempStr = reader.ReadToEnd(); + var respContent = JsonConvert.DeserializeObject(tempStr); + return respContent; + } + } + catch + { + return default(T); + } + finally + { + if (response != null) response.Close(); + } + } + + private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => true; } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Driver/BackupDriverCommand.cs b/src/c#/GeneralUpdate.Core/Driver/BackupDriverCommand.cs index 7c8979547dd56f34bec6358f08b2a80867dd19f7..a98efe95d24ff65aaf87cabdf5fc4ff0d17abf45 100644 --- a/src/c#/GeneralUpdate.Core/Driver/BackupDriverCommand.cs +++ b/src/c#/GeneralUpdate.Core/Driver/BackupDriverCommand.cs @@ -10,7 +10,7 @@ namespace GeneralUpdate.Core.Driver { private DriverInformation _information; - public BackupDriverCommand(DriverInformation information)=> _information = information; + public BackupDriverCommand(DriverInformation information) => _information = information; public void Execute() { @@ -31,7 +31,7 @@ namespace GeneralUpdate.Core.Driver * If no test driver files are available, you can run the following command to export all installed driver files. * (1) dism /online /export-driver /destination:"D:\packet\cache\" * (2) pnputil /export-driver * D:\packet\cache - * + * * The following code example exports the specified driver to the specified directory. * pnputil /export-driver oem14.inf D:\packet\cache */ diff --git a/src/c#/GeneralUpdate.Core/Driver/CommandExecutor.cs b/src/c#/GeneralUpdate.Core/Driver/CommandExecutor.cs index 55faa1dd738b60f2ecc419535640f5f9d3180ad2..aa4fb1156f327f65c9e268110ad92ccdd08d3e46 100644 --- a/src/c#/GeneralUpdate.Core/Driver/CommandExecutor.cs +++ b/src/c#/GeneralUpdate.Core/Driver/CommandExecutor.cs @@ -22,7 +22,7 @@ Hardware problems: If the hardware device fails or the hardware configuration ch Before doing anything, create a system restore point so that it can be restored to its previous state if something goes wrong. Update the driver regularly to ensure that the driver is compatible with the current operating system version. If possible, use pre-tested drivers that are proven to work. - * + * */ var processStartInfo = new ProcessStartInfo { diff --git a/src/c#/GeneralUpdate.Core/Driver/DeleteDriverCommand.cs b/src/c#/GeneralUpdate.Core/Driver/DeleteDriverCommand.cs index 6fb4e1d50068e1646f1485243f9dc3119ed23b04..0d21452ff0689931fe7e1ed6de68245ea9340f24 100644 --- a/src/c#/GeneralUpdate.Core/Driver/DeleteDriverCommand.cs +++ b/src/c#/GeneralUpdate.Core/Driver/DeleteDriverCommand.cs @@ -11,7 +11,7 @@ namespace GeneralUpdate.Core.Driver public void Execute() { //Before installing the driver, delete the driver that has been installed on the local system. Otherwise, an exception may occur. - foreach (var driver in _information.Drivers) + foreach (var driver in _information.Drivers) { var command = new StringBuilder("/c pnputil /delete-driver ") .Append(driver) @@ -20,4 +20,4 @@ namespace GeneralUpdate.Core.Driver } } } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Driver/DriverInformation.cs b/src/c#/GeneralUpdate.Core/Driver/DriverInformation.cs index bf442b9255cc52b31cb569ee6a00d931cdfe486f..3e1e1da45d332e92a6fc752a86be973895c016d1 100644 --- a/src/c#/GeneralUpdate.Core/Driver/DriverInformation.cs +++ b/src/c#/GeneralUpdate.Core/Driver/DriverInformation.cs @@ -1,5 +1,4 @@ 锘縰sing GeneralUpdate.Core.Exceptions; -using System; using System.Collections.Generic; using System.Linq; @@ -25,12 +24,13 @@ namespace GeneralUpdate.Core.Driver /// public List Drivers { get; private set; } - private DriverInformation(){} + private DriverInformation() + { } public class Builder { private DriverInformation _information = new DriverInformation(); - + public Builder SetInstallDirectory(string installDirectory) { _information.InstallDirectory = installDirectory; @@ -56,8 +56,8 @@ namespace GeneralUpdate.Core.Driver public DriverInformation Build() { - if (string.IsNullOrWhiteSpace(_information.InstallDirectory) || - string.IsNullOrWhiteSpace(_information.OutPutDirectory) || + if (string.IsNullOrWhiteSpace(_information.InstallDirectory) || + string.IsNullOrWhiteSpace(_information.OutPutDirectory) || !_information.Drivers.Any()) { ThrowExceptionUtility.ThrowIfNull("Cannot create DriverInformation, not all fields are set."); diff --git a/src/c#/GeneralUpdate.Core/Driver/InstallDriverCommand.cs b/src/c#/GeneralUpdate.Core/Driver/InstallDriverCommand.cs index 74e7a05a07e3677bd3842b9157ef17191cb3c7fe..17953cd1d9c1060732c2a8e3e448976b5dfd8bff 100644 --- a/src/c#/GeneralUpdate.Core/Driver/InstallDriverCommand.cs +++ b/src/c#/GeneralUpdate.Core/Driver/InstallDriverCommand.cs @@ -12,7 +12,7 @@ namespace GeneralUpdate.Core.Driver { private DriverInformation _information; - public InstallDriverCommand(DriverInformation information)=> _information = information; + public InstallDriverCommand(DriverInformation information) => _information = information; public void Execute() { @@ -22,7 +22,7 @@ namespace GeneralUpdate.Core.Driver { /* * 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. - * + * * 2.Before installation, you need to delete the previously installed driver, otherwise PnPUtil will prompt 259 to exit the code. * (On Windows, an ExitCode value of 259 (STILL_ACTIVE) means that the process is still running) * If you do not remove the previous installation 259 prompt will give you a misleading impression of what is running. diff --git a/src/c#/GeneralUpdate.Core/Driver/RestoreDriverCommand.cs b/src/c#/GeneralUpdate.Core/Driver/RestoreDriverCommand.cs index f36486cbc03ffd4016bd333c3fae1347339692f0..f05c1679ed8cfa0f3bd7527b8e0c4a4fea1b659e 100644 --- a/src/c#/GeneralUpdate.Core/Driver/RestoreDriverCommand.cs +++ b/src/c#/GeneralUpdate.Core/Driver/RestoreDriverCommand.cs @@ -1,7 +1,7 @@ -锘縰sing System.IO; +锘縰sing GeneralUpdate.Core.Exceptions; using System; +using System.IO; using System.Text; -using GeneralUpdate.Core.Exceptions; namespace GeneralUpdate.Core.Driver { @@ -9,7 +9,7 @@ namespace GeneralUpdate.Core.Driver { private DriverInformation _information; - public RestoreDriverCommand(DriverInformation information)=> _information = information; + public RestoreDriverCommand(DriverInformation information) => _information = information; public void Execute() { diff --git a/src/c#/GeneralUpdate.Core/Events/CommonArgs/ExceptionEventArgs.cs b/src/c#/GeneralUpdate.Core/Events/CommonArgs/ExceptionEventArgs.cs index eb845184323855576d38073e9e665bbfd7e233ad..2b54d23d2b289d2853b8fabf34bb7688d5df293a 100644 --- a/src/c#/GeneralUpdate.Core/Events/CommonArgs/ExceptionEventArgs.cs +++ b/src/c#/GeneralUpdate.Core/Events/CommonArgs/ExceptionEventArgs.cs @@ -11,7 +11,7 @@ namespace GeneralUpdate.Core.Events.CommonArgs _exception = exception; } - public ExceptionEventArgs(string mesage)=> _exception = new Exception(mesage); + public ExceptionEventArgs(string mesage) => _exception = new Exception(mesage); public Exception Exception => _exception; } diff --git a/src/c#/GeneralUpdate.Core/Events/OSSArgs/OSSDownloadArgs.cs b/src/c#/GeneralUpdate.Core/Events/OSSArgs/OSSDownloadArgs.cs index 25dca5345eb2958e847872f3e60333d86fb8eb09..44cb32643571ccb37a3c3c8208ba6edefd41dd50 100644 --- a/src/c#/GeneralUpdate.Core/Events/OSSArgs/OSSDownloadArgs.cs +++ b/src/c#/GeneralUpdate.Core/Events/OSSArgs/OSSDownloadArgs.cs @@ -20,4 +20,4 @@ namespace GeneralUpdate.Core.Events.OSSArgs TotalLength = totalLength; } } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Exceptions/CustomException/GeneralUpdateException.cs b/src/c#/GeneralUpdate.Core/Exceptions/CustomException/GeneralUpdateException.cs index 258fc84c9d51de4b7cfb79bf94a2aebbfad65e1a..7e2d60594bd77e3932325a469a0513fb9fab0536 100644 --- a/src/c#/GeneralUpdate.Core/Exceptions/CustomException/GeneralUpdateException.cs +++ b/src/c#/GeneralUpdate.Core/Exceptions/CustomException/GeneralUpdateException.cs @@ -15,7 +15,7 @@ namespace GeneralUpdate.Core.Exceptions.CustomException private const String c_args = "Args"; private readonly TExceptionArgs m_args; - public TExceptionArgs Args=> m_args; + public TExceptionArgs Args => m_args; public GeneralUpdateException(String message = null, Exception innerException = null) : this(null, message, innerException) { diff --git a/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs b/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs index a8bbea558c61a88f30d5812eede561e5108f1987..25c310d08cfdb89a72f3c52b75cc39f0c4a76283 100644 --- a/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs +++ b/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs @@ -6,14 +6,14 @@ namespace GeneralUpdate.Core.Exceptions { internal sealed class ThrowExceptionUtility { - public static void ThrowGeneralUpdateException(ExceptionArgs args) + public static void ThrowGeneralUpdateException(ExceptionArgs args) => Throw(args.ToString(), args); #region Common public static void ThrowFileNotFound(string file) => Throw($"File cannot be accessed {file}!"); - public static void ThrowIfNull(string errorMessage = null) + public static void ThrowIfNull(string errorMessage = null) { errorMessage = errorMessage ?? "Parameter cannot be null"; Throw(errorMessage); @@ -52,6 +52,6 @@ namespace GeneralUpdate.Core.Exceptions public static void Throw(string message, params object[] args) where T : Exception, new() => throw (T)Activator.CreateInstance(typeof(T), message, args); - #endregion + #endregion Common } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs index 4cc57610b751277943e4c744f19afa7f613c57bf..8b4965b51c0d9c9c9239bf476dffc1a42ac27c60 100644 --- a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs +++ b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs @@ -1,8 +1,8 @@ 锘縰sing GeneralUpdate.Core.Bootstrap; +using GeneralUpdate.Core.ContentProvider; using GeneralUpdate.Core.Domain.Entity; using GeneralUpdate.Core.Domain.Entity.Assembler; using GeneralUpdate.Core.Domain.Enum; -using GeneralUpdate.Core.Exceptions; using GeneralUpdate.Core.Strategys; using GeneralUpdate.Core.Utils; using System; @@ -13,7 +13,7 @@ namespace GeneralUpdate.Core { public class GeneralUpdateBootstrap : AbstractBootstrap { - public GeneralUpdateBootstrap() : base()=> Remote(); + public GeneralUpdateBootstrap() : base() => Remote(); /// /// Gets values from system environment variables (ClientParameter object to base64 string). @@ -26,7 +26,7 @@ namespace GeneralUpdate.Core var processInfo = SerializeUtil.Deserialize(base64); Packet = ProcessAssembler.ToPacket(processInfo); Packet.AppType = AppType.UpgradeApp; - Packet.TempPath = $"{FileUtil.GetTempDirectory(processInfo.LastVersion)}{Path.DirectorySeparatorChar}"; + Packet.TempPath = $"{FileProvider.GetTempDirectory(processInfo.LastVersion)}{Path.DirectorySeparatorChar}"; } catch (Exception ex) { diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdateOSS.cs b/src/c#/GeneralUpdate.Core/GeneralUpdateOSS.cs index 1a21bd622ca22529f4f7ab1fc134fa2ec9b12938..d6525c47569390d6c2ccc4eae0d65e5e3f8aa232 100644 --- a/src/c#/GeneralUpdate.Core/GeneralUpdateOSS.cs +++ b/src/c#/GeneralUpdate.Core/GeneralUpdateOSS.cs @@ -17,7 +17,7 @@ namespace GeneralUpdate.Core private GeneralUpdateOSS() { } - #endregion + #endregion Constructors #region Public Methods @@ -27,7 +27,7 @@ namespace GeneralUpdate.Core /// /// /// - public static async Task Start(ParamsOSS parameter,Encoding encoding) where TStrategy : AbstractStrategy, new() + public static async Task Start(ParamsOSS parameter, Encoding encoding) where TStrategy : AbstractStrategy, new() { await BaseStart(parameter, encoding); } @@ -67,7 +67,7 @@ namespace GeneralUpdate.Core AddListener(callbackAction); } - #endregion + #endregion Public Methods #region Private Methods @@ -82,7 +82,7 @@ namespace GeneralUpdate.Core /// The class that needs to be injected with the corresponding platform update policy or inherits the abstract update policy. /// List of parameter. /// - private static async Task BaseStart(TParams parameter,Encoding encoding) where TStrategy : AbstractStrategy, new() where TParams : class + private static async Task BaseStart(TParams parameter, Encoding encoding) where TStrategy : AbstractStrategy, new() where TParams : class { //Initializes and executes the policy. var strategyFunc = new Func(() => new TStrategy()); @@ -92,6 +92,6 @@ namespace GeneralUpdate.Core await strategy.ExecuteTaskAsync(); } - #endregion + #endregion Private Methods } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/HashAlgorithms/Md5HashAlgorithm.cs b/src/c#/GeneralUpdate.Core/HashAlgorithms/Md5HashAlgorithm.cs index d7bbd0bcb17bf92a7085eaca9a0b8f0b0a3d415f..650203436d7873497ad906ae9780f3c3cb4d4375 100644 --- a/src/c#/GeneralUpdate.Core/HashAlgorithms/Md5HashAlgorithm.cs +++ b/src/c#/GeneralUpdate.Core/HashAlgorithms/Md5HashAlgorithm.cs @@ -4,6 +4,6 @@ namespace GeneralUpdate.Core.HashAlgorithms { public class Md5HashAlgorithm : HashAlgorithmBase { - protected override HashAlgorithm GetHashAlgorithm()=> MD5.Create(); + protected override HashAlgorithm GetHashAlgorithm() => MD5.Create(); } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/HashAlgorithms/Sha1HashAlgorithm.cs b/src/c#/GeneralUpdate.Core/HashAlgorithms/Sha1HashAlgorithm.cs index 1013e2f7fcbef2dbf4f5439b6fe05fa5690dd8c3..cec89ba1e735e983d3386d3467f7a1d6fb1fad94 100644 --- a/src/c#/GeneralUpdate.Core/HashAlgorithms/Sha1HashAlgorithm.cs +++ b/src/c#/GeneralUpdate.Core/HashAlgorithms/Sha1HashAlgorithm.cs @@ -4,6 +4,6 @@ namespace GeneralUpdate.Core.HashAlgorithms { public class Sha1HashAlgorithm : HashAlgorithmBase { - protected override HashAlgorithm GetHashAlgorithm()=> new SHA1Managed(); + protected override HashAlgorithm GetHashAlgorithm() => new SHA1Managed(); } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/HashAlgorithms/Sha256HashAlgorithm.cs b/src/c#/GeneralUpdate.Core/HashAlgorithms/Sha256HashAlgorithm.cs index e88290a3e93ba40c9f77a455acc65f5b7f29d7de..d6135eaee2621cad9a8fe6f6c8c4f2c75e0f138a 100644 --- a/src/c#/GeneralUpdate.Core/HashAlgorithms/Sha256HashAlgorithm.cs +++ b/src/c#/GeneralUpdate.Core/HashAlgorithms/Sha256HashAlgorithm.cs @@ -4,6 +4,6 @@ namespace GeneralUpdate.Core.HashAlgorithms { public class Sha256HashAlgorithm : HashAlgorithmBase { - protected override HashAlgorithm GetHashAlgorithm()=> SHA256.Create(); + protected override HashAlgorithm GetHashAlgorithm() => SHA256.Create(); } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Pipelines/Context/BaseContext.cs b/src/c#/GeneralUpdate.Core/Pipelines/Context/BaseContext.cs index ae70b982e43e8146fb73ccba56369d9857a7e5a3..f00c56ca61a2b147988ddfeb2a4135f958359314 100644 --- a/src/c#/GeneralUpdate.Core/Pipelines/Context/BaseContext.cs +++ b/src/c#/GeneralUpdate.Core/Pipelines/Context/BaseContext.cs @@ -21,7 +21,8 @@ namespace GeneralUpdate.Core.Pipelines.Context public List BlackFiles { get; private set; } public List BlackFileFormats { get; private set; } - private BaseContext() { } + private BaseContext() + { } public class Builder { @@ -81,10 +82,7 @@ namespace GeneralUpdate.Core.Pipelines.Context return this; } - public BaseContext Build() - { - return _context; - } + public BaseContext Build() => _context; } } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/DriveMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/DriveMiddleware.cs index 4532b2cafe07e4bcfc036c15ba4d4df015bace84..46f5ff3d9b8ad954e384041722a27c05fc0a3578 100644 --- a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/DriveMiddleware.cs +++ b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/DriveMiddleware.cs @@ -1,10 +1,10 @@ -锘縰sing System; +锘縰sing GeneralUpdate.Core.Driver; +using GeneralUpdate.Core.Pipelines.Context; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Threading.Tasks; -using GeneralUpdate.Core.Driver; -using GeneralUpdate.Core.Pipelines.Context; namespace GeneralUpdate.Core.Pipelines.Middleware { @@ -17,8 +17,8 @@ namespace GeneralUpdate.Core.Pipelines.Middleware { var drivers = GetAllDriverDirectories(context.TargetPath); var information = new DriverInformation.Builder() - .SetInstallDirectory(Path.Combine(context.SourcePath,context.Version.ToString())) - .SetOutPutDirectory(Path.Combine(context.TargetPath,context.Version.ToString())) + .SetInstallDirectory(Path.Combine(context.SourcePath, context.Version.ToString())) + .SetOutPutDirectory(Path.Combine(context.TargetPath, context.Version.ToString())) .SetDriverNames(drivers) .Build(); @@ -70,7 +70,7 @@ namespace GeneralUpdate.Core.Pipelines.Middleware /// /// /// - private bool IsDriverFile(string filePath)=> + private bool IsDriverFile(string filePath) => string.Equals(Path.GetExtension(filePath), ".inf", StringComparison.OrdinalIgnoreCase); } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/HashMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/HashMiddleware.cs index 3db8ae943ccfa1e43d1c2491d884bc36328c39f9..f4ba5cda1a1a9963d1755bd3faf33fcee8da76d5 100644 --- a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/HashMiddleware.cs +++ b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/HashMiddleware.cs @@ -1,6 +1,5 @@ 锘縰sing GeneralUpdate.Core.Domain.Enum; using GeneralUpdate.Core.Events; -using GeneralUpdate.Core.Events.CommonArgs; using GeneralUpdate.Core.Events.MultiEventArgs; using GeneralUpdate.Core.HashAlgorithms; using GeneralUpdate.Core.Pipelines.Context; diff --git a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/MiddlewareExtensions.cs b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/MiddlewareExtensions.cs index 0fd56870c272e72d3ae7dd2e1f72bc6f813bb13e..a6363516322106725d9738d3450495c5b2e99178 100644 --- a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/MiddlewareExtensions.cs +++ b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/MiddlewareExtensions.cs @@ -15,15 +15,15 @@ namespace GeneralUpdate.Core.Pipelines.Middleware private const DynamicallyAccessedMemberTypes MiddlewareAccessibility = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods; - public static IPipelineBuilder UseMiddleware<[DynamicallyAccessedMembers(MiddlewareAccessibility)] TMiddleware>(this IPipelineBuilder pipeline) => pipeline.UseMiddleware(typeof(TMiddleware),true); + public static IPipelineBuilder UseMiddleware<[DynamicallyAccessedMembers(MiddlewareAccessibility)] TMiddleware>(this IPipelineBuilder pipeline) => pipeline.UseMiddleware(typeof(TMiddleware), true); - public static IPipelineBuilder UseMiddlewareIf<[DynamicallyAccessedMembers(MiddlewareAccessibility)] TMiddleware>(this IPipelineBuilder pipeline,bool condition = false) => pipeline.UseMiddleware(typeof(TMiddleware), condition); + public static IPipelineBuilder UseMiddlewareIf<[DynamicallyAccessedMembers(MiddlewareAccessibility)] TMiddleware>(this IPipelineBuilder pipeline, bool condition = false) => pipeline.UseMiddleware(typeof(TMiddleware), condition); public static IPipelineBuilder UseMiddleware( this IPipelineBuilder pipeline, [DynamicallyAccessedMembers(MiddlewareAccessibility)] Type middleware, bool condition) { - if(!condition) return pipeline; + if (!condition) return pipeline; if (!typeof(IMiddleware).IsAssignableFrom(middleware)) throw new ArgumentException($"The middleware type must implement \"{typeof(IMiddleware)}\"."); diff --git a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/WillMessageMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/WillMessageMiddleware.cs index f1125c793c919022c249a1f4752ee1a835a43962..b7b38d162d356b22421dc558eeee7f559e3e9b5e 100644 --- a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/WillMessageMiddleware.cs +++ b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/WillMessageMiddleware.cs @@ -8,9 +8,9 @@ namespace GeneralUpdate.Core.Pipelines.Middleware { public async Task InvokeAsync(BaseContext context, MiddlewareStack stack) { - WillMessageManager.Instance.Backup(context.SourcePath, context.TargetPath, context.Version.ToString(), context.Version.Hash ,context.AppType); + WillMessageManager.Instance.Backup(context.SourcePath, context.TargetPath, context.Version.ToString(), context.Version.Hash, context.AppType); var node = stack.Pop(); if (node != null) await node.Next.Invoke(context, stack); } } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Strategys/AbstractStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/AbstractStrategy.cs index 6ba1277ba341b6394f6292fdb8123ee6ed08a005..5b7384ec546216fb25d6195bd7849ddc88805396 100644 --- a/src/c#/GeneralUpdate.Core/Strategys/AbstractStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategys/AbstractStrategy.cs @@ -18,6 +18,6 @@ namespace GeneralUpdate.Core.Strategys public virtual void Create(T parameter) where T : class => throw new NotImplementedException(); - public virtual void Create(T parameter,Encoding encoding) where T : class => throw new NotImplementedException(); + public virtual void Create(T parameter, Encoding encoding) where T : class => throw new NotImplementedException(); } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs index 6a550f33ee88cd8b3c020df506da1c4c465b8f0a..10f482baa90c7c65474be61da2a6a5343422b997 100644 --- a/src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs @@ -1,4 +1,5 @@ -锘縰sing GeneralUpdate.Core.Domain.Entity; +锘縰sing GeneralUpdate.Core.ContentProvider; +using GeneralUpdate.Core.Domain.Entity; using GeneralUpdate.Core.Domain.Enum; using GeneralUpdate.Core.Domain.PO; using GeneralUpdate.Core.Domain.PO.Assembler; @@ -6,7 +7,6 @@ using GeneralUpdate.Core.Download; using GeneralUpdate.Core.Events; using GeneralUpdate.Core.Events.CommonArgs; using GeneralUpdate.Core.Events.MultiEventArgs; -using GeneralUpdate.Core.Utils; using GeneralUpdate.Zip; using GeneralUpdate.Zip.Factory; using System; @@ -28,7 +28,7 @@ namespace GeneralUpdate.Core.Strategys private ParamsOSS _parameter; private Encoding _encoding; - #endregion + #endregion Private Members #region Public Methods @@ -49,7 +49,7 @@ namespace GeneralUpdate.Core.Strategys if (!File.Exists(jsonPath)) throw new FileNotFoundException(jsonPath); //2.Parse the JSON version configuration file content. - var versions = FileUtil.GetJson>(jsonPath); + var versions = FileProvider.GetJson>(jsonPath); if (versions == null) throw new NullReferenceException(nameof(versions)); //3.Download version by version according to the version of the configuration file. @@ -70,7 +70,7 @@ namespace GeneralUpdate.Core.Strategys }); } - #endregion + #endregion Public Methods #region Private Methods @@ -106,16 +106,16 @@ namespace GeneralUpdate.Core.Strategys try { bool isCompleted = true; - foreach (VersionInfo version in versions) + foreach (VersionInfo version in versions) { - var zipFilePath = Path.Combine(_appPath,$"{version.Name}.zip"); + var zipFilePath = Path.Combine(_appPath, $"{version.Name}.zip"); var zipFactory = new GeneralZipFactory(); zipFactory.UnZipProgress += (sender, e) => EventManager.Instance.Dispatch>(this, new MultiDownloadProgressChangedEventArgs(version, ProgressType.Updatefile, "Updating file...")); - zipFactory.Completed += (sender, e) => + zipFactory.Completed += (sender, e) => { isCompleted = e.IsCompleted; - if(File.Exists(zipFilePath)) File.Delete(zipFilePath); + if (File.Exists(zipFilePath)) File.Delete(zipFilePath); }; zipFactory.CreateOperate(OperationType.GZip, version.Name, zipFilePath, _appPath, false, _encoding); zipFactory.UnZip(); @@ -129,6 +129,6 @@ namespace GeneralUpdate.Core.Strategys } } - #endregion + #endregion Private Methods } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Strategys/PlatformMac/MacStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/PlatformMac/MacStrategy.cs deleted file mode 100644 index 0ca92349902b584bd8f67530436dab7feb23cfae..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.Core/Strategys/PlatformMac/MacStrategy.cs +++ /dev/null @@ -1,24 +0,0 @@ -锘縰sing GeneralUpdate.Core.Domain.Enum; - -namespace GeneralUpdate.Core.Strategys.PlatformMac -{ - public class MacStrategy : AbstractStrategy - { - public override string GetPlatform() => PlatformType.Mac; - - public override void Create(T parameter) - { - base.Create(parameter); - } - - public override void Execute() - { - base.Execute(); - } - - public override bool StartApp(string appName, int appType) - { - return base.StartApp(appName, appType); - } - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs index 7d46afeb68daa334739e8ace77da21cb259ae6a3..d4eeaf60e23b256afc8a99f296cba7c6ed97bd71 100644 --- a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs @@ -1,11 +1,11 @@ -锘縰sing GeneralUpdate.Core.Domain.Entity; +锘縰sing GeneralUpdate.Core.ContentProvider; +using GeneralUpdate.Core.Domain.Entity; using GeneralUpdate.Core.Domain.Enum; using GeneralUpdate.Core.Events; using GeneralUpdate.Core.Events.CommonArgs; using GeneralUpdate.Core.Pipelines; using GeneralUpdate.Core.Pipelines.Context; using GeneralUpdate.Core.Pipelines.Middleware; -using GeneralUpdate.Core.Utils; using GeneralUpdate.Core.WillMessage; using System; using System.Diagnostics; @@ -42,7 +42,7 @@ namespace GeneralUpdate.Core.Strategys.PlatformWindows { foreach (var version in updateVersions) { - var patchPath = FileUtil.GetTempDirectory(PATCHS); + var patchPath = FileProvider.GetTempDirectory(PATCHS); var zipFilePath = Path.Combine(Packet.TempPath, $"{version.Name}{Packet.Format}"); var context = new BaseContext.Builder() diff --git a/src/c#/GeneralUpdate.Core/Utils/ConvertUtil.cs b/src/c#/GeneralUpdate.Core/Utils/ConvertUtil.cs deleted file mode 100644 index 6e197394fe34a0e75aa8bdbded555c8acbaf8900..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.Core/Utils/ConvertUtil.cs +++ /dev/null @@ -1,77 +0,0 @@ -锘縰sing System.Text; - -namespace GeneralUpdate.Core.Utils -{ - public class ConvertUtil - { - public static Encoding ToEncoding(int type) - { - Encoding encoding = Encoding.Default; - switch (type) - { - case 1: - encoding = Encoding.UTF8; - break; - - case 2: - encoding = Encoding.UTF7; - break; - - case 3: - encoding = Encoding.UTF32; - break; - - case 4: - encoding = Encoding.Unicode; - break; - - case 5: - encoding = Encoding.BigEndianUnicode; - break; - - case 6: - encoding = Encoding.ASCII; - break; - - case 7: - encoding = Encoding.Default; - break; - } - return encoding; - } - - public static int ToEncodingType(Encoding encoding) - { - int type = -1; - if (encoding == Encoding.UTF8) - { - type = 1; - } - else if (encoding == Encoding.UTF7) - { - type = 2; - } - else if (encoding == Encoding.UTF32) - { - type = 3; - } - else if (encoding == Encoding.Unicode) - { - type = 4; - } - else if (encoding == Encoding.BigEndianUnicode) - { - type = 5; - } - else if (encoding == Encoding.ASCII) - { - type = 6; - } - else if (encoding == Encoding.Default) - { - type = 7; - } - return type; - } - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Utils/HttpUtil.cs b/src/c#/GeneralUpdate.Core/Utils/HttpUtil.cs deleted file mode 100644 index 798944251314ed9a34d775a1e4093d412cdeb79a..0000000000000000000000000000000000000000 --- a/src/c#/GeneralUpdate.Core/Utils/HttpUtil.cs +++ /dev/null @@ -1,87 +0,0 @@ -锘縰sing Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Security; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Threading.Tasks; - -namespace GeneralUpdate.Core.Utils -{ - public sealed class HttpUtil - { - public static async Task GetTaskAsync(string http_url, string header_key = null, string header_value = null) - { - HttpWebResponse response = null; - try - { - ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult); - string httpUri = http_url; - var encoding = Encoding.GetEncoding("utf-8"); - var request = (HttpWebRequest)WebRequest.Create(httpUri); - request.Method = "GET"; - request.Accept = "text/html, application/xhtml+xml, */*"; - request.ContentType = "application/x-www-form-urlencoded"; - request.Timeout = 15000; - if (!string.IsNullOrEmpty(header_key) && !string.IsNullOrEmpty(header_value)) - { - request.Headers[header_key] = header_value; - } - response = (HttpWebResponse)await request.GetResponseAsync(); - if (response.StatusCode != HttpStatusCode.OK) return default(T); - using (var reader = new StreamReader(response.GetResponseStream(), encoding)) - { - var tempStr = reader.ReadToEnd(); - var respContent = JsonConvert.DeserializeObject(tempStr); - return respContent; - } - } - catch - { - return default(T); - } - finally - { - if (response != null) response.Close(); - } - } - - public static async Task PostFileTaskAsync(string httpUrl, Dictionary parameters, string filePath) - { - try - { - Uri uri = new Uri(httpUrl); - using (var client = new HttpClient()) - using (var content = new MultipartFormDataContent()) - { - foreach (var parameter in parameters) - { - var stringContent = new StringContent(parameter.Value); - content.Add(stringContent, parameter.Key); - } - - if (string.IsNullOrWhiteSpace(filePath) && File.Exists(filePath)) - { - var fileStream = File.OpenRead(filePath); - var fileInfo = new FileInfo(filePath); - var fileContent = new StreamContent(fileStream); - content.Add(fileContent, "file", Path.GetFileName(filePath)); - } - - var result = await client.PostAsync(uri, content); - var reseponseJson = await result.Content.ReadAsStringAsync(); - return JsonConvert.DeserializeObject(reseponseJson); - } - } - catch - { - return default(T); - } - } - - private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => true; - } -} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/WillMessage/WillMessageManager.cs b/src/c#/GeneralUpdate.Core/WillMessage/WillMessageManager.cs index c7916eef99904587f8bc215c96db87c0964fcf57..947914d91bd428a0bfb919df85cc84dc51579249 100644 --- a/src/c#/GeneralUpdate.Core/WillMessage/WillMessageManager.cs +++ b/src/c#/GeneralUpdate.Core/WillMessage/WillMessageManager.cs @@ -1,5 +1,5 @@ -锘縰sing GeneralUpdate.Core.Domain.PO; -using GeneralUpdate.Core.Utils; +锘縰sing GeneralUpdate.Core.ContentProvider; +using GeneralUpdate.Core.Domain.PO; using System; using System.Collections.Generic; using System.IO; @@ -7,37 +7,39 @@ using System.Linq; namespace GeneralUpdate.Core.WillMessage { - internal class WillMessageManager + public class WillMessageManager { #region Private Members - internal const string DEFULT_WILL_MESSAGE_DIR = @"C:\generalupdate_willmessages"; - internal const string DEFULT_WILL_MESSAGE_FILE = "will_message.json"; + private string TempPath = Path.GetTempPath(); + public const string DEFULT_WILL_MESSAGE_DIR = "generalupdate_willmessages"; + public const string BACKUP_DIR = "generalupdate_backup"; + public const string DEFULT_WILL_MESSAGE_FILE = "will_message.json"; - internal const string BACKUP_ROOT_PATH = @"C:\generalupdate_backup"; private string _packetPath; private string _appPath; private string _backupPath; - private Stack _backupStack = new Stack(); + private readonly Stack _backupStack = new Stack(); private string _willMessageFile; private WillMessagePO _willMessage; private bool _isFirstTime = true; private static WillMessageManager _instance; - private readonly static object _instanceLock = new object(); + private static readonly object _instanceLock = new object(); - #endregion + #endregion Private Members #region Constructors - private WillMessageManager() { } + private WillMessageManager() + { } - #endregion + #endregion Constructors #region Public Properties - internal static WillMessageManager Instance + public static WillMessageManager Instance { get { @@ -55,17 +57,17 @@ namespace GeneralUpdate.Core.WillMessage } } - #endregion + #endregion Public Properties #region Public Methods - internal WillMessagePO GetWillMessage(string path = null) + public WillMessagePO GetWillMessage(string path = null) { _willMessageFile = string.IsNullOrWhiteSpace(path) ? GetWillMessagePath() : path; - return _willMessage = FileUtil.GetJson(_willMessageFile); + return _willMessage = FileProvider.GetJson(_willMessageFile); } - internal void Clear() + public void Clear() { _packetPath = null; _appPath = null; @@ -73,16 +75,16 @@ namespace GeneralUpdate.Core.WillMessage _willMessage = null; _willMessageFile = null; _backupStack.Clear(); - FileUtil.DeleteDir(DEFULT_WILL_MESSAGE_DIR); - FileUtil.DeleteDir(BACKUP_ROOT_PATH); + FileProvider.DeleteDir(DEFULT_WILL_MESSAGE_DIR); + FileProvider.DeleteDir(GetBackupPath()); } - internal void Backup(string appPath, string packetPath, string version,string hash,int appType) + public void Backup(string appPath, string packetPath, string version, string hash, int appType) { - if (!Directory.Exists(BACKUP_ROOT_PATH)) - Directory.CreateDirectory(BACKUP_ROOT_PATH); + if (!Directory.Exists(GetBackupPath())) + Directory.CreateDirectory(GetBackupPath()); - var versionDir = Path.Combine(BACKUP_ROOT_PATH, version, appType == 1 ? "ClientApp" : "UpgradeApp"); + var versionDir = Path.Combine(GetBackupPath(), version, appType == 1 ? "ClientApp" : "UpgradeApp"); if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); @@ -90,10 +92,10 @@ namespace GeneralUpdate.Core.WillMessage _packetPath = packetPath; _backupPath = versionDir; ProcessDirectory(_packetPath, _appPath, _backupPath); - _backupStack.Push(new BackupPO { Version = version, AppType = appType, AppPath = _appPath, BackupPath = _backupPath , Hash = hash }); + _backupStack.Push(new BackupPO { Version = version, AppType = appType, AppPath = _appPath, BackupPath = _backupPath, Hash = hash }); } - internal void Restore() + public void Restore() { if (_willMessage == null || _willMessage.Message == null) return; while (_willMessage.Message.Any()) @@ -105,7 +107,7 @@ namespace GeneralUpdate.Core.WillMessage } } - internal void Builder() + public void Builder() { if (!_backupStack.Any()) return; @@ -115,10 +117,10 @@ namespace GeneralUpdate.Core.WillMessage .SetCreateTime(DateTime.Now) .SetChangeTime(DateTime.Now) .Build(); - FileUtil.CreateJson(Path.Combine(DEFULT_WILL_MESSAGE_DIR, DateTime.Now.ToString("yyyyMMdd")), DEFULT_WILL_MESSAGE_FILE, _willMessage); + FileProvider.CreateJson(GetWillMessagePath(), _willMessage); } - internal void Check() + public void Check() { var message = GetWillMessage(); if (message == null) return; @@ -133,20 +135,26 @@ namespace GeneralUpdate.Core.WillMessage { case WillMessageStatus.NotStarted: return; + case WillMessageStatus.Failed: Restore(); break; + case WillMessageStatus.Completed: Clear(); break; } } - #endregion + #endregion Public Methods #region Private Methods - private string GetWillMessagePath() => Path.Combine(DEFULT_WILL_MESSAGE_DIR, DateTime.Now.ToString("yyyyMMdd"), DEFULT_WILL_MESSAGE_FILE); + private string GetWillMessagePath() => + Path.Combine(TempPath, DEFULT_WILL_MESSAGE_DIR, DateTime.Now.ToString("yyyyMMdd"), DEFULT_WILL_MESSAGE_FILE); + + private string GetBackupPath() => + Path.Combine(TempPath, BACKUP_DIR); private void ProcessDirectory(string targetDirectory, string basePath, string destPath) { @@ -192,6 +200,6 @@ namespace GeneralUpdate.Core.WillMessage return relativePath.Replace('/', Path.DirectorySeparatorChar); } - #endregion + #endregion Private Methods } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Differential/Config/ConfigFactory.cs b/src/c#/GeneralUpdate.Differential/Config/ConfigFactory.cs index dd840c902ae733ec95e9158c58dce0b858fe4e14..5033c1cb8a0688b4acb8a27d4f1fb2d39e53c71f 100644 --- a/src/c#/GeneralUpdate.Differential/Config/ConfigFactory.cs +++ b/src/c#/GeneralUpdate.Differential/Config/ConfigFactory.cs @@ -1,6 +1,5 @@ -锘縰sing GeneralUpdate.Core.HashAlgorithms; -using GeneralUpdate.Core.Utils; -using GeneralUpdate.Differential.Common; +锘縰sing GeneralUpdate.Core.ContentProvider; +using GeneralUpdate.Core.HashAlgorithms; using GeneralUpdate.Differential.Config.Cache; using GeneralUpdate.Differential.Config.Handles; using System; @@ -159,7 +158,7 @@ namespace GeneralUpdate.Differential.Config foreach (var file in rootDirectoryInfo.GetFiles()) { var extensionName = Path.GetExtension(file.Name); - if (!Filefilter.GetBlackFileFormats().Contains(extensionName)) continue; + if (!FileProvider.GetBlackFileFormats().Contains(extensionName)) continue; var fullName = file.FullName; files.Add(fullName); } diff --git a/src/c#/GeneralUpdate.Differential/Config/Handles/IniHandle.cs b/src/c#/GeneralUpdate.Differential/Config/Handles/IniHandle.cs index 8520412cd0baab3e071e8276139f00a88499c29a..2ea2cb0c483044b503fcb15773b7b211f545d010 100644 --- a/src/c#/GeneralUpdate.Differential/Config/Handles/IniHandle.cs +++ b/src/c#/GeneralUpdate.Differential/Config/Handles/IniHandle.cs @@ -32,7 +32,7 @@ namespace GeneralUpdate.Differential.Config.Handles throw new NotImplementedException(); } - Dictionary> ParseIniFile(string filePath) + private Dictionary> ParseIniFile(string filePath) { Dictionary> iniData = new Dictionary>(); string currentSection = ""; @@ -58,7 +58,7 @@ namespace GeneralUpdate.Differential.Config.Handles return iniData; } - static Dictionary> GetIniFileDiff( + private static Dictionary> GetIniFileDiff( Dictionary> originalIni, Dictionary> targetIni) { @@ -88,7 +88,7 @@ namespace GeneralUpdate.Differential.Config.Handles return diffIni; } - void MergeIniFiles( + private void MergeIniFiles( Dictionary> targetIni, Dictionary> diffIni) { @@ -109,7 +109,7 @@ namespace GeneralUpdate.Differential.Config.Handles } } - void SaveIniFile(string filePath, Dictionary> iniData) + private void SaveIniFile(string filePath, Dictionary> iniData) { using (StreamWriter writer = new StreamWriter(filePath, false, Encoding.UTF8)) { diff --git a/src/c#/GeneralUpdate.Differential/Config/Handles/JsonHandle.cs b/src/c#/GeneralUpdate.Differential/Config/Handles/JsonHandle.cs index 14b41e8dbce475f5182e69607c214ca2c8855a73..2c5a9cb52ecf276a572b5dbf830efc849a26a40e 100644 --- a/src/c#/GeneralUpdate.Differential/Config/Handles/JsonHandle.cs +++ b/src/c#/GeneralUpdate.Differential/Config/Handles/JsonHandle.cs @@ -126,7 +126,8 @@ namespace GeneralUpdate.Differential.Config.Handles return result; } - private void Read(string originalJson,string diffJson) { + private void Read(string originalJson, string diffJson) + { JObject originalObject = JObject.Parse(originalJson); JObject diffObject = JObject.Parse(diffJson); } diff --git a/src/c#/GeneralUpdate.ClientCore/Differential/Common/.gitkeep b/src/c#/GeneralUpdate.Differential/ContentProvider/.gitkeep similarity index 100% rename from src/c#/GeneralUpdate.ClientCore/Differential/Common/.gitkeep rename to src/c#/GeneralUpdate.Differential/ContentProvider/.gitkeep diff --git a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs index 44ec20b88fdd91c54dbdc294eb468ba17e7b33a5..95f4438c0af95f816f3fd6649572f96a9ab9b5a7 100644 --- a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs +++ b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs @@ -1,9 +1,6 @@ -锘縰sing GeneralUpdate.Core.HashAlgorithms; -using GeneralUpdate.Core.Utils; +锘縰sing GeneralUpdate.Core.ContentProvider; +using GeneralUpdate.Core.HashAlgorithms; using GeneralUpdate.Differential.Binary; -using GeneralUpdate.Differential.Common; -using GeneralUpdate.Differential.ContentProvider; -using GeneralUpdate.Zip.Events; using System; using System.Collections.Generic; using System.IO; @@ -46,7 +43,7 @@ namespace GeneralUpdate.Differential { lock (_lockObj) { - if (_instance == null) + if (_instance == null) { _instance = new DifferentialCore(); } @@ -80,7 +77,7 @@ namespace GeneralUpdate.Differential //Take the left tree as the center to match the files that are not in the right tree . var fileProvider = new FileProvider(); var nodes = await fileProvider.Compare(sourcePath, targetPath); - + //Binary differencing of like terms . foreach (var file in nodes.Item3) { @@ -103,7 +100,7 @@ namespace GeneralUpdate.Differential var oldfile = finOldFile == null ? "" : finOldFile.FullName; var newfile = file.FullName; var extensionName = Path.GetExtension(file.FullName); - if (File.Exists(oldfile) && File.Exists(newfile) && !Filefilter.GetBlackFileFormats().Contains(extensionName)) + if (File.Exists(oldfile) && File.Exists(newfile) && !FileProvider.GetBlackFileFormats().Contains(extensionName)) { //Generate the difference file to the difference directory . await new BinaryHandle().Clean(oldfile, newfile, tempPath0); @@ -116,8 +113,8 @@ namespace GeneralUpdate.Differential //If a file is found that needs to be deleted, a list of files is written to the update package. var exceptFiles = await fileProvider.Except(sourcePath, targetPath); - if(exceptFiles != null && exceptFiles.Count() > 0) - FileUtil.CreateJson(patchPath, DELETE_FILES_NAME, exceptFiles); + if (exceptFiles != null && exceptFiles.Count() > 0) + FileProvider.CreateJson(Path.Combine(patchPath, DELETE_FILES_NAME), exceptFiles); } catch (Exception ex) { @@ -137,14 +134,14 @@ namespace GeneralUpdate.Differential if (!Directory.Exists(appPath) || !Directory.Exists(patchPath)) return; try { - var patchFiles = FileUtil.GetAllFiles(patchPath); - var oldFiles = FileUtil.GetAllFiles(appPath); + var patchFiles = FileProvider.GetAllfiles(patchPath); + var oldFiles = FileProvider.GetAllfiles(appPath); //If a JSON file for the deletion list is found in the update package, it will be deleted based on its contents. - var deleteListJson = patchFiles.FirstOrDefault(i=>i.Name.Equals(DELETE_FILES_NAME)); - if (deleteListJson != null) + var deleteListJson = patchFiles.FirstOrDefault(i => i.Name.Equals(DELETE_FILES_NAME)); + if (deleteListJson != null) { - var deleteFiles = FileUtil.GetJson>(deleteListJson.FullName); + var deleteFiles = FileProvider.GetJson>(deleteListJson.FullName); var hashAlgorithm = new Sha256HashAlgorithm(); foreach (var file in deleteFiles) { @@ -183,7 +180,7 @@ namespace GeneralUpdate.Differential /// /// A collection of blacklist files that are skipped when updated. /// A collection of blacklist file name extensions that are skipped on update. - public void SetBlocklist(List blackFiles, List blackFileFormats) => Filefilter.SetBlacklist(blackFiles, blackFileFormats); + public void SetBlocklist(List blackFiles, List blackFileFormats) => FileProvider.SetBlacklist(blackFiles, blackFileFormats); #endregion Public Methods @@ -219,12 +216,12 @@ namespace GeneralUpdate.Differential { try { - var dirCompare = new DirectoryComparer(patchPath, appPath); - var listExcept = dirCompare.Comparer(); + var fileProvider = new FileProvider(); + var listExcept = fileProvider.Comparer(appPath, patchPath); foreach (var file in listExcept) { var extensionName = Path.GetExtension(file.FullName); - if (Filefilter.GetBlackFileFormats().Contains(extensionName)) continue; + if (FileProvider.GetBlackFileFormats().Contains(extensionName)) continue; var targetFileName = file.FullName.Replace(patchPath, "").TrimStart("\\".ToCharArray()); var targetPath = Path.Combine(appPath, targetFileName); var parentFolder = Directory.GetParent(targetPath); diff --git a/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj b/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj index 00fffc8937275530eeed7553838a499711a6cf66..cb3eba97d3d0574caf3e03a6c329d5c426984136 100644 --- a/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj +++ b/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj @@ -14,6 +14,7 @@ + @@ -25,6 +26,13 @@ + + + + + + + @@ -42,7 +50,6 @@ - @@ -54,6 +61,7 @@ + diff --git a/src/c#/GeneralUpdate.ClientCore/Strategys/PlatformMac/.gitkeep b/src/c#/GeneralUpdate.Maui.OSS/ContentProvider/.gitkeep similarity index 100% rename from src/c#/GeneralUpdate.ClientCore/Strategys/PlatformMac/.gitkeep rename to src/c#/GeneralUpdate.Maui.OSS/ContentProvider/.gitkeep diff --git a/src/c#/GeneralUpdate.Maui.OSS/GeneralUpdate.Maui.OSS.csproj b/src/c#/GeneralUpdate.Maui.OSS/GeneralUpdate.Maui.OSS.csproj index f150deb23484f61a9c75d735f210ae68a0470cc1..fde0276d1c3d49a8e44a193339cd9413bbd91e23 100644 --- a/src/c#/GeneralUpdate.Maui.OSS/GeneralUpdate.Maui.OSS.csproj +++ b/src/c#/GeneralUpdate.Maui.OSS/GeneralUpdate.Maui.OSS.csproj @@ -43,13 +43,20 @@ + - + + + + + + + @@ -66,7 +73,6 @@ - @@ -74,7 +80,6 @@ - diff --git a/src/c#/GeneralUpdate.Maui.OSS/GeneralUpdateOSS.cs b/src/c#/GeneralUpdate.Maui.OSS/GeneralUpdateOSS.cs index 795eead6fa73baaf616bada729ddf88e37e374de..5523a4f53e21a45103ebf80a8b2c0165206617ac 100644 --- a/src/c#/GeneralUpdate.Maui.OSS/GeneralUpdateOSS.cs +++ b/src/c#/GeneralUpdate.Maui.OSS/GeneralUpdateOSS.cs @@ -16,7 +16,7 @@ namespace GeneralUpdate.Maui.OSS private GeneralUpdateOSS() { } - #endregion + #endregion Constructors #region Public Methods @@ -53,7 +53,7 @@ namespace GeneralUpdate.Maui.OSS AddListener(callbackAction); } - #endregion + #endregion Public Methods #region Private Methods @@ -78,6 +78,6 @@ namespace GeneralUpdate.Maui.OSS if (callbackAction != null) EventManager.Instance.AddListener(callbackAction); } - #endregion + #endregion Private Methods } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Maui.OSS/Platforms/Android/AndroidManifest.xml b/src/c#/GeneralUpdate.Maui.OSS/Platforms/Android/AndroidManifest.xml index f9b832e45b60234f9733c93f5bdeb12b97ef5706..b0f2e2a3e219b720565d77ce3f3a94d3e6f21514 100644 --- a/src/c#/GeneralUpdate.Maui.OSS/Platforms/Android/AndroidManifest.xml +++ b/src/c#/GeneralUpdate.Maui.OSS/Platforms/Android/AndroidManifest.xml @@ -1,5 +1,5 @@ 锘 - + - + \ No newline at end of file diff --git a/src/c#/GeneralUpdate.OSSClient/AppShell.xaml b/src/c#/GeneralUpdate.OSSClient/AppShell.xaml index c766f29d5907ac7e0674e6b13e2eea128e0e3089..05b5b0518e0253a07995dc9118a7900e8d2673e1 100644 --- a/src/c#/GeneralUpdate.OSSClient/AppShell.xaml +++ b/src/c#/GeneralUpdate.OSSClient/AppShell.xaml @@ -10,5 +10,4 @@ Title="Home" ContentTemplate="{DataTemplate local:MainPage}" Route="MainPage" /> - - + \ No newline at end of file diff --git a/src/c#/GeneralUpdate.OSSClient/MainPage.xaml b/src/c#/GeneralUpdate.OSSClient/MainPage.xaml index a5fd5afc5fc76bd19a9907a0392a5b2e662b609f..636a0e891d0b3632d4077438325c57c1826191b9 100644 --- a/src/c#/GeneralUpdate.OSSClient/MainPage.xaml +++ b/src/c#/GeneralUpdate.OSSClient/MainPage.xaml @@ -34,8 +34,6 @@ SemanticProperties.Hint="Counts the number of times you click" Clicked="OnCounterClicked" HorizontalOptions="Center" /> - - - + \ No newline at end of file diff --git a/src/c#/GeneralUpdate.OSSClient/MauiProgram.cs b/src/c#/GeneralUpdate.OSSClient/MauiProgram.cs index 87aa782e67aa71ff89019d716a891c3895c964da..49737cd8a6ee1ca61cccb890c628b4e460224416 100644 --- a/src/c#/GeneralUpdate.OSSClient/MauiProgram.cs +++ b/src/c#/GeneralUpdate.OSSClient/MauiProgram.cs @@ -16,7 +16,7 @@ namespace GeneralUpdate.OSSClient }); #if DEBUG - builder.Logging.AddDebug(); + builder.Logging.AddDebug(); #endif return builder.Build(); diff --git a/src/c#/GeneralUpdate.OSSClient/Platforms/Android/MainActivity.cs b/src/c#/GeneralUpdate.OSSClient/Platforms/Android/MainActivity.cs index 9e45c1cbe0199a9c36d431d9be3c6044a894c211..00f343bcaa2bfb9f81476acd13db868de9542f7e 100644 --- a/src/c#/GeneralUpdate.OSSClient/Platforms/Android/MainActivity.cs +++ b/src/c#/GeneralUpdate.OSSClient/Platforms/Android/MainActivity.cs @@ -1,6 +1,5 @@ 锘縰sing Android.App; using Android.Content.PM; -using Android.OS; namespace GeneralUpdate.OSSClient { diff --git a/src/c#/GeneralUpdate.OSSClient/Resources/Styles/Colors.xaml b/src/c#/GeneralUpdate.OSSClient/Resources/Styles/Colors.xaml index 245758ba179319c7248201d70f956d9c2527982b..3f82da216a7e621c4f4971545cb19248e33df9a0 100644 --- a/src/c#/GeneralUpdate.OSSClient/Resources/Styles/Colors.xaml +++ b/src/c#/GeneralUpdate.OSSClient/Resources/Styles/Colors.xaml @@ -1,6 +1,6 @@ 锘 - @@ -17,19 +17,19 @@ #404040 #212121 #141414 - - - - - - - - - - - - - + + + + + + + + + + + + + #F7B548 #FFD590 @@ -40,5 +40,4 @@ #3E8EED #72ACF1 #A7CBF6 - \ No newline at end of file diff --git a/src/c#/GeneralUpdate.OSSClient/Resources/Styles/Styles.xaml b/src/c#/GeneralUpdate.OSSClient/Resources/Styles/Styles.xaml index dc4a03475b51cc49102b46b661373ffc04f7abe4..152a2fef6f2e979661ceb87826c33d84f7c862f6 100644 --- a/src/c#/GeneralUpdate.OSSClient/Resources/Styles/Styles.xaml +++ b/src/c#/GeneralUpdate.OSSClient/Resources/Styles/Styles.xaml @@ -1,6 +1,6 @@ 锘 - @@ -9,14 +9,14 @@ @@ -401,5 +401,4 @@ - - + \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Maui.OSS/Utils/.gitkeep b/src/c#/GeneralUpdate.SystemService/ContentProvider/.gitkeep similarity index 100% rename from src/c#/GeneralUpdate.Maui.OSS/Utils/.gitkeep rename to src/c#/GeneralUpdate.SystemService/ContentProvider/.gitkeep diff --git a/src/c#/GeneralUpdate.SystemService/Domain/DTO/Assembler/.gitkeep b/src/c#/GeneralUpdate.SystemService/Domain/DTO/Assembler/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/c#/GeneralUpdate.SystemService/Domain/Entity/Assembler/.gitkeep b/src/c#/GeneralUpdate.SystemService/Domain/Entity/Assembler/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/c#/GeneralUpdate.SystemService/Exceptions/CustomArgs/.gitkeep b/src/c#/GeneralUpdate.SystemService/Exceptions/CustomArgs/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/c#/GeneralUpdate.SystemService/Exceptions/CustomException/.gitkeep b/src/c#/GeneralUpdate.SystemService/Exceptions/CustomException/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/c#/GeneralUpdate.SystemService/GeneralUpdate.SystemService.csproj b/src/c#/GeneralUpdate.SystemService/GeneralUpdate.SystemService.csproj index 3bd060bd1d58a73e871f2ebfa59d8fe262918a77..5018bdeed9c04b64971760d989317cb60fe43ae4 100644 --- a/src/c#/GeneralUpdate.SystemService/GeneralUpdate.SystemService.csproj +++ b/src/c#/GeneralUpdate.SystemService/GeneralUpdate.SystemService.csproj @@ -8,13 +8,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + @@ -22,4 +57,9 @@ + + + + + diff --git a/src/c#/GeneralUpdate.SystemService/HashAlgorithms/.gitkeep b/src/c#/GeneralUpdate.SystemService/HashAlgorithms/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/c#/GeneralUpdate.SystemService/Properties/launchSettings.json b/src/c#/GeneralUpdate.SystemService/Properties/launchSettings.json index ab9db06fa0d92187e7f4e1ab8988c61b9e2af1a6..fe8baafcc9a7073a9b90370b573696f84e9fb75a 100644 --- a/src/c#/GeneralUpdate.SystemService/Properties/launchSettings.json +++ b/src/c#/GeneralUpdate.SystemService/Properties/launchSettings.json @@ -9,4 +9,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.SystemService/Services/WillMessageService.cs b/src/c#/GeneralUpdate.SystemService/Services/WillMessageService.cs index cc9c554c429756450a2bbc1c813b4952670b2dfd..3aed374629226f1f9f146153b52ef0b1bd0a129b 100644 --- a/src/c#/GeneralUpdate.SystemService/Services/WillMessageService.cs +++ b/src/c#/GeneralUpdate.SystemService/Services/WillMessageService.cs @@ -1,5 +1,6 @@ 锘縰sing GeneralUpdate.Core.WillMessage; using System.Diagnostics; + #if WINDOWS using System.Runtime.InteropServices; #endif @@ -21,17 +22,17 @@ namespace GeneralUpdate.SystemService.Services private FileSystemWatcher _fileWatcher; private ILogger _logger; -#endregion + #endregion Private Members #region Constructors - public WillMessageService(IConfiguration configuration, ILogger logger) + public WillMessageService(IConfiguration configuration, ILogger logger) { _path = configuration.GetValue("WatcherPath"); _logger = logger; } - #endregion + #endregion Constructors #region Public Methods @@ -56,7 +57,7 @@ namespace GeneralUpdate.SystemService.Services _logger.LogInformation("File watcher executed."); stoppingToken.Register(() => OnStopping()); _fileWatcher = new FileSystemWatcher(_path); - // Watch for changes in LastAccess and LastWrite times, and the renaming of files or directories. + // Watch for changes in LastAccess and LastWrite times, and the renaming of files or directories. _fileWatcher.NotifyFilter = NotifyFilters.LastWrite; // Only watch text files. _fileWatcher.Filter = "*.*"; @@ -84,11 +85,11 @@ namespace GeneralUpdate.SystemService.Services return base.StopAsync(cancellationToken); } - #endregion + #endregion Public Methods #region Private Methods - private void OnChanged(object sender, FileSystemEventArgs e) + private void OnChanged(object sender, FileSystemEventArgs e) { try { @@ -116,7 +117,7 @@ namespace GeneralUpdate.SystemService.Services } } - private void Diagnosis(string processName) + private void Diagnosis(string processName) { try { @@ -140,6 +141,6 @@ namespace GeneralUpdate.SystemService.Services } } -#endregion + #endregion Private Methods } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.SystemService/Utrils/.gitkeep b/src/c#/GeneralUpdate.SystemService/Utrils/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/c#/GeneralUpdate.SystemService/appsettings.Development.json b/src/c#/GeneralUpdate.SystemService/appsettings.Development.json index b2dcdb67421cdf46236defda1c6fbf1d9eead5ee..07c8e4cc680fa2b051873422be097f9f5385cd16 100644 --- a/src/c#/GeneralUpdate.SystemService/appsettings.Development.json +++ b/src/c#/GeneralUpdate.SystemService/appsettings.Development.json @@ -5,4 +5,4 @@ "Microsoft.Hosting.Lifetime": "Information" } } -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.SystemService/appsettings.json b/src/c#/GeneralUpdate.SystemService/appsettings.json index 1ac231fab880fe7f8109ba14d53b609731d81aba..27023230ed39dd36f97cbe4ec5d2dccdd11ab51a 100644 --- a/src/c#/GeneralUpdate.SystemService/appsettings.json +++ b/src/c#/GeneralUpdate.SystemService/appsettings.json @@ -6,4 +6,4 @@ } }, "WatcherPath": "C:\\generalupdate_willmessage" -} +} \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Upgrad/Program.cs b/src/c#/GeneralUpdate.Upgrad/Program.cs index 0a9e88af83c568c01d740fc87e3d3b33a2f8fd62..ac3952d242901f7d19098c54c041cb154691b774 100644 --- a/src/c#/GeneralUpdate.Upgrad/Program.cs +++ b/src/c#/GeneralUpdate.Upgrad/Program.cs @@ -1,10 +1,8 @@ 锘縰sing GeneralUpdate.Core; using GeneralUpdate.Core.Bootstrap; -using GeneralUpdate.Core.Domain.Entity; using GeneralUpdate.Core.Domain.Enum; using GeneralUpdate.Core.Events.CommonArgs; using GeneralUpdate.Core.Events.MultiEventArgs; -using GeneralUpdate.Core.Strategys; using GeneralUpdate.Core.Strategys.PlatformWindows; using System.Text; diff --git a/src/c#/GeneralUpdate.sln b/src/c#/GeneralUpdate.sln index b42f9e2365d2939c1abbfd6d7822e41f7d7e6298..0bcd9f746d5a22357b24f0e7ee4943f4410ed100 100644 --- a/src/c#/GeneralUpdate.sln +++ b/src/c#/GeneralUpdate.sln @@ -11,16 +11,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeneralUpdate.Single", "Gen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.Zip", "GeneralUpdate.Zip\GeneralUpdate.Zip.csproj", "{D94882E1-55A7-4787-B049-265F52DC576E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.AspNetCore", "GeneralUpdate.AspNetCore\GeneralUpdate.AspNetCore.csproj", "{7D529953-3846-485F-AC71-3EEACB9161EC}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.ClientCore", "GeneralUpdate.ClientCore\GeneralUpdate.ClientCore.csproj", "{BAEFF926-6B2C-46F1-BB73-AA2AB1355565}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.Differential", "GeneralUpdate.Differential\GeneralUpdate.Differential.csproj", "{40BDA496-7614-4213-92D0-3B1B187675D3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{74BE0282-A10D-4A81-A0F0-FAA79A6152B7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.Api", "GeneralUpdate.Api\GeneralUpdate.Api.csproj", "{AE3E4ADF-CE3B-4E94-B1BE-F0B9916B7F20}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.Upgrad", "GeneralUpdate.Upgrad\GeneralUpdate.Upgrad.csproj", "{E1F9FF93-CA63-4A9C-82F0-450F09ED81F9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.Maui.OSS", "GeneralUpdate.Maui.OSS\GeneralUpdate.Maui.OSS.csproj", "{C4BDA544-2A6E-442C-B7D0-32CD7A996933}" @@ -49,10 +45,6 @@ Global {D94882E1-55A7-4787-B049-265F52DC576E}.Debug|Any CPU.Build.0 = Debug|Any CPU {D94882E1-55A7-4787-B049-265F52DC576E}.Release|Any CPU.ActiveCfg = Release|Any CPU {D94882E1-55A7-4787-B049-265F52DC576E}.Release|Any CPU.Build.0 = Release|Any CPU - {7D529953-3846-485F-AC71-3EEACB9161EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7D529953-3846-485F-AC71-3EEACB9161EC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7D529953-3846-485F-AC71-3EEACB9161EC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7D529953-3846-485F-AC71-3EEACB9161EC}.Release|Any CPU.Build.0 = Release|Any CPU {BAEFF926-6B2C-46F1-BB73-AA2AB1355565}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BAEFF926-6B2C-46F1-BB73-AA2AB1355565}.Debug|Any CPU.Build.0 = Debug|Any CPU {BAEFF926-6B2C-46F1-BB73-AA2AB1355565}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -61,10 +53,6 @@ Global {40BDA496-7614-4213-92D0-3B1B187675D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {40BDA496-7614-4213-92D0-3B1B187675D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {40BDA496-7614-4213-92D0-3B1B187675D3}.Release|Any CPU.Build.0 = Release|Any CPU - {AE3E4ADF-CE3B-4E94-B1BE-F0B9916B7F20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AE3E4ADF-CE3B-4E94-B1BE-F0B9916B7F20}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AE3E4ADF-CE3B-4E94-B1BE-F0B9916B7F20}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AE3E4ADF-CE3B-4E94-B1BE-F0B9916B7F20}.Release|Any CPU.Build.0 = Release|Any CPU {E1F9FF93-CA63-4A9C-82F0-450F09ED81F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E1F9FF93-CA63-4A9C-82F0-450F09ED81F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {E1F9FF93-CA63-4A9C-82F0-450F09ED81F9}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -95,10 +83,8 @@ Global {35BFF228-5EE4-49A6-B721-FB0122E967A0} = {91F059E6-7AD3-4FB7-9604-30A7849C6EFF} {57300FDD-58E9-489E-BF2E-C69A87938845} = {91F059E6-7AD3-4FB7-9604-30A7849C6EFF} {D94882E1-55A7-4787-B049-265F52DC576E} = {91F059E6-7AD3-4FB7-9604-30A7849C6EFF} - {7D529953-3846-485F-AC71-3EEACB9161EC} = {91F059E6-7AD3-4FB7-9604-30A7849C6EFF} {BAEFF926-6B2C-46F1-BB73-AA2AB1355565} = {91F059E6-7AD3-4FB7-9604-30A7849C6EFF} {40BDA496-7614-4213-92D0-3B1B187675D3} = {91F059E6-7AD3-4FB7-9604-30A7849C6EFF} - {AE3E4ADF-CE3B-4E94-B1BE-F0B9916B7F20} = {74BE0282-A10D-4A81-A0F0-FAA79A6152B7} {E1F9FF93-CA63-4A9C-82F0-450F09ED81F9} = {74BE0282-A10D-4A81-A0F0-FAA79A6152B7} {C4BDA544-2A6E-442C-B7D0-32CD7A996933} = {91F059E6-7AD3-4FB7-9604-30A7849C6EFF} {2877DCA1-7EA6-42E9-A1C2-399B51E24893} = {74BE0282-A10D-4A81-A0F0-FAA79A6152B7}