예제 #1
0
        public void DeleteSection(Section section, ModuleBase module)
        {
            // Delete module content if the connected module allows this
            module.DeleteModuleContent();

            // Remove connections
            this._commonDao.DeleteObject(section);
            // Invalidate cache
            this._commonDao.RemoveCollectionFromCache("Cuyahoga.Core.Domain.Node.Sections");
        }
예제 #2
0
        private void rptSections_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Delete" || e.CommandName == "Detach")
            {
                int     sectionId = Int32.Parse(e.CommandArgument.ToString());
                Section section   = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId);

                if (e.CommandName == "Delete")
                {
                    section.Node = ActiveNode;
                    try
                    {
                        // First tell the module to remove its content.
                        ModuleBase module = ModuleLoader.GetModuleFromSection(section);
                        module.DeleteModuleContent();
                        // Make sure there is no gap in the section indexes.
                        // ABUSE: this method was not designed for this, but works fine.
                        section.ChangeAndUpdatePositionsAfterPlaceholderChange(section.PlaceholderId, section.Position,
                                                                               false);
                        // Now delete the Section.
                        ActiveNode.Sections.Remove(section);
                        CoreRepository.DeleteObject(section);
                    }
                    catch (Exception ex)
                    {
                        ShowError(ex.Message);
                        log.Error(String.Format("Error deleting section : {0}.", section.Id), ex);
                    }
                }
                if (e.CommandName == "Detach")
                {
                    try
                    {
                        // Make sure there is no gap in the section indexes.
                        // ABUSE: this method was not designed for this, but works fine.
                        section.ChangeAndUpdatePositionsAfterPlaceholderChange(section.PlaceholderId, section.Position,
                                                                               false);
                        // Now detach the Section.
                        ActiveNode.Sections.Remove(section);
                        section.Node          = null;
                        section.PlaceholderId = null;
                        CoreRepository.UpdateObject(section);
                        // Update search index to make sure the content of detached sections doesn't
                        // show up in a search.
                        SearchHelper.UpdateIndexFromSection(section);
                    }
                    catch (Exception ex)
                    {
                        ShowError(ex.Message);
                        log.Error(String.Format("Error detaching section : {0}.", section.Id), ex);
                    }
                }
                BindSections();
            }
        }
예제 #3
0
        private void rptSections_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int     sectionId = Int32.Parse(e.CommandArgument.ToString());
            Section section   = (Section)base.CoreRepository.GetObjectById(typeof(Section), sectionId);

            if (e.CommandName == "Delete")
            {
                try
                {
                    // First tell the module to remove its content.
                    ModuleBase module = this.ModuleLoader.GetModuleFromSection(section);
                    module.DeleteModuleContent();

                    // Remove from all template sections
                    IList templates = this.CoreRepository.GetTemplatesBySection(section);
                    foreach (Template template in templates)
                    {
                        string attachedPlaceholderId = null;
                        foreach (DictionaryEntry entry in template.Sections)
                        {
                            if (entry.Value == section)
                            {
                                attachedPlaceholderId = entry.Key.ToString();
                                break;
                            }
                        }
                        template.Sections.Remove(attachedPlaceholderId);
                        base.CoreRepository.UpdateObject(template);
                    }

                    // Now delete the Section.
                    base.CoreRepository.DeleteObject(section);
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                    log.Error(String.Format("Lỗi khi xóa vùng phân hệ : {0}.", section.Id.ToString()), ex);
                }
            }
            BindSections();
        }