Exemplo n.º 1
0
        /// <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();
                    }
                }
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
    /// <summary>
    /// Binds the folders.
    /// </summary>
    private void BindFolders()
    {
        List <JsonTreeNode> nodes = new List <JsonTreeNode>();

        using (IDataReader reader = FileTreeItem.GetItemById(FileTreeItem.GetRoot(SiteId)))
        {
            if (reader.Read())
            {
                string       nodeId = MakeNodeId("folder-" + reader["PageId"].ToString());
                JsonTreeNode node   = JsonTreeNode.CreateNode(nodeId, reader["PageId"].ToString(), "/", "Content", "Folder-List", String.Format("folderid={0}&siteid={1}", reader["PageId"].ToString(), SiteId.ToString()), TreeListType.Folders.ToString());
                nodes.Add(node);
                BindFolders(node, (int)reader["PageId"]);
            }
            reader.Close();
        }

        WriteArray(nodes);
    }