using System; using System.Threading; using System.Threading.Tasks; using FrameworkBLL.Version; using FrameworkDAL.DTO.Version; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Controllers { [ApiController] [Route("[controller]")] public class VersionController : ControllerBase { private readonly IVersionBLL _versionBLL; public VersionController(IVersionBLL versionBLL) { _versionBLL = versionBLL; } [HttpGet("VersionCheck")] [AllowAnonymous] public async Task> VersionCheck( [FromQuery] string ConnectionName, CancellationToken ct) { try { var loginDTO = new LoginDTO(); // Call the BLL var result = await _versionBLL.VersionCheck(ConnectionName); // Return success response return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NotRequired, loginDTO ); } catch (Exception ex) { // Always return an error response return await GB5Shared.ResponseStandard.Response.CreateErrorResponse( "VersionCheck failed: " + ex.Message, CacheKeyLevel.NotRequired,null! ); } } // Sibling to VersionCheck, deliberately separate: reflects the real compiled // artifact (AssemblyMetadata stamped by Directory.Build.props), never the // MDBLevelSetting/MAppVersion database rows VersionCheck compares. Process-wide, // not tenant-scoped, so no ConnectionName param. [HttpGet("BuildInfo")] [AllowAnonymous] public async Task> BuildInfo(CancellationToken ct) { try { var loginDTO = new LoginDTO(); var result = _versionBLL.GetBuildInfo(); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NotRequired, loginDTO ); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateErrorResponse( "BuildInfo failed: " + ex.Message, CacheKeyLevel.NotRequired, null! ); } } } }