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 }));
        }
Beispiel #2
0
        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 }));
        }
Beispiel #3
0
        internal void FinalizeInstall(SettingsViewModel model)
        {
            // Default these two properties for installations
            model.IgnoreSearchIndexErrors = true;
            model.IsPublicSite            = true;

            // Update the web.config first, so all connections can be referenced.
            _configReaderWriter.Save(model);

            // Install the database
            _installationService.Install(model);
        }
Beispiel #4
0
        public ActionResult Setup(InstallModel installModel)
        {
            if (CurrentRequestData.DatabaseIsInstalled)
            {
                return(Redirect("~"));
            }

            //set page timeout to 5 minutes
            Server.ScriptTimeout = 300;

            var installationResult = _installationService.Install(installModel);

            if (!installationResult.Success)
            {
                ViewData["installationResult"] = installationResult;

                return(ShowPage(installModel));
            }
            return(Redirect("~"));
        }
Beispiel #5
0
        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 }));
        }