diff --git a/src/c#/GeneralUpdate.AspNetCore/Services/GeneralUpdateService.cs b/src/c#/GeneralUpdate.AspNetCore/Services/GeneralUpdateService.cs
index 0adb99e1860f2e22a7a310b8bac476d8e24af8f0..d65c71333964f00b4c0d4c6b7bed9f9d35524b6b 100644
--- a/src/c#/GeneralUpdate.AspNetCore/Services/GeneralUpdateService.cs
+++ b/src/c#/GeneralUpdate.AspNetCore/Services/GeneralUpdateService.cs
@@ -63,5 +63,11 @@ namespace GeneralUpdate.AspNetCore.Services
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
index 82cf9a0ca645f8be535ba1a7cce22362993d97e4..7e49511e0b371d2ea57b1382098706e90dba1670 100644
--- a/src/c#/GeneralUpdate.AspNetCore/Services/IUpdateService.cs
+++ b/src/c#/GeneralUpdate.AspNetCore/Services/IUpdateService.cs
@@ -1,4 +1,5 @@
using GeneralUpdate.Core.Domain.DTO;
+using System;
using System.Collections.Generic;
namespace GeneralUpdate.AspNetCore.Services
@@ -17,5 +18,21 @@ namespace GeneralUpdate.AspNetCore.Services
///
/// 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.ClientCore/GeneralClientBootstrap.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
index b7c690e6c95708ab750c875193dc9a7a36f0997a..9227e626dcb54fd725cd9b100baee2da23516516 100644
--- a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
+++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
@@ -8,6 +8,7 @@ using GeneralUpdate.Core.Exceptions.CustomArgs;
using GeneralUpdate.Core.Exceptions.CustomException;
using GeneralUpdate.Core.Strategys;
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -21,11 +22,16 @@ namespace GeneralUpdate.ClientCore
///
public class GeneralClientBootstrap : AbstractBootstrap
{
- private Func _customOption;
- private Func> _customTaskOption;
+ private Func _customSkipOption;
+ private Func> _customSkipTaskOption;
+
+ private List> _customOptions;
+ private List>> _customTaskOptions;
public GeneralClientBootstrap() : base()
{
+ _customOptions = new List>();
+ _customTaskOptions = new List>>();
}
#region Public Methods
@@ -48,6 +54,8 @@ namespace GeneralUpdate.ClientCore
private async Task BaseLaunch()
{
+ //bool isSuccess = await ExecuteCustomOptions();
+ //if (!isSuccess) return this;
var versionService = new VersionService();
var mainResp = await versionService.ValidationVersion(Packet.MainUpdateUrl);
var upgradeResp = await versionService.ValidationVersion(Packet.UpdateUrl);
@@ -126,10 +134,10 @@ namespace GeneralUpdate.ClientCore
///
/// Custom function ,Custom actions to let users decide whether to update. true update false do not update .
///
- public GeneralClientBootstrap SetCustomOption(Func func)
+ public GeneralClientBootstrap SetCustomSkipOption(Func func)
{
if (func == null) throw new ArgumentNullException(nameof(func));
- _customOption = func;
+ _customSkipOption = func;
return this;
}
@@ -139,10 +147,38 @@ namespace GeneralUpdate.ClientCore
/// Custom function ,Custom actions to let users decide whether to update. true update false do not update .
///
///
- public GeneralClientBootstrap SetCustomOption(Func> func)
+ public GeneralClientBootstrap SetCustomSkipOption(Func> func)
{
if (func == null) throw new ArgumentNullException(nameof(func));
- _customTaskOption = func;
+ _customSkipTaskOption = func;
+ return this;
+ }
+
+ ///
+ /// 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.
+ ///
+ ///
+ ///
+ ///
+ public GeneralClientBootstrap AddCustomOption(Func func)
+ {
+ if(func == null) throw new ArgumentNullException(nameof(func));
+ _customOptions.Add(func);
+ return this;
+ }
+
+ ///
+ /// 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.
+ ///
+ ///
+ ///
+ ///
+ public GeneralClientBootstrap AddCustomOption(Func> func)
+ {
+ if (func == null) throw new ArgumentNullException(nameof(func));
+ _customTaskOptions.Add(func);
return this;
}
@@ -173,8 +209,8 @@ namespace GeneralUpdate.ClientCore
{
bool isSkip = false;
if (isForcibly) return false;
- if (_customTaskOption != null) isSkip = await _customTaskOption.Invoke();
- if (_customOption != null) isSkip = _customOption.Invoke();
+ if (_customSkipTaskOption != null) isSkip = await _customSkipTaskOption.Invoke();
+ if (_customSkipOption != null) isSkip = _customSkipOption.Invoke();
return isSkip;
}
catch (Exception ex)
@@ -183,6 +219,30 @@ namespace GeneralUpdate.ClientCore
}
}
+ ///
+ /// Performs all injected custom operations.
+ ///
+ ///
+ private async Task ExecuteCustomOptions()
+ {
+ if (_customOptions.Any())
+ {
+ _customOptions.ForEach(option => option.Invoke());
+ return true;
+ }
+
+ if (_customTaskOptions.Any())
+ {
+ foreach (var option in _customTaskOptions)
+ {
+ await option.Invoke();
+ }
+ return true;
+ }
+
+ return true;
+ }
+
#endregion Private Methods
}
}
\ No newline at end of file
diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs
index 3c90b525bea8516891d0031b3ebf32180b1d8a4d..10519c9a93bdaa5cda6745cf4a35df69336e1d4b 100644
--- a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs
+++ b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs
@@ -12,10 +12,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).
diff --git a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs
index a0893a27d812b608ccd55f85c92bcb28f0d1eeb9..864a67e6729c479439d87127177ea1b13043359f 100644
--- a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs
+++ b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs
@@ -141,7 +141,7 @@ namespace GeneralUpdate.Core.Strategys.PlatformWindows
///
private void WaitForProcessToStart(string applicationPath, TimeSpan timeout, Action callbackAction = null)
{
- using (Process process = Process.Start(applicationPath))
+ using (var process = Process.Start(applicationPath))
{
var startTime = DateTime.UtcNow;
while (DateTime.UtcNow - startTime < timeout)