/// <summary> /// Runs Post install actions such as clearning any necessary cache, reloading the correct tree nodes, etc... /// </summary> /// <param name="packageId"></param> /// <param name="dir"></param> private void PerformPostInstallCleanup(int packageId, string dir) { BasePage.Current.ClientTools.ReloadActionNode(true, true); _installer.InstallCleanUp(packageId, dir); //clear the tree cache ClientTools.ClearClientTreeCache().RefreshTree("packager"); TreeDefinitionCollection.Instance.ReRegisterTrees(); BizLogicAction.ReRegisterActionsAndHandlers(); }
/// <summary> /// Runs Post install actions such as clearning any necessary cache, reloading the correct tree nodes, etc... /// </summary> /// <param name="packageId"></param> /// <param name="dir"></param> private void PerformPostInstallCleanup(int packageId, string dir) { _installer.InstallCleanUp(packageId, dir); // Update ClientDependency version var clientDependencyConfig = new Umbraco.Core.Configuration.ClientDependencyConfiguration(LoggerResolver.Current.Logger); var clientDependencyUpdated = clientDependencyConfig.IncreaseVersionNumber(); //clear the tree cache - we'll do this here even though the browser will reload, but just in case it doesn't can't hurt. ClientTools.ClearClientTreeCache().RefreshTree("packager"); TreeDefinitionCollection.Instance.ReRegisterTrees(); BizLogicAction.ReRegisterActionsAndHandlers(); }
protected void confirmUnInstall(object sender, EventArgs e) { bool refreshCache = false; //Uninstall Stylesheets foreach (ListItem li in stylesheets.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { StyleSheet s = new StyleSheet(nId); if (s != null) { s.delete(); pack.Data.Stylesheets.Remove(nId.ToString()); } } } } //Uninstall templates foreach (ListItem li in templates.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { Template s = new Template(nId); if (s != null) { s.RemoveAllReferences(); s.delete(); pack.Data.Templates.Remove(nId.ToString()); } } } } //Uninstall macros foreach (ListItem li in macros.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { Macro s = new Macro(nId); if (s != null && !String.IsNullOrEmpty(s.Name)) { // remove from cache runtimeMacro.GetMacro(s.Id).removeFromCache(); s.Delete(); } pack.Data.Macros.Remove(nId.ToString()); } } } //Remove Document types foreach (ListItem li in documentTypes.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { DocumentType s = new DocumentType(nId); if (s != null) { s.delete(); pack.Data.Documenttypes.Remove(nId.ToString()); // refresh content cache when document types are removed refreshCache = true; } } } } //Remove Dictionary items foreach (ListItem li in dictionaryItems.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { cms.businesslogic.Dictionary.DictionaryItem di = new global::umbraco.cms.businesslogic.Dictionary.DictionaryItem(nId); if (di != null) { di.delete(); pack.Data.DictionaryItems.Remove(nId.ToString()); } } } } //Remove Data types foreach (ListItem li in dataTypes.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { cms.businesslogic.datatype.DataTypeDefinition dtd = new global::umbraco.cms.businesslogic.datatype.DataTypeDefinition(nId); if (dtd != null) { dtd.delete(); pack.Data.DataTypes.Remove(nId.ToString()); } } } } pack.Save(); if (!isManifestEmpty()) { Response.Redirect(Request.RawUrl); } else { BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, "executing undo actions"); // uninstall actions try { System.Xml.XmlDocument actionsXml = new System.Xml.XmlDocument(); actionsXml.LoadXml("<Actions>" + pack.Data.Actions + "</Actions>"); BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, actionsXml.OuterXml); foreach (XmlNode n in actionsXml.DocumentElement.SelectNodes("//Action")) { try { cms.businesslogic.packager.PackageAction.UndoPackageAction(pack.Data.Name, n.Attributes["alias"].Value, n); } catch (Exception ex) { BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } } } catch (Exception ex) { BusinessLogic.Log.Add(global::umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } //moved remove of files here so custom package actions can still undo //Remove files foreach (ListItem li in files.Items) { if (li.Selected) { //here we need to try to find the file in question as most packages does not support the tilde char string file = IOHelper.FindFile(li.Value); string filePath = IOHelper.MapPath(file); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); pack.Data.Files.Remove(li.Value); } } } pack.Save(); pack.Delete(); packageUninstalled.Visible = true; installedPackagePanel.Visible = false; } // refresh cache if (refreshCache) { library.RefreshContent(); } //ensure that all tree's are refreshed after uninstall ClientTools.ClearClientTreeCache() .RefreshTree(); TreeDefinitionCollection.Instance.ReRegisterTrees(); BizLogicAction.ReRegisterActionsAndHandlers(); }
private void processInstall(string currentStep) { string dir = helper.Request("dir"); int packageId = 0; int.TryParse(helper.Request("pId"), out packageId); //first load in the config from the temporary directory //this will ensure that the installer have access to all the new files and the package manifest p.LoadConfig(dir); switch (currentStep) { case "businesslogic": p.InstallBusinessLogic(packageId, dir); //making sure that publishing actions performed from the cms layer gets pushed to the presentation library.RefreshContent(); if (p.Control != null && p.Control != "") { Response.Redirect("installer.aspx?installing=customInstaller&dir=" + dir + "&pId=" + packageId.ToString()); } else { Response.Redirect("installer.aspx?installing=finished&dir=" + dir + "&pId=" + packageId.ToString()); } break; case "customInstaller": if (p.Control != null && p.Control != "") { hideAllPanes(); configControl = new System.Web.UI.UserControl().LoadControl(SystemDirectories.Root + p.Control); configControl.ID = "packagerConfigControl"; pane_optional.Controls.Add(configControl); pane_optional.Visible = true; } else { hideAllPanes(); pane_success.Visible = true; BasePage.Current.ClientTools.ReloadActionNode(true, true); } break; case "finished": hideAllPanes(); string url = p.Url; string packageViewUrl = "installedPackage.aspx?id=" + packageId.ToString(); bt_viewInstalledPackage.OnClientClick = "document.location = '" + packageViewUrl + "'; return false;"; if (!string.IsNullOrEmpty(url)) { lit_authorUrl.Text = " <em>" + ui.Text("or") + "</em> <a href='" + url + "' target=\"_blank\">" + ui.Text("viewPackageWebsite") + "</a>"; } pane_success.Visible = true; BasePage.Current.ClientTools.ReloadActionNode(true, true); p.InstallCleanUp(packageId, dir); //clear the tree cache ClientTools.ClearClientTreeCache() .RefreshTree("packager"); TreeDefinitionCollection.Instance.ReRegisterTrees(); BizLogicAction.ReRegisterActionsAndHandlers(); break; default: break; } }
protected void confirmUnInstall(object sender, EventArgs e) { var refreshCache = false; //Uninstall Stylesheets foreach (ListItem li in stylesheets.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { var s = new StyleSheet(nId); s.delete(); _pack.Data.Stylesheets.Remove(nId.ToString()); } } } //Uninstall templates foreach (ListItem li in templates.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { var s = new Template(nId); s.RemoveAllReferences(); s.delete(); _pack.Data.Templates.Remove(nId.ToString()); } } } //Uninstall macros foreach (ListItem li in macros.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { var s = new Macro(nId); if (!string.IsNullOrEmpty(s.Name)) { s.Delete(); } _pack.Data.Macros.Remove(nId.ToString()); } } } //Remove Document Types var contentTypes = new List <IContentType>(); var contentTypeService = ApplicationContext.Current.Services.ContentTypeService; foreach (ListItem li in documentTypes.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { var contentType = contentTypeService.GetContentType(nId); if (contentType != null) { contentTypes.Add(contentType); _pack.Data.Documenttypes.Remove(nId.ToString(CultureInfo.InvariantCulture)); // refresh content cache when document types are removed refreshCache = true; } } } } //Order the DocumentTypes before removing them if (contentTypes.Any()) { var orderedTypes = (from contentType in contentTypes orderby contentType.ParentId descending, contentType.Id descending select contentType); foreach (var contentType in orderedTypes) { contentTypeService.Delete(contentType); } } //Remove Dictionary items foreach (ListItem li in dictionaryItems.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { var di = new cms.businesslogic.Dictionary.DictionaryItem(nId); di.delete(); _pack.Data.DictionaryItems.Remove(nId.ToString()); } } } //Remove Data types foreach (ListItem li in dataTypes.Items) { if (li.Selected) { int nId; if (int.TryParse(li.Value, out nId)) { var dtd = new cms.businesslogic.datatype.DataTypeDefinition(nId); dtd.delete(); _pack.Data.DataTypes.Remove(nId.ToString()); } } } _pack.Save(); if (!IsManifestEmpty()) { Response.Redirect(Request.RawUrl); } else { // uninstall actions try { var actionsXml = new XmlDocument(); actionsXml.LoadXml("<Actions>" + _pack.Data.Actions + "</Actions>"); LogHelper.Debug <installedPackage>("executing undo actions: {0}", () => actionsXml.OuterXml); foreach (XmlNode n in actionsXml.DocumentElement.SelectNodes("//Action")) { try { cms.businesslogic.packager.PackageAction.UndoPackageAction(_pack.Data.Name, n.Attributes["alias"].Value, n); } catch (Exception ex) { LogHelper.Error <installedPackage>("An error occurred running undo actions", ex); } } } catch (Exception ex) { LogHelper.Error <installedPackage>("An error occurred running undo actions", ex); } //moved remove of files here so custom package actions can still undo //Remove files foreach (ListItem li in files.Items) { if (li.Selected) { //here we need to try to find the file in question as most packages does not support the tilde char var file = IOHelper.FindFile(li.Value); var filePath = IOHelper.MapPath(file); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); _pack.Data.Files.Remove(li.Value); } } } _pack.Save(); _pack.Delete(); packageUninstalled.Visible = true; installedPackagePanel.Visible = false; } // refresh cache if (refreshCache) { library.RefreshContent(); } //ensure that all tree's are refreshed after uninstall ClientTools.ClearClientTreeCache() .RefreshTree(); TreeDefinitionCollection.Instance.ReRegisterTrees(); BizLogicAction.ReRegisterActionsAndHandlers(); }