public IHttpActionResult Install(InstallationRequestModel model) { var areTableInstalled = DatabaseManager.IsDatabaseInstalled(); if (areTableInstalled) { return(Response(new { Success = false, Message = "Database already installed" })); } //lets save the database settings to config file var connectionString = ""; var providerName = ""; connectionString = @"Data Source=.\sqlexpress;Initial Catalog=roasteddesk;Integrated Security=False;Persist Security Info=False;User ID=iis_user;Password=iis_user"; providerName = "SqlServer"; var databaseSettings = mobSocialEngine.ActiveEngine.Resolve <IDatabaseSettings>(); databaseSettings.WriteSettings(connectionString, providerName); //perform the installation _installationService.Install(); //then feed the data _installationService.FillRequiredSeedData(model.AdminEmail, model.Password); return(Response(new { Success = true })); }
public IActionResult Install(InstallationRequestModel model) { var databaseSettings = DependencyResolver.Resolve <IDatabaseSettings>(); var areTableInstalled = DatabaseManager.IsDatabaseInstalled(databaseSettings); if (areTableInstalled) { return(Json(new { success = false, error = T("Database already installed") })); } //lets save the database settings to config file var connectionString = model.ConnectionString; var providerName = model.ProviderName; // "SqlServer"; //todo: make it selectable to allow sqlite and other providers //create the connection string if required if (!model.IsConnectionString) { connectionString = DatabaseManager.CreateConnectionString(new ConnectionStringRequest() { IntegratedSecurity = model.IntegratedSecurity, Timeout = 0, ProviderName = model.ProviderName, Password = model.DatabasePassword, ServerName = model.ServerUrl, UserName = model.DatabaseUserName, DatabaseName = model.DatabaseName }); } //check if we have correct connection string if (!DatabaseManager.IsValidConnection(providerName, connectionString)) { return(Json(new { success = false, error = T("Failed to connect to database") })); } databaseSettings.WriteSettings(connectionString, providerName); //perform the installation _installationService.Install(); //save app settings _applicationConfiguration.SetSetting(ApplicationConfig.AppSettingsEncryptionKey, _cryptographyService.GetRandomPassword(32)); _applicationConfiguration.SetSetting(ApplicationConfig.AppSettingsEncryptionSalt, _cryptographyService.GetRandomPassword(32)); _applicationConfiguration.SetSetting(ApplicationConfig.AppSettingsApiSecret, _cryptographyService.GetRandomPassword(32)); //then feed the data _installationService.FillRequiredSeedData(model.AdminEmail, model.Password, "//" + ApplicationEngine.CurrentHttpContext.Request.Host.Value, model.StoreName); //restart the app ServerHelper.RestartApplication(); return(Json(new { success = true })); }
public IHttpActionResult Install(InstallationRequestModel model) { if (!ModelState.IsValid) { return(Response(new { Success = false, Message = "Insufficient data sent to complete installation" })); } var areTableInstalled = DatabaseManager.IsDatabaseInstalled(); if (areTableInstalled) { return(Response(new { Success = false, Message = "Database already installed" })); } //lets save the database settings to config file var connectionString = model.ConnectionString; var providerName = "SqlServer"; if (!model.IsConnectionString) { connectionString = DatabaseManager.CreateConnectionString(model.ServerUrl, model.DatabaseName, model.DatabaseUserName, model.DatabasePassword, false, 0); } //check if we have correct connection string if (!DatabaseManager.DatabaseConnects(connectionString)) { return(Response(new { Success = false, Message = "Failed to connect to database" })); } var databaseSettings = mobSocialEngine.ActiveEngine.Resolve <IDatabaseSettings>(); databaseSettings.WriteSettings(connectionString, DatabaseManager.GetProviderName(providerName)); //perform the installation _installationService.Install(); //then feed the data _installationService.FillRequiredSeedData(model.AdminEmail, model.Password, HttpContext.Current.Request.Url.Host); return(Response(new { Success = true })); }