diff --git a/src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj b/src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj
index 94ea81d5..72e8d98f 100644
--- a/src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj
+++ b/src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj
@@ -6,6 +6,8 @@
enable
enable
+ true
+ win-x64
diff --git a/src/c#/GeneralUpdate.Client/Program.cs b/src/c#/GeneralUpdate.Client/Program.cs
index 360f6cd3..b807e4f5 100644
--- a/src/c#/GeneralUpdate.Client/Program.cs
+++ b/src/c#/GeneralUpdate.Client/Program.cs
@@ -8,7 +8,7 @@
namespace GeneralUpdate.Client
{
- internal class Progra
+ internal class Program
{
private static void Main(string[] args)
{
@@ -67,8 +67,14 @@ private static void Main(string[] args)
.Option(UpdateOption.Format, Format.ZIP)
.LaunchAsync();
});*/
-
- GeneralClientOSS.Start(new ParamsOSS("http://192.168.50.203/versions.json", "GeneralUpdate.Client.exe","1.0.0.0", "versions.json"));
+
+ var paramsOSS = new GlobalConfigInfoOSS();
+ paramsOSS.Url = "http://192.168.50.203/versions.json";
+ paramsOSS.CurrentVersion = "1.0.0.0";
+ paramsOSS.VersionFileName = "versions.json";
+ paramsOSS.AppName = "GeneralUpdate.Client.exe";
+ paramsOSS.Encoding = Encoding.UTF8.WebName;
+ GeneralClientOSS.Start(paramsOSS);
Console.Read();
}
@@ -85,8 +91,7 @@ private static void OnMultiAllDownloadCompleted(object arg1, MultiAllDownloadCom
private static void OnMultiDownloadCompleted(object arg1, MultiDownloadCompletedEventArgs arg2)
{
- var v = arg2.Version as VersionInfo;
- Debug.WriteLine(v.Version);
+ var v = arg2.Version;
}
private static void OnMultiDownloadStatistics(object arg1, MultiDownloadStatisticsEventArgs arg2)
diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs
index 4d2a127f..8c7db0b9 100644
--- a/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs
+++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs
@@ -23,7 +23,7 @@ private GeneralClientOSS() { }
///
/// Starting an OSS update for windows platform.
///
- public static async Task Start(ParamsOSS configParams, string upgradeAppName = "GeneralUpdate.Upgrade.exe")
+ public static async Task Start(GlobalConfigInfoOSS configGlobalConfigInfo, string upgradeAppName = "GeneralUpdate.Upgrade.exe")
{
await Task.Run(() =>
{
@@ -31,30 +31,29 @@ await Task.Run(() =>
{
var basePath = Thread.GetDomain().BaseDirectory;
//Download the version information file from OSS to be updated.(JSON)
- var versionsFilePath = Path.Combine(basePath, configParams.VersionFileName);
- DownloadFile(configParams.Url, versionsFilePath);
+ var versionsFilePath = Path.Combine(basePath, configGlobalConfigInfo.VersionFileName);
+ DownloadFile(configGlobalConfigInfo.Url, versionsFilePath);
if (!File.Exists(versionsFilePath)) return;
- var versions = GeneralFileManager.GetJson>(versionsFilePath);
+ var versions = GeneralFileManager.GetJson>(versionsFilePath);
if (versions == null || versions.Count == 0) return;
versions = versions.OrderByDescending(x => x.PubTime).ToList();
var newVersion = versions.First();
//Determine whether the current client version needs to be upgraded.
- if (!IsUpgrade(configParams.CurrentVersion, newVersion.Version))
+ if (!IsUpgrade(configGlobalConfigInfo.CurrentVersion, newVersion.Version))
return;
- var json = JsonSerializer.Serialize(configParams);
- Environment.SetEnvironmentVariable("ParamsOSS", json, EnvironmentVariableTarget.User);
-
//If you confirm that an update is required, start the upgrade application.
var appPath = Path.Combine(basePath, $"{upgradeAppName}");
if (!File.Exists(appPath))
throw new Exception($"The application does not exist {upgradeAppName} !");
+ var json = JsonSerializer.Serialize(configGlobalConfigInfo);
+ Environment.SetEnvironmentVariable("GlobalConfigInfoOSS", json, EnvironmentVariableTarget.User);
Process.Start(appPath);
}
catch (Exception ex)
{
- EventManager.Instance.Dispatch(new GeneralClientOSS(), new ExceptionEventArgs(ex));
+ throw new Exception(ex.Message + "\n" + ex.StackTrace);
}
finally
{
@@ -86,13 +85,4 @@ private static void DownloadFile(string url, string path)
using var webClient = new WebClient();
webClient.DownloadFile(new Uri(url), path);
}
-
- public static void AddListenerException(Action