protected void OnAddSubColumn(object sender, CommandEventArgs e)
        {
            if (Parent is Tab)
            {
                PortalDefinition        pd = PortalDefinition.Load();
                PortalDefinition.Column _objCurrentColumn = pd.GetColumn(e.CommandArgument.ToString());
                if (_objCurrentColumn != null)
                {
                    PortalDefinition.Column _objNewColumn = PortalDefinition.Column.Create(_objCurrentColumn);

                    _objCurrentColumn.Columns.Add(_objNewColumn);

                    pd.Save();
                    if (AddSubColumn != null)
                    {
                        AddSubColumn(this, _objNewColumn);
                    }
                }
            }
            else if (Parent is Template)
            {
                TemplateDefinition      td = TemplateDefinition.Load();
                PortalDefinition.Column _objCurrentColumn = td.GetColumn(e.CommandArgument.ToString());
                if (_objCurrentColumn != null)
                {
                    PortalDefinition.Column _objNewColumn = PortalDefinition.Column.Create(_objCurrentColumn);

                    _objCurrentColumn.Columns.Add(_objNewColumn);

                    td.Save();
                    if (AddSubColumn != null)
                    {
                        AddSubColumn(this, _objNewColumn);
                    }
                }
            }
        }
        /// <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);
        }
Beispiel #3
0
        /// <summary>
        /// Thủ tục lưu các thông tin đã xác lập của 1 Cột
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnSave(object sender, EventArgs args)
        {
            try
            {
                if (Page.IsValid)
                {
                    // Save
                    PortalDefinition.Column _objColumn = null;
                    PortalDefinition        pd         = null;
                    TemplateDefinition      td         = null;

                    if (Parent is Tab)
                    {
                        // Lấy thông tin về cột cần sửa
                        pd         = PortalDefinition.Load();
                        _objColumn = pd.GetColumn(CurrentColumnReference);
                    }
                    else if (Parent is Template)
                    {
                        td         = TemplateDefinition.Load();
                        _objColumn = td.GetColumn(CurrentColumnReference);
                    }

                    if (_objColumn != null)
                    {
                        // Cập nhật lại tên cột và độ rộng của cột
                        _objColumn.ColumnName = txtTitle.Text;

                        // Cập nhật màu nền của cột
                        _objColumn.ColumnCustomStyle = txtCustomStyle.Text;

                        // Cập nhật mức độ của cột
                        _objColumn.ColumnLevel = Convert.ToInt32(drdColumnLevel.SelectedValue);
                        //lay ve do rong cua cot
                        string strColWidth = txtColWidth.Text;
                        try
                        {
                            _objColumn.ColumnWidth = chkDefaultColumnWidth.Checked ? "" : strColWidth;
                        }
                        catch
                        {
                            // Nếu có lỗi, lấy độ rộng mặc định
                            _objColumn.ColumnWidth = "";
                        }
                    }

                    if (Parent is Tab)
                    {
                        pd.Save();
                    }
                    else if (Parent is Template)
                    {
                        td.Save();
                    }

                    CurrentColumnReference = _objColumn.ColumnReference;

                    if (Save != null)
                    {
                        Save(this, new EventArgs());
                    }
                }
            }
            catch (Exception e)
            {
                lbError.Text = e.Message;
            }
        }
Beispiel #4
0
        internal void MoveColumnRight(string _strColumnReference)
        {
            // Nạp cấu trúc Portal
            PortalDefinition _objPortal = PortalDefinition.Load();

            // Lấy thông tin về cột cần dịch chuyển
            PortalDefinition.Column _objSelectedColumn = _objPortal.GetColumn(_strColumnReference);

            // Nếu cột cần dịch chuyển không tồn tại thì kết thúc hàm
            if (_objSelectedColumn != null)
            {
                // Tìm kiếm danh sách cột trong đó có cột đang xét
                PortalDefinition.Column _objParentColumn = _objSelectedColumn.ColumnParent;
                ArrayList _arrColumnsList = null;

                // Nếu cột cha rỗng thì cột đang xét trực thuộc Tab
                if (_objParentColumn == null)
                {
                    // Lấy thông tin Tab hiện thời
                    PortalDefinition.Tab _objCurrentTab = _objPortal.GetTab(CurrentReference);
                    if (_objCurrentTab != null)
                    {
                        // Lấy danh sách cột của Tab
                        _arrColumnsList = _objCurrentTab.Columns;
                    }
                }
                else
                {
                    // Nếu cột đang xét là cột con của 1 cột khác, thì trả về danh sách các cột đồng cấp
                    _arrColumnsList = _objParentColumn.Columns;
                }

                // Biến lưu vị trí của cột đã chọn trong danh sách
                int _intCurrentColumnIndex = 0;

                // Biến lưu trữ số cột đồng mức với cột đã chọn
                int _intSameLevelColumnsCount = 0;

                // Kiểm duyệt danh sách cột đồng cấp
                // Đếm cột có cùng Level
                for (int _intColumnCount = 0; _intColumnCount < _arrColumnsList.Count; _intColumnCount++)
                {
                    PortalDefinition.Column _objColumn = _arrColumnsList[_intColumnCount] as PortalDefinition.Column;
                    if (_objColumn.ColumnLevel == _objSelectedColumn.ColumnLevel)
                    {
                        if (_objColumn.ColumnReference == _objSelectedColumn.ColumnReference)
                        {
                            _intCurrentColumnIndex = _intSameLevelColumnsCount;
                        }
                        _intSameLevelColumnsCount++;
                    }
                }

                // Duyệt danh sách các cột cùng cấp
                if (_arrColumnsList != null && _intSameLevelColumnsCount > 0)
                {
                    // Để di chuyển sang phải --> không thể đang là vị trí cuối cùng
                    if (_intCurrentColumnIndex >= (_intSameLevelColumnsCount - 1))
                    {
                        return;
                    }
                    else
                    {
                        // Di chuyển cột đã chọn sang trái
                        _arrColumnsList.RemoveAt(_intCurrentColumnIndex);
                        _arrColumnsList.Insert(_intCurrentColumnIndex + 1, _objSelectedColumn);
                    }
                }
            }

            // Lưu cấu trúc Portal
            _objPortal.Save();

            // Nạp dữ liệu Tab
            LoadData(CurrentReference);

            // Nạp dữ liệu cột
            if (CurrentColumnReference != "")
            {
                EditColumn(CurrentColumnReference);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Thủ tục nạp dữ liệu về Tab đang sửa
        /// </summary>
        /// <param name="tabRef">Mã tham chiếu đến Tab đang sửa</param>
        public void LoadData(string tabRef)
        {
            CurrentReference = tabRef;

            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab t = pd.GetTab(CurrentReference);

            txtTitle.Text       = HttpUtility.HtmlDecode(t.title);
            txtReference.Text   = CurrentReference;
            chkIsHidden.Checked = t.IsHidden;

            TemplateDefinition td = TemplateDefinition.Load();
            ArrayList          _arrTemplateList = new ArrayList();

            _arrTemplateList.Add(string.Empty);
            foreach (TemplateDefinition.Template template in td.templates)
            {
                _arrTemplateList.Add(template.reference);
            }
            ddrTemplateList.DataSource = _arrTemplateList;
            ddrTemplateList.DataBind();

            //string _strSkinFolder = Portal.Ultility.ConfigurationSetting.GetConfigPhysicalPath(t.reference, Config.GetAppConfigValue("SkinPrefix"), Config.GetAppConfigValue("SkinFolder"));
            string    _strSkinFolder     = Server.MapPath("");
            ArrayList _arrConfigFileList = new ArrayList();

            _arrConfigFileList.Add("Skin.Default.config");
            int _intSelectedIndex = 0;

            if (Directory.Exists(_strSkinFolder))
            {
                DirectoryInfo _difConfig = new DirectoryInfo(_strSkinFolder);
                foreach (FileInfo _objConfigFile in _difConfig.GetFiles())
                {
                    string _strFileNamePart = "" + "." + t.reference + ".";
                    if (_objConfigFile.Name.IndexOf(_strFileNamePart) >= 0)
                    {
                        if (_objConfigFile.Name == t.SkinName)
                        {
                            _intSelectedIndex = _arrConfigFileList.Count;
                        }
                        _arrConfigFileList.Add(_objConfigFile.Name);
                    }
                }
            }
            ddrSkins.DataSource = _arrConfigFileList;
            ddrSkins.DataBind();
            if (_arrConfigFileList.Count > 0)
            {
                ddrSkins.SelectedIndex = _intSelectedIndex;
            }

            RolesCtrl.LoadData(t.roles);

            // Đọc danh sách Columns của Tab
            // Hiển thị danh sách các Module được gắn vào từng Column
            lstColumns.LoadColumnList(t);

            ShowColumnsList();
        }