Esempio n. 1
0
        private void UpdateTabs(TemplateApplyingMode _objGenerateMode)
        {
            PortalDefinition _objPortal = PortalDefinition.Load();

            EditionTypeRow[] _arrAllEditionTypes = null;

            using (MainDB _objDB = new MainDB())
            {
                _arrAllEditionTypes = _objDB.EditionTypeCollection.GetAll();
            }

            if (_arrAllEditionTypes != null)
            {
                foreach (EditionTypeRow _objEdition in _arrAllEditionTypes)
                {
                    PortalDefinition.Tab _objCurrentEdition  = _objPortal.GetTab(_objEdition.EditionDisplayURL);
                    ArrayList            _arrTemplateColumns = _objPortal.CloneToTemplateTab(_objPortal.TemplateColumns) as ArrayList;
                    ReGenModuleID(ref _arrTemplateColumns);

                    if (_objCurrentEdition != null)
                    {
                        // Nếu cho phép cập nhật chuyên san thì cần xét thêm chuyên san phải khác với chuyên san mẫu
                        if (_objGenerateMode.EditionType && _objCurrentEdition.reference != _objPortal.TemplateReference)
                        {
                            _objCurrentEdition.Columns = _arrTemplateColumns;
                            _objCurrentEdition.title   = _objEdition.EditionName;
                        }
                        AddCategoryTab(_objPortal, _objCurrentEdition.tabs, _objEdition.EditionType_ID.ToString(), null, _objEdition.EditionDisplayURL, _objGenerateMode);
                    }
                    else
                    {
                        PortalDefinition.Tab      _objNewEditionTab = PortalDefinition.Tab.Create(_objEdition.EditionDisplayURL);
                        PortalDefinition.ViewRole _objViewRole      = new PortalDefinition.ViewRole();
                        _objViewRole.name = Config.EveryoneRoles;
                        _objNewEditionTab.roles.Add(_objViewRole);
                        _objNewEditionTab.Columns = _arrTemplateColumns;
                        _objPortal.tabs.Add(_objNewEditionTab);

                        AddCategoryTab(_objPortal, _objNewEditionTab.tabs, _objEdition.EditionType_ID.ToString(), null, _objEdition.EditionDisplayURL, _objGenerateMode);
                    }
                }
            }

            _objPortal.Save();
            Response.Redirect(Request.Url.PathAndQuery);
        }
Esempio n. 2
0
        protected void btnApplyTemplateToAllSubCategoryTab_Click(object sender, EventArgs e)
        {
            TemplateApplyingMode _objGenerateMode = new TemplateApplyingMode(false, false, true);

            UpdateTabs(_objGenerateMode);
        }
Esempio n. 3
0
        protected void btnApplyTemplateToAllEditionTab_Click(object sender, EventArgs e)
        {
            TemplateApplyingMode _objGenerateMode = new TemplateApplyingMode(true, false, false);

            UpdateTabs(_objGenerateMode);
        }
Esempio n. 4
0
        /// <summary>
        /// Thủ tục khởi tạo hoặc cập nhật một Tab chứa thông tin về một Edition, Category cha hoặc một Category con
        /// </summary>
        /// <param name="_objPortal">Đối tượng lưu cấu trúc Portal</param>
        /// <param name="_arrTabsCollection">Mảng chứa danh sách Tab ở mức đang xét</param>
        /// <param name="_strEditionTypeID">Mã tham chiếu đến chuyên san</param>
        /// <param name="_strParentCategoryID">Mã tham chiếu đến Category cha</param>
        /// <param name="_strParentCategoryDisplayURL">Chuỗi tham chiếu đến Tab của Category cha</param>
        private void AddCategoryTab(PortalDefinition _objPortal, ArrayList _arrTabsCollection, string _strEditionTypeID, string _strParentCategoryID, string _strParentCategoryDisplayURL, TemplateApplyingMode _objGenerateMode)
        {
            // Khai báo mảng lưu danh sách Category cần duyệt
            CategoryRow[] _arrCategories = null;
            using (MainDB _objDb = new MainDB())
            {
                if (_strEditionTypeID == null)
                {
                    // Nếu không có mã chuyên san thì lấy danh sách các Category cha
                    _arrCategories = _objDb.CategoryCollection.GetAsArray("Cat_ParentID " + (_strParentCategoryID == null ? " IS NULL" : (" = " + _strParentCategoryID)), "");
                }
                else
                {
                    // Nếu có mã chuyên san thì lấy danh sách các Category con
                    _arrCategories = _objDb.CategoryCollection.GetAsArray("EditionType_ID = " + _strEditionTypeID + " AND Cat_ParentID " + (_strParentCategoryID == null ? " IS NULL" : (" = " + _strParentCategoryID)), "");
                }
            }

            if (_arrCategories != null && _arrCategories.Length > 0)
            {
                // Duyệt danh sách Category có cần tạo Tab
                foreach (CategoryRow _objCategory in _arrCategories)
                {
                    // Khai báo chuỗi lưu mã tham chiếu đến Tab của Category đang xét
                    string _strNewCategoryTabURl = _strParentCategoryDisplayURL + "." + _objCategory.Cat_DisplayURL;

                    // Lấy thông tin về Tab cần cập nhật
                    PortalDefinition.Tab _objCurrentCategoryTab = _objPortal.GetTab(_strNewCategoryTabURl);

                    // Lấy mẫu Tab đã được lưu
                    ArrayList _arrTemplateColumns = _objPortal.CloneToTemplateTab(_objPortal.TemplateColumns) as ArrayList;

                    // Làm mới các mã tham chiếu trong mẫu
                    ReGenModuleID(ref _arrTemplateColumns);

                    // Nếu Tab cần cập nhật không tồn tại
                    if (_objCurrentCategoryTab == null)
                    {
                        // Tạo Tab mới
                        PortalDefinition.Tab      _objNewCategoryTab = PortalDefinition.Tab.Create(_strNewCategoryTabURl);
                        PortalDefinition.ViewRole _objViewRole       = new PortalDefinition.ViewRole();
                        _objViewRole.name = Config.EveryoneRoles;
                        _objNewCategoryTab.roles.Add(_objViewRole);
                        _objNewCategoryTab.Columns = _arrTemplateColumns;
                        _objNewCategoryTab.title   = _objCategory.Cat_Name;
                        _arrTabsCollection.Add(_objNewCategoryTab);

                        AddCategoryTab(_objPortal, _objNewCategoryTab.tabs, null, _objCategory.Cat_ID.ToString(), _strNewCategoryTabURl, _objGenerateMode);
                    }
                    else
                    {
                        bool _blnAllowGeneration = _objCategory.IsCat_ParentIDNull ? _objGenerateMode.ParentCategory : _objGenerateMode.SubCategory;

                        // Nếu cho phép cập nhật thì cần xét them là tab cần cập nhật phải khác với tab mẫu
                        if (_blnAllowGeneration && _objCurrentCategoryTab.reference != _objPortal.TemplateReference)
                        {
                            _objCurrentCategoryTab.Columns = _arrTemplateColumns;
                            _objCurrentCategoryTab.title   = _objCategory.Cat_Name;
                        }

                        AddCategoryTab(_objPortal, _objCurrentCategoryTab.tabs, null, _objCategory.Cat_ID.ToString(), _strNewCategoryTabURl, _objGenerateMode);
                    }
                }
            }
        }