예제 #1
0
        /// <summary>
        /// Ham thuc hien Them mot tab moi khi them mot category. Tabref duoc tinh va chuyen theo dang
        /// Edition.CatParent.Subcat
        /// </summary>
        /// <param name="_EditionRef">Thong tin ve edition ref</param>
        /// <param name="_ParentRef">Thong tin ve catparent reFt</param>
        /// <param name="_NewRef">Thong tin ve ref cua cat moi</param>
        /// <param name="_NewTabTitle">Tieu de cua tab</param>
        public void AddCategoryTab(string _EditionRef, string _ParentRef, string _NewRef, string _NewTabTitle)
        {
            PortalDefinition _objPortal    = PortalDefinition.Load();
            string           strCurrTabRef = _EditionRef;

            if (_ParentRef != "")
            {
                strCurrTabRef += "." + _ParentRef;
            }
            PortalDefinition.Tab _objCurrentCategoryTab = _objPortal.GetTab(strCurrTabRef);

            if (_objCurrentCategoryTab == null)
            {
                PortalDefinition.Tab t = PortalDefinition.Tab.Create();
                t.reference = strCurrTabRef;
                t.title     = strCurrTabRef;

                _objPortal.tabs.Add(t);
                _objCurrentCategoryTab = _objPortal.GetTab(strCurrTabRef);
            }

            if (_objCurrentCategoryTab != null)
            {
                PortalDefinition.Tab      _newtab      = PortalDefinition.Tab.Create(_NewRef);
                PortalDefinition.ViewRole _objViewRole = new PortalDefinition.ViewRole();
                _objViewRole.name = Portal.API.Config.EveryoneRoles;
                _newtab.roles.Add(_objViewRole);
                _newtab.title     = _NewTabTitle;
                _newtab.reference = strCurrTabRef + "." + _NewRef;                //EditionRef+"."+_ParentRef
                _objCurrentCategoryTab.tabs.Add(_newtab);
                _objPortal.Save();
            }
        }
        protected void OnAddRole(object sender, EventArgs args)
        {
            if(ShowRoleType && (cbAddRole.SelectedIndex == 0 || cbAddRoleType.SelectedIndex == 0)) return;
            if(!ShowRoleType && cbAddRole.SelectedIndex == 0 ) return;

            PortalDefinition.Role role = null;
            if(ShowRoleType)
            {
                if(cbAddRoleType.SelectedItem.Value == "view")
                {
                    role = new PortalDefinition.ViewRole();
                }
                else
                {
                    role = new PortalDefinition.EditRole();
                }
            }
            else
            {
                role = new PortalDefinition.ViewRole();
            }

            role.name = cbAddRole.SelectedItem.Value;
            roleList.Add(role);

            Bind();
        }
예제 #3
0
        protected void OnAddRole(object sender, EventArgs args)
        {
            if (ShowRoleType && (cbAddRole.SelectedIndex == 0 || cbAddRoleType.SelectedIndex == 0))
            {
                return;
            }
            if (!ShowRoleType && cbAddRole.SelectedIndex == 0)
            {
                return;
            }

            PortalDefinition.Role role = null;
            if (ShowRoleType)
            {
                if (cbAddRoleType.SelectedItem.Value == "view")
                {
                    role = new PortalDefinition.ViewRole();
                }
                else
                {
                    role = new PortalDefinition.EditRole();
                }
            }
            else
            {
                role = new PortalDefinition.ViewRole();
            }

            role.name = cbAddRole.SelectedItem.Text;
            roleList.Add(role);

            Bind();
        }
예제 #4
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);
        }
        void saveModule(ref PortalDefinition.Module module, XmlNode htmlModule)
        {
            string reference = xmlNodeToText(htmlModule.SelectSingleNode("@ref"));

            if (!string.IsNullOrEmpty(reference))
            {
                module.reference = reference;
            }

            module.title = xmlNodeToText(htmlModule.SelectSingleNode("@title"));
            int.TryParse(xmlNodeToText(htmlModule.SelectSingleNode("@cacheduration")), out module.CacheTime);
            module.type = xmlNodeToText(htmlModule.SelectSingleNode("@type"));

            PortalDefinition.ViewRole viewrole = new PortalDefinition.ViewRole();
            viewrole.name = "TATCA";
            module.roles.Add(viewrole);
        }
예제 #6
0
        /// <summary>
        /// Add new tab to Portal.config [bacth, 10:11 AM 5/26/2008]
        /// </summary>
        /// <param name="tabRef">new tab reference</param>
        /// <param name="parentTabRef">parent tab reference</param>
        /// <param name="title">new tab title</param>
        /// <param name="cloneTabRef">layout tab copied</param>
        /// <returns></returns>
        public static bool AddNewTab(string tabRef, string parentTabRef, string title, string cloneTabRef)
        {
            //string config1 = HttpContext.Current.Server.MapPath("~/settings/Portal.config"); // current application
            //string config2 = @"D:\shared\Portal.config"; // synchronous other file

            PortalDefinition portal = PortalDefinition.Load();

            PortalDefinition.Tab newTab    = portal.GetTab(tabRef);
            PortalDefinition.Tab parentTab = portal.GetTab(parentTabRef);
            if (newTab == null)
            {
                // add new tab
                newTab           = PortalDefinition.Tab.Create();
                newTab.reference = tabRef;
                newTab.title     = title;
                parentTab.tabs.Add(newTab);
                // tab roles
                PortalDefinition.ViewRole role = new PortalDefinition.ViewRole();
                role.name = Portal.API.Config.EveryoneRoles;
                newTab.roles.Add(role);
                // tab layout
                if (!string.IsNullOrEmpty(cloneTabRef))
                {
                    PortalDefinition.Tab cloneTab = portal.GetTab(cloneTabRef);
                    if (cloneTab != null)
                    {
                        newTab.Columns = cloneTab.CloneColumns();
                        foreach (PortalDefinition.Column c in newTab.Columns)
                        {
                            getNewRef(c);
                        }
                    }
                }
            }
            portal.Save();
            return(true);
        }
예제 #7
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);
                    }
                }
            }
        }