diff --git a/src/EventHub.Domain.Shared/Assemblies/AssemblyInfoHelper.cs b/src/EventHub.Domain.Shared/Assemblies/AssemblyInfoHelper.cs new file mode 100644 index 0000000..33e5f0b --- /dev/null +++ b/src/EventHub.Domain.Shared/Assemblies/AssemblyInfoHelper.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Threading; +using Volo.Abp; + +namespace EventHub; + +public static class AssemblyInfoHelper +{ + private const string AssemblyInfoCacheKey = "AssemblyInfoCacheKey"; + private readonly static Dictionary AssemblyInfoCache = new(); + + public static AssemblyInfo Get() + { + if (AssemblyInfoCache.TryGetValue(AssemblyInfoCacheKey, out var assemblyInfo)) + { + return assemblyInfo; + } + + var abpCorePackageVersion = GetAbpCorePackageVersion(); + var applicationAssembly = Assembly.GetEntryAssembly(); + var applicationVersion = applicationAssembly?.GetFileVersion(); + var modificationDate = applicationAssembly?.Location == null ? DateTime.Now : File.GetLastWriteTime(applicationAssembly.Location); + + assemblyInfo = new AssemblyInfo(abpCorePackageVersion, applicationVersion, modificationDate); + + AssemblyInfoCache[AssemblyInfoCacheKey] = assemblyInfo; + + return assemblyInfo; + } + + private static string GetAbpCorePackageVersion() + { + var abpCoreAssembly = Assembly.GetAssembly(typeof(AbpApplicationBase)); + + return abpCoreAssembly == null + ? string.Empty + : abpCoreAssembly.GetFileVersion(); + } + + public class AssemblyInfo + { + public string AbpCoreVersion { get; } + + public string Version { get; } + + public DateTime ModificationDate { get; } + + public AssemblyInfo(string abpCoreVersion, string version, DateTime modificationDate) + { + AbpCoreVersion = abpCoreVersion; + Version = version; + ModificationDate = modificationDate; + } + } +} \ No newline at end of file diff --git a/src/EventHub.Web.Theme/Themes/EventHub/Components/Footer/Default.cshtml b/src/EventHub.Web.Theme/Themes/EventHub/Components/Footer/Default.cshtml index d9816d7..9fdf36f 100644 --- a/src/EventHub.Web.Theme/Themes/EventHub/Components/Footer/Default.cshtml +++ b/src/EventHub.Web.Theme/Themes/EventHub/Components/Footer/Default.cshtml @@ -8,6 +8,7 @@ @inject IOptions UrlOptions @{ var currentPageUrl = Context.Request.GetDisplayUrl(); + var platformVersion = EventHub.AssemblyInfoHelper.Get(); }