Exemplo n.º 1
0
        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 async Task <InstallationResponseModel> Post([FromBody] InstallationRequestModel model)
        {
            var installation = model.ToInstallation();
            await _installationRepository.CreateAsync(installation);

            return(new InstallationResponseModel(installation, true));
        }
Exemplo n.º 3
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 }));
        }
Exemplo n.º 4
0
        public IHttpActionResult TestConnection(InstallationRequestModel model)
        {
            if (model == null)
            {
                return(Response(new { Success = false }));
            }

            var connectionString = model.ConnectionString;

            if (!model.IsConnectionString)
            {
                connectionString = DatabaseManager.CreateConnectionString(model.ServerUrl, model.DatabaseName,
                                                                          model.DatabaseUserName, model.DatabasePassword, false, 0);
            }

            var connectionSucceeds = DatabaseManager.DatabaseConnects(connectionString);

            return(Response(new { Success = connectionSucceeds }));
        }
Exemplo n.º 5
0
        public async Task <OperationDataResult <InstallationsModel> > Index(InstallationRequestModel pnRequestModel)
        {
            try
            {
                var installationsModel = new InstallationsModel();

                var installationsQuery = _dbContext.Installations
                                         .Where(x => x.WorkflowState != Constants.WorkflowStates.Removed)
                                         .AsQueryable();

                if (!pnRequestModel.NameFilter.IsNullOrEmpty() && pnRequestModel.NameFilter != "")
                {
                    installationsQuery = installationsQuery.Where(x => x.Name.Contains(pnRequestModel.NameFilter));
                }

                QueryHelper.AddSortToQuery(installationsQuery, pnRequestModel.Sort, pnRequestModel.IsSortDsc);

                installationsModel.Total = installationsQuery.Count();

                installationsQuery
                    = installationsQuery
                      .Skip(pnRequestModel.Offset)
                      .Take(pnRequestModel.PageSize);

                var installations = await installationsQuery.Select(x => new InstallationModel
                {
                    Id   = x.Id,
                    Name = x.Name
                }).ToListAsync();

                installationsModel.InstallationList = installations;


                return(new OperationDataResult <InstallationsModel>(true, installationsModel));
            }
            catch (Exception e)
            {
                Trace.TraceError(e.Message);
                _coreHelper.LogException(e.Message);
                return(new OperationDataResult <InstallationsModel>(false,
                                                                    _trashInspectionLocalizationService.GetString("ErrorObtainingInstallations")));
            }
        }
Exemplo n.º 6
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 }));
        }
Exemplo n.º 7
0
 public async Task <OperationDataResult <InstallationsModel> > Index(InstallationRequestModel requestModel)
 {
     return(await _installationService.Index(requestModel));
 }