Exemplo n.º 1
0
        public async Task <IActionResult> Index(InstallViewModel model)
        {
            if (Installed)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //_logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    //var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
                    //await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl);

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    //_logger.LogInformation("User created a new account with password.");
                    return(RedirectToAction("InstallFinished"));
                }
            }

            return(View(model));
        }
    protected override void Run()
    {
        Dispatcher = Dispatcher.CurrentDispatcher;
        var model   = new BootstrapperApplicationModel(this);
        var command = model.BootstrapperApplication.Command;

        if (command.Action == LaunchAction.Uninstall && (command.Display == Display.None || command.Display == Display.Embedded))
        {
            model.LogMessage("Starting silent uninstaller.");
            var viewModel = new SilentUninstallViewModel(model, Engine);
            Engine.Detect();
        }
        else
        {
            model.LogMessage("Starting installer.");
            var viewModel = new InstallViewModel(model);
            var view      = new InstallView(viewModel);
            view.Closed += (sender, e) => Dispatcher.InvokeShutdown();
            model.SetWindowHandle(view);
            Engine.Detect();
            view.Show();
        }
        Dispatcher.Run();
        Engine.Quit(model.FinalResult);
    }
Exemplo n.º 3
0
        public ActionResult TestSendEmail(InstallViewModel model)
        {
            var    smtpSettings = model?.Smtp;
            string errorMessage = "Email server settings invalid";

            if (smtpSettings != null)
            {
                if (Email.TryPingHost(smtpSettings.Host, smtpSettings.Port, out errorMessage))
                {
                    var settings = new SmtpSettings(smtpSettings.Host, smtpSettings.Port, smtpSettings.EnableSsl,
                                                    smtpSettings.UserName, smtpSettings.Password, smtpSettings.Domain);
                    var testEmail = new Email(settings, model.Smtp.TestEmailFromAddress, new List <string> {
                        model.Smtp.TestEmailToAddress
                    }, $"{WebAppInfo.Name} test email", "This is a test e-mail");
                    if (testEmail.TrySend(out errorMessage))
                    {
                        return(Content(""));
                    }
                    throw new EmailException(errorMessage, ErrorMessages.EmailCannotbeSent);
                }
                else
                {
                    throw new EmailException(errorMessage, ErrorMessages.EmailServerCannotBeConnected);
                }
            }
            throw new EmailException(errorMessage, ErrorMessages.EmailServerCannotBeConnected);
        }
Exemplo n.º 4
0
 public InstallView(InstallViewModel viewModel)
 {
     this.InitializeComponent();
     this.DataContext = viewModel;
     this.Closed     += (sender, e) =>
                        viewModel.CancelCommand.Execute(this);
 }
Exemplo n.º 5
0
        public string BuildCacheConnectionString(InstallViewModel model)
        {
            string connectionString = "";
            var    cacheProvider    = CacheProviders.Memory; // default

            if (!string.IsNullOrEmpty(model.SelectedCacheProvider))
            {
                Enum.TryParse(model.SelectedCacheProvider, out cacheProvider);
            }
            switch (cacheProvider)
            {
            case CacheProviders.Redis:
                if (model.CacheConfigs != null)
                {
                    connectionString = CacheProvider.BuildConnectionString(ExtractCacheInfo(model, false));
                }
                break;

            case CacheProviders.Memory:
                connectionString = "";
                break;

            default:
                throw new DatabaseException($"{cacheProvider} cache provider not supported",
                                            ErrorMessages.CacheProviderNotSupported.Fmt(cacheProvider));
            }
            return(connectionString);
        }
Exemplo n.º 6
0
        public string BuildDbConnectionString(InstallViewModel model)
        {
            string connectionString = "";
            var    dbProvider       = DbProviders.SqlServer; // default

            if (!string.IsNullOrEmpty(model.SelectedDatabaseProvider))
            {
                Enum.TryParse(model.SelectedDatabaseProvider, out dbProvider);
            }
            switch (dbProvider)
            {
            case DbProviders.SqlServer:
                if (model.SqlServer != null)
                {
                    connectionString = _dbProviderFactory.Create(DbProviders.SqlServer).BuildConnectionString(ExtractDatabaseInfo(model, false));
                }
                break;

            case DbProviders.SQLite:
                if (model.Sqlite != null)
                {
                    connectionString = _dbProviderFactory.Create(DbProviders.SQLite).BuildConnectionString(ExtractDatabaseInfo(model, false));
                }
                break;

            default:
                throw new DatabaseException($"{dbProvider} database provider not supported",
                                            ErrorMessages.DataProviderNotSupported.Fmt(dbProvider));
            }
            return(connectionString);
        }
Exemplo n.º 7
0
        public async Task <ActionResult> Register([FromBody] InstallViewModel installation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(installation));
            }

            var user = new ApplicationUser {
                FirstName = installation.FirstName, LastName = installation.LastName, UserName = installation.Email, Email = installation.Email
            };
            var result = await userManager.CreateAsync(user, installation.Password);

            if (!result.Succeeded)
            {
                return(BadRequest(result.Errors));
            }

            try
            {
                await roleManager.CreateAsync(new IdentityRole("Administrator"));

                await userManager.AddToRoleAsync(user, "Administrator");
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }

            return(NoContent());
        }
Exemplo n.º 8
0
        public ActionResult Install(InstallViewModel model)
        {
            Configuration            config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath);
            ConnectionStringsSection con    = (ConnectionStringsSection)config.GetSection("connectionStrings");

            con.ConnectionStrings["con"].ConnectionString = $"server={model.ServerHost};database={model.DbName};uid={model.ServerName};pwd={model.ServerPwd}";
            config.Save();


            SqlConnection con1 = new SqlConnection($"server={model.ServerHost};database=master;uid={model.ServerName};pwd={model.ServerPwd}");

            con1.Open();
            var cmd = con1.CreateCommand();

            cmd.CommandText = $"create database {model.DbName}";
            cmd.ExecuteNonQuery();
            cmd.CommandText = $"use {model.DbName}";
            cmd.ExecuteNonQuery();

            var sql = System.IO.File.ReadAllText(Request.MapPath("~/Tools/install.txt"), Encoding.Default);

            var setSql = sql.Split(new[] { "go" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var s in setSql)
            {
                cmd.CommandText = s;
                cmd.ExecuteNonQuery();
            }

            con1.Close();
            return(Content("ok"));
        }
Exemplo n.º 9
0
        public ActionResult Index()
        {
            bool easyInstall = System.Configuration.ConfigurationManager.AppSettings["EasyInstall"].ToLowerInvariant() == "true";

            if (!easyInstall)
            {
                return(this.Failed("Access is denied. In order to use this feature, please enter a key named EasyInstall with value true on Web.config/AppSettings.", System.Net.HttpStatusCode.Conflict));
            }

            if (!Directory.Exists(HostingEnvironment.MapPath("~/Resources/_Configs")))
            {
                return(this.Failed("Cannot continue. The configuration template directory: /Resources/_Configs was not found.", System.Net.HttpStatusCode.Conflict));
            }

            var model = EasyInstallConfigFile.Get();

            if (model == null)
            {
                model = new InstallViewModel
                {
                    DomainName   = this.Request.Url.Host,
                    DatabaseName = ByConvention.ConvertToTenantName(this.Request.Url.Host),
                    SqlServer    = new SqlServerConfig(),
                    PostgreSQL   = new PostgreSQLConfig()
                };
            }

            return(this.View("~/Views/EasyInstall.cshtml", model));
        }
Exemplo n.º 10
0
        public InstallView(InstallViewModel installViewModel)
        {
            this.InitializeComponent();
            this.DataContext = installViewModel;

            //fired when the close button is clicked
            this.Closed += (sender, e) => installViewModel.CancelCommand.Execute(this);
        }
Exemplo n.º 11
0
        public InstallView(InstallViewModel viewModel)
        {
            InitializeComponent();

            DataContext = viewModel;
            Closed     += (cS, cE) =>
            {
                viewModel.CancelCommand.Execute(viewModel);
            };
        }
Exemplo n.º 12
0
        public IActionResult Index()
        {
            var vm = new InstallViewModel
            {
                AuthorizeUrl =
                    $"{_slackWebApiConfig.AuthorizeUrl}?client_id={_testAppConfig.ClientId}&scope={_testAppConfig.Scope}"
            };

            return(View(vm));
        }
        public AttendedViewModel(IInstallationService installationService, InstallViewModel installViewModel, ModifyViewModel modifyViewModel, UninstallViewModel uninstallViewModel)
        {
            _installationService = installationService;
            _installViewModel    = installViewModel;
            _modifyViewModel     = modifyViewModel;
            _uninstallViewModel  = uninstallViewModel;

            _installViewModel.Closed   += ChildOnClosed;
            _uninstallViewModel.Closed += ChildOnClosed;
        }
Exemplo n.º 14
0
        public ActionResult Index(InstallViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            _userService.Create(model.ToUser(_encryption));

            return(Redirect("/"));
        }
Exemplo n.º 15
0
        private DatabaseInfo ExtractDatabaseInfo(InstallViewModel model, bool fromConnectionString)
        {
            DbProviders selectedDbProvider = DbProviders.None;

            Enum.TryParse(model.SelectedDatabaseProvider, out selectedDbProvider);
            var providerFactory = _dbProviderFactory.Create(selectedDbProvider);

            DatabaseInfo dbInfo = null;

            switch (selectedDbProvider)
            {
            case DbProviders.SqlServer:
                if (fromConnectionString)
                {
                    dbInfo = new DatabaseInfo(DbProviders.SqlServer, model.SqlServer.ConnectionString);
                    model.SqlServer.DatabaseServer = dbInfo.DataSource;
                    model.SqlServer.DatabaseName   = dbInfo.InitialCatalog;
                    if (!string.IsNullOrWhiteSpace(dbInfo.UserName) && !string.IsNullOrWhiteSpace(dbInfo.Password))
                    {
                        model.SqlServer.IntegratedSecurity = true;
                        model.SqlServer.Username           = dbInfo.UserName;
                        model.SqlServer.Password           = dbInfo.Password;
                    }
                }
                else
                {
                    dbInfo = new DatabaseInfo(DbProviders.SqlServer,
                                              model.SqlServer.DatabaseServer,
                                              model.SqlServer.DatabaseName,
                                              model.SqlServer.IntegratedSecurity ? null : model.SqlServer.Username,
                                              model.SqlServer.IntegratedSecurity ? null : model.SqlServer.Password,
                                              false);
                }
                break;

            case DbProviders.SQLite:
                if (model.Advanced)
                {
                    dbInfo = new DatabaseInfo(DbProviders.SQLite, model.Sqlite.ConnectionString);
                    model.Sqlite.DataSource = dbInfo.DataSource;
                    model.Sqlite.Password   = dbInfo.Password;
                }
                else
                {
                    dbInfo = new DatabaseInfo(DbProviders.SQLite, model.Sqlite.DataSource, model.Sqlite.DataSource, null, model.Sqlite.Password, true);
                }
                break;

            default:
                throw new DatabaseException($"{model.SelectedDatabaseProvider} database provider not supported",
                                            ErrorMessages.DataProviderNotSupported.Fmt(model.SelectedDatabaseProvider));
            }
            return(dbInfo);
        }
Exemplo n.º 16
0
 void InstallView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (InstallViewModel.GetViewModel().State == InstallState.Applying)
     {
         e.Cancel = true;
         return;
     }
     else
     {
         CustomBootstrapperApplication.Dispatcher.InvokeShutdown();
     }
 }
Exemplo n.º 17
0
 public ActionResult VerifyInstallationKey(InstallViewModel model)
 {
     if (model != null && model.InstallationKey == _rohamConfigs.InstallationPassword)
     {
         SetKeyVerified(model.Uid, true);
     }
     else
     {
         SetKeyVerified(model.Uid, false);
     }
     return(RedirectToAction("", new { uid = model.Uid }));
 }
Exemplo n.º 18
0
        public PartialViewResult GetDatabaseProviderPartialView(InstallViewModel model)
        {
            var dbProvider = DbProviders.SqlServer; // default

            if (!string.IsNullOrEmpty(model.SelectedDatabaseProvider))
            {
                Enum.TryParse(model.SelectedDatabaseProvider, out dbProvider);
            }
            switch (dbProvider)
            {
            case DbProviders.SqlServer:
                if (model.SqlServer == null)
                {
                    var dbInfo = new DatabaseInfo(DbProviders.SqlServer, "localhost", "RohamDb", "", "", true);
                    model.SqlServer = new SqlServerViewModel
                    {
                        ConnectionString = _dbProviderFactory.Create(DbProviders.SqlServer).BuildConnectionString(dbInfo),
                        DatabaseServer   = dbInfo.DataSource,
                        DatabaseName     = dbInfo.InitialCatalog,
                        Username         = dbInfo.UserName,
                        Password         = dbInfo.Password,
                    };
                }
                else
                {
                    model.SqlServer.ConnectionString = _dbProviderFactory.Create(DbProviders.SqlServer).BuildConnectionString(ExtractDatabaseInfo(model, model.Advanced));
                }
                return(PartialView("~/Areas/Admin/Views/Install/_SqlServer.cshtml", model));

            case DbProviders.SQLite:
                if (model.Sqlite == null)
                {
                    var dbInfo = new DatabaseInfo(DbProviders.SqlServer, "Roham", "RohamDb", "", "", true);
                    model.Sqlite = new SqliteViewModel
                    {
                        ConnectionString = _dbProviderFactory.Create(DbProviders.SQLite).BuildConnectionString(dbInfo),
                        DataSource       = dbInfo.DataSource,
                        Password         = dbInfo.Password,
                    };
                }
                else
                {
                    model.Sqlite.ConnectionString = _dbProviderFactory.Create(DbProviders.SQLite).BuildConnectionString(ExtractDatabaseInfo(model, model.Advanced));
                }
                return(PartialView("~/Areas/Admin/Views/Install/_Sqlite.cshtml", model));

            default:
                throw new DatabaseException($"{dbProvider} database provider not supported",
                                            ErrorMessages.DataProviderNotSupported.Fmt(dbProvider));
            }
        }
Exemplo n.º 19
0
        protected override void Run()
        {
            Dispatcher = Dispatcher.CurrentDispatcher;
            var model     = new BootstrapperApplicationModel(this);
            var viewModel = new InstallViewModel(model);

            view    = new InstallView(viewModel);
            restreq = new restart();
            model.SetWindowHandle(view);
            this.Engine.Detect();
            view.Show();
            Dispatcher.Run();
            this.Engine.Quit(model.FinalResult);
        }
Exemplo n.º 20
0
        public ActionResult TestSmtpConnect(InstallViewModel model)
        {
            var    smtpSettings = model?.Smtp;
            string errorMessage = "Email server settings invalid";

            if (smtpSettings != null)
            {
                if (Email.TryPingHost(smtpSettings.Host, smtpSettings.Port, out errorMessage))
                {
                    return(Content(""));
                }
            }
            throw new EmailException(errorMessage, ErrorMessages.EmailServerCannotBeConnected);
        }
Exemplo n.º 21
0
        internal static string WriteConfig(InstallViewModel model)
        {
            string pathToConfigTemplateDirectory = HostingEnvironment.MapPath("~/Resources/_Configs");
            string pathToConfigDirectory         = HostingEnvironment.MapPath("~/Resources/Configs");


            if (!Directory.Exists(pathToConfigDirectory))
            {
                FileSystem.CopyDirectory(pathToConfigTemplateDirectory, pathToConfigDirectory);
            }

            WriteFile(model.SqlServer, "~/Resources/Configs/SQLServer.json");
            WriteFile(model.PostgreSQL, "~/Resources/Configs/PostgreSQL.json");

            WriteFile(new[]
            {
                new
                {
                    model.DbProvider,
                    model.DomainName,
                    model.DatabaseName,
                    EnforceSsl                 = false,
                    CdnDomain                  = "",
                    Synonyms                   = new string[] { },
                    BackupDirectory            = "",
                    BackupDirectoryIsFixedPath = false,
                    AdminEmail                 = model.ApplicationUser,
                    BcryptedAdminPassword      = PasswordManager.GetHashedPassword(model.ApplicationUser, model.ApplicationUserPassword)
                }
            }, "~/Resources/Configs/DomainsApproved.json");

            WriteFile(new
            {
                Cultures = "en",
                ApplicationLogDirectory = @"C:\frapid-logs",
                MinimumLogLevel         = "Information",
                BackupScheduleUTC       = "0, 15",
                EodScheduleUTC          = "0, 5",
                model.DefaultCacheType,
                IsDevelopment = true
            }, "~/Resources/Configs/Parameters.json");

            WriteFile(new
            {
                ConfigString = model.RedisConnectionString
            }, "~/Resources/Configs/RedisConfig.json");

            return("OK");
        }
Exemplo n.º 22
0
        public InstallViewModel UpdateModel()
        {
            List <DatabaseListItem> allDatabases = new List <DatabaseListItem>()
            {
                new DatabaseListItem()
                {
                    Id = 1, Name = "MSSQL"
                }, new DatabaseListItem()
                {
                    Id = 2, Name = "MySQL"
                }
            };

            try
            {
                // Every request will be granted the most up-to-date data
                Configuration.GlobalWebsiteConfig.RefreshData();

                // View model
                InstallViewModel model = new InstallViewModel();
                // HTML Select
                model.AllDatabases = allDatabases;

                // If the installation was completed, the user is shown actual connection string and database in use
                if (Configuration.GlobalWebsiteConfig.InstallationCompleted)
                {
                    int idOfDb = 1;
                    switch (Configuration.GlobalWebsiteConfig.TypeOfDatabase)
                    {
                    case "mssql": idOfDb = 1; break;

                    case "mysql": idOfDb = 2; break;
                    }
                    model.SelectedDatabase = idOfDb;
                    model.ConnectionString = Configuration.GlobalWebsiteConfig.ConnectionString;
                    model.RecreateDatabase = false; // by default unchecked
                }
                return(model);
            }
            catch
            {
                InstallViewModel model = new InstallViewModel();
                model.AllDatabases     = allDatabases;
                model.ConnectionString = string.Empty;
                model.SelectedDatabase = default(int);
                return(model);
            }
        }
Exemplo n.º 23
0
        public async Task <ActionResult> Index(InstallViewModel model)
        {
            // Self registration is active as long as the administrator was not created yet
            var roleExists = await _rolesRepository.RoleExists(RoleConstants.SuperAdminRole);

            if (roleExists)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (ModelState.IsValid)
            {
                var user = _usersRepository.Get().SingleOrDefault(x => x.Email == model.Email);
                if (user == null)
                {
                    user = new ApplicationUser
                    {
                        Email    = model.Email,
                        UserName = model.Email,
                    };

                    var userResult = await UserManager.CreateAsync(user, model.Password);

                    if (userResult.Succeeded)
                    {
                        await SendAdminEmailConfirmation(user.Id, "Confirm your account");

                        ViewBag.Message = ViewResource.RegisterConfirmationMessage;
                        return(View("Info"));
                    }
                    else
                    {
                        AddErrors(userResult);
                    }
                }
                else
                {
                    await SendAdminEmailConfirmation(user.Id, "Confirm your account");

                    ViewBag.Message = ViewResource.RegisterConfirmationMessage;
                    return(View("Info"));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 24
0
        public ActionResult Index()
        {
            var appSettings = _installAppService.GetAppSettingsJson();

            if (DatabaseCheckHelper.Exist(appSettings.ConnectionString))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var model = new InstallViewModel
            {
                Languages       = DefaultLanguagesCreator.InitialLanguages,
                AppSettingsJson = appSettings
            };

            return(View(model));
        }
Exemplo n.º 25
0
        public ActionResult Index()
        {
            var appSettings      = _installAppService.GetAppSettingsJson();
            var connectionString = _appConfiguration[$"ConnectionStrings:{PortalConsts.ConnectionStringName}"];

            if (_databaseCheckHelper.Exist(connectionString))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var model = new InstallViewModel
            {
                Languages       = DefaultLanguagesCreator.InitialLanguages,
                AppSettingsJson = appSettings
            };

            return(View(model));
        }
Exemplo n.º 26
0
        //This is our UI's primary entry point. This method will be called by the Burn engine.
        protected override void Run()
        {
            //Dispatcher object provides a means for sending messages between the UI thread and any backend threads.
            Dispatcher = Dispatcher.CurrentDispatcher;

            //MVVM pattern
            var model     = new BootstrapperApplicationModel(this);
            var viewModel = new InstallViewModel(model);
            var view      = new InstallView(viewModel);

            // Sets the handle for a Windows Presentation Foundation (WPF) window.
            // This handle is used by the Burn engine when performing the install or uninstall.
            model.SetWindowHandle(view);

            //This will start the Burn engine. engine will go-ahead to check if our bundle is already installed.
            this.Engine.Detect();

            //This code is to wait for a second before closing our flash screen. Otherwise the WPF window will load very fast.
            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(1)
            };

            timer.Start();
            timer.Tick += (sender, args) =>
            {
                model.LogMessage("Time elapsed.Loading the window");
                timer.Stop();
                view.Show();
            };

            //This event is fired when the window is loaded. Here we are closing the flash screen.
            view.Loaded += (sender, e) =>
            {
                model.LogMessage("FrameworkElement loaded event fired.");
                model.CustomBootstrapperApplication.Engine.CloseSplashScreen();
            };

            //halts execution of this method at that line until the Dispatcher is shut down.
            Dispatcher.Run();

            //shut down the Burn engine
            this.Engine.Quit(model.FinalResult);
        }
Exemplo n.º 27
0
        public PartialViewResult GetCacheProviderPartialView(InstallViewModel model)
        {
            var cacheProvider = CacheProviders.Memory; // default

            if (!string.IsNullOrEmpty(model.SelectedCacheProvider))
            {
                Enum.TryParse(model.SelectedCacheProvider, out cacheProvider);
            }
            switch (cacheProvider)
            {
            case CacheProviders.Redis:
                if (model.CacheConfigs == null)
                {
                    string hostName = "localhost";
                    int    port     = 6379;
                    model.CacheConfigs = new CacheConfigsViewModel
                    {
                        Provider         = CacheProviders.Redis,
                        Host             = hostName,
                        Port             = port,
                        ConnectionString = CacheProvider.BuildConnectionString(new CacheInfo(CacheProviders.Redis, hostName, port))
                    };
                }
                else
                {
                    model.CacheConfigs.Provider         = CacheProviders.Redis;
                    model.CacheConfigs.ConnectionString = CacheProvider.BuildConnectionString(ExtractCacheInfo(model, model.AdvancedCache));
                }
                return(PartialView("~/Areas/Admin/Views/Install/_Cache.cshtml", model));

            case CacheProviders.Memory:
                model.CacheConfigs = new CacheConfigsViewModel
                {
                    Provider = CacheProviders.Memory,
                };
                model.CacheConfigs.ConnectionString = "";
                return(PartialView("~/Areas/Admin/Views/Install/_Cache.cshtml", model));

            default:
                throw new DatabaseException($"{cacheProvider} cache provider not supported",
                                            ErrorMessages.CacheProviderNotSupported.Fmt(cacheProvider));
            }
        }
Exemplo n.º 28
0
        private CacheInfo ExtractCacheInfo(InstallViewModel model, bool fromConnectionString)
        {
            var selectedCacheProvider = CacheProviders.Memory;

            Enum.TryParse(model.SelectedCacheProvider, out selectedCacheProvider);

            var cacheConfigs = model?.CacheConfigs;

            if (cacheConfigs == null)
            {
                cacheConfigs = new CacheConfigsViewModel();
            }
            cacheConfigs.Provider = selectedCacheProvider;

            CacheInfo cacheInfo = null;

            switch (selectedCacheProvider)
            {
            case CacheProviders.Memory:
                cacheInfo = new CacheInfo(CacheProviders.Memory);
                break;

            case CacheProviders.Redis:
                if (fromConnectionString)
                {
                    cacheInfo = CacheProvider.CreateInfo(CacheProviders.Redis, model.CacheConfigs.ConnectionString);
                    model.CacheConfigs.Host = cacheInfo.Host;
                    model.CacheConfigs.Port = cacheInfo.Port;
                    model.CacheConfigs.Ssl  = cacheInfo.Ssl;
                }
                else
                {
                    cacheInfo = new CacheInfo(CacheProviders.Redis, cacheConfigs.Host, cacheConfigs.Port, cacheConfigs.Ssl, cacheConfigs.Password);
                }
                break;

            default:
                throw new CacheExeption($"{model.SelectedCacheProvider} cache provider not supported",
                                        ErrorMessages.CacheProviderNotSupported.Fmt(model.SelectedCacheProvider));
            }
            return(cacheInfo);
        }
Exemplo n.º 29
0
        public async Task <IActionResult> Index(InstallViewModel model)
        {
            if (installed)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (ModelState.IsValid)
            {
                await registerRoles();

                if (await registerUserAsync(model.Email, model.Password, Role.ROLE_ADMIN))
                {
                    return(RedirectToAction("Installed"));
                }
                else
                {
                    return(View(model));
                }
            }

            return(View(model));
        }
Exemplo n.º 30
0
        public ActionResult Index(string uid = null)
        {
            if (!_rohamConfigs.IsInstalled)
            {
                var dbInfo = new DatabaseInfo(DbProviders.SqlServer, "localhost", WebAppInfo.Name, "", "", true);
                var vm     = new InstallViewModel
                {
                    SelectedDatabaseProvider = dbInfo.DbProvider.ToString(),
                    IsInstalled = false,
                    SqlServer   = new SqlServerViewModel
                    {
                        ConnectionString = _dbProviderFactory.Create(dbInfo.DbProvider).BuildConnectionString(dbInfo),
                        DatabaseServer   = dbInfo.DataSource,
                        DatabaseName     = dbInfo.InitialCatalog,
                        Username         = dbInfo.UserName,
                        Password         = dbInfo.Password,
                    },
                    SelectedCacheProvider = CacheProviders.Memory.ToString(),
                    SelectedEmailProvider = "smtp",
                    CacheConfigs          = null,
                    InstallationKey       = "",
                };

                if (IsKeyVerified(uid))
                {
                    ViewBag.KeyVerified = true;
                }
                else if (uid != null)
                {
                    ModelState.AddModelError(nameof(ErrorMessages.InstallationKeyInvalid), ErrorMessages.InstallationKeyInvalid);
                }
                return(View("Install", vm));
            }
            else
            {
                return(RedirectToAction("upgrade"));
            }
        }