Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
JusterZhu committed Dec 30, 2023
1 parent 90da933 commit 4e2e60c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
71 changes: 34 additions & 37 deletions src/c#/GeneralUpdate.Client/MySample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private async void GetMessage(string msg)

#region 常规更新

public void Upgrade()
public async Task Upgrade()
{
//Task.Run(async () =>
//{
Expand All @@ -51,42 +51,39 @@ public void Upgrade()
// await GeneralClientOSS.Start(@params);
//});

Task.Run(async () =>
{
//ClientStrategy该更新策略将完成1.自动升级组件自更新 2.启动更新组件 3.配置好ClientParameter无需再像之前的版本写args数组进程通讯了。
//generalClientBootstrap.Config(baseUrl, "B8A7FADD-386C-46B0-B283-C9F963420C7C").
var configinfo = GetWindowsConfigInfo();
var generalClientBootstrap = await new GeneralClientBootstrap()
//单个或多个更新包下载通知事件
.AddListenerMultiDownloadProgress(OnMultiDownloadProgressChanged)
//单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件
.AddListenerMultiDownloadStatistics(OnMultiDownloadStatistics)
//单个或多个更新包下载完成
.AddListenerMultiDownloadCompleted(OnMultiDownloadCompleted)
//完成所有的下载任务通知
.AddListenerMultiAllDownloadCompleted(OnMultiAllDownloadCompleted)
//下载过程出现的异常通知
.AddListenerMultiDownloadError(OnMultiDownloadError)
//整个更新过程出现的任何问题都会通过这个事件通知
.AddListenerException(OnException)
.Config(configinfo)
.Option(UpdateOption.DownloadTimeOut, 60)
.Option(UpdateOption.Encoding, Encoding.Default)
.Option(UpdateOption.Format, Format.ZIP)
//开启驱动更新
.Option(UpdateOption.Drive, true)
//开启遗言功能,需要部署GeneralUpdate.SystemService Windows服务。
//.Option(UpdateOption.WillMessage, true)
.Strategy<WindowsStrategy>()
//注入一个func让用户决定是否跳过本次更新,如果是强制更新则不生效
//.SetCustomSkipOption(ShowCustomOption)
//注入一个自定义方法集合,该集合会在更新启动前执行。执行自定义方法列表如果出现任何异常,将通过异常订阅通知。(推荐在更新之前检查当前软件环境)
//.AddCustomOption(new List<Func<bool>>() { () => Check1(), () => Check2() })
//默认黑名单文件: { "Newtonsoft.Json.dll" } 默认黑名单文件扩展名: { ".patch", ".7z", ".zip", ".rar", ".tar" , ".json" }
//如果不需要扩展,需要重新传入黑名单集合来覆盖。
//.SetBlacklist(GetBlackFiles(), GetBlackFormats())
.LaunchTaskAsync();
});
//ClientStrategy该更新策略将完成1.自动升级组件自更新 2.启动更新组件 3.配置好ClientParameter无需再像之前的版本写args数组进程通讯了。
//generalClientBootstrap.Config(baseUrl, "B8A7FADD-386C-46B0-B283-C9F963420C7C").
var configinfo = GetWindowsConfigInfo();
var generalClientBootstrap = await new GeneralClientBootstrap()
//单个或多个更新包下载通知事件
.AddListenerMultiDownloadProgress(OnMultiDownloadProgressChanged)
//单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件
.AddListenerMultiDownloadStatistics(OnMultiDownloadStatistics)
//单个或多个更新包下载完成
.AddListenerMultiDownloadCompleted(OnMultiDownloadCompleted)
//完成所有的下载任务通知
.AddListenerMultiAllDownloadCompleted(OnMultiAllDownloadCompleted)
//下载过程出现的异常通知
.AddListenerMultiDownloadError(OnMultiDownloadError)
//整个更新过程出现的任何问题都会通过这个事件通知
.AddListenerException(OnException)
.Config(configinfo)
.Option(UpdateOption.DownloadTimeOut, 60)
.Option(UpdateOption.Encoding, Encoding.Default)
.Option(UpdateOption.Format, Format.ZIP)
//开启驱动更新
.Option(UpdateOption.Drive, true)
//开启遗言功能,需要部署GeneralUpdate.SystemService Windows服务。
.Option(UpdateOption.WillMessage, true)
.Strategy<WindowsStrategy>()
//注入一个func让用户决定是否跳过本次更新,如果是强制更新则不生效
//.SetCustomSkipOption(ShowCustomOption)
//注入一个自定义方法集合,该集合会在更新启动前执行。执行自定义方法列表如果出现任何异常,将通过异常订阅通知。(推荐在更新之前检查当前软件环境)
//.AddCustomOption(new List<Func<bool>>() { () => Check1(), () => Check2() })
//默认黑名单文件: { "Newtonsoft.Json.dll" } 默认黑名单文件扩展名: { ".patch", ".7z", ".zip", ".rar", ".tar" , ".json" }
//如果不需要扩展,需要重新传入黑名单集合来覆盖。
//.SetBlacklist(GetBlackFiles(), GetBlackFormats())
.LaunchTaskAsync();
}

private bool Check1() => true;
Expand Down
1 change: 1 addition & 0 deletions src/c#/GeneralUpdate.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ static void Main(string[] args)
MySample sample = new MySample();
//await sample.TestDifferentialClean();
//await sample.TestDifferentialDirty();
await sample.Upgrade();
});
Console.Read();
}
Expand Down

0 comments on commit 4e2e60c

Please sign in to comment.