using System.Reflection; using FrameworkDAL.DTO.Version; using FrameworkDAL.CustomCode.Version; namespace FrameworkBLL.Version { public class VersionBLL : IVersionBLL { private readonly IVersionDAL _VersionDAL; public VersionBLL(IVersionDAL VersionDAL) { _VersionDAL = VersionDAL; } public async Task> VersionCheck(string ConnectionName) { try { return await _VersionDAL.VersionCheck(ConnectionName); } catch (Exception) { throw; } } public async Task VersionUrlIdentifier(string ConnectionName) { try { return await _VersionDAL.VersionUrlIdentifier(ConnectionName); } catch (Exception) { throw; } } // Reflects the actual compiled artifact, never a database row. No DAL round-trip: // build identity is process-wide, not tenant-scoped. // // GitSha comes from AssemblyInformationalVersion ("1.0.0+<40-char-sha>"), which the // .NET SDK itself stamps from the .git folder at build time (confirmed on SDK // 10.0.106 with no SourceLink package installed) — no custom git plumbing needed. // BuildTimestampUtc comes from the GB5BuildTimestampUtc AssemblyMetadata item added // by Directory.Build.props' GB5StampBuildIdentity target, since the SDK has no // built-in equivalent for a build timestamp. public BuildInfoDTO GetBuildInfo() { var assembly = typeof(VersionBLL).Assembly; var informationalVersion = assembly.GetCustomAttribute() ?.InformationalVersion; var plusIndex = informationalVersion?.IndexOf('+') ?? -1; var gitSha = plusIndex >= 0 ? informationalVersion![(plusIndex + 1)..] : "unknown"; var buildTimestampUtc = assembly.GetCustomAttributes() .FirstOrDefault(a => a.Key == "GB5BuildTimestampUtc")?.Value ?? "unknown"; return new BuildInfoDTO { GitSha = gitSha, BuildTimestampUtc = buildTimestampUtc, ServiceName = Assembly.GetEntryAssembly()?.GetName().Name, HostMachineName = Environment.MachineName }; } } }