/// <summary> /// Processes the delete command. /// </summary> /// <param name="items">The items.</param> void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { string id = keys[0]; // delete selected sites Guid siteId = new Guid(id); using (TransactionScope scope = new TransactionScope()) { SiteDto dto = CMSContext.Current.GetSiteDto(siteId, true); if (dto.Site.Rows.Count > 0) { // delete menus MenuDto menuDto = MenuManager.GetMenuDto(siteId); if (menuDto.Menu.Rows.Count > 0) { foreach (MenuDto.MenuRow menuRow in menuDto.Menu.Rows) { menuRow.Delete(); } } if (menuDto.HasChanges()) { MenuManager.SaveMenuDto(menuDto); } // delete folders and pages int rootId = FileTreeItem.GetRoot(siteId); FileTreeItem.DeleteFileItem(rootId); //delete site dto.Site[0].Delete(); CMSContext.Current.SaveSite(dto); } scope.Complete(); } } } }
public void ContentSystem_ImportExportSite() { Guid[] siteIDs; Guid applicationId = AppContext.Current.ApplicationId; ImportExportHelper importExportHelper = new ImportExportHelper(); //import data using (FileStream stream = File.Open("SiteExport-B2C.xml", FileMode.Open)) { siteIDs = importExportHelper.ImportSite(stream, applicationId, Guid.Empty, false); } Guid siteId = siteIDs[0]; FileStream fs = new FileStream("Content_SiteExport.xml", FileMode.Create, FileAccess.ReadWrite); importExportHelper.ExportSite(siteId, fs); SiteDto siteDto = CMSContext.Current.GetSiteDto(siteId); // delete menus MenuDto menuDto = MenuManager.GetMenuDto(siteId); if (menuDto.Menu.Rows.Count > 0) { foreach (MenuDto.MenuRow menuRow in menuDto.Menu.Rows) { menuRow.Delete(); } } if (menuDto.HasChanges()) { MenuManager.SaveMenuDto(menuDto); } // delete folders and pages int rootId = FileTreeItem.GetRoot(siteId); FileTreeItem.DeleteFileItem(rootId); //delete site siteDto.Site[0].Delete(); CMSContext.Current.SaveSite(siteDto); }
/// <summary> /// Processes the delete command. /// </summary> /// <param name="items">The items.</param> void ProcessDeleteCommand(string[] items) { if (!ProfileContext.Current.CheckPermission("content:site:nav:mng:delete")) { throw new UnauthorizedAccessException("Current user does not have enough rights to access the requested operation."); } for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { int folderId = Int32.Parse(keys[0]); // delete selected sites FileTreeItem.DeleteFileItem(folderId); } } }