From 653b8565499f74578cda2f07da9ab7fc24507679 Mon Sep 17 00:00:00 2001 From: "Juster.zhu" Date: Sat, 23 Sep 2023 23:12:06 +0800 Subject: [PATCH] Only the generation function of the last words function is retained --- .../Domain/PO/TestamentPO.cs | 24 ++++++++------ .../Testament/GeneralTestamentProvider.cs | 31 ++++++------------- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/c#/GeneralUpdate.Core/Domain/PO/TestamentPO.cs b/src/c#/GeneralUpdate.Core/Domain/PO/TestamentPO.cs index 140395e0..42de03c6 100644 --- a/src/c#/GeneralUpdate.Core/Domain/PO/TestamentPO.cs +++ b/src/c#/GeneralUpdate.Core/Domain/PO/TestamentPO.cs @@ -4,20 +4,24 @@ namespace GeneralUpdate.Core.Domain.PO { public class TestamentPO { - public TestamentPO() - { - UUID = Guid.NewGuid().ToString(); - CreateTime = DateTime.Now; - } - - public string UUID { get; private set; } + /// + /// The tracking id of this update request + /// + public string TrackID { get; set; } + /// + /// dump files everywhere after an exception occurs. + /// public string DumpPath { get; set; } - public DateTime CreateTime { get; private set; } + /// + /// Backup the file path that needs to be updated before updating. + /// + public string BackupPath { get; set; } + /// + /// Exception information that occurs when updating fails. + /// public Exception Exception { get; set; } - - public VersionPO Version { get; set; } } } diff --git a/src/c#/GeneralUpdate.Core/Testament/GeneralTestamentProvider.cs b/src/c#/GeneralUpdate.Core/Testament/GeneralTestamentProvider.cs index 6cee0209..2050f384 100644 --- a/src/c#/GeneralUpdate.Core/Testament/GeneralTestamentProvider.cs +++ b/src/c#/GeneralUpdate.Core/Testament/GeneralTestamentProvider.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using Microsoft.Diagnostics.NETCore.Client; using System.Threading.Tasks; +using System.Collections.Generic; namespace GeneralUpdate.Core.Testament { @@ -22,38 +23,24 @@ public GeneralTestamentProvider(string url, string path) _dumpPath = Path.Combine(path, DUMP_FILE); } - /// - /// When the program is started, the contents of the last note will be analyzed to restore the backup or continue to update the last note. - /// - public void Demolish() - { - //TODO: If the backup file is rolled back to the current process, the restoration file will fail... - var testamentPO = FileUtil.ReadJsonFile(_testamentPath); - File.Delete(_testamentPath); - } - /// /// Generate the contents of the last word, read the last word when the next program starts for backup restoration or re-update. /// /// - public void Build(VersionPO version,Exception exception) + public void Build(TestamentPO testament) { - if (version == null) return; + if (testament == null) return; Task.Run(async () => { - //Generate last words locally. - var testament = new TestamentPO(); - testament.Exception = exception; - testament.Version = version; - testament.DumpPath = _dumpPath; FileUtil.CreateJsonFile(_testamentPath, TESTAMENT_FILE, testament); - - //dump files locally everywhere. CreateDump(); - - //Report the current update failure to the server. - await HttpUtil.GetTaskAsync(_url); + var parameters = new Dictionary + { + { "TrackID", testament.TrackID }, + { "Exception", testament.Exception.ToString() } + }; + await HttpUtil.PostFileTaskAsync(_url, parameters, _dumpPath); }); }