@namespace Oqtane.Installer.Controls @implements Oqtane.Interfaces.IDatabaseConfigControl @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer
@if (_security == "custom") {
} @code { private string _server = "127.0.0.1"; private string _port = "5432"; private string _database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm"); private string _security = "integrated"; private string _uid = String.Empty; private string _pwd = String.Empty; private string _passwordType = "password"; private string _togglePassword = string.Empty; protected override void OnInitialized() { _togglePassword = SharedLocalizer["ShowPassword"]; } public string GetConnectionString() { var connectionString = String.Empty; if (!String.IsNullOrEmpty(_server) && !String.IsNullOrEmpty(_database) && !String.IsNullOrEmpty(_port)) { connectionString = $"Server={_server};Port={_port};Database={_database};"; } if (_security == "integrated") { connectionString += "Integrated Security=true;"; } else { if (!String.IsNullOrEmpty(_uid) && !String.IsNullOrEmpty(_pwd)) { connectionString += $"User ID={_uid};Password={_pwd};"; } else { connectionString = String.Empty; } } return connectionString; } private void TogglePassword() { if (_passwordType == "password") { _passwordType = "text"; _togglePassword = SharedLocalizer["HidePassword"]; } else { _passwordType = "password"; _togglePassword = SharedLocalizer["ShowPassword"]; } } }