Skip to content

Commit

Permalink
clear: clear all code files
Browse files Browse the repository at this point in the history
  • Loading branch information
JusterZhu committed Jan 18, 2024
1 parent cd0190f commit 1b1a4a1
Show file tree
Hide file tree
Showing 69 changed files with 474 additions and 514 deletions.
2 changes: 0 additions & 2 deletions src/c#/GeneralUpdate.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using GeneralUpdate.AspNetCore.DTO;
using GeneralUpdate.AspNetCore.Hubs;
using GeneralUpdate.AspNetCore.Services;
using GeneralUpdate.Core.Domain.DTO;
using GeneralUpdate.Core.Domain.Enum;
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json;

var builder = WebApplication.CreateBuilder(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ private void ParameterVerification(int clientType, string clientVersion, string
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) { }
private void ParameterVerification(int clientType, string clientVersion, string clientAppkey, string appSecretKey, string meesage, string dumpBase64, string logBase64, Exception exception)
{ }
}
}
4 changes: 2 additions & 2 deletions src/c#/GeneralUpdate.AspNetCore/Services/IUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public interface IUpdateService
string Update(int clientType, string clientVersion, string serverLastVersion, string clientAppKey, string appSecretKey, bool isForce, List<VersionDTO> versions);

/// <summary>
/// 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.
/// 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.
/// </summary>
/// <param name="clientType">1:ClientApp 2:UpdateApp</param>
Expand Down
50 changes: 25 additions & 25 deletions src/c#/GeneralUpdate.Client/MySample.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
using GeneralUpdate.ClientCore;
using GeneralUpdate.Core.Bootstrap;
using GeneralUpdate.Core.ContentProvider;
using GeneralUpdate.Core.Domain.Entity;
using GeneralUpdate.Core.Events.MultiEventArgs;
using GeneralUpdate.Core.Strategys.PlatformWindows;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GeneralUpdate.Core.Domain.Enum;
using GeneralUpdate.Core.Driver;
using GeneralUpdate.Core.Events.CommonArgs;
using GeneralUpdate.Core.Events.MultiEventArgs;
using GeneralUpdate.Core.Strategys.PlatformWindows;
using GeneralUpdate.Core.WillMessage;
using GeneralUpdate.Differential;
using System.IO;
using GeneralUpdate.Core.Driver;
using System.Diagnostics;
using GeneralUpdate.Core.WillMessage;
using GeneralUpdate.Core.ContentProvider;
using System.Text;

namespace GeneralUpdate.Client
{
Expand All @@ -39,7 +34,7 @@ private async void GetMessage(string msg)
if (isUpdate) Upgrade();
}

#endregion
#endregion 推送功能

#region 常规更新

Expand Down Expand Up @@ -212,29 +207,28 @@ private void OnMultiDownloadError(object sender, MultiDownloadErrorEventArgs e)

private void DispatchMessage(string message)
{

}

#endregion
#endregion 常规更新

#region 测试二进制更新包整理

public async Task TestDifferentialClean()
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);
}

public async Task TestDifferentialDirty()
public async Task TestDifferentialDirty()
{
var path1 = "D:\\packet\\source";
var path2 = "D:\\packet\\patchs";
await DifferentialCore.Instance.Dirty(path1, path2);
}

#endregion
#endregion 测试二进制更新包整理

#region 测试驱动功能

Expand Down Expand Up @@ -299,7 +293,7 @@ private List<string> GetAllDriverDirectories(string path)
private bool IsDriverFile(string filePath) =>
string.Equals(Path.GetExtension(filePath), ".inf", StringComparison.OrdinalIgnoreCase);

#endregion
#endregion 测试驱动功能

#region 测试WillMessage

Expand All @@ -312,7 +306,7 @@ public void TestWillMessage()
for (int i = 0; i < 1; i++)
{
var version = "1.0.0." + i;
WillMessageManager.Instance.Backup(path1,path2, version, hash, 1);
WillMessageManager.Instance.Backup(path1, path2, version, hash, 1);
}
WillMessageManager.Instance.Builder();
var obj = WillMessageManager.Instance.GetWillMessage();
Expand All @@ -321,16 +315,22 @@ public void TestWillMessage()
//WillMessageManager.Instance.Clear();
}

#endregion
#endregion 测试WillMessage

#region 文件管理测试

public void TestFileProvider()
public void TestFileProvider()
{
//FileProvider fileProvider = new FileProvider();
//fileProvider.Handle();
var sourcePath = "D:\\packet\\source";
var targetPath = "D:\\packet\\target";
var resultPath = "D:\\packet\\patchs";

FileProvider fileProvider = new FileProvider();
var list = fileProvider.Handle(sourcePath, targetPath, resultPath, null, FileOperations.Query, SetOperations.Intersection, true, true);
foreach (var item in list)
Console.WriteLine(item.Name);
}

#endregion
#endregion 文件管理测试
}
}
}
12 changes: 5 additions & 7 deletions src/c#/GeneralUpdate.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using GeneralUpdate.Core.HashAlgorithms;

namespace GeneralUpdate.Client
namespace GeneralUpdate.Client
{
internal class Program
{
static void Main(string[] args)
private static void Main(string[] args)
{
MySample sample = new MySample();
sample.TestWillMessage();
//Task.Run(async() =>
sample.TestFileProvider();
//Task.Run(async() =>
//{
// //415eed05eb310f480d1e4d15516fa00e484ddb9f416908b217f17b782ded2030
// //var zip1 = @"D:\github_project\WpfClient\WebApi\UpdateFiles\WpfClient_1_24.1.5.1218.zip";
Expand All @@ -27,4 +25,4 @@ static void Main(string[] args)
Console.Read();
}
}
}
}
14 changes: 7 additions & 7 deletions src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public GeneralClientBootstrap SetCustomSkipOption(Func<Task<bool>> func)
}

/// <summary>
/// Add an asynchronous custom operation.
/// 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.
/// </summary>
/// <param name="func"></param>
Expand All @@ -172,7 +172,7 @@ public GeneralClientBootstrap AddCustomOption(List<Func<bool>> funcs)
}

/// <summary>
/// Add a synchronization custom operation.
/// 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.
/// </summary>
/// <param name="func"></param>
Expand Down Expand Up @@ -223,10 +223,10 @@ private async Task<bool> IsSkip(bool isForcibly)
}

/// <summary>
/// Performs all injected custom operations.
/// Performs all injected custom operations.
/// </summary>
/// <returns></returns>
private async Task ExecuteCustomOptions()
private async Task ExecuteCustomOptions()
{
if (_customTaskOptions.Any())
{
Expand All @@ -242,7 +242,7 @@ private async Task ExecuteCustomOptions()
foreach (var option in _customOptions)
{
var isSuccess = option.Invoke();
if (!isSuccess)
if (!isSuccess)
Core.Events.EventManager.Instance.Dispatch<Action<object, Core.Events.CommonArgs.ExceptionEventArgs>>(this, new Core.Events.CommonArgs.ExceptionEventArgs($"{nameof(option)}Execution failure!"));
}
}
Expand All @@ -251,7 +251,7 @@ private async Task ExecuteCustomOptions()
/// <summary>
/// The values passed between processes during previous updates are cleared when the client starts.
/// </summary>
private void ClearEnvironmentVariable()
private void ClearEnvironmentVariable()
{
try
{
Expand All @@ -278,7 +278,7 @@ private bool CheckWillMessage()
foreach (var item in Packet.UpdateVersions)
{
var msg = willMessage.Message.Peek();
if (string.Equals(msg.Version, item.Version,StringComparison.OrdinalIgnoreCase))
if (string.Equals(msg.Version, item.Version, StringComparison.OrdinalIgnoreCase))
{
return false;
}
Expand Down
14 changes: 7 additions & 7 deletions src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using GeneralUpdate.Core.Domain.Entity;
using GeneralUpdate.Core.ContentProvider;
using GeneralUpdate.Core.Domain.Entity;
using GeneralUpdate.Core.Domain.Entity.Assembler;
using GeneralUpdate.Core.Domain.PO;
using GeneralUpdate.Core.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -32,7 +32,7 @@ await Task.Run(() =>
var versionsFilePath = Path.Combine(basePath, configParams.VersionFileName);
DownloadFile(configParams.Url + "/" + configParams.VersionFileName, versionsFilePath);
if (!File.Exists(versionsFilePath)) return;
var versions = FileUtil.GetJson<List<VersionPO>>(versionsFilePath);
var versions = FileProvider.GetJson<List<VersionPO>>(versionsFilePath);
if (versions == null || versions.Count == 0) return;
versions = versions.OrderByDescending(x => x.PubTime).ToList();
var newVersion = versions.First();
Expand All @@ -49,7 +49,7 @@ await Task.Run(() =>
GeneralUpdate.Core.Events.EventManager.Instance.Dispatch<Action<object, GeneralUpdate.Core.Events.CommonArgs.ExceptionEventArgs>>(typeof(GeneralClientOSS), new GeneralUpdate.Core.Events.CommonArgs.ExceptionEventArgs(ex));
throw new Exception($"GeneralClientOSS update exception ! {ex.Message}", ex.InnerException);
}
finally
finally
{
Process.GetCurrentProcess().Kill();
}
Expand All @@ -62,19 +62,19 @@ await Task.Run(() =>
/// <param name="clientVersion"></param>
/// <param name="serverVersion"></param>
/// <returns>true: Upgrade required , false: No upgrade is required</returns>
private static bool IsUpgrade(string clientVersion,string serverVersion)
private static bool IsUpgrade(string clientVersion, string serverVersion)
{
if (string.IsNullOrWhiteSpace(clientVersion) || string.IsNullOrWhiteSpace(serverVersion)) return false;
Version currentClientVersion = null;
Version currentServerVersion = null;
bool isParseClientVersion = Version.TryParse(clientVersion, out currentClientVersion);
bool isParseServerVersion = Version.TryParse(serverVersion, out currentServerVersion);
if(!isParseClientVersion || !isParseServerVersion) return false;
if (!isParseClientVersion || !isParseServerVersion) return false;
if (currentClientVersion < currentServerVersion) return true;
return false;
}

private static void DownloadFile(string url,string path)
private static void DownloadFile(string url, string path)
{
using (var webClient = new WebClient())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<None Remove="Strategys\PlatformLinux\.gitkeep" />
<None Remove="Strategys\PlatformWindows\.gitkeep" />
<None Remove="Utils\.gitkeep" />
<None Remove="WillMessage\.gitkeep" />
<None Remove="ZipFactory\Events\.gitkeep" />
<None Remove="ZipFactory\Factory\.gitkeep" />
<None Remove="ZipFactory\G7z\.gitkeep" />
Expand All @@ -76,6 +77,7 @@
<Compile Include="..\GeneralUpdate.Core\Bootstrap\UpdateOptionValue.cs" Link="Bootstrap\UpdateOptionValue.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileNode.cs" Link="Differential\ContentProvider\FileNode.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileProvider-Manage.cs" Link="Differential\ContentProvider\FileProvider-Manage.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileProvider-Serialization.cs" Link="Differential\ContentProvider\FileProvider-Serialization.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileProvider.cs" Link="Differential\ContentProvider\FileProvider.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileTree.cs" Link="Differential\ContentProvider\FileTree.cs" />
<Compile Include="..\GeneralUpdate.Core\CustomAwaiter\IAwaitable.cs" Link="CustomAwaiter\IAwaitable.cs" />
Expand Down Expand Up @@ -154,9 +156,6 @@
<Compile Include="..\GeneralUpdate.Core\Strategys\IStrategy.cs" Link="Strategys\IStrategy.cs" />
<Compile Include="..\GeneralUpdate.Core\Strategys\PlatformLinux\LinuxStrategy.cs" Link="Strategys\PlatformLinux\LinuxStrategy.cs" />
<Compile Include="..\GeneralUpdate.Core\Strategys\PlatformWindows\WindowsStrategy.cs" Link="Strategys\PlatformWindows\WindowsStrategy.cs" />
<Compile Include="..\GeneralUpdate.Core\Utils\ConvertUtil.cs" Link="Utils\ConvertUtil.cs" />
<Compile Include="..\GeneralUpdate.Core\Utils\FileUtil.cs" Link="Utils\FileUtil.cs" />
<Compile Include="..\GeneralUpdate.Core\Utils\HttpUtil.cs" Link="Utils\HttpUtil.cs" />
<Compile Include="..\GeneralUpdate.Core\Utils\SerializeUtil.cs" Link="Utils\SerializeUtil.cs" />
<Compile Include="..\GeneralUpdate.Core\WillMessage\WillMessageManager.cs" Link="WillMessage\WillMessageManager.cs" />
<Compile Include="..\GeneralUpdate.Differential\Binary\BinaryHandle.cs" Link="Differential\Binary\BinaryHandle.cs" />
Expand Down
20 changes: 10 additions & 10 deletions src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using GeneralUpdate.Core.Domain.Entity;
using GeneralUpdate.Core.ContentProvider;
using GeneralUpdate.Core.Domain.Entity;
using GeneralUpdate.Core.Domain.Enum;
using GeneralUpdate.Core.Download;
using GeneralUpdate.Core.Events;
using GeneralUpdate.Core.Events.CommonArgs;
using GeneralUpdate.Core.Events.MultiEventArgs;
using GeneralUpdate.Core.Strategys;
using GeneralUpdate.Core.Utils;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down Expand Up @@ -62,7 +62,7 @@ public virtual TBootstrap LaunchAsync()
Packet.Encoding = GetOption(UpdateOption.Encoding) ?? Encoding.Default;
Packet.DownloadTimeOut = GetOption(UpdateOption.DownloadTimeOut);
Packet.AppName = $"{Packet.AppName ?? GetOption(UpdateOption.MainApp)}{EXECUTABLE_FILE}";
Packet.TempPath = $"{FileUtil.GetTempDirectory(Packet.LastVersion)}{Path.DirectorySeparatorChar}";
Packet.TempPath = $"{FileProvider.GetTempDirectory(Packet.LastVersion)}{Path.DirectorySeparatorChar}";
Packet.DriveEnabled = GetOption(UpdateOption.Drive) ?? false;
Packet.WillMessageEnabled = GetOption(UpdateOption.WillMessage) ?? false;
var manager = new DownloadManager<VersionInfo>(Packet.TempPath, Packet.Format, Packet.DownloadTimeOut);
Expand Down Expand Up @@ -95,7 +95,7 @@ protected IStrategy InitStrategy()
return _strategy;
}

protected string GetPlatform()=> _strategy.GetPlatform();
protected string GetPlatform() => _strategy.GetPlatform();

protected IStrategy ExecuteStrategy()
{
Expand Down Expand Up @@ -173,17 +173,17 @@ public virtual T GetOption<T>(UpdateOption<T> option)

#region Callback event.

public TBootstrap AddListenerMultiAllDownloadCompleted(Action<object, MultiAllDownloadCompletedEventArgs> callbackAction)=> AddListener(callbackAction);
public TBootstrap AddListenerMultiAllDownloadCompleted(Action<object, MultiAllDownloadCompletedEventArgs> callbackAction) => AddListener(callbackAction);

public TBootstrap AddListenerMultiDownloadProgress(Action<object, MultiDownloadProgressChangedEventArgs> callbackAction)=> AddListener(callbackAction);
public TBootstrap AddListenerMultiDownloadProgress(Action<object, MultiDownloadProgressChangedEventArgs> callbackAction) => AddListener(callbackAction);

public TBootstrap AddListenerMultiDownloadCompleted(Action<object, MultiDownloadCompletedEventArgs> callbackAction)=> AddListener(callbackAction);
public TBootstrap AddListenerMultiDownloadCompleted(Action<object, MultiDownloadCompletedEventArgs> callbackAction) => AddListener(callbackAction);

public TBootstrap AddListenerMultiDownloadError(Action<object, MultiDownloadErrorEventArgs> callbackAction)=> AddListener(callbackAction);
public TBootstrap AddListenerMultiDownloadError(Action<object, MultiDownloadErrorEventArgs> callbackAction) => AddListener(callbackAction);

public TBootstrap AddListenerMultiDownloadStatistics(Action<object, MultiDownloadStatisticsEventArgs> callbackAction)=> AddListener(callbackAction);
public TBootstrap AddListenerMultiDownloadStatistics(Action<object, MultiDownloadStatisticsEventArgs> callbackAction) => AddListener(callbackAction);

public TBootstrap AddListenerException(Action<object, ExceptionEventArgs> callbackAction)=> AddListener(callbackAction);
public TBootstrap AddListenerException(Action<object, ExceptionEventArgs> callbackAction) => AddListener(callbackAction);

protected TBootstrap AddListener<TArgs>(Action<object, TArgs> callbackAction) where TArgs : EventArgs
{
Expand Down
4 changes: 2 additions & 2 deletions src/c#/GeneralUpdate.Core/ContentProvider/FileNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class FileNode
public int RightType { get; set; }

public string RelativePath { get; set; }

#endregion Public Properties

#region Constructors
Expand Down Expand Up @@ -138,7 +138,7 @@ public override bool Equals(object obj)
if (obj == null) return false;
var tempNode = obj as FileNode;
if (tempNode == null) throw new ArgumentException(nameof(tempNode));
return string.Equals(Hash, tempNode.Hash,StringComparison.OrdinalIgnoreCase) && string.Equals(Name, tempNode.Name,StringComparison.OrdinalIgnoreCase);
return string.Equals(Hash, tempNode.Hash, StringComparison.OrdinalIgnoreCase) && string.Equals(Name, tempNode.Name, StringComparison.OrdinalIgnoreCase);
}

public override int GetHashCode() => base.GetHashCode();
Expand Down
Loading

0 comments on commit 1b1a4a1

Please sign in to comment.