コード例 #1
0
        /// <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;
        }
コード例 #2
0
        /// <summary>
        /// SetInstallConfig - Saves configuration n DotNetNuke.Install.Config
        /// </summary>        
        public void SetInstallConfig(InstallConfig installConfig)
        {
            if (installConfig == null)
            {
                return;
            }

            //Load Template
            var installTemplate = new XmlDocument();
            Upgrade.GetInstallTemplate(installTemplate);
            XmlNode dotnetnukeNode = installTemplate.SelectSingleNode("//dotnetnuke");

            //Set Version            
            if (!string.IsNullOrEmpty(installConfig.Version))
            {
                XmlNode versionNode = installTemplate.SelectSingleNode("//dotnetnuke/version");

                if (versionNode == null)
                {
                    versionNode = AppendNewXmlNode(ref installTemplate, ref dotnetnukeNode, "version", installConfig.Version);
                }

                versionNode.InnerText = installConfig.Version;
            }

            //Set installer culture            
            if (!string.IsNullOrEmpty(installConfig.InstallCulture))
            {
                XmlNode versionNode = installTemplate.SelectSingleNode("//dotnetnuke/installCulture");

                if (versionNode == null)
                {
                    versionNode = AppendNewXmlNode(ref installTemplate, ref dotnetnukeNode, "installCulture", installConfig.InstallCulture);
                }

                versionNode.InnerText = installConfig.InstallCulture;
            }

            //Set SuperUser
            if (installConfig.SuperUser != null)
            {
                XmlNode superUserNode = installTemplate.SelectSingleNode("//dotnetnuke/superuser");
                if (superUserNode == null)
                {
                    superUserNode = AppendNewXmlNode(ref installTemplate, ref dotnetnukeNode, "superuser", installConfig.Version);
                }
                else
                {
                    superUserNode.RemoveAll();
                }

                AppendNewXmlNode(ref installTemplate, ref superUserNode, "firstname", installConfig.SuperUser.FirstName);
                AppendNewXmlNode(ref installTemplate, ref superUserNode, "lastname", installConfig.SuperUser.LastName);
                AppendNewXmlNode(ref installTemplate, ref superUserNode, "username", installConfig.SuperUser.UserName);
                AppendNewXmlNode(ref installTemplate, ref superUserNode, "password", installConfig.SuperUser.Password);
                AppendNewXmlNode(ref installTemplate, ref superUserNode, "email", installConfig.SuperUser.Email);
                AppendNewXmlNode(ref installTemplate, ref superUserNode, "updatepassword", "false");
            }

            //Set Folder Mappings Settings            
            if (!string.IsNullOrEmpty(installConfig.FolderMappingsSettings))
            {
                XmlNode folderMappingsNode = installTemplate.SelectSingleNode("//dotnetnuke/"+FolderMappingsConfigController.Instance.ConfigNode);

                if (folderMappingsNode == null)
                {
                    folderMappingsNode = AppendNewXmlNode(ref installTemplate, ref dotnetnukeNode, FolderMappingsConfigController.Instance.ConfigNode, installConfig.FolderMappingsSettings);
                }

                folderMappingsNode.InnerText = installConfig.FolderMappingsSettings;
            }

            //Set Portals
            if (installConfig.Portals != null && installConfig.Portals.Count > 0)
            {
                XmlNode portalsNode = installTemplate.SelectSingleNode("//dotnetnuke/portals");
                if (portalsNode == null)
                {
                    portalsNode = AppendNewXmlNode(ref installTemplate, ref dotnetnukeNode, "portals", installConfig.Version);
                }
                else
                {
                    portalsNode.RemoveAll();
                }


                foreach (PortalConfig portalConfig in installConfig.Portals)
                {
                    XmlNode portalNode = AppendNewXmlNode(ref installTemplate, ref portalsNode, "portal", null);
                    XmlNode administratorNode = AppendNewXmlNode(ref installTemplate, ref portalNode, "administrator", null);
                    XmlNode portalAliasesNode = AppendNewXmlNode(ref installTemplate, ref portalNode, "portalaliases", null);
                    AppendNewXmlNode(ref installTemplate, ref portalNode, "portalname", portalConfig.PortalName);
                    AppendNewXmlNode(ref installTemplate, ref administratorNode, "firstname", portalConfig.AdminFirstName);
                    AppendNewXmlNode(ref installTemplate, ref administratorNode, "lastname", portalConfig.AdminLastName);
                    AppendNewXmlNode(ref installTemplate, ref administratorNode, "username", portalConfig.AdminUserName);
                    AppendNewXmlNode(ref installTemplate, ref administratorNode, "password", portalConfig.AdminPassword);
                    AppendNewXmlNode(ref installTemplate, ref administratorNode, "email", portalConfig.AdminEmail);
                    AppendNewXmlNode(ref installTemplate, ref portalNode, "description", portalConfig.Description);
                    AppendNewXmlNode(ref installTemplate, ref portalNode, "keywords", portalConfig.Keywords);
                    AppendNewXmlNode(ref installTemplate, ref portalNode, "templatefile", portalConfig.TemplateFileName);
                    AppendNewXmlNode(ref installTemplate, ref portalNode, "ischild", portalConfig.IsChild.ToString().ToLower());
                    AppendNewXmlNode(ref installTemplate, ref portalNode, "homedirectory", portalConfig.HomeDirectory);

                    foreach (string portalAliase in portalConfig.PortAliases)
                    {
                        AppendNewXmlNode(ref installTemplate, ref portalAliasesNode, "portalalias", portalAliase);
                    }
                }
            }

            //Set the settings
            if (installConfig.Settings != null && installConfig.Settings.Count > 0)
            {
                XmlNode settingsNode = installTemplate.SelectSingleNode("//dotnetnuke/settings");
                if (settingsNode == null)
                {
                    settingsNode = AppendNewXmlNode(ref installTemplate, ref dotnetnukeNode, "settings", null);
                }
                else
                {
                    settingsNode.RemoveAll();
                }

                foreach (HostSettingConfig setting in installConfig.Settings)
                {
                    XmlNode settingNode = AppendNewXmlNode(ref installTemplate, ref settingsNode, setting.Name, setting.Value);
                    if (setting.IsSecure)
                    {
                        XmlAttribute attribute = installTemplate.CreateAttribute("Secure");
                        attribute.Value = "true";
                        settingNode.Attributes.Append(attribute);
                    }
                }
            }

            //Set Connection
            if (installConfig.Connection != null)
            {
                XmlNode connectionNode = installTemplate.SelectSingleNode("//dotnetnuke/connection");
                if (connectionNode == null)
                {
                    connectionNode = AppendNewXmlNode(ref installTemplate, ref dotnetnukeNode, "connection", null);
                }
                else
                {
                    connectionNode.RemoveAll();
                }

                AppendNewXmlNode(ref installTemplate, ref connectionNode, "server", installConfig.Connection.Server);
                AppendNewXmlNode(ref installTemplate, ref connectionNode, "database", installConfig.Connection.Database);
                AppendNewXmlNode(ref installTemplate, ref connectionNode, "file", installConfig.Connection.File);
                AppendNewXmlNode(ref installTemplate, ref connectionNode, "integrated", installConfig.Connection.Integrated.ToString().ToLower());
                AppendNewXmlNode(ref installTemplate, ref connectionNode, "user", installConfig.Connection.User);
                AppendNewXmlNode(ref installTemplate, ref connectionNode, "password", installConfig.Connection.Password);
                AppendNewXmlNode(ref installTemplate, ref connectionNode, "runasdbowner", installConfig.Connection.RunAsDbowner.ToString().ToLower());
                AppendNewXmlNode(ref installTemplate, ref connectionNode, "qualifier", installConfig.Connection.Qualifier);
                AppendNewXmlNode(ref installTemplate, ref connectionNode, "upgradeconnectionstring", installConfig.Connection.UpgradeConnectionString);
            }

            Upgrade.SetInstallTemplate(installTemplate);
        }
コード例 #3
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Page_Init runs when the Page is initialised
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <history>
 /// 	[cnurse]	02/14/2007	Created
 /// </history>
 /// -----------------------------------------------------------------------------
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     //if previous config deleted create new empty one
     string installConfig = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Install", "DotNetNuke.install.config");
     if (!File.Exists(installConfig))
     {
         File.Copy(installConfig + ".resources", installConfig);
     }
     GetInstallerLocales();
     if (!Page.IsPostBack || _installConfig == null)
     {
         _installConfig = InstallController.Instance.GetInstallConfig();
         _connectionConfig = _installConfig.Connection;
     }
 }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        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");
        }
コード例 #6
0
        /// <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);
        }