Beispiel #1
0
        private void AddPortal()
        {
            //Start Timer
            Upgrade.StartTimer();

            //Write out Header
            HtmlUtils.WriteHeader(Response, "addPortal");

            Response.Write("<h2>Add Portal Status Report</h2>");
            Response.Flush();

            // install new portal(s)
            string strNewFile = Globals.ApplicationMapPath + "\\Install\\Portal\\Portals.resources";

            if (File.Exists(strNewFile))
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlNodeList nodes;
                int         intPortalId;
                xmlDoc.Load(strNewFile);

                // parse portal(s) if available
                nodes = xmlDoc.SelectNodes("//dotnetnuke/portals/portal");
                foreach (XmlNode node in nodes)
                {
                    if (node != null)
                    {
                        intPortalId = Upgrade.AddPortal(node, true, 0);
                    }
                }

                // delete the file
                try
                {
                    File.SetAttributes(strNewFile, FileAttributes.Normal);
                    File.Delete(strNewFile);
                }
                catch
                {
                    // error removing the file
                }

                Response.Write("<h2>Installation Complete</h2>");
                Response.Write("<br><br><h2><a href='../Default.aspx'>Click Here To Access Your Portal</a></h2><br><br>");
                Response.Flush();
            }

            //Write out Footer
            HtmlUtils.WriteFooter(Response);
        }
Beispiel #2
0
        public void Install(bool status, int indent, string type)
        {
            string InstallPath = Globals.ApplicationMapPath + "\\Install";

            if (Directory.Exists(InstallPath))
            {
                string[] folders = Directory.GetDirectories(InstallPath);
                foreach (string folder in folders)
                {
                    string[] files = Directory.GetFiles(folder);
                    foreach (string file in files)
                    {
                        switch (type.ToLower())
                        {
                        case "modules":

                            // install custom module
                            InstallModules(file, status, indent);
                            break;

                        default:

                            // install custom module
                            InstallModules(file, status, indent);

                            // install skin
                            if (file.ToLower().IndexOf("\\skin\\") != -1)
                            {
                                // check if valid skin
                                if (Path.GetExtension(file.ToLower()) == ".zip")
                                {
                                    if (status)
                                    {
                                        HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Installing Skin File " + file + ":<br>");
                                    }
                                    SkinController.UploadSkin(Globals.HostMapPath, SkinInfo.RootSkin, Path.GetFileNameWithoutExtension(file), file);
                                    // delete file
                                    DeleteFile(file);
                                }
                            }

                            // install container
                            if (file.ToLower().IndexOf("\\container\\") != -1)
                            {
                                // check if valid container
                                if (Path.GetExtension(file.ToLower()) == ".zip")
                                {
                                    if (status)
                                    {
                                        HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Installing Container File " + file + ":<br>");
                                    }
                                    SkinController.UploadSkin(Globals.HostMapPath, SkinInfo.RootContainer, Path.GetFileNameWithoutExtension(file), file);
                                    // delete file
                                    DeleteFile(file);
                                }
                            }

                            // install language pack
                            if (file.ToLower().IndexOf("\\language\\") != -1)
                            {
                                // check if valid language pack
                                if (Path.GetExtension(file.ToLower()) == ".zip")
                                {
                                    if (status)
                                    {
                                        HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Installing Language File " + file + ":<br>");
                                    }
                                    LocaleFilePackReader objLocaleFilePackReader = new LocaleFilePackReader();
                                    objLocaleFilePackReader.Install(file);
                                    // delete file
                                    DeleteFile(file);
                                }
                            }

                            // install template
                            if (file.ToLower().IndexOf("\\template\\") != -1)
                            {
                                // check if valid template file ( .template or .template.resources )
                                if (file.ToLower().IndexOf(".template") != -1)
                                {
                                    if (status)
                                    {
                                        HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Installing Template " + file + ":<br>");
                                    }
                                    string strNewFile = Globals.HostMapPath + "\\" + Path.GetFileName(file);
                                    if (File.Exists(strNewFile))
                                    {
                                        File.Delete(strNewFile);
                                    }
                                    File.Move(file, strNewFile);
                                }
                            }

                            //Install Portal(s)
                            if (file.ToLower().IndexOf("\\portal\\") != -1)
                            {
                                //Check if valid portals file
                                if (file.ToLower().IndexOf(".resources") != -1)
                                {
                                    XmlDocument xmlDoc = new XmlDocument();
                                    XmlNodeList nodes;
                                    xmlDoc.Load(file);

                                    // parse portal(s) if available
                                    nodes = xmlDoc.SelectNodes("//dotnetnuke/portals/portal");
                                    foreach (XmlNode node in nodes)
                                    {
                                        if (node != null)
                                        {
                                            if (status)
                                            {
                                                HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Installing Portals:<br>");
                                            }
                                            int portalId = Upgrade.AddPortal(node, true, indent);
                                            if (portalId > -1)
                                            {
                                                HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent + 2, "Successfully Installed Portal " + portalId + ":<br>");
                                            }
                                            else
                                            {
                                                HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent + 2, "Portal failed to install:<br>");
                                            }
                                        }
                                    }
                                    // delete file
                                    DeleteFile(file);
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }