/// ----------------------------------------------------------------------------- /// <summary> /// The Rollback method rolls back the package installation /// </summary> /// <history> /// [cnurse] 07/31/2007 created /// </history> /// ----------------------------------------------------------------------------- public override void Rollback() { for (int index = 0; index <= _componentInstallers.Count - 1; index++) { ComponentInstallerBase compInstaller = _componentInstallers.Values[index]; if (compInstaller.Version > Package.InstalledVersion && compInstaller.Completed) { Log.AddInfo(Util.COMPONENT_RollingBack + " - " + compInstaller.Type); compInstaller.Rollback(); Log.AddInfo(Util.COMPONENT_RolledBack + " - " + compInstaller.Type); } } //If Previously Installed Package exists then we need to update the DataStore with this if (_installedPackage == null) { //No Previously Installed Package - Delete newly added Package PackageController.Instance.DeleteExtensionPackage(Package); } else { //Previously Installed Package - Rollback to Previously Installed PackageController.Instance.SaveExtensionPackage(_installedPackage); } }
/// ----------------------------------------------------------------------------- /// <summary> /// The Uninstall method uninstalls the components of the package /// </summary> /// <history> /// [cnurse] 07/25/2007 created /// </history> /// ----------------------------------------------------------------------------- public override void UnInstall() { //Iterate through all the Components for (int index = 0; index <= _componentInstallers.Count - 1; index++) { ComponentInstallerBase compInstaller = _componentInstallers.Values[index]; var fileInstaller = compInstaller as FileInstaller; if (fileInstaller != null) { fileInstaller.DeleteFiles = DeleteFiles; } Log.ResetFlags(); Log.AddInfo(Util.UNINSTALL_StartComp + " - " + compInstaller.Type); compInstaller.UnInstall(); Log.AddInfo(Util.COMPONENT_UnInstalled + " - " + compInstaller.Type); if (Log.Valid) { Log.AddInfo(Util.UNINSTALL_SuccessComp + " - " + compInstaller.Type); } else { Log.AddWarning(Util.UNINSTALL_WarningsComp + " - " + compInstaller.Type); } } //Remove the Package information from the Data Store PackageController.Instance.DeleteExtensionPackage(Package); }
/// ----------------------------------------------------------------------------- /// <summary> /// The Commit method commits the package installation /// </summary> /// <history> /// [cnurse] 08/01/2007 created /// </history> /// ----------------------------------------------------------------------------- public override void Commit() { for (int index = 0; index <= _componentInstallers.Count - 1; index++) { ComponentInstallerBase compInstaller = _componentInstallers.Values[index]; if (compInstaller.Version >= Package.InstalledVersion && compInstaller.Completed) { compInstaller.Commit(); } } //Add Event Message if (_eventMessage != null && !String.IsNullOrEmpty(_eventMessage.Attributes["UpgradeVersionsList"])) { _eventMessage.Attributes.Set("desktopModuleID", Null.NullInteger.ToString()); EventQueueController.SendMessage(_eventMessage, "Application_Start"); } if (Log.Valid) { Log.AddInfo(Util.INSTALL_Committed); } else { Log.AddFailure(Util.INSTALL_Aborted); } Package.InstallerInfo.PackageID = Package.PackageID; }
/// ----------------------------------------------------------------------------- /// <summary> /// This Constructor creates a new PackageInstaller instance /// </summary> /// <param name="package">A PackageInfo instance</param> /// <history> /// [cnurse] 01/21/2008 created /// </history> /// ----------------------------------------------------------------------------- public PackageInstaller(PackageInfo package) { IsValid = true; DeleteFiles = Null.NullBoolean; Package = package; if (!string.IsNullOrEmpty(package.Manifest)) { //Create an XPathDocument from the Xml var doc = new XPathDocument(new StringReader(package.Manifest)); XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("package"); ReadComponents(nav); } else { ComponentInstallerBase installer = InstallerFactory.GetInstaller(package.PackageType); if (installer != null) { //Set package installer.Package = package; //Set type installer.Type = package.PackageType; _componentInstallers.Add(0, installer); } } }
/// ----------------------------------------------------------------------------- /// <summary> /// The GetInstaller method instantiates the relevant Component Installer /// </summary> /// <param name="manifestNav">The manifest (XPathNavigator) for the component</param> /// <param name="package">The associated PackageInfo instance</param> /// <history> /// [cnurse] 07/25/2007 created /// </history> /// ----------------------------------------------------------------------------- public static ComponentInstallerBase GetInstaller(XPathNavigator manifestNav, PackageInfo package) { string installerType = Util.ReadAttribute(manifestNav, "type"); string componentVersion = Util.ReadAttribute(manifestNav, "version"); ComponentInstallerBase installer = GetInstaller(installerType); if (installer != null) { //Set package installer.Package = package; //Set type installer.Type = installerType; if (!string.IsNullOrEmpty(componentVersion)) { installer.Version = new Version(componentVersion); } else { installer.Version = package.Version; } //Read Manifest if (package.InstallerInfo.InstallMode != InstallMode.ManifestOnly || installer.SupportsManifestOnlyInstall) { installer.ReadManifest(manifestNav); } } return(installer); }
/// ----------------------------------------------------------------------------- /// <summary> /// The Install method installs the components of the package. /// </summary> /// ----------------------------------------------------------------------------- public override void Install() { bool isCompleted = true; try { // Save the Package Information if (this._installedPackage != null) { this.Package.PackageID = this._installedPackage.PackageID; } // Save Package PackageController.Instance.SaveExtensionPackage(this.Package); // Iterate through all the Components for (int index = 0; index <= this._componentInstallers.Count - 1; index++) { ComponentInstallerBase compInstaller = this._componentInstallers.Values[index]; if ((this._installedPackage == null) || (compInstaller.Version > this.Package.InstalledVersion) || this.Package.InstallerInfo.RepairInstall) { this.Log.AddInfo(Util.INSTALL_Start + " - " + compInstaller.Type); compInstaller.Install(); if (compInstaller.Completed) { if (compInstaller.Skipped) { this.Log.AddInfo(Util.COMPONENT_Skipped + " - " + compInstaller.Type); } else { this.Log.AddInfo(Util.COMPONENT_Installed + " - " + compInstaller.Type); } } else { this.Log.AddFailure(Util.INSTALL_Failed + " - " + compInstaller.Type); isCompleted = false; break; } } } } catch (Exception ex) { this.Log.AddFailure(Util.INSTALL_Aborted + " - " + this.Package.Name + ":" + ex.Message); } if (isCompleted) { // All components successfully installed so Commit any pending changes this.Commit(); } else { // There has been a failure so Rollback this.Rollback(); } }
/// ----------------------------------------------------------------------------- /// <summary> /// The ReadComponents method reads the components node of the manifest file. /// </summary> /// ----------------------------------------------------------------------------- private void ReadComponents(XPathNavigator manifestNav) { foreach (XPathNavigator componentNav in manifestNav.CreateNavigator().Select("components/component")) { // Set default order to next value (ie the same as the size of the collection) int order = this._componentInstallers.Count; string type = componentNav.GetAttribute("type", string.Empty); if (this.InstallMode == InstallMode.Install) { string installOrder = componentNav.GetAttribute("installOrder", string.Empty); if (!string.IsNullOrEmpty(installOrder)) { order = int.Parse(installOrder); } } else { string unInstallOrder = componentNav.GetAttribute("unInstallOrder", string.Empty); if (!string.IsNullOrEmpty(unInstallOrder)) { order = int.Parse(unInstallOrder); } } if (this.Package.InstallerInfo != null) { this.Log.AddInfo(Util.DNN_ReadingComponent + " - " + type); } ComponentInstallerBase installer = InstallerFactory.GetInstaller(componentNav, this.Package); if (installer == null) { this.Log.AddFailure(Util.EXCEPTION_InstallerCreate); } else { this._componentInstallers.Add(order, installer); this.Package.InstallerInfo.AllowableFiles += ", " + installer.AllowableFiles; } } }
/// ----------------------------------------------------------------------------- /// <summary> /// The Commit method commits the package installation /// </summary> /// <history> /// [cnurse] 08/01/2007 created /// </history> /// ----------------------------------------------------------------------------- public override void Commit() { for (int index = 0; index <= _componentInstallers.Count - 1; index++) { ComponentInstallerBase compInstaller = _componentInstallers.Values[index]; if (compInstaller.Version >= Package.InstalledVersion && compInstaller.Completed) { compInstaller.Commit(); } } if (Log.Valid) { Log.AddInfo(Util.INSTALL_Committed); } else { Log.AddFailure(Util.INSTALL_Aborted); } Package.InstallerInfo.PackageID = Package.PackageID; }
/// ----------------------------------------------------------------------------- /// <summary> /// The GetInstaller method instantiates the relevant Component Installer /// </summary> /// <param name="installerType">The type of Installer</param> /// <history> /// [cnurse] 07/25/2007 created /// </history> /// ----------------------------------------------------------------------------- public static ComponentInstallerBase GetInstaller(string installerType) { ComponentInstallerBase installer = null; switch (installerType) { case "File": installer = new FileInstaller(); break; case "Assembly": installer = new AssemblyInstaller(); break; case "ResourceFile": installer = new ResourceFileInstaller(); break; case "AuthenticationSystem": case "Auth_System": installer = new AuthenticationInstaller(); break; case "DashboardControl": installer = new DashboardInstaller(); break; case "Script": installer = new ScriptInstaller(); break; case "Config": installer = new ConfigInstaller(); break; case "Cleanup": installer = new CleanupInstaller(); break; case "Skin": installer = new SkinInstaller(); break; case "Container": installer = new ContainerInstaller(); break; case "Module": installer = new ModuleInstaller(); break; case "CoreLanguage": installer = new LanguageInstaller(LanguagePackType.Core); break; case "ExtensionLanguage": installer = new LanguageInstaller(LanguagePackType.Extension); break; case "Provider": installer = new ProviderInstaller(); break; case "SkinObject": installer = new SkinControlInstaller(); break; case "UrlProvider": installer = new UrlProviderInstaller(); break; case "Widget": installer = new WidgetInstaller(); break; case "JavaScript_Library": installer = new JavaScriptLibraryInstaller(); break; case "JavaScriptFile": installer = new JavaScriptFileInstaller(); break; default: //Installer type is defined in the List var listController = new ListController(); ListEntryInfo entry = listController.GetListEntryInfo("Installer", installerType); if (entry != null && !string.IsNullOrEmpty(entry.Text)) { //The class for the Installer is specified in the Text property installer = (ComponentInstallerBase)Reflection.CreateObject(entry.Text, "Installer_" + entry.Value); } break; } return(installer); }