diff --git a/src/c#/GeneralUpdate.Api/Program.cs b/src/c#/GeneralUpdate.Api/Program.cs index d1536828cee76099035e2ce89fde2703ce6c3c6b..35a851f2abe33130c2f82595c8aa751d9aea9e54 100644 --- a/src/c#/GeneralUpdate.Api/Program.cs +++ b/src/c#/GeneralUpdate.Api/Program.cs @@ -14,21 +14,21 @@ var app = builder.Build(); /** * Push the latest version information in real time. */ -app.MapHub("/versionhub"); +//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"; -}); +//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. diff --git a/src/c#/GeneralUpdate.Client/MySample.cs b/src/c#/GeneralUpdate.Client/MySample.cs index f462fb5b023119dbb7cd976e4fd14690cf174001..cdd6a1719f4b83126e7023421334e1da4deeca44 100644 --- a/src/c#/GeneralUpdate.Client/MySample.cs +++ b/src/c#/GeneralUpdate.Client/MySample.cs @@ -10,17 +10,19 @@ using System.Text; using System.Threading.Tasks; using GeneralUpdate.Core.Domain.Enum; using GeneralUpdate.Core.Events.CommonArgs; +using GeneralUpdate.Differential; namespace GeneralUpdate.Client { internal class MySample { + #region 推送功能 + private const string baseUrl = @"http://127.0.0.1:5001"; private const string hubName = "versionhub"; - internal MySample() + internal MySample() { - //var md5 = FileUtil.GetFileMD5(@"F:\test\update.zip"); //Receive sample code pushed by the server //VersionHub.Instance.Subscribe($"{baseUrl}/{hubName}", "TESTNAME", new Action(GetMessage)); } @@ -32,19 +34,21 @@ namespace GeneralUpdate.Client if (isUpdate) Upgrade(); } - private void OnClicked(object sender, EventArgs e) => Upgrade(); + #endregion + + #region 常规更新 - private void Upgrade() + public void Upgrade() { - Task.Run(async () => - { - var url = "http://192.168.50.203"; - var appName = "GeneralUpdate.Client"; - var version = "1.0.0.0"; - var versionFileName = "version.json"; - ParamsOSS @params = new ParamsOSS(url, appName, version, versionFileName); - await GeneralClientOSS.Start(@params); - }); + //Task.Run(async () => + //{ + // var url = "http://192.168.50.203"; + // var appName = "GeneralUpdate.Client"; + // var version = "1.0.0.0"; + // var versionFileName = "version.json"; + // ParamsOSS @params = new ParamsOSS(url, appName, version, versionFileName); + // await GeneralClientOSS.Start(@params); + //}); Task.Run(async () => { @@ -71,15 +75,15 @@ namespace GeneralUpdate.Client //开启驱动更新 .Option(UpdateOption.Drive, true) //开启遗言功能,需要部署GeneralUpdate.SystemService Windows服务。 - .Option(UpdateOption.WillMessage, true) + //.Option(UpdateOption.WillMessage, true) .Strategy() //注入一个func让用户决定是否跳过本次更新,如果是强制更新则不生效 - .SetCustomSkipOption(ShowCustomOption) + //.SetCustomSkipOption(ShowCustomOption) //注入一个自定义方法集合,该集合会在更新启动前执行。执行自定义方法列表如果出现任何异常,将通过异常订阅通知。(推荐在更新之前检查当前软件环境) - .AddCustomOption(new List>() { () => Check1(), () => Check2() }) + //.AddCustomOption(new List>() { () => Check1(), () => Check2() }) //默认黑名单文件: { "Newtonsoft.Json.dll" } 默认黑名单文件扩展名: { ".patch", ".7z", ".zip", ".rar", ".tar" , ".json" } //如果不需要扩展,需要重新传入黑名单集合来覆盖。 - .SetBlacklist(GetBlackFiles(), GetBlackFormats()) + //.SetBlacklist(GetBlackFiles(), GetBlackFormats()) .LaunchTaskAsync(); }); } @@ -206,7 +210,21 @@ namespace GeneralUpdate.Client private void DispatchMessage(string message) { - + + } + + #endregion + + #region 测试二进制更新包整理 + + public async Task TestDifferentialClean() + { + var path1 = "D:\\packet\\source"; + var path2 = "D:\\packet\\target"; + var path3 = "D:\\packet\\patchs"; + await DifferentialCore.Instance.Clean(path1, path2, path3); } + + #endregion } } diff --git a/src/c#/GeneralUpdate.Client/Program.cs b/src/c#/GeneralUpdate.Client/Program.cs index bcd1ce6b9e38456f1c59492462da6bc637cefb7a..f46a15ed9a8c88aeb05e25865c95e1a1262f57cd 100644 --- a/src/c#/GeneralUpdate.Client/Program.cs +++ b/src/c#/GeneralUpdate.Client/Program.cs @@ -4,6 +4,11 @@ { static void Main(string[] args) { + Task.Run(async() => + { + MySample sample = new MySample(); + await sample.TestDifferentialClean(); + }); Console.Read(); } } diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs index 555e18f48c92ebb4f7718f85a739b5815d605c24..aa92529ca005bd7afe50c2d3886f204d5907dada 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs +++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs @@ -7,6 +7,7 @@ using GeneralUpdate.Core.Domain.Service; using GeneralUpdate.Core.Exceptions.CustomArgs; using GeneralUpdate.Core.Exceptions.CustomException; using GeneralUpdate.Core.Strategys; +using GeneralUpdate.Core.WillMessage; using System; using System.Collections.Generic; using System.Diagnostics; @@ -60,6 +61,7 @@ namespace GeneralUpdate.ClientCore var versionService = new VersionService(); var mainResp = await versionService.ValidationVersion(Packet.MainUpdateUrl); var upgradeResp = await versionService.ValidationVersion(Packet.UpdateUrl); + //if (!CheckWillMessage()) return this; Packet.IsUpgradeUpdate = upgradeResp.Body.IsUpdate; Packet.IsMainUpdate = mainResp.Body.IsUpdate; //No need to update, return directly. @@ -265,6 +267,25 @@ namespace GeneralUpdate.ClientCore } } + /// + /// When the update version information requested by the server contains the update failed version, the update execution flow is directly interrupted + /// + /// + private bool CheckWillMessage() + { + var willMessage = WillMessageManager.Instance.GetWillMessage(); + if (willMessage == null) return true; + foreach (var item in Packet.UpdateVersions) + { + var msg = willMessage.Message.Peek(); + if (string.Equals(msg.Version, item.Version,StringComparison.OrdinalIgnoreCase)) + { + return false; + } + } + return true; + } + #endregion Private Methods } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj b/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj index 156e66dd51ba4da35e14fc0dc79c1b84483d3d3d..2dc1fd226f3d70d28cecbfc09fd7ddedbe854a38 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj +++ b/src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj @@ -158,6 +158,7 @@ + diff --git a/src/c#/GeneralUpdate.Core/Domain/PO/WillMessagePO.cs b/src/c#/GeneralUpdate.Core/Domain/PO/WillMessagePO.cs index 2e5919865d40cec0dd60c1ad40c065e7c30837fc..0daf488c9fabc4db62caea39c7397900b2b1a963 100644 --- a/src/c#/GeneralUpdate.Core/Domain/PO/WillMessagePO.cs +++ b/src/c#/GeneralUpdate.Core/Domain/PO/WillMessagePO.cs @@ -27,6 +27,8 @@ namespace GeneralUpdate.Core.Domain.PO public string Version { get; set; } + public string Hash { get; set; } + public int AppType { get; set; } } diff --git a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/DriveMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/DriveMiddleware.cs index 018f02c8b870aec25640c30489f7c20be94adbdd..4532b2cafe07e4bcfc036c15ba4d4df015bace84 100644 --- a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/DriveMiddleware.cs +++ b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/DriveMiddleware.cs @@ -16,10 +16,8 @@ namespace GeneralUpdate.Core.Pipelines.Middleware public async Task InvokeAsync(BaseContext context, MiddlewareStack stack) { var drivers = GetAllDriverDirectories(context.TargetPath); - var information = new DriverInformation.Builder() .SetInstallDirectory(Path.Combine(context.SourcePath,context.Version.ToString())) - //TODO: TargetPath to CachePath .SetOutPutDirectory(Path.Combine(context.TargetPath,context.Version.ToString())) .SetDriverNames(drivers) .Build(); @@ -47,9 +45,7 @@ namespace GeneralUpdate.Core.Pipelines.Middleware foreach (string filePath in Directory.GetFiles(path)) { if (IsDriverFile(filePath)) - { driverDirectories.Add(filePath); - } } foreach (string directory in Directory.GetDirectories(path)) diff --git a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/WillMessageMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/WillMessageMiddleware.cs index a3c71f340a172c49ab31ca74d5eb76fffcad918b..f1125c793c919022c249a1f4752ee1a835a43962 100644 --- a/src/c#/GeneralUpdate.Core/Pipelines/Middleware/WillMessageMiddleware.cs +++ b/src/c#/GeneralUpdate.Core/Pipelines/Middleware/WillMessageMiddleware.cs @@ -8,7 +8,7 @@ namespace GeneralUpdate.Core.Pipelines.Middleware { public async Task InvokeAsync(BaseContext context, MiddlewareStack stack) { - WillMessageManager.Instance.Backup(context.SourcePath, context.TargetPath, context.Version.ToString(), 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); } diff --git a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs index 0dcbd251bd82b4a75fbdd52e1927b88892d7ba1c..33b9e64265d045029bb2da717cbae4d9dc50628f 100644 --- a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs @@ -29,10 +29,7 @@ namespace GeneralUpdate.Core.Strategys.PlatformWindows #region Public Methods - public override void Create(T parameter) - { - Packet = parameter as Packet; - } + public override void Create(T parameter)=> Packet = parameter as Packet; public override void Execute() { @@ -46,7 +43,7 @@ namespace GeneralUpdate.Core.Strategys.PlatformWindows foreach (var version in updateVersions) { var patchPath = FileUtil.GetTempDirectory(PATCHS); - var zipFilePath = $"{Packet.TempPath}{version.Name}{Packet.Format}"; + var zipFilePath = Path.Combine(Packet.TempPath, $"{version.Name}{Packet.Format}"); var context = new BaseContext.Builder() .SetVersion(version) @@ -124,7 +121,7 @@ namespace GeneralUpdate.Core.Strategys.PlatformWindows { try { - if (System.IO.File.Exists(Packet.TempPath)) System.IO.File.Delete(Packet.TempPath); + if (File.Exists(Packet.TempPath)) File.Delete(Packet.TempPath); var dirPath = Path.GetDirectoryName(Packet.TempPath); if (Directory.Exists(dirPath)) Directory.Delete(dirPath, true); return true; diff --git a/src/c#/GeneralUpdate.Core/Utils/FileUtil.cs b/src/c#/GeneralUpdate.Core/Utils/FileUtil.cs index b0e981b0ed6d0a4ada22bf9ec837ecc6e87a9e70..482dec9c28ddba80e178c464f27f19837aa67cfa 100644 --- a/src/c#/GeneralUpdate.Core/Utils/FileUtil.cs +++ b/src/c#/GeneralUpdate.Core/Utils/FileUtil.cs @@ -2,39 +2,11 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; namespace GeneralUpdate.Core.Utils { public static class FileUtil { - public static void DirectoryCopy(string sourceDirName, string destDirName, - bool copySubDirs, bool isOverWrite, Action action) - { - var dir = new DirectoryInfo(sourceDirName); - if (!dir.Exists) return; - var dirs = dir.GetDirectories(); - if (!Directory.Exists(destDirName)) - { - Directory.CreateDirectory(destDirName); - } - foreach (var file in dir.GetFiles()) - { - var tempPath = Path.Combine(destDirName, file.Name); - file.CopyTo(tempPath, isOverWrite); - if (action != null) action.Invoke(file.Name); - } - if (copySubDirs) - { - foreach (var subdir in dirs) - { - var tempPath = Path.Combine(destDirName, subdir.Name); - DirectoryCopy(subdir.FullName, tempPath, true, isOverWrite, action); - } - } - Directory.Delete(sourceDirName, true); - } - public static string GetTempDirectory(string name) { var path2 = $"generalupdate_{DateTime.Now.ToString("yyyy-MM-dd")}_{name}"; @@ -46,45 +18,6 @@ namespace GeneralUpdate.Core.Utils return tempDir; } - /// - /// Compare the contents of two folders for equality. - /// - /// source path - /// target path - /// item1 : The following files are in both folders, item2 : The following files are in list1 but not list2. - public static IEnumerable Compare(string folder1, string folder2) - { - // Create two identical or different temporary folders - // on a local drive and change these file paths. - var dir1 = new DirectoryInfo(folder1); - var dir2 = new DirectoryInfo(folder2); - - // Take a snapshot of the file system. - var list1 = dir1.GetFiles("*.*", SearchOption.AllDirectories); - var list2 = dir2.GetFiles("*.*", SearchOption.AllDirectories); - - //A custom file comparer defined below - var fileCompare = new FileCompare(); - - // This query determines whether the two folders contain - // identical file lists, based on the custom file comparer - // that is defined in the FileCompare class. - // The query executes immediately because it returns a bool. - //areIdentical true : the two folders are the same; false : The two folders are not the same. - var areIdentical = list1.SequenceEqual(list2, fileCompare); - - // Find the common files. It produces a sequence and doesn't - // execute until the foreach statement. - // list1.Intersect(list2, fileCompare); - - // Find the set difference between the two folders. - // For this example we only check one way. - //The following files are in list1 but not list2 - // (from file in list1 select file).Except(list2, fileCompare); - var result = (from file in list1 select file).Except(list2, fileCompare); - return (from file in list1 select file).Except(list2, fileCompare); - } - public static FileInfo[] GetAllFiles(string path) { try @@ -136,32 +69,4 @@ namespace GeneralUpdate.Core.Utils Directory.Delete(path, true); } } - - /// - /// This implementation defines a very simple comparison - /// between two FileInfo objects. It only compares the name - /// of the files being compared and their length in bytes. - /// - public class FileCompare : IEqualityComparer - { - public FileCompare() - { } - - public bool Equals(FileInfo f1, FileInfo f2) - { - return (f1.Name == f2.Name && - f1.Length == f2.Length); - } - - // Return a hash that reflects the comparison criteria. According to the - // rules for IEqualityComparer, if Equals is true, then the hash codes must - // also be equal. Because equality as defined here is a simple value equality, not - // reference identity, it is possible that two or more objects will produce the same - // hash code. - public int GetHashCode(FileInfo fi) - { - string s = $"{fi.Name}{fi.Length}"; - return s.GetHashCode(); - } - } } \ 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 3183a4ebc345e5125d6053717f2a9264b8d40b5e..c7916eef99904587f8bc215c96db87c0964fcf57 100644 --- a/src/c#/GeneralUpdate.Core/WillMessage/WillMessageManager.cs +++ b/src/c#/GeneralUpdate.Core/WillMessage/WillMessageManager.cs @@ -77,7 +77,7 @@ namespace GeneralUpdate.Core.WillMessage FileUtil.DeleteDir(BACKUP_ROOT_PATH); } - internal void Backup(string appPath, string packetPath, string version,int appType) + internal void Backup(string appPath, string packetPath, string version,string hash,int appType) { if (!Directory.Exists(BACKUP_ROOT_PATH)) Directory.CreateDirectory(BACKUP_ROOT_PATH); @@ -90,7 +90,7 @@ namespace GeneralUpdate.Core.WillMessage _packetPath = packetPath; _backupPath = versionDir; ProcessDirectory(_packetPath, _appPath, _backupPath); - _backupStack.Push(new BackupPO { Version = version, AppType = appType, AppPath = _appPath, BackupPath = _backupPath }); + _backupStack.Push(new BackupPO { Version = version, AppType = appType, AppPath = _appPath, BackupPath = _backupPath , Hash = hash }); } internal void Restore() diff --git a/src/c#/GeneralUpdate.Differential/Common/DirectoryComparer.cs b/src/c#/GeneralUpdate.Differential/Common/DirectoryComparer.cs new file mode 100644 index 0000000000000000000000000000000000000000..e08bbc4c4aa78b8b8140997f3a42948b8c6ef8a7 --- /dev/null +++ b/src/c#/GeneralUpdate.Differential/Common/DirectoryComparer.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace GeneralUpdate.Differential.Common +{ + internal class DirectoryComparer + { + private readonly string _directoryA; + private readonly 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() + { + 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(); + return missingFiles; + } + + private IEnumerable GetAllFiles(string directoryPath) + { + var directories = new Stack(); + directories.Push(directoryPath); + + while (directories.Count > 0) + { + var currentDirectory = directories.Pop(); + + if (Directory.EnumerateFiles(currentDirectory, "*.inf").Any()) + continue; + + IEnumerable currentFiles; + try + { + currentFiles = Directory.EnumerateFiles(currentDirectory); + } + catch + { + continue; + } + + foreach (var file in currentFiles) + { + yield return file; + } + + IEnumerable subDirectories; + try + { + subDirectories = Directory.EnumerateDirectories(currentDirectory); + } + catch + { + continue; + } + + foreach (var subDirectory in subDirectories) + { + directories.Push(subDirectory); + } + } + } + } +} diff --git a/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs b/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs index 1aa883c43b96891f8e6ff986d844f3f81618c3a5..43f266ef53c7732dc0e3f6635cf3fe590892def5 100644 --- a/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs +++ b/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs @@ -136,7 +136,7 @@ namespace GeneralUpdate.Differential.ContentProvider if (obj == null) return false; var tempNode = obj as FileNode; if (tempNode == null) throw new ArgumentException(nameof(tempNode)); - return Hash.Equals(tempNode.Hash) && Name.Equals(tempNode.Name); + 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/ContentProvider/FileProvider.cs b/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs index 2ddf0170cc6e78bbeed11a8e0804fb2a26a9acab..5f1a5b322d45ba4775c57fe6880191afd1314b61 100644 --- a/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs +++ b/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs @@ -1,11 +1,9 @@ using GeneralUpdate.Core.HashAlgorithms; -using GeneralUpdate.Core.Utils; using GeneralUpdate.Differential.Common; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.InteropServices.ComTypes; using System.Threading; using System.Threading.Tasks; @@ -13,12 +11,8 @@ namespace GeneralUpdate.Differential.ContentProvider { public class FileProvider { - #region Private Members - private long _fileCount = 0; - #endregion Private Members - #region Public Methods /// @@ -54,16 +48,23 @@ namespace GeneralUpdate.Differential.ContentProvider { var leftFileNodes = Read(leftPath); var rightFileNodes = Read(rightPath); - var resultNodes = new List(); - foreach (var leftNode in leftFileNodes) - { - var findObj = rightFileNodes.FirstOrDefault(i => i.Equals(leftNode)); - if (findObj == null) resultNodes.Add(leftNode); - } - return resultNodes; + Dictionary dictB = rightFileNodes.ToDictionary(x => x.Name, x => x); + List filesOnlyInA = leftFileNodes.Where(f => !dictB.ContainsKey(f.Name)).ToList(); + return filesOnlyInA; }); } + private void Get(string leftPath, string rightPath) + { + var leftFileNodes = Directory.GetFiles(leftPath, "*", SearchOption.AllDirectories) + .Select(f => f.Substring(leftPath.Length)).ToList(); + + var rightFileNodes = Directory.GetFiles(rightPath, "*", SearchOption.AllDirectories) + .Select(f => f.Substring(rightPath.Length)).ToList(); + + leftFileNodes.Except(rightFileNodes).Select(x => leftPath + x).ToList(); + } + #endregion Public Methods #region Private Methods diff --git a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs index 1b9b902796474ffddbdaca5364c3a3fe8a66e668..0ca8dd2d4bd95d8e2c7e932e5422ab3aa314b7ef 100644 --- a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs +++ b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs @@ -3,14 +3,11 @@ using GeneralUpdate.Core.Utils; using GeneralUpdate.Differential.Binary; using GeneralUpdate.Differential.Common; using GeneralUpdate.Differential.ContentProvider; -using GeneralUpdate.Zip; using GeneralUpdate.Zip.Events; -using GeneralUpdate.Zip.Factory; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Threading.Tasks; namespace GeneralUpdate.Differential @@ -68,14 +65,14 @@ namespace GeneralUpdate.Differential /// /// Generate patch file [Cannot contain files with the same name but different extensions] . /// - /// Previous version folder path . + /// Previous version folder path . /// Recent version folder path. /// Store discovered incremental update files in a temporary directory . /// Incremental package generation progress callback function. /// 7z or zip /// Incremental packet encoding format . /// - public async Task Clean(string appPath, string targetPath, string patchPath = null, Action compressProgressCallback = null, OperationType type = OperationType.GZip, Encoding encoding = null, string name = null) + public async Task Clean(string sourcePath, string targetPath, string patchPath = null) { try { @@ -84,7 +81,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(appPath, targetPath); + var nodes = await fileProvider.Compare(sourcePath, targetPath); //Binary differencing of like terms . foreach (var file in nodes.Item3) @@ -120,16 +117,9 @@ 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(appPath, targetPath); + var exceptFiles = await fileProvider.Except(sourcePath, targetPath); if(exceptFiles != null && exceptFiles.Count() > 0) FileUtil.CreateJson(patchPath, DELETE_FILES_NAME, exceptFiles); - - var factory = new GeneralZipFactory(); - _compressProgressCallback = compressProgressCallback; - if (_compressProgressCallback != null) factory.CompressProgress += OnCompressProgress; - //The update package exists in the 'target path' directory. - name = name ?? new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds().ToString(); - factory.CreateOperate(type, name, patchPath, targetPath, true, encoding).CreateZip(); } catch (Exception ex) { @@ -231,7 +221,8 @@ namespace GeneralUpdate.Differential { try { - var listExcept = FileUtil.Compare(patchPath, appPath); + var dirCompare = new DirectoryComparer(patchPath, appPath); + var listExcept = dirCompare.Comparer(); foreach (var file in listExcept) { var extensionName = Path.GetExtension(file.FullName); @@ -251,8 +242,6 @@ namespace GeneralUpdate.Differential } } - private void OnCompressProgress(object sender, BaseCompressProgressEventArgs e) => _compressProgressCallback(sender, e); - #endregion Private Methods } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Upgrad/Program.cs b/src/c#/GeneralUpdate.Upgrad/Program.cs index 8e8625cbfccfad3f015d945e8f27569b42efc2ee..6189220b0fd1794b255db98235af6d403a8b1d18 100644 --- a/src/c#/GeneralUpdate.Upgrad/Program.cs +++ b/src/c#/GeneralUpdate.Upgrad/Program.cs @@ -16,25 +16,25 @@ namespace GeneralUpdate.Upgrad { Task.Run(async () => { - var url = "http://192.168.50.203"; - var appName = "GeneralUpdate.Client"; - var version = "1.0.0.0"; + //var url = "http://192.168.50.203"; + //var appName = "GeneralUpdate.Client"; + //var version = "1.0.0.0"; - //Part1 OSS服务示例 - var versionFileName = "version.json"; - ParamsOSS @params = new ParamsOSS(url, appName, version, versionFileName); - GeneralUpdateOSS.AddListenerMultiDownloadProgress(OnMultiDownloadProgressChanged); - //单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件 - GeneralUpdateOSS.AddListenerMultiDownloadStatistics(OnMultiDownloadStatistics); - //单个或多个更新包下载完成 - GeneralUpdateOSS.AddListenerMultiDownloadCompleted(OnMultiDownloadCompleted); - //完成所有的下载任务通知 - GeneralUpdateOSS.AddListenerMultiAllDownloadCompleted(OnMultiAllDownloadCompleted); - //下载过程出现的异常通知 - GeneralUpdateOSS.AddListenerMultiDownloadError(OnMultiDownloadError); - //整个更新过程出现的任何问题都会通过这个事件通知 - GeneralUpdateOSS.AddListenerException(OnException); - await GeneralUpdateOSS.Start(@params,Encoding.Default); + ////Part1 OSS服务示例 + //var versionFileName = "version.json"; + //ParamsOSS @params = new ParamsOSS(url, appName, version, versionFileName); + //GeneralUpdateOSS.AddListenerMultiDownloadProgress(OnMultiDownloadProgressChanged); + ////单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件 + //GeneralUpdateOSS.AddListenerMultiDownloadStatistics(OnMultiDownloadStatistics); + ////单个或多个更新包下载完成 + //GeneralUpdateOSS.AddListenerMultiDownloadCompleted(OnMultiDownloadCompleted); + ////完成所有的下载任务通知 + //GeneralUpdateOSS.AddListenerMultiAllDownloadCompleted(OnMultiAllDownloadCompleted); + ////下载过程出现的异常通知 + //GeneralUpdateOSS.AddListenerMultiDownloadError(OnMultiDownloadError); + ////整个更新过程出现的任何问题都会通过这个事件通知 + //GeneralUpdateOSS.AddListenerException(OnException); + //await GeneralUpdateOSS.Start(@params,Encoding.Default); //Part 2 常规更新示例 var bootStrap = await new GeneralUpdateBootstrap() diff --git a/src/c#/GeneralUpdate.sln b/src/c#/GeneralUpdate.sln index 332f7dd68bc541f294ebf64d1dc4833d328e18ed..b42f9e2365d2939c1abbfd6d7822e41f7d7e6298 100644 --- a/src/c#/GeneralUpdate.sln +++ b/src/c#/GeneralUpdate.sln @@ -17,33 +17,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.ClientCore", 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}") = "tests", "tests", "{50B6BB53-63A9-414B-9BB0-79A69EEF6785}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestCore", "TestCore\TestCore.csproj", "{87CC0A7B-AA1F-4DC3-BCF2-ECC9FE58D6BA}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestClientCore", "TestClientCore\TestClientCore.csproj", "{03AF5019-F078-45C7-B1DF-1A492D940D56}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestMD5", "TestMD5\TestMD5.csproj", "{EA65E0B6-7E13-4323-A87A-290E62904D4F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestDifferential", "TestDifferential\TestDifferential.csproj", "{7C1F7111-9A73-4F4E-9C7E-03C977E443E1}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestZIP", "TestZIP\TestZIP.csproj", "{B9E98E0F-DA64-4253-AAE9-B0DBB534AFEF}" -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}") = "TestMauiApp", "TestMauiApp\TestMauiApp.csproj", "{9A28F525-124A-4019-8F09-BC48030E0E70}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.Maui.OSS", "GeneralUpdate.Maui.OSS\GeneralUpdate.Maui.OSS.csproj", "{C4BDA544-2A6E-442C-B7D0-32CD7A996933}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.OSSClient", "GeneralUpdate.OSSClient\GeneralUpdate.OSSClient.csproj", "{2877DCA1-7EA6-42E9-A1C2-399B51E24893}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.SystemService", "GeneralUpdate.SystemService\GeneralUpdate.SystemService.csproj", "{8CE233CF-F337-4579-983D-7327567634FA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeneralUpdate.Client", "GeneralUpdate.Client\GeneralUpdate.Client.csproj", "{7779FB4A-D121-48CC-B033-C3D36BD5D4FF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneralUpdate.Client", "GeneralUpdate.Client\GeneralUpdate.Client.csproj", "{7779FB4A-D121-48CC-B033-C3D36BD5D4FF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -75,26 +61,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 - {87CC0A7B-AA1F-4DC3-BCF2-ECC9FE58D6BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {87CC0A7B-AA1F-4DC3-BCF2-ECC9FE58D6BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {87CC0A7B-AA1F-4DC3-BCF2-ECC9FE58D6BA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {87CC0A7B-AA1F-4DC3-BCF2-ECC9FE58D6BA}.Release|Any CPU.Build.0 = Release|Any CPU - {03AF5019-F078-45C7-B1DF-1A492D940D56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {03AF5019-F078-45C7-B1DF-1A492D940D56}.Debug|Any CPU.Build.0 = Debug|Any CPU - {03AF5019-F078-45C7-B1DF-1A492D940D56}.Release|Any CPU.ActiveCfg = Release|Any CPU - {03AF5019-F078-45C7-B1DF-1A492D940D56}.Release|Any CPU.Build.0 = Release|Any CPU - {EA65E0B6-7E13-4323-A87A-290E62904D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EA65E0B6-7E13-4323-A87A-290E62904D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EA65E0B6-7E13-4323-A87A-290E62904D4F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EA65E0B6-7E13-4323-A87A-290E62904D4F}.Release|Any CPU.Build.0 = Release|Any CPU - {7C1F7111-9A73-4F4E-9C7E-03C977E443E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7C1F7111-9A73-4F4E-9C7E-03C977E443E1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7C1F7111-9A73-4F4E-9C7E-03C977E443E1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7C1F7111-9A73-4F4E-9C7E-03C977E443E1}.Release|Any CPU.Build.0 = Release|Any CPU - {B9E98E0F-DA64-4253-AAE9-B0DBB534AFEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B9E98E0F-DA64-4253-AAE9-B0DBB534AFEF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9E98E0F-DA64-4253-AAE9-B0DBB534AFEF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9E98E0F-DA64-4253-AAE9-B0DBB534AFEF}.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 @@ -103,12 +69,6 @@ Global {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 {E1F9FF93-CA63-4A9C-82F0-450F09ED81F9}.Release|Any CPU.Build.0 = Release|Any CPU - {9A28F525-124A-4019-8F09-BC48030E0E70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9A28F525-124A-4019-8F09-BC48030E0E70}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9A28F525-124A-4019-8F09-BC48030E0E70}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {9A28F525-124A-4019-8F09-BC48030E0E70}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9A28F525-124A-4019-8F09-BC48030E0E70}.Release|Any CPU.Build.0 = Release|Any CPU - {9A28F525-124A-4019-8F09-BC48030E0E70}.Release|Any CPU.Deploy.0 = Release|Any CPU {C4BDA544-2A6E-442C-B7D0-32CD7A996933}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C4BDA544-2A6E-442C-B7D0-32CD7A996933}.Debug|Any CPU.Build.0 = Debug|Any CPU {C4BDA544-2A6E-442C-B7D0-32CD7A996933}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -138,14 +98,8 @@ Global {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} - {87CC0A7B-AA1F-4DC3-BCF2-ECC9FE58D6BA} = {50B6BB53-63A9-414B-9BB0-79A69EEF6785} - {03AF5019-F078-45C7-B1DF-1A492D940D56} = {50B6BB53-63A9-414B-9BB0-79A69EEF6785} - {EA65E0B6-7E13-4323-A87A-290E62904D4F} = {50B6BB53-63A9-414B-9BB0-79A69EEF6785} - {7C1F7111-9A73-4F4E-9C7E-03C977E443E1} = {50B6BB53-63A9-414B-9BB0-79A69EEF6785} - {B9E98E0F-DA64-4253-AAE9-B0DBB534AFEF} = {50B6BB53-63A9-414B-9BB0-79A69EEF6785} {AE3E4ADF-CE3B-4E94-B1BE-F0B9916B7F20} = {74BE0282-A10D-4A81-A0F0-FAA79A6152B7} {E1F9FF93-CA63-4A9C-82F0-450F09ED81F9} = {74BE0282-A10D-4A81-A0F0-FAA79A6152B7} - {9A28F525-124A-4019-8F09-BC48030E0E70} = {50B6BB53-63A9-414B-9BB0-79A69EEF6785} {C4BDA544-2A6E-442C-B7D0-32CD7A996933} = {91F059E6-7AD3-4FB7-9604-30A7849C6EFF} {2877DCA1-7EA6-42E9-A1C2-399B51E24893} = {74BE0282-A10D-4A81-A0F0-FAA79A6152B7} {8CE233CF-F337-4579-983D-7327567634FA} = {91F059E6-7AD3-4FB7-9604-30A7849C6EFF} diff --git a/src/c#/TestClientCore/Properties/launchSettings.json b/src/c#/TestClientCore/Properties/launchSettings.json deleted file mode 100644 index 1bd4d2f7fdb047aff358dd03b3e1a2c823e1ab8e..0000000000000000000000000000000000000000 --- a/src/c#/TestClientCore/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "TestClientCore": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:65349;http://localhost:65365" - } - } -} \ No newline at end of file diff --git a/src/c#/TestClientCore/TestClientCore.csproj b/src/c#/TestClientCore/TestClientCore.csproj deleted file mode 100644 index 45ace51baf7d4afbe3267a16a1f0496e39a82ae7..0000000000000000000000000000000000000000 --- a/src/c#/TestClientCore/TestClientCore.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - - - - - - - - - diff --git a/src/c#/TestClientCore/UnitTest1.cs b/src/c#/TestClientCore/UnitTest1.cs deleted file mode 100644 index d9a77991f2647f0eb9b473724801ba3dfe45714e..0000000000000000000000000000000000000000 --- a/src/c#/TestClientCore/UnitTest1.cs +++ /dev/null @@ -1,189 +0,0 @@ -using GeneralUpdate.ClientCore; -using GeneralUpdate.Core.Domain.Entity; - -namespace TestClientCore -{ - public class Tests - { - [SetUp] - public void Setup() - { - - } - - [Test] - public void Test1() - { - Task.Run(async () => - { - var url = "http://192.168.50.203"; - var appName = "GeneralUpdate.Client"; - var version = "1.0.0"; - var versionFileName = "version.json"; - ParamsOSS @params = new ParamsOSS(url, appName, version, versionFileName); - await GeneralClientOSS.Start(@params); - }); - } - - //public delegate void BoilHandle(object obj, EventArgs eventArgs); - //public event BoilHandle BoilEvent;//װί - - //public void Test1() - //{ - // BoilEvent += Program_BoilEvent; - // GeneralEventManager.Instance.AddListener(BoilEvent); - // GeneralEventManager.Instance.Dispatch(this, new EventArgs()); - //} - - //private void Program_BoilEvent(object obj, EventArgs eventArgs) - //{ - // Console.WriteLine(1); - //} - - //private const string baseUrl = @"http://127.0.0.1:5001", hubName = "versionhub"; - //private const string baseUrl1 = @"http://127.0.0.1:5001"; - //private const string baseUrl2 = @"http://127.0.0.1:5001"; - ////InitVersionHub(); - //#region VersionHub - - ///// - ///// Subscription server push version message. - ///// - //private void InitVersionHub() - //{ - // VersionHub.Instance.Subscribe($"{baseUrl}/{hubName}", "TESTNAME", new Action(GetMessage)); - //} - - //private void GetMessage(string msg) - //{ - // TxtMessage.Text = msg; - //} - - //#endregion VersionHub - - //#region GeneralUpdate Core - - ////private ClientParameter clientParameter; - - //private void BtnClientTest_Click(object sender, RoutedEventArgs e) - //{ - // Task.Run(async () => - // { - // //Ϣ - // var mainVersion = "1.1.1.1"; - - // //öͻ֮佻õĶ - // //clientParameter = new ClientParameter(); - - // //Ŀͻ˳Ӧõַ - // //clientParameter.InstallPath = @"D:\Updatetest_hub\Run_app"; - // //¹ҳ - // //clientParameter.UpdateLogUrl = "https://www.baidu.com/"; - - // #region update app. - - // //clientParameter.ClientVersion = "9.1.3.0";//"1.1.1.1"; - - // ////ͻͣ1.ͻ 2. - // //clientParameter.AppType = (int)AppType.UpdateApp; - // //clientParameter.AppSecretKey = "41A54379-C7D6-4920-8768-21A3468572E5"; - // ////֤µķ˵ַ - // //clientParameter.ValidateUrl = $"{baseUrl}/validate/{ clientParameter.AppType }/{ clientParameter.ClientVersion }/{clientParameter.AppSecretKey}"; - // ////°صַ - // //clientParameter.UpdateUrl = $"{baseUrl}/versions/{ clientParameter.AppType }/{ clientParameter.ClientVersion }/{clientParameter.AppSecretKey}"; - // ////³exe - // //clientParameter.AppName = "AutoUpdate.Core"; - // //ָӦԿֿͻӦ - - // #endregion update app. - - // #region main app. - - // //İ汾 - // //clientParameter.ClientVersion = "1.1.1"; - // //ͻexe - // //clientParameter.MainAppName = "AutoUpdate.ClientCore"; - // //ͻ֤µķ˵ַ - // //clientParameter.MainValidateUrl = $"{baseUrl}/validate/{ (int)AppType.ClientApp }/{ mainVersion }/{clientParameter.AppSecretKey}"; - // //ͻ˸°صַ - // //clientParameter.MainUpdateUrl = $"{baseUrl}/versions/{ (int)AppType.ClientApp }/{ mainVersion }/{clientParameter.AppSecretKey}"; - - // #endregion main app. - - // var generalClientBootstrap = new GeneralClientBootstrap(); - // //°֪ͨ¼ - // generalClientBootstrap.MultiDownloadProgressChanged += OnMultiDownloadProgressChanged; - // //°ٶȡʣ¼ǰذ汾Ϣ֪ͨ¼ - // generalClientBootstrap.MultiDownloadStatistics += OnMultiDownloadStatistics; - // //° - // generalClientBootstrap.MultiDownloadCompleted += OnMultiDownloadCompleted; - // //е֪ͨ - // generalClientBootstrap.MultiAllDownloadCompleted += OnMultiAllDownloadCompleted; - // //عֵ̳쳣֪ͨ - // generalClientBootstrap.MultiDownloadError += OnMultiDownloadError; - // //¹ֵ̳κⶼͨ¼֪ͨ - // generalClientBootstrap.Exception += OnException; - // //ClientStrategyø²Խ1.ԶԸ 2. 3.úClientParameter֮ǰİ汾дargsͨѶˡ - // generalClientBootstrap.Config("", ""). - // //generalClientBootstrap.Config(baseUrl,"appsecretkey"). - // Option(UpdateOption.DownloadTimeOut, 60). - // Option(UpdateOption.Encoding, Encoding.Default). - // Option(UpdateOption.Format, "zip"). - // //עһfuncûǷθ£ǿƸЧ - // SetCustomOption(ShowCustomOption). - // Strategy(); - // await generalClientBootstrap.LaunchTaskAsync(); - // }); - //} - - ///// - ///// ûǷθ - ///// - ///// - //private bool ShowCustomOption() - //{ - // var messageBoxResult = MessageBox.Show("⵽汾һ£Ƿ£", "click", MessageBoxButton.YesNoCancel); - // return messageBoxResult == MessageBoxResult.Yes; - //} - - //private void OnMultiDownloadStatistics(object sender, MultiDownloadStatisticsEventArgs e) - //{ - // //e.Remaining ʣʱ - // //e.Speed ٶ - // //e.Version ǰصİ汾Ϣ - //} - - //private void OnMultiDownloadProgressChanged(object sender, MultiDownloadProgressChangedEventArgs e) - //{ - // //e.TotalBytesToReceive ǰ°ҪصܴС - // //e.ProgressValue ǰֵ - // //e.ProgressPercentage ǰȵİٷֱ - // //e.Version ǰصİ汾Ϣ - // //e.Type ǰִеIJ 1.ProgressType.Check 汾Ϣ 2.ProgressType.Donwload صǰ汾 3. ProgressType.Updatefile µǰ汾 4. ProgressType.Done 5.ProgressType.Fail ʧ - // //e.BytesReceived شС - //} - - //private void OnException(object sender, ExceptionEventArgs e) - //{ - // Debug.WriteLine(e.Exception.Message); - //} - - //private void OnMultiAllDownloadCompleted(object sender, MultiAllDownloadCompletedEventArgs e) - //{ - // //e.FailedVersions; ʧشİ汾ԭͳƵüϵС - // Debug.WriteLine($"Is all download completed {e.IsAllDownloadCompleted}."); - //} - - //private void OnMultiDownloadCompleted(object sender, MultiDownloadCompletedEventArgs e) - //{ - // //Debug.WriteLine($"{ e.Version.Name } download completed."); - //} - - //private void OnMultiDownloadError(object sender, MultiDownloadErrorEventArgs e) - //{ - // //Debug.WriteLine($"{ e.Version.Name } error!"); - //} - - //#endregion GeneralUpdate Core - } -} \ No newline at end of file diff --git a/src/c#/TestClientCore/Usings.cs b/src/c#/TestClientCore/Usings.cs deleted file mode 100644 index cefced496989c526cbcde61dc2100f20baa7634a..0000000000000000000000000000000000000000 --- a/src/c#/TestClientCore/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; \ No newline at end of file diff --git a/src/c#/TestCore/Properties/launchSettings.json b/src/c#/TestCore/Properties/launchSettings.json deleted file mode 100644 index fd82c7078dc902db54e4dacf92c693a723befefc..0000000000000000000000000000000000000000 --- a/src/c#/TestCore/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "TestCore": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:65353;http://localhost:65361" - } - } -} \ No newline at end of file diff --git a/src/c#/TestCore/TestCore.csproj b/src/c#/TestCore/TestCore.csproj deleted file mode 100644 index 28ba577fe9acdb8db03ca394830c770bcafd0603..0000000000000000000000000000000000000000 --- a/src/c#/TestCore/TestCore.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - - - - - - - - - diff --git a/src/c#/TestCore/UnitTest1.cs b/src/c#/TestCore/UnitTest1.cs deleted file mode 100644 index d6663d9b956fe662eaea23a052bff544a64e799d..0000000000000000000000000000000000000000 --- a/src/c#/TestCore/UnitTest1.cs +++ /dev/null @@ -1,29 +0,0 @@ -using GeneralUpdate.Core.Driver; - -namespace TestCore -{ - public class Tests - { - [Test] - public void Test1() - { - string installDir = "D:\\packet\\patch"; - string outPutDir = "D:\\packet\\cache"; - string name = "netrasa.inf"; - - var information = new DriverInformation.Builder() - .SetInstallDirectory(installDir) - .SetOutPutDirectory(outPutDir) - .SetDriverNames(new List { name }) - .Build(); - - Assert.IsNotNull(information); - - var processor = new DriverProcessor(); - processor.AddCommand(new BackupDriverCommand(information)); - processor.AddCommand(new DeleteDriverCommand(information)); - processor.AddCommand(new InstallDriverCommand(information)); - processor.ProcessCommands(); - } - } -} \ No newline at end of file diff --git a/src/c#/TestCore/Usings.cs b/src/c#/TestCore/Usings.cs deleted file mode 100644 index cefced496989c526cbcde61dc2100f20baa7634a..0000000000000000000000000000000000000000 --- a/src/c#/TestCore/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; \ No newline at end of file diff --git a/src/c#/TestDifferential/Properties/launchSettings.json b/src/c#/TestDifferential/Properties/launchSettings.json deleted file mode 100644 index afdb502d797daca842ed87a3ae2d52a195c0c2dc..0000000000000000000000000000000000000000 --- a/src/c#/TestDifferential/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "TestDifferential": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:65351;http://localhost:65367" - } - } -} \ No newline at end of file diff --git a/src/c#/TestDifferential/TestDifferential.csproj b/src/c#/TestDifferential/TestDifferential.csproj deleted file mode 100644 index a0ff16f22f0fe534285d2a826f67e08b87e1d481..0000000000000000000000000000000000000000 --- a/src/c#/TestDifferential/TestDifferential.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - - - - - - - - - diff --git a/src/c#/TestDifferential/UnitTest1.cs b/src/c#/TestDifferential/UnitTest1.cs deleted file mode 100644 index dbd8452b3ebfed8bf4ad4f4c7a112932452c6b49..0000000000000000000000000000000000000000 --- a/src/c#/TestDifferential/UnitTest1.cs +++ /dev/null @@ -1,87 +0,0 @@ -using GeneralUpdate.Differential; - -namespace TestDifferential -{ - public class Tests - { - [SetUp] - public void Setup() - { - } - - [Test] - public void TestDrity() - { - Task.Run(async () => - { - try - { - var path1 = @"F:\temp\source"; - var path3 = @"F:\temp\patchs"; - await DifferentialCore.Instance.Dirty(path1, path3); - } - catch (Exception) - { - Assert.Fail(); - } - Assert.Pass(); - }); - } - - [Test] - public void TestClean() - { - Task.Run(async () => - { - try - { - var path1 = @"F:\temp\source"; - var path2 = @"F:\temp\target"; - var path3 = @"F:\temp\patchs"; - await DifferentialCore.Instance.Clean(path1, path2, path3); - } - catch (Exception) - { - Assert.Fail(); - } - Assert.Pass(); - }); - } - - //[Test] - //public void TestScan() - //{ - // Task.Run(async () => - // { - // try - // { - // var path1 = @"F:\temp\source"; - // var path2 = @"F:\temp\target"; - // await ConfigFactory.Instance.Scan(path1, path2); - // } - // catch (Exception) - // { - // Assert.Fail(); - // } - // Assert.Pass(); - // }); - //} - - //[Test] - //public void TestDeploy() - //{ - // Task.Run(async () => - // { - // try - // { - // await ConfigFactory.Instance.Deploy(); - // } - // catch (Exception) - // { - // Assert.Fail(); - // } - // Assert.Pass(); - // }); - //} - } -} \ No newline at end of file diff --git a/src/c#/TestDifferential/Usings.cs b/src/c#/TestDifferential/Usings.cs deleted file mode 100644 index cefced496989c526cbcde61dc2100f20baa7634a..0000000000000000000000000000000000000000 --- a/src/c#/TestDifferential/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; \ No newline at end of file diff --git a/src/c#/TestMD5/Properties/launchSettings.json b/src/c#/TestMD5/Properties/launchSettings.json deleted file mode 100644 index 42a683a9c1a4841094266725ad7ebd0c62f4a2d0..0000000000000000000000000000000000000000 --- a/src/c#/TestMD5/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "TestMD5": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:65350;http://localhost:65364" - } - } -} \ No newline at end of file diff --git a/src/c#/TestMD5/TestMD5.csproj b/src/c#/TestMD5/TestMD5.csproj deleted file mode 100644 index 02edef7dab386d1742d468d36e31ea9bddc2dfe5..0000000000000000000000000000000000000000 --- a/src/c#/TestMD5/TestMD5.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - - - - - - - - - diff --git a/src/c#/TestMD5/UnitTest1.cs b/src/c#/TestMD5/UnitTest1.cs deleted file mode 100644 index 9e6a35d436981658b736eae3b6e43d749da1f33c..0000000000000000000000000000000000000000 --- a/src/c#/TestMD5/UnitTest1.cs +++ /dev/null @@ -1,20 +0,0 @@ -using GeneralUpdate.Core.Utils; - -namespace TestMD5 -{ - public class Tests - { - [Test] - public void Test1() - { - try - { - } - catch (Exception ex) - { - Assert.Fail(); - } - Assert.Pass(); - } - } -} \ No newline at end of file diff --git a/src/c#/TestMD5/Usings.cs b/src/c#/TestMD5/Usings.cs deleted file mode 100644 index cefced496989c526cbcde61dc2100f20baa7634a..0000000000000000000000000000000000000000 --- a/src/c#/TestMD5/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; \ No newline at end of file diff --git a/src/c#/TestMauiApp/App.xaml b/src/c#/TestMauiApp/App.xaml deleted file mode 100644 index 7cade3d8afc39f24ea11c54d79193c4c68e73430..0000000000000000000000000000000000000000 --- a/src/c#/TestMauiApp/App.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/c#/TestMauiApp/App.xaml.cs b/src/c#/TestMauiApp/App.xaml.cs deleted file mode 100644 index 8dad6b27f3e87a2cbaffd85893d5c4e4f8fb6bc0..0000000000000000000000000000000000000000 --- a/src/c#/TestMauiApp/App.xaml.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TestMauiApp -{ - public partial class App : Application - { - public App() - { - InitializeComponent(); - - MainPage = new AppShell(); - } - } -} \ No newline at end of file diff --git a/src/c#/TestMauiApp/AppShell.xaml b/src/c#/TestMauiApp/AppShell.xaml deleted file mode 100644 index b0b210be40f35a058ef1c864fa52a8f5f0746436..0000000000000000000000000000000000000000 --- a/src/c#/TestMauiApp/AppShell.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/c#/TestMauiApp/AppShell.xaml.cs b/src/c#/TestMauiApp/AppShell.xaml.cs deleted file mode 100644 index 36de397dbb256ef497dc05b2d8c6a8e57f89e457..0000000000000000000000000000000000000000 --- a/src/c#/TestMauiApp/AppShell.xaml.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TestMauiApp -{ - public partial class AppShell : Shell - { - public AppShell() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/src/c#/TestMauiApp/MainPage.xaml b/src/c#/TestMauiApp/MainPage.xaml deleted file mode 100644 index bcca7f3e0933415a269f04d7d5526724abc19650..0000000000000000000000000000000000000000 --- a/src/c#/TestMauiApp/MainPage.xaml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - -