@namespace Oqtane.UI @inject NavigationManager NavigationManager @inject IInstallationService InstallationService @inject ISiteService SiteService @inject IUserService UserService

Database Configuration


Application Administrator





@((MarkupString) _message)
@code { private string _databaseType = "LocalDB"; private string _serverName = "(LocalDb)\\MSSQLLocalDB"; private string _databaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm"); private string _username = ""; private string _password = ""; private string _hostUsername = Constants.HostUser; private string _hostPassword = ""; private string _confirmPassword = ""; private string _hostEmail = ""; private string _message = ""; private string _integratedSecurityDisplay = "display: none;"; private string _loadingDisplay = "display: none;"; private void SetIntegratedSecurity(ChangeEventArgs e) { if (Convert.ToBoolean((string) e.Value)) { _integratedSecurityDisplay = "display: none;"; } else { _integratedSecurityDisplay = ""; } } private async Task Install() { if (_hostUsername != "" && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && _hostEmail != "") { _loadingDisplay = ""; StateHasChanged(); string connectionstring = ""; if (_databaseType == "LocalDB") { 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; } } var config = new InstallConfig { ConnectionString = connectionstring, HostUser = _hostUsername, HostEmail = _hostEmail, Password = _hostPassword, IsMaster = true, }; Installation installation = await InstallationService.Install(config); //TODO: Should be moved to Database manager if (installation.Success) { Site site = new Site(); site.TenantId = -1; // will be populated on server site.Name = "Default Site"; site.LogoFileId = null; site.FaviconFileId = null; site.DefaultThemeType = Constants.DefaultTheme; site.DefaultLayoutType = Constants.DefaultLayout; site.DefaultContainerType = Constants.DefaultContainer; site.PwaIsEnabled = false; site.PwaAppIconFileId = null; site.PwaSplashIconFileId = null; site.AllowRegistration = false; site = await SiteService.AddSiteAsync(site, null); User user = new User(); user.SiteId = site.SiteId; user.Username = _hostUsername; user.Password = _hostPassword; user.Email = _hostEmail; user.DisplayName = _hostUsername; user = await UserService.AddUserAsync(user); NavigationManager.NavigateTo("", true); } else { _message = "
" + installation.Message + "
"; _loadingDisplay = "display: none;"; } } else { _message = "
Please Enter All Fields And Ensure Passwords Match And Are Greater Than 5 Characters In Length
"; } } }