Add support for Sqlite - Installation path tested but AddSite not supported yet
This commit is contained in:
@ -27,10 +27,19 @@
|
||||
<select class="custom-select" @bind="@_databaseType">
|
||||
<option value="LocalDB">@Localizer["Local Database"]</option>
|
||||
<option value="SQLServer">@Localizer["SQL Server"]</option>
|
||||
<option value="Sqlite">@Localizer["Sqlite"]</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr style="@(_databaseType == "Sqlite" ? "" : "display: none")">
|
||||
<td>
|
||||
<label class="control-label" style="font-weight: bold">@Localizer["File Name:"] </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" @bind="@_fileName" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="@(_databaseType == "Sqlite" ? "display: none" : "")">
|
||||
<td>
|
||||
<label class="control-label" style="font-weight: bold">@Localizer["Server:"] </label>
|
||||
</td>
|
||||
@ -38,7 +47,7 @@
|
||||
<input type="text" class="form-control" @bind="@_serverName" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr style="@(_databaseType == "Sqlite" ? "display: none" : "")">
|
||||
<td>
|
||||
<label class="control-label" style="font-weight: bold">@Localizer["Database:"] </label>
|
||||
</td>
|
||||
@ -46,7 +55,7 @@
|
||||
<input type="text" class="form-control" @bind="@_databaseName" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr style="@(_databaseType == "Sqlite" ? "display: none" : "")">
|
||||
<td>
|
||||
<label class="control-label" style="font-weight: bold">@Localizer["Integrated Security:"] </label>
|
||||
</td>
|
||||
@ -129,6 +138,7 @@
|
||||
@code {
|
||||
private string _databaseType = "LocalDB";
|
||||
private string _serverName = "(LocalDb)\\MSSQLLocalDB";
|
||||
private string _fileName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm") + ".db";
|
||||
private string _databaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||
private string _username = string.Empty;
|
||||
private string _password = string.Empty;
|
||||
@ -138,6 +148,8 @@
|
||||
private string _hostEmail = string.Empty;
|
||||
private string _message = string.Empty;
|
||||
private string _integratedSecurityDisplay = "display: none;";
|
||||
private string _fileFieldsDisplay = "display: none;";
|
||||
private string _serverFieldsDisplay = "display: none;";
|
||||
private string _loadingDisplay = "display: none;";
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
@ -158,33 +170,38 @@
|
||||
|
||||
private async Task Install()
|
||||
{
|
||||
if (_serverName != "" && _databaseName != "" && _hostUsername != "" && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && _hostEmail != "")
|
||||
if (((_serverName != "" && _databaseName != "") || _fileName !="") && _hostUsername != "" && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && _hostEmail != "")
|
||||
{
|
||||
_loadingDisplay = "";
|
||||
StateHasChanged();
|
||||
|
||||
var connectionstring = "";
|
||||
if (_databaseType == "LocalDB")
|
||||
switch (_databaseType)
|
||||
{
|
||||
connectionstring = "Data Source=" + _serverName + ";AttachDbFilename=|DataDirectory|\\" + _databaseName + ".mdf;Initial Catalog=" + _databaseName + ";Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionstring = "Data Source=" + _serverName + ";Initial Catalog=" + _databaseName + ";";
|
||||
if (_integratedSecurityDisplay == "display: none;")
|
||||
{
|
||||
connectionstring += "Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionstring += "User ID=" + _username + ";Password=" + _password;
|
||||
}
|
||||
case "LocalDB":
|
||||
connectionstring = "Data Source=" + _serverName + ";AttachDbFilename=|DataDirectory|\\" + _databaseName + ".mdf;Initial Catalog=" + _databaseName + ";Integrated Security=SSPI;";
|
||||
break;
|
||||
case "SQLServer":
|
||||
connectionstring = "Data Source=" + _serverName + ";Initial Catalog=" + _databaseName + ";";
|
||||
if (_integratedSecurityDisplay == "display: none;")
|
||||
{
|
||||
connectionstring += "Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionstring += "User ID=" + _username + ";Password=" + _password;
|
||||
}
|
||||
break;
|
||||
case "Sqlite":
|
||||
connectionstring = "Data Source=" + _fileName;
|
||||
break;
|
||||
}
|
||||
|
||||
Uri uri = new Uri(NavigationManager.Uri);
|
||||
|
||||
var config = new InstallConfig
|
||||
{
|
||||
DatabaseType = _databaseType,
|
||||
ConnectionString = connectionstring,
|
||||
Aliases = uri.Authority,
|
||||
HostEmail = _hostEmail,
|
||||
|
Reference in New Issue
Block a user