/// <summary> /// GetInstallConfig - Returns configuration stored in DotNetNuke.Install.Config /// </summary> /// <returns>ConnectionConfig object. Null if information is not present in the config file</returns> public InstallConfig GetInstallConfig() { var installConfig = new InstallConfig(); //Load Template var installTemplate = new XmlDocument(); Upgrade.GetInstallTemplate(installTemplate); //Parse the root node XmlNode rootNode = installTemplate.SelectSingleNode("//dotnetnuke"); if (rootNode != null) { installConfig.Version = XmlUtils.GetNodeValue(rootNode.CreateNavigator(), "version"); installConfig.InstallCulture = XmlUtils.GetNodeValue(rootNode.CreateNavigator(), "installCulture") ?? Localization.Localization.SystemLocale; } //Parse the scripts node XmlNode scriptsNode = installTemplate.SelectSingleNode("//dotnetnuke/scripts"); if (scriptsNode != null) { foreach (XmlNode scriptNode in scriptsNode) { if (scriptNode != null) { installConfig.Scripts.Add(scriptNode.InnerText); } } } //Parse the connection node XmlNode connectionNode = installTemplate.SelectSingleNode("//dotnetnuke/connection"); if (connectionNode != null) { var connectionConfig = new ConnectionConfig(); //Build connection string from the file connectionConfig.Server = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "server"); connectionConfig.Database = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "database"); connectionConfig.File = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "file"); connectionConfig.Integrated = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "integrated").ToLower() == "true"; connectionConfig.User = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "user"); connectionConfig.Password = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "password"); connectionConfig.RunAsDbowner = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "runasdbowner").ToLower() == "true"; connectionConfig.Qualifier = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "qualifier"); connectionConfig.UpgradeConnectionString = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "upgradeconnectionstring"); installConfig.Connection = connectionConfig; } //Parse the superuser node XmlNode superUserNode = installTemplate.SelectSingleNode("//dotnetnuke/superuser"); if (superUserNode != null) { var superUserConfig = new SuperUserConfig(); superUserConfig.FirstName = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "firstname"); superUserConfig.LastName = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "lastname"); superUserConfig.UserName = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "username"); superUserConfig.Password = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "password"); superUserConfig.Email = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "email"); superUserConfig.Locale = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "locale"); superUserConfig.UpdatePassword = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "updatepassword").ToLower() == "true"; installConfig.SuperUser = superUserConfig; } //Parse the license node XmlNode licenseNode = installTemplate.SelectSingleNode("//dotnetnuke/license"); if (licenseNode != null) { var licenseConfig = new LicenseConfig(); licenseConfig.AccountEmail = XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "accountEmail"); licenseConfig.InvoiceNumber = XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "invoiceNumber"); licenseConfig.WebServer = XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "webServer"); licenseConfig.LicenseType = XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "licenseType"); if (!String.IsNullOrEmpty(XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "trial"))) { licenseConfig.TrialRequest = bool.Parse(XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "trial")); } installConfig.License = licenseConfig; } //Parse the settings node XmlNode settingsNode = installTemplate.SelectSingleNode("//dotnetnuke/settings"); if (settingsNode != null) { foreach (XmlNode settingNode in settingsNode.ChildNodes) { if (settingNode != null && !string.IsNullOrEmpty(settingNode.Name)) { bool settingIsSecure = false; if (settingNode.Attributes != null) { XmlAttribute secureAttrib = settingNode.Attributes["Secure"]; if ((secureAttrib != null)) { if (secureAttrib.Value.ToLower() == "true") { settingIsSecure = true; } } } installConfig.Settings.Add(new HostSettingConfig {Name = settingNode.Name, Value = settingNode.InnerText, IsSecure = settingIsSecure}); } } } var folderMappingsNode = installTemplate.SelectSingleNode("//dotnetnuke/"+FolderMappingsConfigController.Instance.ConfigNode); installConfig.FolderMappingsSettings = (folderMappingsNode != null)? folderMappingsNode.InnerXml : String.Empty; //Parse the portals node XmlNodeList portalsNode = installTemplate.SelectNodes("//dotnetnuke/portals/portal"); if (portalsNode != null) { foreach (XmlNode portalNode in portalsNode) { if (portalNode != null) { var portalConfig = new PortalConfig(); portalConfig.PortalName = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "portalname"); XmlNode adminNode = portalNode.SelectSingleNode("administrator"); if (adminNode != null) { portalConfig.AdminFirstName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "firstname"); portalConfig.AdminLastName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "lastname"); portalConfig.AdminUserName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "username"); portalConfig.AdminPassword = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "password"); portalConfig.AdminEmail = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "email"); } portalConfig.Description = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "description"); portalConfig.Keywords = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "keywords"); portalConfig.TemplateFileName = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "templatefile"); portalConfig.IsChild = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "ischild").ToLower() == "true"; ; portalConfig.HomeDirectory = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "homedirectory"); //Get the Portal Alias XmlNodeList portalAliases = portalNode.SelectNodes("portalaliases/portalalias"); if (portalAliases != null) { foreach (XmlNode portalAliase in portalAliases) { if (!string.IsNullOrEmpty(portalAliase.InnerText)) { portalConfig.PortAliases.Add(portalAliase.InnerText); } } } installConfig.Portals.Add(portalConfig); } } } return installConfig; }
private void CreateSite(PortalConfig portal, InstallConfig installConfig) { var domain = ""; if ((HttpContext.Current != null)) { domain = Globals.GetDomainName(HttpContext.Current.Request, true).ToLowerInvariant().Replace("/install/launchautoinstall", "").Replace("/install", "").Replace("/runinstall", ""); } var portalController = new PortalController(); var serverPath = Globals.ApplicationMapPath + "\\"; //Get the Portal Alias var portalAlias = domain; if (portal.PortAliases.Count > 0) portalAlias = portal.PortAliases[0]; //Verify that portal alias is not present if (PortalAliasController.GetPortalAliasLookup(portalAlias.ToLower()) != null) { string description = Localization.Localization.GetString("SkipCreatingSite", LocalInstallResourceFile); Details = string.Format(description, portalAlias); return; } //Create default email var email = portal.AdminEmail; if (string.IsNullOrEmpty(email)) { email = "admin@" + domain.Replace("www.", ""); //Remove any domain subfolder information ( if it exists ) if (email.IndexOf("/") != -1) { email = email.Substring(0, email.IndexOf("/")); } } //install LP if installing in a different language string culture = installConfig.InstallCulture; if (!culture.Equals("en-us", StringComparison.InvariantCultureIgnoreCase)) { string installFolder = HttpContext.Current.Server.MapPath("~/Install/language"); Upgrade.InstallPackage(installFolder + "\\installlanguage.resources", "Language", false); } var template = Upgrade.FindBestTemplate(portal.TemplateFileName); UserInfo userInfo; if (!String.IsNullOrEmpty(portal.AdminUserName)) userInfo = Upgrade.CreateUserInfo(portal.AdminFirstName, portal.AdminLastName, portal.AdminUserName, portal.AdminPassword, email); else userInfo = Upgrade.CreateUserInfo(installConfig.SuperUser.FirstName, installConfig.SuperUser.LastName, installConfig.SuperUser.UserName, installConfig.SuperUser.Password, installConfig.SuperUser.Email); var childPath = string.Empty; if (portal.IsChild) childPath = portalAlias.Substring(portalAlias.LastIndexOf("/") + 1); //Create Portal var portalId = portalController.CreatePortal(portal.PortalName, userInfo, portal.Description, portal.Keywords, template, portal.HomeDirectory, portalAlias, serverPath, serverPath + childPath, portal.IsChild); if (portalId > -1) { foreach (var alias in portal.PortAliases) { portalController.AddPortalAlias(portalId, alias); } } //remove en-US from portal if installing in a different language if (!culture.Equals("en-us", StringComparison.InvariantCultureIgnoreCase)) { var locale = LocaleController.Instance.GetLocale("en-US"); Localization.Localization.RemoveLanguageFromPortal(portalId, locale.LanguageId); } //Log user in to site var loginStatus = UserLoginStatus.LOGIN_FAILURE; UserController.UserLogin(portalId, userInfo.Username, installConfig.SuperUser.Password, "", "", "", ref loginStatus, false); InstallController.Instance.RemoveFromInstallConfig("//dotnetnuke/superuser/password"); }
/// <summary> /// Updates and synchronizes DotNetNuke.install.config with Web.config /// </summary> /// <param name="installInfo"></param> private static void UpdateInstallConfig(Dictionary<string, string> installInfo) { _installConfig = new InstallConfig(); // SuperUser Config _installConfig.SuperUser = new SuperUserConfig(); _installConfig.SuperUser.UserName = installInfo["username"]; _installConfig.SuperUser.Password = installInfo["password"]; _installConfig.SuperUser.Locale = _culture; // Defaults _installConfig.SuperUser.Email = "*****@*****.**"; _installConfig.SuperUser.FirstName = "SuperUser"; _installConfig.SuperUser.LastName = "Account"; // website culture _installConfig.InstallCulture = installInfo["language"]; // Website Portal Config var portalConfig = new PortalConfig(); portalConfig.PortalName = installInfo["websiteName"]; portalConfig.TemplateFileName = installInfo["template"]; portalConfig.IsChild = false; _installConfig.Portals = new List<PortalConfig>(); _installConfig.Portals.Add(portalConfig); InstallController.Instance.SetInstallConfig(_installConfig); }
/// <summary> /// Updates and synchronizes DotNetNuke.install.config with Web.config /// </summary> /// <param name="installInfo"></param> private static void UpdateInstallConfig(Dictionary<string, string> installInfo) { _installConfig = new InstallConfig { SuperUser = new SuperUserConfig { UserName = installInfo["username"], Password = installInfo["password"], Locale = _culture, Email = installInfo["email"], FirstName = "SuperUser", LastName = "Account" }, InstallCulture = installInfo["language"] }; // SuperUser Config // Defaults // website culture // Website Portal Config var portalConfig = new PortalConfig { PortalName = installInfo["websiteName"], TemplateFileName = installInfo["template"], IsChild = false }; _installConfig.Portals = new List<PortalConfig> {portalConfig}; InstallController.Instance.SetInstallConfig(_installConfig); }