first commit
This commit is contained in:
37
Keps.WinForms/Services/AppVersionService.cs
Normal file
37
Keps.WinForms/Services/AppVersionService.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using Keps.WinForms.Infrastructure;
|
||||
|
||||
namespace Keps.WinForms.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 데이터베이스에 저장된 현재 프로그램 버전을 조회하는 서비스입니다.
|
||||
/// </summary>
|
||||
public sealed class AppVersionService
|
||||
{
|
||||
private readonly SqlConnectionFactory _connectionFactory;
|
||||
|
||||
/// <summary>
|
||||
/// 애플리케이션 버전 조회 서비스를 생성합니다.
|
||||
/// </summary>
|
||||
/// <param name="connectionFactory">DB 연결을 생성하는 팩토리.</param>
|
||||
public AppVersionService(SqlConnectionFactory connectionFactory)
|
||||
{
|
||||
_connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 데이터베이스의 정보 테이블에서 현재 프로그램 버전을 조회합니다.
|
||||
/// </summary>
|
||||
/// <returns>버전 문자열. 조회 결과가 없으면 빈 문자열.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user