43 lines
1.5 KiB
Plaintext
43 lines
1.5 KiB
Plaintext
@namespace Oqtane.Installer.Controls
|
|
@implements Oqtane.Interfaces.IDatabaseConfigControl
|
|
@inject IStringLocalizer<Installer> Localizer
|
|
|
|
@{
|
|
foreach (var field in _connectionStringFields)
|
|
{
|
|
var fieldId = field.Name.ToLowerInvariant();
|
|
field.Value = field.Value.Replace("{{Date}}", DateTime.UtcNow.ToString("yyyyMMddHHmm"));
|
|
|
|
<tr>
|
|
<td>
|
|
<Label For="@fieldId" HelpText="@field.HelpText" ResourceKey="@field.Name">@Localizer[$"{field.FriendlyName}:"]</Label>
|
|
</td>
|
|
<td>
|
|
<input id="@fieldId" type="text" class="form-control" @bind="@field.Value" />
|
|
</td>
|
|
</tr>
|
|
}
|
|
}
|
|
|
|
@code {
|
|
private readonly List<ConnectionStringField> _connectionStringFields = new()
|
|
{
|
|
new() {Name = "Server", FriendlyName = "Server", Value = "(LocalDb)\\MSSQLLocalDB", HelpText="Enter the database server"},
|
|
new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}", HelpText="Enter the name of the database"}
|
|
};
|
|
|
|
public string GetConnectionString()
|
|
{
|
|
var connectionString = String.Empty;
|
|
|
|
var server = _connectionStringFields[0].Value;
|
|
var database = _connectionStringFields[1].Value;
|
|
|
|
if (!String.IsNullOrEmpty(server) && !String.IsNullOrEmpty(database))
|
|
{
|
|
connectionString = $"Data Source={server};AttachDbFilename=|DataDirectory|\\{database}.mdf;Initial Catalog={database};Integrated Security=SSPI;";
|
|
}
|
|
|
|
return connectionString;
|
|
}
|
|
} |