public void delete(int id, string username, string password) { Authenticate(username, password); if (id == 0) throw new Exception("ID must be specifed when updating"); cms.businesslogic.template.Template template = new cms.businesslogic.template.Template(id); template.delete(); }
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(); }