diff --git a/src/c#/.vs/ProjectEvaluation/generalupdate.metadata.v5 b/src/c#/.vs/ProjectEvaluation/generalupdate.metadata.v5 index 8ea0b844c8115e68ac194283c4e8abea766492e2..d0155d55df361baf21c81fd3b0efaf2f9866639e 100644 Binary files a/src/c#/.vs/ProjectEvaluation/generalupdate.metadata.v5 and b/src/c#/.vs/ProjectEvaluation/generalupdate.metadata.v5 differ diff --git a/src/c#/.vs/ProjectEvaluation/generalupdate.projects.v5 b/src/c#/.vs/ProjectEvaluation/generalupdate.projects.v5 index fe4868496333cd405f0a721e70747f682518c176..bdc3730b8c7eab312d7bb4d5328fce9b04dd10db 100644 Binary files a/src/c#/.vs/ProjectEvaluation/generalupdate.projects.v5 and b/src/c#/.vs/ProjectEvaluation/generalupdate.projects.v5 differ diff --git a/src/c#/GeneralUpdate.Client/MainPage.xaml.cs b/src/c#/GeneralUpdate.Client/MainPage.xaml.cs index fa47991299bdc40a876e08db5725cf405c0ae564..454bbf466a2768f04550257549eeeb4f9f038dda 100644 --- a/src/c#/GeneralUpdate.Client/MainPage.xaml.cs +++ b/src/c#/GeneralUpdate.Client/MainPage.xaml.cs @@ -40,46 +40,32 @@ namespace GeneralUpdate.Client { Task.Run(async () => { - //主程序信息 - var mainVersion = "1.1.1.1"; - - #region update app. + #region Config. //该对象用于主程序客户端与更新组件进程之间交互用的对象 - //clientParameter = new ClientParameter(); - + var config = new Configinfo(); //本机的客户端程序应用地址 - //clientParameter.InstallPath = @"D:\Updatetest_hub\Run_app"; + config.InstallPath = @"D:\Updatetest_hub\Run_app"; //更新公告网页 - //clientParameter.UpdateLogUrl = "https://www.baidu.com/"; - - //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"; + config.UpdateLogUrl = "https://www.baidu.com/"; + //客户端当前版本号 + config.ClientVersion = "1.1.1.1"; + //客户端类型:1.主程序客户端 2.更新组件 + config.AppType = AppType.ClientApp; //指定应用密钥,用于区分客户端应用 - - #endregion update app. - - #region main app. - - //更新组件的版本号 - //clientParameter.ClientVersion = "1.1.1"; + config.AppSecretKey = "41A54379-C7D6-4920-8768-21A3468572E5"; + //更新组件更新包下载地址 + config.UpdateUrl = $"{baseUrl}/versions/{config.AppType}/{config.ClientVersion}/{config.AppSecretKey}"; + //更新程序exe名称 + config.AppName = "AutoUpdate.Core"; //主程序客户端exe名称 - //clientParameter.MainAppName = "AutoUpdate.ClientCore"; - //主程序客户端请求验证更新的服务端地址 - //clientParameter.MainValidateUrl = $"{baseUrl}/validate/{ (int)AppType.ClientApp }/{ mainVersion }/{clientParameter.AppSecretKey}"; + config.MainAppName = "AutoUpdate.ClientCore"; + //主程序信息 + var mainVersion = "1.1.1.1"; //主程序客户端更新包下载地址 - //clientParameter.MainUpdateUrl = $"{baseUrl}/versions/{ (int)AppType.ClientApp }/{ mainVersion }/{clientParameter.AppSecretKey}"; + config.MainUpdateUrl = $"{baseUrl}/versions/{AppType.ClientApp}/{mainVersion}/{config.AppSecretKey}"; - #endregion main app. + #endregion update app. var generalClientBootstrap = new GeneralClientBootstrap(); //单个或多个更新包下载通知事件 diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs index f5888bccab63878e7b2056599bf49fc2c7798641..227568a34bdd7c2e937a703179bc8338883f8ff7 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs +++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs @@ -23,12 +23,20 @@ namespace GeneralUpdate.ClientCore #region Public Methods + /// + /// Start the update. + /// + /// public override GeneralClientBootstrap LaunchAsync() { Task.Run(() => BaseLaunch()); return this; } + /// + /// Start the update. + /// + /// public Task LaunchTaskAsync() => BaseLaunch(); private async Task BaseLaunch() @@ -87,6 +95,11 @@ namespace GeneralUpdate.ClientCore } } + /// + /// Custom Configuration. + /// + /// + /// public GeneralClientBootstrap Config(Configinfo info) { Packet.AppType = info.AppType; @@ -113,6 +126,12 @@ namespace GeneralUpdate.ClientCore return this; } + /// + /// Let the user decide whether to update in the state of non-mandatory update. + /// + /// Custom funcion ,Custom actions to let users decide whether to update. true update false do not update . + /// + /// public GeneralClientBootstrap SetCustomOption(Func> func) { if (func == null) throw new ArgumentNullException(nameof(func)); diff --git a/src/c#/TestZIP/TestZIP.csproj b/src/c#/TestZIP/TestZIP.csproj index 51e6422bb5c675f720ba62e3ddd78c39bf8a3fd8..37e881dbba20409ac690fb7238afb0fb5c16f9c2 100644 --- a/src/c#/TestZIP/TestZIP.csproj +++ b/src/c#/TestZIP/TestZIP.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/src/c#/TestZIP/UnitTest1.cs b/src/c#/TestZIP/UnitTest1.cs index 86da16476358e688bda5bffd59d4d5ab9d81baf0..6941ee11e376c02b26aee1c936cff084719838c2 100644 --- a/src/c#/TestZIP/UnitTest1.cs +++ b/src/c#/TestZIP/UnitTest1.cs @@ -1,3 +1,5 @@ +using GeneralUpdate.Zip; +using GeneralUpdate.Zip.Factory; using System.Diagnostics; namespace TestZIP @@ -6,84 +8,55 @@ namespace TestZIP { [Test] - public void Test1() + public void CreatZip() { + try + { + string sourcePath = "D:\\Updatetest_hub\\Run_app"; + string destinationPath = "D:\\Updatetest_hub"; + string name = "testpacket.zip"; + var factory = new GeneralZipFactory(); + factory.CompressProgress += (a,e) => + { + Console.WriteLine($"fileName:{e.Name},fileSize:{e.Size},fileIndex:{e.Index},filePath:{e.Path},fileCount:{e.Count}"); + }; + factory.Completed += (a,e) => + { + Console.WriteLine($"IsCompleted:{ e.IsCompleted }"); + }; + factory.CreatefOperate(OperationType.GZip, name, sourcePath, destinationPath,false,System.Text.Encoding.Default). + CreatZip(); + } + catch + { + Assert.Fail(); + } Assert.Pass(); } - //#region GeneralUpdate Zip - - ///// - ///// Create Zip - ///// - ///// - ///// - //private void BtnCreateZip_Click(object sender, RoutedEventArgs e) - //{ - // try - // { - // var factory = new GeneralZipFactory(); - // factory.CompressProgress += OnCompressProgress; - // //Compress all files in this pathD:\Updatetest_hub\Run_app D:\Updatetest_hub - // factory.CreatefOperate(GetOperationType(), TxtZipPath.Text, TxtUnZipPath.Text). - // CreatZip(); - // } - // catch (Exception ex) - // { - // MessageBox.Show($"CreatZip error : {ex.Message} "); - // } - //} - - ///// - ///// UnZip - ///// - ///// - ///// - //private void BtnUnZip_Click(object sender, RoutedEventArgs e) - //{ - // try - // { - // var factory = new GeneralZipFactory(); - // factory.UnZipProgress += OnUnZipProgress; - // factory.Completed += OnCompleted; - // //D:\Updatetest_hub\Run_app\1.zip , D:\Updatetest_hub - // factory.CreatefOperate(GetOperationType(), TxtZipPath.Text, TxtUnZipPath.Text, true). - // UnZip(); - // } - // catch (Exception ex) - // { - // MessageBox.Show($"UnZip error : {ex.Message} "); - // } - //} - - //private void OnCompleted(object sender, BaseCompleteEventArgs e) - //{ - // Debug.WriteLine($"IsCompleted {e.IsCompleted}."); - //} - - //private OperationType GetOperationType() - //{ - // OperationType operationType = 0; - // var item = CmbxZipFormat.SelectedItem as ComboBoxItem; - // switch (item.Content) - // { - // case "ZIP": - // operationType = OperationType.GZip; - // break; - - // case "7z": - // operationType = OperationType.G7z; - // break; - // } - // return operationType; - //} - - //private void OnCompressProgress(object sender, BaseCompressProgressEventArgs e) - //{ Debug.WriteLine($"CompressProgress - name:{e.Name}, count:{e.Count}, index:{e.Index}, size:{e.Size}."); } - - //private void OnUnZipProgress(object sender, BaseUnZipProgressEventArgs e) - //{ Debug.WriteLine($"UnZipProgress - name:{e.Name}, count:{e.Count}, index:{e.Index}, size:{e.Size}."); } - - //#endregion GeneralUpdate Zip + [Test] + public void UnZip() + { + try + { + string sourcePath = "D:\\Updatetest_hub\\Run_app\\1.zip"; + string destinationPath = "D:\\Updatetest_hub"; + string name = "testpacket.zip"; + var factory = new GeneralZipFactory(); + factory.UnZipProgress += (a,e) => + { + Console.WriteLine($"fileName:{e.Name},fileSize:{e.Size},fileIndex:{e.Index},filePath:{e.Path},fileCount:{e.Count}"); + }; + factory.Completed += (a, e) => + { + Console.WriteLine($"IsCompleted:{e.IsCompleted}"); + }; + factory.CreatefOperate(OperationType.GZip, name, sourcePath, destinationPath, false, System.Text.Encoding.Default). + UnZip(); + } + catch (Exception ex) + { + } + } } } \ No newline at end of file