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; } } } } }
/// <summary> /// The cmdAdd_Click runs when the Add Button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// </remarks> /// <history> /// [cnurse] 16/9/2004 Updated for localization, Help and 508 /// </history> protected void cmdAdd_Click( object sender, EventArgs e ) { try { string strFileName; string strExtension; string strMessage = ""; HttpPostedFile postedFile = cmdBrowse.PostedFile; //Get localized Strings string strInvalid = Localization.GetString( "InvalidExt", this.LocalResourceFile ); strFileName = Path.GetFileName( postedFile.FileName ); strExtension = Path.GetExtension( strFileName ); if( !String.IsNullOrEmpty( postedFile.FileName ) ) { switch( FileType ) { case UploadType.File: // content files strMessage += FileSystemUtils.UploadFile( RootFolder + ddlFolders.SelectedItem.Value.Replace( "/", "\\" ), postedFile, chkUnzip.Checked ); break; case UploadType.Skin: // skin package if( strExtension.ToLower() == ".zip" ) { //SkinController objSkins = new SkinController(); Label objLbl = new Label(); objLbl.CssClass = "Normal"; objLbl.Text = SkinController.UploadSkin( RootFolder, SkinInfo.RootSkin, Path.GetFileNameWithoutExtension( postedFile.FileName ), postedFile.InputStream ); phPaLogs.Controls.Add( objLbl ); } else { strMessage += strInvalid + " " + FileTypeName + " " + strFileName; } break; case UploadType.Container: // container package if( strExtension.ToLower() == ".zip" ) { //SkinController objSkins = new SkinController(); Label objLbl = new Label(); objLbl.CssClass = "Normal"; objLbl.Text = SkinController.UploadSkin( RootFolder, SkinInfo.RootContainer, Path.GetFileNameWithoutExtension( postedFile.FileName ), postedFile.InputStream ); phPaLogs.Controls.Add( objLbl ); } else { strMessage += strInvalid + " " + FileTypeName + " " + strFileName; } break; case UploadType.Module: // custom module if( strExtension.ToLower() == ".zip" ) { phPaLogs.Visible = true; PaInstaller pa = new PaInstaller( postedFile.InputStream, Request.MapPath( "." ) ); pa.Install(); phPaLogs.Controls.Add( pa.InstallerInfo.Log.GetLogsTable() ); } else { strMessage += strInvalid + " " + FileTypeName + " " + strFileName; } break; case UploadType.LanguagePack: if( strExtension.ToLower() == ".zip" ) { LocaleFilePackReader objLangPack = new LocaleFilePackReader(); phPaLogs.Controls.Add( objLangPack.Install( postedFile.InputStream ).GetLogsTable() ); } else { strMessage += strInvalid + " " + FileTypeName + " " + strFileName; } break; } } if( phPaLogs.Controls.Count > 0 ) { tblLogs.Visible = true; } else if( strMessage == "" ) { Response.Redirect( ReturnURL(), true ); } else { lblMessage.Text = strMessage; } } catch( Exception exc ) //Module failed to load { Exceptions.ProcessModuleLoadException( this, exc ); } }