示例#1
0
        private void btnDatabaseInfoNext_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txtDBServerName.Text) || string.IsNullOrWhiteSpace(this.txtDBName.Text))
            {
                DialogController.ShowMessage(
                    "Database Info",
                    "Please make sure you have entered a Database Server Name and\na Database Name.",
                    SystemIcons.Warning,
                    DialogController.DialogButtons.OK);

                return;
            }

            try
            {
                IISController.CreateSite(
                    this.SiteName,
                    this.InstallFolder,
                    this.chkSiteSpecificAppPool.Checked,
                    this.chkDeleteSiteIfExists.Checked);

                FileSystemController.UpdateHostsFile(this.SiteName);

                FileSystemController.CreateDirectories(
                    this.InstallFolder,
                    this.SiteName,
                    this.chkSiteSpecificAppPool.Checked,
                    this.txtDBServerName.Text.Trim(),
                    this.txtDBServerName.Text,
                    this.rdoWindowsAuthentication.Checked,
                    this.txtDBUserName.Text,
                    this.txtDBPassword.Text);

                var databaseController = new DatabaseController(
                    this.txtDBName.Text,
                    this.txtDBServerName.Text,
                    this.rdoWindowsAuthentication.Checked,
                    this.txtDBUserName.Text,
                    this.txtDBPassword.Text,
                    this.InstallFolder,
                    this.chkSiteSpecificAppPool.Checked,
                    this.SiteName);
                databaseController.CreateDatabase();
                databaseController.SetDatabasePermissions();

                this.tabInstallPackage.Enabled = false;
                this.tabSiteInfo.Enabled       = false;
                this.tabDatabaseInfo.Enabled   = false;
                this.tabControl.TabPages.Insert(3, this.tabProgress);
                this.tabProgress.Enabled      = true;
                this.lblProgress.Visible      = true;
                this.progressBar.Visible      = true;
                this.tabControl.SelectedIndex = 3;

                this.SaveUserSettings();

                this.ReadAndExtract(this.txtLocalInstallPackage.Text, Path.Combine(this.txtInstallBaseFolder.Text, this.txtInstallSubFolder.Text, "Website"));
                FileSystemController.ModifyConfig(
                    this.txtDBServerName.Text,
                    this.rdoWindowsAuthentication.Checked,
                    this.txtDBUserName.Text,
                    this.txtDBPassword.Text,
                    this.txtDBName.Text,
                    this.InstallFolder);

                this.btnVisitSite.Visible = true;
                Log.Logger.Information("Site {siteName} ready to visit", this.SiteName);
            }
            catch (SiteExistsException ex)
            {
                DialogController.ShowMessage(ex.Source, ex.Message, SystemIcons.Warning, DialogController.DialogButtons.OK);
            }
            catch (IISControllerException ex)
            {
                DialogController.ShowMessage(ex.Source, ex.Message, SystemIcons.Error, DialogController.DialogButtons.OK);
            }
            catch (FileSystemControllerException ex)
            {
                DialogController.ShowMessage(ex.Source, ex.Message, SystemIcons.Error, DialogController.DialogButtons.OK);
            }
            catch (DatabaseControllerException ex)
            {
                DialogController.ShowMessage(ex.Source, ex.Message, SystemIcons.Error, DialogController.DialogButtons.OK);
            }
            catch (Exception ex)
            {
                DialogController.ShowMessage("Database Info Next", ex.Message, SystemIcons.Error, DialogController.DialogButtons.OK);
                throw;
            }
        }