feat 上行系统版本信息
This commit is contained in:
parent
fd52e9c843
commit
b692f8e41c
|
@ -120,4 +120,9 @@ public static class Topics
|
|||
/// 上行系统状态信息
|
||||
/// </summary>
|
||||
public const string ReportSystemStat = $"up/{SN}/601/{Version}";
|
||||
|
||||
/// <summary>
|
||||
/// 上行系统版本信息
|
||||
/// </summary>
|
||||
public const string ReportSystemVersion = $"up/{SN}/602/{Version}";
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
namespace MasstransferExporter.StatExporter.Model;
|
||||
|
||||
public class SystemVersion
|
||||
{
|
||||
public Version softwareVersion { get; set; }
|
||||
|
||||
public string hardwareVersion { get; set; }
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using MasstransferCommon.Atrributes;
|
||||
using MasstransferCommon.Events;
|
||||
using MasstransferCommon.Model.Constant;
|
||||
using MasstransferCommunicate.Mqtt.Client;
|
||||
using MasstransferExporter.StatExporter.Model;
|
||||
using Minio.DataModel.Args;
|
||||
|
||||
namespace MasstransferExporter.StatExporter;
|
||||
|
||||
/// <summary>
|
||||
/// 系统版本统计信息
|
||||
/// 定时触发,1d 一次
|
||||
/// </summary>
|
||||
public class SystemVersionExporter : Instant
|
||||
{
|
||||
private static async Task StartVersionExport(EventType type, bool start)
|
||||
{
|
||||
var version = new SystemVersion
|
||||
{
|
||||
softwareVersion = GetSoftwreVersion(),
|
||||
hardwareVersion = "1.0.0",
|
||||
};
|
||||
await MessageQueueHelper.Publish(Topics.ReportSystemVersion, version);
|
||||
}
|
||||
|
||||
private static Version GetSoftwreVersion()
|
||||
{
|
||||
var masstransferDir = "C:\\Users\\wangkaiyi\\RiderProjects\\MasstransferHost\\MasstransferDesktop\\bin\\Debug\\net7.0\\masstransfer.dll";
|
||||
// 使用 AssemblyLoadContext 动态加载程序集
|
||||
var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(masstransferDir);
|
||||
|
||||
// 获取程序集的 AssemblyName 对象
|
||||
var assemblyName = assembly.GetName();
|
||||
return assemblyName.Version;
|
||||
}
|
||||
|
||||
public void Initialized()
|
||||
{
|
||||
EventBus<bool>.AddEventHandler(EventType.StartUp, StartVersionExport);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue