Created ExpiredOOOStatusWorker
This commit is contained in:
30
FabApprovalWorkerService/Services/DbConnectionService.cs
Normal file
30
FabApprovalWorkerService/Services/DbConnectionService.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Data.Sqlite;
|
||||
|
||||
using System.Data;
|
||||
|
||||
namespace FabApprovalWorkerService.Services;
|
||||
|
||||
public interface IDbConnectionService {
|
||||
IDbConnection GetConnection();
|
||||
}
|
||||
|
||||
public class DbConnectionService : IDbConnectionService {
|
||||
private readonly string _envName;
|
||||
private readonly string _dbConnectionString;
|
||||
|
||||
public DbConnectionService() {
|
||||
_envName = Environment.GetEnvironmentVariable("FabApprovalEnvironmentName") ??
|
||||
throw new ArgumentNullException("FabApprovalEnvironmentName environment variable not found");
|
||||
_dbConnectionString = Environment.GetEnvironmentVariable("FabApprovalDbConnectionString") ??
|
||||
throw new ArgumentNullException("FabApprovalDbConnectionString environment variable not found");
|
||||
}
|
||||
|
||||
public IDbConnection GetConnection() {
|
||||
if (_envName.ToLower().Equals("development")) {
|
||||
return new SqliteConnection(_dbConnectionString);
|
||||
} else {
|
||||
return new SqlConnection(_dbConnectionString);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user