using System; using System.Data.SqlClient; using Keps.WinForms.Infrastructure; namespace Keps.WinForms.Services { /// /// 데이터베이스에 저장된 현재 프로그램 버전을 조회하는 서비스입니다. /// public sealed class AppVersionService { private readonly SqlConnectionFactory _connectionFactory; /// /// 애플리케이션 버전 조회 서비스를 생성합니다. /// /// DB 연결을 생성하는 팩토리. public AppVersionService(SqlConnectionFactory connectionFactory) { _connectionFactory = connectionFactory; } /// /// 데이터베이스의 정보 테이블에서 현재 프로그램 버전을 조회합니다. /// /// 버전 문자열. 조회 결과가 없으면 빈 문자열. public string GetCurrentVersion() { using (SqlConnection connection = _connectionFactory.Open()) using (SqlCommand command = new SqlCommand(LegacySqlCatalog.ProgramVersion, connection)) { object value = command.ExecuteScalar(); return value == null ? string.Empty : Convert.ToString(value); } } } }