' ' DotNetNukeŽ - http://www.dotnetnuke.com ' Copyright (c) 2002-2009 ' by DotNetNuke Corporation ' ' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated ' documentation files (the "Software"), to deal in the Software without restriction, including without limitation ' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and ' to permit persons to whom the Software is furnished to do so, subject to the following conditions: ' ' The above copyright notice and this permission notice shall be included in all copies or substantial portions ' of the Software. ' ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED ' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF ' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ' DEALINGS IN THE SOFTWARE. ' Imports System.Data.Common Imports System.IO Imports System.Xml Imports System.Xml.XPath Imports DotNetNuke.Application Imports DotNetNuke.Entities.Modules Imports DotNetNuke.Framework.Providers Imports DotNetNuke.Security.Membership Imports DotNetNuke.Services.Localization Imports DotNetNuke.Services.Mail Namespace DotNetNuke.Services.Install ''' ----------------------------------------------------------------------------- ''' ''' The InstallWizard class provides the Installation Wizard for DotNetNuke ''' ''' ''' ''' ''' [cnurse] 01/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Partial Class InstallWizard Inherits PageBase : Implements DotNetNuke.UI.Utilities.IClientAPICallbackEventHandler #Region "Private Members" Private connectionString As String = Null.NullString Private dataProvider As DataProvider = dataProvider.Instance Private _DataBaseVersion As System.Version Private _localesFile As String = "/Install/App_LocalResources/Locales.xml" Private _installTemplate As XmlDocument #End Region #Region "Protected Members" Protected ReadOnly Property ApplicationVersion() As System.Version Get Return DotNetNukeContext.Current.Application.Version End Get End Property Protected ReadOnly Property DatabaseVersion() As System.Version Get If _DataBaseVersion Is Nothing Then _DataBaseVersion = dataProvider.Instance().GetVersion End If Return _DataBaseVersion End Get End Property Protected ReadOnly Property BaseVersion() As System.Version Get Return Services.Upgrade.Upgrade.GetInstallVersion(InstallTemplate) End Get End Property Protected ReadOnly Property InstallTemplate() As XmlDocument Get If _installTemplate Is Nothing Then _installTemplate = New XmlDocument Services.Upgrade.Upgrade.GetInstallTemplate(_installTemplate) End If Return _installTemplate End Get End Property Protected Shadows LocalResourceFile As String = "~/Install/App_LocalResources/InstallWizard.aspx.resx" Protected Property PermissionsValid() As Boolean Get Dim _Valid As Boolean = False If Not ViewState("PermissionsValid") Is Nothing Then _Valid = Convert.ToBoolean(ViewState("PermissionsValid")) End If Return _Valid End Get Set(ByVal value As Boolean) ViewState("PermissionsValid") = value End Set End Property Protected Property PortalId() As Integer Get Dim _PortalId As Integer = Null.NullInteger If Not ViewState("PortalId") Is Nothing Then _PortalId = Convert.ToInt32(ViewState("PortalId")) End If Return _PortalId End Get Set(ByVal value As Integer) ViewState("PortalId") = value End Set End Property Protected Property Versions() As String Get Dim _Versions As String = Null.NullString If Not ViewState("Versions") Is Nothing Then _Versions = Convert.ToString(ViewState("Versions")) End If Return _Versions End Get Set(ByVal value As String) ViewState("Versions") = value End Set End Property #End Region #Region "Private Methods" ''' ----------------------------------------------------------------------------- ''' ''' BindAuthSystems binds the Authentication Systems checkbox list ''' ''' ''' ''' ''' [cnurse] 02/28/2008 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindAuthSystems() BindPackageItems("AuthSystem", lstAuthSystems, lblNoAuthSystems, "NoAuthSystems", lblAuthSystemsError) End Sub ''' ----------------------------------------------------------------------------- ''' ''' BindConnectionString binds the connection String info ''' ''' ''' ''' ''' [cnurse] 01/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindConnectionString() Dim connection As String = Config.GetConnectionString() Dim connectionParams As String() = connection.Split(";") For Each connectionParam As String In connection.Split(";") Dim index As Integer = connectionParam.IndexOf("=") If index > 0 Then Dim key As String = connectionParam.Substring(0, index) Dim value As String = connectionParam.Substring(index + 1) Select Case key.ToLower Case "server", "data source", "address", "addr", "network address" txtServer.Text = value Case "database", "initial catalog" txtDatabase.Text = value Case "uid", "user id", "user" txtUserId.Text = value Case "pwd", "password" txtPassword.Text = value Case "integrated security" chkIntegrated.Checked = (value.ToLower = "true") Case "attachdbfilename" txtFile.Text = value.Replace("|DataDirectory|", "") End Select End If Next If chkIntegrated.Checked Then chkOwner.Checked = True End If chkOwner.Enabled = Not chkIntegrated.Checked End Sub ''' ----------------------------------------------------------------------------- ''' ''' Gets the userid for the upgradeConnectionString ''' ''' ''' ''' ''' [smehaffie] 07/13/2008 Created ''' ''' ----------------------------------------------------------------------------- Private Function GetUpgradeConnectionStringUserID() As String Dim dbUser As String = "" Dim connection As String = Config.GetUpgradeConnectionString() Dim connectionParams As String() 'If connection string does not use integrated security, then get user id. If connection.ToLower().Contains("user id") Or connection.ToLower().Contains("uid") Or connection.ToLower().Contains("user") Then connectionParams = connection.Split(";"c) For Each connectionParam As String In connectionParams Dim index As Integer = connectionParam.IndexOf("=") If index > 0 Then Dim key As String = connectionParam.Substring(0, index) Dim value As String = connectionParam.Substring(index + 1) If "user id|uuid|user".Contains(key.Trim.ToLower()) Then dbUser = value.Trim() End If End If Next End If Return dbUser End Function ''' ----------------------------------------------------------------------------- ''' ''' BindDatabases binds the supported databases ''' ''' ''' ''' ''' [cnurse] 02/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindDatabases() If (Config.GetDefaultProvider("data").Name = "SqlDataProvider") Then Dim connection As String = Config.GetConnectionString() If connection.ToLower().Contains("attachdbfilename") Then rblDatabases.Items.FindByValue("SQLFile").Selected = True Else rblDatabases.Items.FindByValue("SQLDatabase").Selected = True End If End If If (Config.GetDefaultProvider("data").Name = "OracleDataProvider") Then rblDatabases.Items.Add(New ListItem(LocalizeString("Oracle"), "Oracle")) rblDatabases.SelectedIndex = 2 End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' BindLanguages binds the languages checkbox list ''' ''' ''' ''' ''' [cnurse] 02/20/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindLanguages() BindPackageItems("Language", lstLanguages, lblNoLanguages, "NoLanguages", lblLanguagesError) End Sub ''' ----------------------------------------------------------------------------- ''' ''' BindModules binds the modules checkbox list ''' ''' ''' ''' ''' [cnurse] 02/19/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindModules() BindPackageItems("Module", lstModules, lblNoModules, "NoModules", lblModulesError) End Sub Private Sub BindPackageItems(ByVal packageType As String, ByVal list As CheckBoxList, ByVal noItemsLabel As Label, ByVal noItemsKey As String, ByVal errorLabel As Label) Dim arrFiles As String() Dim strFile As String Dim InstallPath As String = ApplicationMapPath & "\Install\" + packageType list.Items.Clear() If Directory.Exists(InstallPath) Then arrFiles = Directory.GetFiles(InstallPath) Dim iFile As Integer = 0 For Each strFile In arrFiles Dim strResource As String = strFile.Replace(InstallPath + "\", "") If strResource.ToLower.EndsWith(".zip") OrElse strResource.ToLower.EndsWith(".resources") Then Dim packageItem As ListItem = New ListItem() ' *.zip packages are installed by default If strResource.ToLower.EndsWith(".zip") Then packageItem.Selected = True packageItem.Enabled = False Else ' *.resources packages will be optional packageItem.Selected = False packageItem.Enabled = True End If packageItem.Value = strResource strResource = strResource.Replace(".zip", "") strResource = strResource.Replace(".resources", "") strResource = strResource.Replace("_Install", ")") strResource = strResource.Replace("_Source", ")") strResource = strResource.Replace("_", " (") packageItem.Text = strResource list.Items.Add(packageItem) End If Next End If If list.Items.Count > 0 Then noItemsLabel.Visible = False Else noItemsLabel.Visible = True noItemsLabel.Text = LocalizeString(noItemsKey) End If If errorLabel IsNot Nothing Then errorLabel.Text = Null.NullString End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' BindPermissions binds the permissions checkbox list ''' ''' ''' ''' ''' [cnurse] 01/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindPermissions(ByVal test As Boolean) PermissionsValid = True lstPermissions.Items.Clear() 'FolderCreate Dim permissionItem As New ListItem() If test Then permissionItem.Selected = VerifyFolderCreate() permissionItem.Enabled = False permissionItem.Text = LocalizeString("FolderCreate") lstPermissions.Items.Add(permissionItem) 'FileCreate permissionItem = New ListItem() If test Then permissionItem.Selected = VerifyFileCreate() permissionItem.Enabled = False permissionItem.Text = LocalizeString("FileCreate") lstPermissions.Items.Add(permissionItem) 'FileDelete permissionItem = New ListItem() If test Then permissionItem.Selected = VerifyFileDelete() permissionItem.Enabled = False permissionItem.Text = LocalizeString("FileDelete") lstPermissions.Items.Add(permissionItem) 'FolderDelete permissionItem = New ListItem() If test Then permissionItem.Selected = VerifyFolderDelete() permissionItem.Enabled = False permissionItem.Text = LocalizeString("FolderDelete") lstPermissions.Items.Add(permissionItem) If test Then If PermissionsValid Then lblPermissionsError.Text = LocalizeString("PermissionsOk") Else lblPermissionsError.Text = LocalizeString("PermissionsError").Replace("{0}", ApplicationMapPath) End If End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' BindPortal binds the portal information ''' ''' ''' ''' ''' [cnurse] 02/19/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindPortal() Dim node As XmlNode = InstallTemplate.SelectSingleNode("//dotnetnuke/portals/portal") If Not node Is Nothing Then Dim adminNode As XmlNode = node.SelectSingleNode("administrator") usrAdmin.FirstName = XmlUtils.GetNodeValue(adminNode, "firstname") usrAdmin.LastName = XmlUtils.GetNodeValue(adminNode, "lastname") usrAdmin.UserName = XmlUtils.GetNodeValue(adminNode, "username") usrAdmin.Email = XmlUtils.GetNodeValue(adminNode, "email") txtPortalTitle.Text = XmlUtils.GetNodeValue(node, "portalname") Dim strTemplate As String = XmlUtils.GetNodeValue(node, "templatefile") Dim strFolder As String = Common.Globals.HostMapPath If System.IO.Directory.Exists(strFolder) Then cboPortalTemplate.Items.Clear() Dim fileEntries As String() = System.IO.Directory.GetFiles(strFolder, "*.template") For Each strFileName As String In fileEntries If Path.GetFileNameWithoutExtension(strFileName) = "admin" Then 'lblMessage.Text = "" Else cboPortalTemplate.Items.Add(Path.GetFileNameWithoutExtension(strFileName)) End If Next If cboPortalTemplate.Items.Count = 0 Then 'lblMessage.Text = Localization.GetString("PortalMissing", Me.LocalResourceFile) End If If Not cboPortalTemplate.Items.FindByValue(strTemplate.Replace(".template", "")) Is Nothing Then cboPortalTemplate.Items.FindByValue(strTemplate.Replace(".template", "")).Selected = True Else cboPortalTemplate.SelectedIndex = 0 End If End If End If lblPortalError.Text = Null.NullString End Sub ''' ----------------------------------------------------------------------------- ''' ''' BindProviders binds the Providers checkbox list ''' ''' ''' ''' ''' [cnurse] 06/24/2008 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindProviders() BindPackageItems("Provider", lstProviders, lblNoProviders, "NoProviders", lblProvidersError) End Sub ''' ----------------------------------------------------------------------------- ''' ''' BindSkins binds the skins checkbox list ''' ''' ''' ''' ''' [cnurse] 02/16/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindSkins() BindPackageItems("Skin", lstSkins, lblNoSkins, "NoSkins", lblSkinsError) BindPackageItems("Container", lstContainers, lblNoContainers, "NoContainers", Nothing) End Sub ''' ----------------------------------------------------------------------------- ''' ''' BindSiperUser binds the superuser information ''' ''' ''' ''' ''' [cnurse] 02/16/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub BindSuperUser(ByVal customButton As LinkButton) Dim superUser As UserInfo = Services.Upgrade.Upgrade.GetSuperUser(InstallTemplate, False) If Not superUser Is Nothing Then usrHost.FirstName = superUser.FirstName usrHost.LastName = superUser.LastName usrHost.UserName = superUser.Username usrHost.Email = superUser.Email End If ShowButton(customButton, True) End Sub ''' ----------------------------------------------------------------------------- ''' ''' EnableButton enables/Disables a Navigation Button ''' ''' ''' ''' ''' [cnurse] 02/28/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub EnableButton(ByVal button As LinkButton, ByVal enabled As Boolean) If Not button Is Nothing Then button.OnClientClick = "return !checkDisabled(this);" If enabled Then button.CssClass = "WizardButton" Else button.CssClass = "WizardButtonDisabled" End If End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' GetInstallerLocales gets an ArrayList of the Locales ''' ''' ''' ''' ''' [cnurse] 01/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function GetInstallerLocales() As ArrayList Dim supportedLocales As ArrayList = New ArrayList Dim filePath As String = Common.Globals.ApplicationMapPath & _localesFile.Replace("/", "\") If File.Exists(filePath) Then Dim doc As New XPathDocument(filePath) For Each nav As XPathNavigator In doc.CreateNavigator.Select("root/language") If nav.NodeType <> XmlNodeType.Comment Then Dim objLocale As New Locale objLocale.Text = nav.GetAttribute("name", "") objLocale.Code = nav.GetAttribute("key", "") objLocale.Fallback = nav.GetAttribute("fallback", "") supportedLocales.Add(objLocale) End If Next Else Dim objLocale As New Locale objLocale.Text = "English" objLocale.Code = "en-US" objLocale.Fallback = "" supportedLocales.Add(objLocale) End If Return supportedLocales End Function ''' ----------------------------------------------------------------------------- ''' ''' GetNextScriptVersion gets the next script to Install ''' ''' ''' ''' ''' [cnurse] 02/15/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function GetNextScriptVersion(ByVal strProviderPath As String, ByVal currentVersion As System.Version) As String Dim strNextVersion As String = "Done" If currentVersion Is Nothing Then strNextVersion = GetBaseDataBaseVersion() Else Dim strScriptVersion As String = Null.NullString Dim arrScripts As ArrayList = Services.Upgrade.Upgrade.GetUpgradeScripts(strProviderPath, currentVersion) If arrScripts.Count > 0 Then 'First Script is next script strScriptVersion = Path.GetFileNameWithoutExtension(CType(arrScripts(0), String)) End If If Not String.IsNullOrEmpty(strScriptVersion) Then strNextVersion = strScriptVersion End If End If Return strNextVersion End Function Private Function GetVersion(ByVal scriptFile As String) As System.Version Return New System.Version(Path.GetFileNameWithoutExtension(scriptFile)) End Function ''' ----------------------------------------------------------------------------- ''' ''' GetWizardButton gets a wizard button from the template ''' ''' ''' ''' ''' [cnurse] 02/28/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function GetWizardButton(ByVal containerID As String, ByVal buttonID As String) As LinkButton Dim navContainer As Control = wizInstall.FindControl(containerID) Dim button As LinkButton = Nothing If Not navContainer Is Nothing Then button = TryCast(navContainer.FindControl(buttonID), LinkButton) End If Return button End Function ''' ----------------------------------------------------------------------------- ''' ''' Initialise configures the first Wizard page ''' ''' ''' ''' ''' [cnurse] 02/15/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub Initialise() If TestDataBaseInstalled() Then 'running current version, so redirect to site home page Response.Redirect("~/Default.aspx", True) Else If DatabaseVersion > New System.Version(0, 0, 0) Then 'Upgrade tblLanguage.Visible = False lblStep0Title.Text = String.Format(LocalizeString("UpgradeTitle"), ApplicationVersion.ToString(3)) lblStep0Detail.Text = String.Format(LocalizeString("Upgrade"), Services.Upgrade.Upgrade.GetStringVersion(DatabaseVersion)) Else 'Install UpdateMachineKey() End If End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' InstallLanguages installs the Optional Languages ''' ''' ''' ''' ''' [cnurse] 02/20/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function InstallAuthSystems() As Boolean Return InstallPackageItems("AuthSystem", lstAuthSystems, lblNoAuthSystems, "InstallAuthSystemError") End Function ''' ----------------------------------------------------------------------------- ''' ''' InstallDatabase intsalls the base Database scripts ''' ''' ''' ''' ''' [cnurse] 02/14/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function InstallDatabase() As String Dim strErrorMessage As String = Null.NullString Dim strProviderPath As String = dataProvider.GetProviderPath() If Not strProviderPath.StartsWith("ERROR:") Then 'Install Base Version strErrorMessage = Services.Upgrade.Upgrade.InstallDatabase(BaseVersion, strProviderPath, InstallTemplate, False) Else 'provider error strErrorMessage = strProviderPath End If If String.IsNullOrEmpty(strErrorMessage) Then 'Get Next Version strErrorMessage = GetNextScriptVersion(strProviderPath, BaseVersion) ElseIf Not strErrorMessage.StartsWith("ERROR:") Then strErrorMessage = "ERROR: " + String.Format(LocalizeString("ScriptError"), Services.Upgrade.Upgrade.GetLogFile(strProviderPath, BaseVersion)) End If Return strErrorMessage End Function ''' ----------------------------------------------------------------------------- ''' ''' InstallHost sets up the Host settings ''' ''' ''' ''' ''' [cnurse] 02/16/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function InstallHost() As Boolean Dim success As Boolean = False Dim strErrorMessage As String = usrHost.Validate() If Not String.IsNullOrEmpty(strErrorMessage) Then Dim strError As String = LocalizeString(strErrorMessage) If strErrorMessage = "PasswordLength" Then strError = String.Format(strError, MembershipProviderConfig.MinPasswordLength) End If lblHostUserError.Text = String.Format(LocalizeString("HostUserError"), strError) Else Try 'Initialise Host Settings Services.Upgrade.Upgrade.InitialiseHostSettings(InstallTemplate, False) 'Create Host User Dim objSuperUserInfo As UserInfo = Services.Upgrade.Upgrade.GetSuperUser(InstallTemplate, False) objSuperUserInfo.FirstName = usrHost.FirstName objSuperUserInfo.LastName = usrHost.LastName objSuperUserInfo.Username = usrHost.UserName objSuperUserInfo.DisplayName = usrHost.FirstName + " " + usrHost.LastName objSuperUserInfo.Membership.Password = usrHost.Password objSuperUserInfo.Email = usrHost.Email UserController.CreateUser(objSuperUserInfo) Services.Upgrade.Upgrade.InstallFiles(InstallTemplate, False) If Not String.IsNullOrEmpty(txtSMTPServer.Text) Then Dim controller As New Entities.Host.HostSettingsController controller.UpdateHostSetting("SMTPServer", txtSMTPServer.Text) controller.UpdateHostSetting("SMTPAuthentication", optSMTPAuthentication.SelectedItem.Value) controller.UpdateHostSetting("SMTPUsername", txtSMTPUsername.Text, True) controller.UpdateHostSetting("SMTPPassword", txtSMTPPassword.Text, True) controller.UpdateHostSetting("SMTPEnableSSL", Convert.ToString(IIf(chkSMTPEnableSSL.Checked, "Y", "N"))) End If 'Clear Host Cache DataCache.ClearHostCache(False) success = True Catch ex As Exception lblHostUserError.Text = String.Format(LocalizeString("HostUserError"), ex.Message) End Try End If Return success End Function ''' ----------------------------------------------------------------------------- ''' ''' InstallLanguages installs the Optional Languages ''' ''' ''' ''' ''' [cnurse] 02/20/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function InstallLanguages() As Boolean Return InstallPackageItems("Language", lstLanguages, lblLanguagesError, "InstallLanguageError") End Function ''' ----------------------------------------------------------------------------- ''' ''' InstallModules installs the Optional Modules ''' ''' ''' ''' ''' [cnurse] 02/19/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function InstallModules() As Boolean Return InstallPackageItems("Module", lstModules, lblModulesError, "InstallModuleError") End Function Private Function InstallPackageItems(ByVal packageType As String, ByVal list As CheckBoxList, ByVal errorLabel As Label, ByVal errorKey As String) As Boolean Dim success As Boolean = False Dim strErrorMessage As String = Null.NullString 'Get current Script time-out Dim scriptTimeOut As Integer = Server.ScriptTimeout Try 'Set Script timeout to MAX value Server.ScriptTimeout = Integer.MaxValue Dim InstallPath As String = ApplicationMapPath & "\Install\" + packageType For Each packageItem As ListItem In list.Items If packageItem.Selected Then If (File.Exists(InstallPath + "\" + packageItem.Value)) Then success = Upgrade.Upgrade.InstallPackage(InstallPath + "\" + packageItem.Value, packageType, False) If Not success Then strErrorMessage += String.Format(LocalizeString(errorKey), packageItem.Text) End If End If End If Next success = String.IsNullOrEmpty(strErrorMessage) Catch ex As Exception strErrorMessage = ex.StackTrace Finally 'restore Script timeout Server.ScriptTimeout = scriptTimeOut End Try If Not success Then errorLabel.Text += strErrorMessage End If Return success End Function ''' ----------------------------------------------------------------------------- ''' ''' InstallPortal installs the Host Portal ''' ''' ''' ''' ''' [cnurse] 02/19/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function InstallPortal() As Boolean Dim success As Boolean = False Dim strErrorMessage As String = usrAdmin.Validate() If Not String.IsNullOrEmpty(strErrorMessage) Then Dim strError As String = LocalizeString(strErrorMessage) If strErrorMessage = "PasswordLength" Then strError = String.Format(strError, MembershipProviderConfig.MinPasswordLength) End If lblPortalError.Text = String.Format(LocalizeString("AdminUserError"), strError) Else Try Dim objPortalController As New PortalController Dim strServerPath As String = ApplicationMapPath & "\" Dim strPortalAlias As String = GetDomainName(HttpContext.Current.Request, True).Replace("/Install", "") Dim strTemplate As String = cboPortalTemplate.SelectedValue + ".template" 'Create Portal PortalId = objPortalController.CreatePortal(txtPortalTitle.Text, usrAdmin.FirstName, usrAdmin.LastName, _ usrAdmin.UserName, usrAdmin.Password, usrAdmin.Email, "", "", Common.Globals.HostMapPath, strTemplate, _ "", strPortalAlias, strServerPath, "", False) success = (PortalId > Null.NullInteger) Catch ex As Exception success = False strErrorMessage = ex.Message End Try If Not success Then lblPortalError.Text = String.Format(LocalizeString("InstallPortalError"), strErrorMessage) End If End If Return success End Function ''' ----------------------------------------------------------------------------- ''' ''' InstallProviders installs the Optional Providers ''' ''' ''' ''' ''' [cnurse] 06/24/2008 Created ''' ''' ----------------------------------------------------------------------------- Private Function InstallProviders() As Boolean Return InstallPackageItems("Provider", lstProviders, lblProvidersError, "InstallProviderError") End Function ''' ----------------------------------------------------------------------------- ''' ''' InstallSkins installs the Optional Skins ''' ''' ''' ''' ''' [cnurse] 02/19/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function InstallSkins() As Boolean Dim skinSuccess As Boolean = InstallPackageItems("Skin", lstSkins, lblSkinsError, "InstallSkinError") Dim containerSuccess As Boolean = InstallPackageItems("Container", lstContainers, lblSkinsError, "InstallContainerError") Return skinSuccess And containerSuccess End Function ''' ----------------------------------------------------------------------------- ''' ''' InstallVersion intsalls the a single version script ''' ''' ''' ''' ''' [cnurse] 02/16/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function InstallVersion(ByVal strVersion As String) As String Dim strErrorMessage As String = Null.NullString Dim version As System.Version = New System.Version(strVersion) Dim strScriptFile As String = Null.NullString Dim strProviderPath As String = dataProvider.GetProviderPath() If Not strProviderPath.StartsWith("ERROR:") Then 'Install Version strScriptFile = Services.Upgrade.Upgrade.GetScriptFile(strProviderPath, version) strErrorMessage += Services.Upgrade.Upgrade.UpgradeVersion(strScriptFile, False) Versions += "," + strVersion 'If version IsNot Nothing Then ' strErrorMessage += Services.Upgrade.Upgrade.UpgradeApplication(version, False) ' ' delete files which are no longer used ' strErrorMessage += Services.Upgrade.Upgrade.DeleteFiles(version, False) ' 'execute config file updates ' strErrorMessage += Services.Upgrade.Upgrade.UpdateConfig(version, False) 'End If Else 'provider error strErrorMessage = strProviderPath End If If String.IsNullOrEmpty(strErrorMessage) Then 'Get Next Version strErrorMessage = GetNextScriptVersion(strProviderPath, version) Else strErrorMessage = "ERROR: (see " & Path.GetFileName(strScriptFile).Replace("." & Upgrade.Upgrade.DefaultProvider, ".log") & " for more information)" End If Return strErrorMessage End Function ''' ----------------------------------------------------------------------------- ''' ''' LocalizePage sets up the Localized Text ''' ''' ''' ''' ''' [cnurse] 02/09/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub LocalizePage() 'Main Title Me.Title = LocalizeString("Title") + " - " + LocalizeString("Page" + wizInstall.ActiveStepIndex.ToString() + ".Title") 'Page Titles For i As Integer = 0 To wizInstall.WizardSteps.Count - 1 wizInstall.WizardSteps(i).Title = LocalizeString("Page" + i.ToString() + ".Title") Next 'Wizard Buttons wizInstall.StartNextButtonText = " " + LocalizeString("Next") wizInstall.FinishPreviousButtonText = " " + LocalizeString("Previous") wizInstall.FinishCompleteButtonText = " " + LocalizeString("Finished") 'Page 0 - Introduction lblStep0Title.Text = String.Format(LocalizeString("IntroTitle"), FormatVersion(ApplicationVersion)) lblStep0Detail.Text = LocalizeString("IntroDetail") lblChooseInstall.Text = LocalizeString("ChooseInstall") lblChooseLanguage.Text = LocalizeString("ChooseLanguage") rblInstall.Items(0).Text = LocalizeString("Full") rblInstall.Items(1).Text = LocalizeString("Typical") rblInstall.Items(2).Text = LocalizeString("Auto") 'Page 1 - File Permissions lblStep1Title.Text = LocalizeString("PermissionsTitle") lblStep1Detail.Text = LocalizeString("PermissionsDetail") lblPermissions.Text = LocalizeString("Permissions") 'File Permissions BindPermissions(False) 'Page 2 - Database Configuration lblStep2Title.Text = LocalizeString("DatabaseConfigTitle") lblStep2Detail.Text = LocalizeString("DatabaseConfigDetail") lblChooseDatabase.Text = LocalizeString("ChooseDatabase") lblServerHelp.Text = LocalizeString("ServerHelp") lblServer.Text = LocalizeString("Server") lblFile.Text = LocalizeString("DatabaseFile") lblDatabaseFileHelp.Text = LocalizeString("DatabaseFileHelp") lblDataBase.Text = LocalizeString("Database") lblDatabaseHelp.Text = LocalizeString("DatabaseHelp") lblIntegrated.Text = LocalizeString("Integrated") lblIntegratedHelp.Text = LocalizeString("IntegratedHelp") lblUserId.Text = LocalizeString("UserId") lblUserHelp.Text = LocalizeString("UserHelp") lblPassword.Text = LocalizeString("Password") lblPasswordHelp.Text = LocalizeString("PasswordHelp") lblOwner.Text = LocalizeString("Owner") lblOwnerHelp.Text = LocalizeString("OwnerHelp") lblQualifier.Text = LocalizeString("Qualifier") lblQualifierHelp.Text = LocalizeString("QualifierHelp") rblDatabases.Items(0).Text = LocalizeString("SQLServerXPress") rblDatabases.Items(1).Text = LocalizeString("SQLServer") 'Page 3 - Database Installation lblStep3Title.Text = LocalizeString("DatabaseInstallTitle") lblStep3Detail.Text = LocalizeString("DatabaseInstallDetail") 'Page 4 - Host User lblStep4Title.Text = LocalizeString("HostUserTitle") lblStep4Detail.Text = LocalizeString("HostUserDetail") usrHost.FirstNameLabel = LocalizeString("FirstName") usrHost.LastNameLabel = LocalizeString("LastName") usrHost.UserNameLabel = LocalizeString("UserName") usrHost.PasswordLabel = LocalizeString("Password") usrHost.ConfirmLabel = LocalizeString("Confirm") usrHost.EmailLabel = LocalizeString("Email") lblSMTPSettings.Text = LocalizeString("SMTPSettings") lblSMTPSettingsHelp.Text = LocalizeString("SMTPSettingsHelp") lblSMTPServer.Text = LocalizeString("SMTPServer") lblSMTPAuthentication.Text = LocalizeString("SMTPAuthentication") lblSMTPEnableSSL.Text = LocalizeString("SMTPEnableSSL") lblSMTPUsername.Text = LocalizeString("SMTPUsername") lblSMTPPassword.Text = LocalizeString("SMTPPassword") 'Page 5 - Modules lblStep5Title.Text = LocalizeString("ModulesTitle") lblStep5Detail.Text = LocalizeString("ModulesDetail") lblModules.Text = LocalizeString("Modules") 'Page 6 - Skins/Containers lblStep6Title.Text = LocalizeString("SkinsTitle") lblStep6Detail.Text = LocalizeString("SkinsDetail") lblSkins.Text = LocalizeString("Skins") lblContainers.Text = LocalizeString("Containers") 'Page 7 - Languages lblStep7Title.Text = LocalizeString("LanguagesTitle") lblStep7Detail.Text = LocalizeString("LanguagesDetail") lblLanguages.Text = LocalizeString("Languages") 'Page 8 - Auth Systems lblStep8Title.Text = LocalizeString("AuthSystemsTitle") lblStep8Detail.Text = LocalizeString("AuthSystemsDetail") lblAuthSystems.Text = LocalizeString("AuthSystems") 'Page 9 - Providers lblStep9Title.Text = LocalizeString("ProvidersTitle") lblStep9Detail.Text = LocalizeString("ProvidersDetail") lblProviders.Text = LocalizeString("Providers") 'Page 10 - Portal lblStep10Title.Text = LocalizeString("PortalTitle") lblStep10Detail.Text = LocalizeString("PortalDetail") usrAdmin.FirstNameLabel = LocalizeString("FirstName") usrAdmin.LastNameLabel = LocalizeString("LastName") usrAdmin.UserNameLabel = LocalizeString("UserName") usrAdmin.PasswordLabel = LocalizeString("Password") usrAdmin.ConfirmLabel = LocalizeString("Confirm") usrAdmin.EmailLabel = LocalizeString("Email") lblAdminUser.Text = LocalizeString("AdminUser") lblPortal.Text = LocalizeString("Portal") lblPortalTitle.Text = LocalizeString("PortalTitle") lblPortalTemplate.Text = LocalizeString("PortalTemplate") 'Page 12 - Complete lblCompleteTitle.Text = LocalizeString("CompleteTitle") lblCompleteDetail.Text = LocalizeString("CompleteDetail") End Sub Private Sub SetupDatabasePage() Dim nextButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "StepNextButton") Dim customButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "CustomButton") SetupDatabasePage(customButton, nextButton) End Sub Private Sub SetupDatabasePage(ByVal customButton As LinkButton, ByVal nextButton As LinkButton) If rblDatabases.SelectedIndex > Null.NullInteger Then Dim isSQLFile As Boolean = (rblDatabases.SelectedValue = "SQLFile") Dim isSQLDb As Boolean = (rblDatabases.SelectedValue = "SQLDatabase") Dim isOracle As Boolean = (rblDatabases.SelectedValue = "Oracle") tblDatabase.Visible = True trFile.Visible = isSQLFile trDatabase.Visible = isSQLDb trIntegrated.Visible = Not isOracle trUser.Visible = Not chkIntegrated.Checked OrElse isOracle trPassword.Visible = Not chkIntegrated.Checked OrElse isOracle chkOwner.Checked = (Config.GetDataBaseOwner() = "dbo.") txtqualifier.Text = Config.GetObjectQualifer() ShowButton(customButton, True) EnableButton(nextButton, True) Else tblDatabase.Visible = False customButton.Visible = False EnableButton(nextButton, False) End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' SetupPage updates the WizardPage ''' ''' ''' ''' ''' [cnurse] 01/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub SetupPage() Dim nextButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "StepNextButton") Dim prevButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "StepPreviousButton") Dim customButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "CustomButton") EnableButton(nextButton, True) EnableButton(prevButton, True) ShowButton(customButton, False) Select Case wizInstall.ActiveStepIndex Case 0 'Page 0 - Welcome lblPermissionsError.Text = "" Case 1 lblDataBaseError.Text = "" 'Page 1 Permissions ShowButton(customButton, True) Case 2 lblPermissionsError.Text = "" ' 'Page 2 - Database Configuration SetupDatabasePage(customButton, nextButton) Case 3 lblDataBaseError.Text = "" lblInstallError.Text = "" lblInstallError.Visible = False EnableButton(nextButton, False) ShowButton(prevButton, False) Case 4 'Page 4 - SuperUser Configuration BindSuperUser(customButton) ShowButton(prevButton, False) Case 5 'Page 5 - Modules BindModules() ShowButton(prevButton, False) Case 6 'Page 6 - Skins/Conatiners BindSkins() ShowButton(prevButton, False) Case 7 'Page 7 - Languages BindLanguages() ShowButton(prevButton, False) Case 8 'Page 8 - Auth Systems BindAuthSystems() ShowButton(prevButton, False) Case 9 'Page 9 - Providers BindProviders() ShowButton(prevButton, False) Case 10 'Page 10 - Portal BindPortal() ShowButton(prevButton, False) End Select End Sub ''' ----------------------------------------------------------------------------- ''' ''' ShowButton shows/hides a Navigation Button ''' ''' ''' ''' ''' [cnurse] 02/28/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Sub ShowButton(ByVal button As LinkButton, ByVal enabled As Boolean) If Not button Is Nothing Then button.Visible = enabled End If End Sub Private Sub ShowHideSMTPCredentials() If optSMTPAuthentication.SelectedValue = "1" Then trSMTPPassword.Visible = True trSMTPUserName.Visible = True Else trSMTPPassword.Visible = False trSMTPUserName.Visible = False End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' TestDatabaseConnection checks the Database connection properties provided ''' ''' ''' ''' ''' [cnurse] 01/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function TestDatabaseConnection() As Boolean Dim success As Boolean = False If String.IsNullOrEmpty(rblDatabases.SelectedValue) Then connectionString = "ERROR:" + LocalizeString("ChooseDbError") Else Dim isSQLFile As Boolean = (rblDatabases.SelectedValue = "SQLFile") Dim builder As DbConnectionStringBuilder = dataProvider.GetConnectionStringBuilder() If Not String.IsNullOrEmpty(txtServer.Text) Then builder("Data Source") = txtServer.Text End If If Not String.IsNullOrEmpty(txtDatabase.Text) And Not isSQLFile Then builder("Initial Catalog") = txtDatabase.Text End If If Not String.IsNullOrEmpty(txtFile.Text) And isSQLFile Then builder("attachdbfilename") = "|DataDirectory|" + txtFile.Text End If If chkIntegrated.Checked Then builder("integrated security") = "true" End If If Not String.IsNullOrEmpty(txtUserId.Text) Then builder("uid") = txtUserId.Text End If If Not String.IsNullOrEmpty(txtPassword.Text) Then builder("pwd") = txtPassword.Text End If If isSQLFile Then builder("user instance") = "true" End If Dim owner As String = txtUserId.Text + "." If chkOwner.Checked Then owner = "dbo." End If connectionString = dataProvider.Instance.TestDatabaseConnection(builder, owner, txtqualifier.Text) End If If connectionString.StartsWith("ERROR:") Then lblDataBaseError.Text = String.Format(LocalizeString("ConnectError"), connectionString.Replace("ERROR:", "")) Else success = True lblDataBaseError.Text = LocalizeString("ConnectSuccess") End If Return success End Function ''' ----------------------------------------------------------------------------- ''' ''' TestDataBaseInstalled checks whether the Database is the current version ''' ''' ''' ''' ''' [cnurse] 02/16/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function TestDataBaseInstalled() As Boolean Dim success As Boolean = True If DatabaseVersion Is Nothing OrElse _ DatabaseVersion.Major <> ApplicationVersion.Major OrElse _ DatabaseVersion.Minor <> ApplicationVersion.Minor OrElse _ DatabaseVersion.Build <> ApplicationVersion.Build Then success = False End If If Not success Then lblInstallError.Text = LocalizeString("Install.Error") End If Return success End Function Private Function TestSMTPSettings() As Boolean If Not String.IsNullOrEmpty(usrHost.Email) Then Dim strMessage As String = DotNetNuke.Services.Mail.Mail.SendMail(usrHost.Email, usrHost.Email, "", "", MailPriority.Normal, _ LocalizeString("EmailTestMessageSubject"), MailFormat.Text, System.Text.Encoding.UTF8, "", "", txtSMTPServer.Text, _ optSMTPAuthentication.SelectedItem.Value, txtSMTPUsername.Text, txtSMTPPassword.Text, chkSMTPEnableSSL.Checked) If strMessage <> "" Then lblHostUserError.Text = String.Format(LocalizeString("SMTPError"), String.Format(LocalizeString("EmailErrorMessage"), strMessage)) Else lblHostUserError.Text = String.Format(LocalizeString("SMTPSuccess"), LocalizeString("EmailSentMessage")) End If Else lblHostUserError.Text = String.Format(LocalizeString("SMTPError"), LocalizeString("SpecifyHostEmailMessage")) End If End Function Private Sub UpdateMachineKey() Dim installationDate As String = Config.GetSetting("InstallationDate") If installationDate Is Nothing Or installationDate = "" Then Dim strError As String = Config.UpdateMachineKey() If strError = "" Then ' send a new request to the application to initiate step 2 Response.Redirect(HttpContext.Current.Request.RawUrl, True) Else '403-3 Error - Redirect to ErrorPage Dim strURL As String = "~/ErrorPage.aspx?status=403_3&error=" & strError HttpContext.Current.Response.Clear() HttpContext.Current.Server.Transfer(strURL) End If End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' VerifyFileCreate checks whether a file can be created ''' ''' ''' ''' ''' [cnurse] 02/09/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function VerifyFileCreate() As Boolean Dim verifyPath As String = Server.MapPath("~/Verify/Verify.txt") Dim verified As Boolean = VerifyFolderCreate() If verified Then 'Attempt to create the File Try If File.Exists(verifyPath) Then File.Delete(verifyPath) End If Dim fileStream As Stream = File.Create(verifyPath) fileStream.Close() Catch ex As Exception verified = False End Try End If If Not verified Then PermissionsValid = False Return verified End Function ''' ----------------------------------------------------------------------------- ''' ''' VerifyFileDelete checks whether a file can be deleted ''' ''' ''' ''' ''' [cnurse] 02/09/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function VerifyFileDelete() As Boolean Dim verifyPath As String = Server.MapPath("~/Verify/Verify.txt") Dim verified As Boolean = VerifyFileCreate() If verified Then 'Attempt to delete the File Try File.Delete(verifyPath) Catch ex As Exception verified = False End Try End If If Not verified Then PermissionsValid = False Return verified End Function ''' ----------------------------------------------------------------------------- ''' ''' VerifyFolderCreate checks whether a folder can be created ''' ''' ''' ''' ''' [cnurse] 01/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function VerifyFolderCreate() As Boolean Dim verifyPath As String = Server.MapPath("~/Verify") Dim verified As Boolean = True 'Attempt to create the Directory Try If Directory.Exists(verifyPath) Then Directory.Delete(verifyPath, True) End If Directory.CreateDirectory(verifyPath) Catch ex As Exception verified = False End Try If Not verified Then PermissionsValid = False Return verified End Function ''' ----------------------------------------------------------------------------- ''' ''' VerifyFolderDelete checks whether a folder can be deleted ''' ''' ''' ''' ''' [cnurse] 01/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Private Function VerifyFolderDelete() As Boolean Dim verifyPath As String = Server.MapPath("~/Verify") Dim verified As Boolean = VerifyFolderCreate() If verified Then 'Attempt to delete the Directory Try Directory.Delete(verifyPath) Catch ex As Exception verified = False End Try End If If Not verified Then PermissionsValid = False Return verified End Function #End Region #Region "Protected Methods" ''' ----------------------------------------------------------------------------- ''' ''' GetBaseDataBaseVersion gets the Base Database Version as a string ''' ''' ''' ''' ''' [cnurse] 03/02/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Function GetBaseDataBaseVersion() As String Return Upgrade.Upgrade.GetStringVersion(BaseVersion) End Function ''' ----------------------------------------------------------------------------- ''' ''' LocalizeString is a helper function for localizing strings ''' ''' ''' ''' ''' [cnurse] 01/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Function LocalizeString(ByVal key As String) As String Return Services.Localization.Localization.GetString(key, Me.LocalResourceFile, cboLanguages.SelectedValue.ToLower) End Function Protected Overrides Sub OnError(ByVal e As System.EventArgs) HttpContext.Current.Response.Clear() HttpContext.Current.Server.Transfer("~/ErrorPage.aspx") End Sub #End Region #Region "Event Handlers" ''' ----------------------------------------------------------------------------- ''' ''' Page_Init runs when the Page is initialised ''' ''' ''' ''' ''' [cnurse] 02/14/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init DotNetNuke.UI.Utilities.ClientAPI.HandleClientAPICallbackEvent(Me) 'Attach Event(s) to the Buttons Dim button As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "CustomButton") If Not button Is Nothing Then AddHandler button.Click, AddressOf wizInstall_CustomButtonClick End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' Page_Load runs when the Page loads ''' ''' ''' ''' ''' [cnurse] 02/09/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'register variable ActionCallback with script necessary to perform callback '[ACTIONTOKEN] will be replaced on the client side with real action DotNetNuke.UI.Utilities.ClientAPI.RegisterClientVariable(Me.Page, "ActionCallback", DotNetNuke.UI.Utilities.ClientAPI.GetCallbackEventReference(Me, "[ACTIONTOKEN]", "successFunc", "this", "errorFunc"), True) lblHostWarning.Visible = Not Regex.IsMatch(Request.Url.Host, "^([a-zA-Z0-9.-]+)$", RegexOptions.IgnoreCase) If Not Page.IsPostBack Then rblInstall.Items.Clear() rblInstall.Items.Add(New ListItem(LocalizeString("Full"), "Full")) rblInstall.Items.Add(New ListItem(LocalizeString("Typical"), "Typical")) rblInstall.Items.Add(New ListItem(LocalizeString("Auto"), "Auto")) rblInstall.SelectedIndex = 1 rblDatabases.Items.Clear() rblDatabases.Items.Add(New ListItem(LocalizeString("SQLServerXPress"), "SQLFile")) rblDatabases.Items.Add(New ListItem(LocalizeString("SQLServer"), "SQLDatabase")) 'Parse the conneection String to the form BindConnectionString() 'Database Choices BindDatabases() If TestDatabaseConnection() Then Initialise() rblInstall.Items(2).Enabled = True lblDataBaseWarning.Visible = False Else 'Install but connection string not configured to point at a valid SQL Server UpdateMachineKey() rblInstall.Items(2).Enabled = False lblDataBaseWarning.Visible = True End If cboLanguages.DataSource = GetInstallerLocales() cboLanguages.DataBind() LocalizePage() wizInstall.ActiveStepIndex = 0 SetupPage() End If End Sub ''' ----------------------------------------------------------------------------- ''' ''' Page_PreRender runs just before the page is rendered ''' ''' ''' ''' ''' [cnurse] 02/15/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender 'Make sure that the password is not cleared on pastback txtPassword.Attributes("value") = txtPassword.Text txtSMTPPassword.Attributes("value") = txtSMTPPassword.Text End Sub ''' ----------------------------------------------------------------------------- ''' ''' Runs when the Selected Language is changed ''' ''' ''' ''' ''' [cnurse] 02/09/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Sub cboLanguages_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboLanguages.SelectedIndexChanged LocalizePage() End Sub ''' ----------------------------------------------------------------------------- ''' ''' Runs when the Integrated Security Checkbox value is changed ''' ''' ''' ''' ''' [cnurse] 02/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Sub chkIntegrated_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkIntegrated.CheckedChanged trUser.Visible = Not chkIntegrated.Checked trPassword.Visible = Not chkIntegrated.Checked If chkIntegrated.Checked Then chkOwner.Checked = True End If chkOwner.Enabled = Not chkIntegrated.Checked End Sub Protected Sub optSMTPAuthentication_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles optSMTPAuthentication.SelectedIndexChanged ShowHideSMTPCredentials() End Sub ''' ----------------------------------------------------------------------------- ''' ''' Runs when there is a ClientCallback ''' ''' ''' ''' ''' [cnurse] 02/09/2007 Created ''' ''' ----------------------------------------------------------------------------- Public Function ProcessAction(ByVal someAction As String) As String Implements DotNetNuke.UI.Utilities.IClientAPICallbackEventHandler.RaiseClientAPICallbackEvent 'First check that we are not being targetted by an AJAX HttpPost, so get the current DB version Dim strProviderPath As String = dataProvider.GetProviderPath() Dim nextVersion As String = GetNextScriptVersion(strProviderPath, DatabaseVersion) If someAction <> nextVersion Then LogException(New Exception("Attempt made to run a Database Script - Possible Attack")) Return "Error: Possible Attack" End If If someAction = GetBaseDataBaseVersion() Then Dim result As String = InstallDatabase() If result = "Done" Then 'Complete Installation Services.Upgrade.Upgrade.UpgradeApplication() End If Return result ElseIf someAction.Contains(".") Then 'Upgrade Database Dim result As String = InstallVersion(someAction) If result = "Done" Then Dim arrVersions As ArrayList = Services.Upgrade.Upgrade.GetUpgradeScripts(strProviderPath, BaseVersion) Dim strErrorMessage As String = Null.NullString For i As Integer = 0 To arrVersions.Count - 1 Dim strVersion = Path.GetFileNameWithoutExtension(CType(arrVersions(i), String)) Dim version As System.Version = New System.Version(strVersion) If version IsNot Nothing Then strErrorMessage += Services.Upgrade.Upgrade.UpgradeApplication(version, False) ' delete files which are no longer used strErrorMessage += Services.Upgrade.Upgrade.DeleteFiles(version, False) 'execute config file updates strErrorMessage += Services.Upgrade.Upgrade.UpdateConfig(version, False) End If Next 'Complete Installation Services.Upgrade.Upgrade.UpgradeApplication() If Not String.IsNullOrEmpty(strErrorMessage) Then result = "ERROR: " + strErrorMessage End If End If Return result Else Return "Done" End If End Function ''' ----------------------------------------------------------------------------- ''' ''' Runs when the Selected Database is changed ''' ''' ''' ''' ''' [cnurse] 02/23/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Sub rblDatabases_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rblDatabases.SelectedIndexChanged BindConnectionString() SetupDatabasePage() End Sub ''' ----------------------------------------------------------------------------- ''' ''' Runs when the Active Wizard Step has changed ''' ''' ''' ''' ''' [cnurse] 02/09/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Sub wizInstall_ActiveStepChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles wizInstall.ActiveStepChanged 'Main Title Me.Title = LocalizeString("Title") + " - " + LocalizeString("Page" + wizInstall.ActiveStepIndex.ToString() + ".Title") If wizInstall.ActiveStepIndex > 0 Then Dim nextButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "StepNextButton") Dim prevButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "StepPreviousButton") nextButton.Text = " " + LocalizeString("Next") prevButton.Text = " " + LocalizeString("Previous") End If Select Case wizInstall.ActiveStepIndex Case 1 'Page 1 - Permissions Dim customButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "CustomButton") customButton.Text = " " + LocalizeString("TestPerm") Case 2 'Page 2 - Database Dim customButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "CustomButton") customButton.Text = " " + LocalizeString("TestDB") Case 4 'Page 4 - SMTP Settings Dim customButton As LinkButton = GetWizardButton("StepNavigationTemplateContainerID", "CustomButton") customButton.Text = " " + LocalizeString("TestSMTP") ShowHideSMTPCredentials() Case 5 'Page 5 - Modules If rblInstall.SelectedValue = "Typical" Then BindModules() If InstallModules() Then 'Skip Modules Page wizInstall.ActiveStepIndex = 6 End If End If Case 6 'Page 6 - Skins/Conatiners If rblInstall.SelectedValue = "Typical" Then BindSkins() If InstallSkins() Then 'Skip Skins Page wizInstall.ActiveStepIndex = 7 End If End If Case 7 'Page 7 - Languages If rblInstall.SelectedValue = "Typical" Then BindLanguages() If InstallLanguages() Then 'Skip Languages Page wizInstall.ActiveStepIndex = 8 End If End If Case 8 'Page 8 - Auth Systems If rblInstall.SelectedValue = "Typical" Then BindAuthSystems() If InstallAuthSystems() Then 'Skip Auth Systems Page wizInstall.ActiveStepIndex = 9 End If End If Case 9 'Page 9 - Providers If rblInstall.SelectedValue = "Typical" Then BindProviders() If InstallProviders() Then 'Skip Providers Page wizInstall.ActiveStepIndex = 10 End If End If End Select SetupPage() End Sub ''' ----------------------------------------------------------------------------- ''' ''' Runs when the Wizard's Custom button is clicked ''' ''' ''' ''' ''' [cnurse] 02/28/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Sub wizInstall_CustomButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Select Case wizInstall.ActiveStepIndex Case 1 'Page 1 - File Permissions BindPermissions(True) Case 2 'Page 2 - Database Connection String TestDatabaseConnection() Case 4 'Page 4 - SMTP Server TestSMTPSettings() End Select End Sub Protected Sub wizInstall_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles wizInstall.FinishButtonClick 'Force an App Restart Config.Touch() 'Redirect to site home page Response.Redirect("~/Default.aspx", True) End Sub ''' ----------------------------------------------------------------------------- ''' ''' Runs when the Wizard's Next button is clicked ''' ''' ''' ''' ''' [cnurse] 02/20/2007 Created ''' ''' ----------------------------------------------------------------------------- Protected Sub wizInstall_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles wizInstall.NextButtonClick Dim nextStep As WizardStep = wizInstall.WizardSteps(e.NextStepIndex) Select Case e.CurrentStepIndex Case 0 If rblInstall.SelectedValue = "Auto" Then Response.Redirect("~/Install/Install.aspx?mode=install") End If Case 1 'Page 1 - File Permissions BindPermissions(True) e.Cancel = Not PermissionsValid Case 2 'Page 2 - Database Configuration Dim canConnect As Boolean = TestDatabaseConnection() If canConnect Then 'Update Connection String Config.UpdateConnectionString(connectionString) Dim dbOwner As String = String.Empty If chkOwner.Checked Then dbOwner = "dbo" Else If (String.IsNullOrEmpty(GetUpgradeConnectionStringUserID())) Then dbOwner = txtUserId.Text Else dbOwner = GetUpgradeConnectionStringUserID() End If End If If rblDatabases.SelectedValue = "Oracle" Then Config.UpdateDataProvider("OracleDataProvider", "", txtqualifier.Text) Else Config.UpdateDataProvider("SqlDataProvider", dbOwner, txtqualifier.Text) End If 'Get Base DatabaseVersion GetBaseDataBaseVersion() Else e.Cancel = True End If Case 3 'Page 3 - Database Installation e.Cancel = Not TestDataBaseInstalled() Case 4 'Page 4 - Host User e.Cancel = Not InstallHost() Case 5 'Page 5 - Modules e.Cancel = Not InstallModules() Case 6 'Page 6 - Skins/Containers e.Cancel = Not InstallSkins() Case 7 'Page 7 - Languages e.Cancel = Not InstallLanguages() Case 8 'Page 8 - Auth Systems e.Cancel = Not InstallAuthSystems() Case 9 'Page 9 - Providers e.Cancel = Not InstallProviders() Case 10 'Page 10 - Portal e.Cancel = Not InstallPortal() End Select End Sub #End Region End Class End Namespace