예제 #1
0
        /// <summary>
        /// Hàm trợ giúp tìm kiếm mã tham chiếu đến chuyên san hiện thời từ mã tham chiếu của Tab đang đượ hiển thị
        /// </summary>
        /// <returns>Mã tham chiếu đến chuyên san hiện thời</returns>
        public static int GetCurrentEditionTypeID()
        {
            // Biến lưu trữ mã của chuyên san hiện thời
            int _intCurrentEditionTypeID = 0;

            string _strCurrentTabRef = System.Web.HttpContext.Current.Request.QueryString["TabRef"];

            //string mrs = Config.GetPortalUniqueCacheKey() + "CurrentEditionTypeID_" + (_strCurrentTabRef == null ? "" : _strCurrentTabRef);
            // Tìm kiếm trong Cache
            //if (System.Web.HttpContext.Current.Cache[mrs] != null) _intCurrentEditionTypeID = (int)System.Web.HttpContext.Current.Cache[mrs];
            //if(_intCurrentEditionTypeID > 0) return _intCurrentEditionTypeID;

            // Nạp thông tin Tab hiện thời
            PortalDefinition.Tab _objCurrentTab = PortalDefinition.GetCurrentTab();

            if (_objCurrentTab != null)
            {
                // Lấy mã tham chiếu của Tab đang dc hiển thị
                string _strTabRef     = _objCurrentTab.reference;
                string _strEditionRef = "";

                // Tìm vị trí dấu chấm đầu tiên
                int _intLastDotPos = _strTabRef.IndexOf('.');

                if (_intLastDotPos > 0)
                {
                    // Tách lấy phần tên đại diện trên URL của chuyên san
                    _strEditionRef = _objCurrentTab.reference.Substring(0, _intLastDotPos);
                }
                else
                {
                    // Nếu không có dấu chấm thì lấy toàn bộ mã tham chiếu của Tab
                    _strEditionRef = _objCurrentTab.reference;
                }

                // Lấy thông tin về chuyên san
                EditionTypeRow _objCurrentEditionType = null;
                using (MainDB _objDB = new MainDB()) {
                    _objCurrentEditionType = _objDB.EditionTypeCollection.GetRow("EditionDisplayURL = '" + _strEditionRef + "'");
                }

                if (_objCurrentEditionType != null)
                {
                    // Tìm thấy chuyên san thì trả về mã tham chiếu của chuyên san
                    _intCurrentEditionTypeID = _objCurrentEditionType.EditionType_ID;
                }
                else
                {
                    // Nếu không tìm thấy chuyên san thì trả về mã tham chiếu của chuyên san đầu tiên trong danh sách chuyên san
                    EditionTypeRow[] _arrCurrentEditionTypes = null;
                    using (MainDB _objDB = new MainDB()) {
                        _arrCurrentEditionTypes = _objDB.EditionTypeCollection.GetTopAsArray(1, "", "EditionType_ID");
                    }
                    if (_arrCurrentEditionTypes != null && _arrCurrentEditionTypes.Length > 0)
                    {
                        _intCurrentEditionTypeID = _arrCurrentEditionTypes[0].EditionType_ID;
                    }
                }
            }

            // Lưu mã của chuyên san hiện thời vào Cache
            //System.Web.HttpContext.Current.Cache.Insert(mrs, _intCurrentEditionTypeID);

            // Trả về 1 nếu không tìm thấy bất kỳ chuyên san nào trong danh sách -- Đã chỉnh sửa để loại bỏ cache vào ngày 05-08
            //edited by trangnva
            return(_intCurrentEditionTypeID);//1
        }
예제 #2
0
        public static void CreateCat(string _catname, string _catdes, string _caturl, int _catparent, int _catedition, string _caticon, bool _catiscolumn, bool _catishide)
        {
            CleanCacheCategory();

            Portal.Core.DAL.CategoryRow objrow = new Portal.Core.DAL.CategoryRow();
            objrow.Cat_Name        = _catname;
            objrow.Cat_Description = _catdes;
            objrow.Cat_DisplayURL  = _caturl;
            objrow.Cat_ParentID    = _catparent;
            objrow.EditionType_ID  = _catedition;
            objrow.Cat_Icon        = _caticon;
            objrow.Cat_isColumn    = _catiscolumn;
            objrow.Cat_isHidden    = _catishide;
            EditionTypeRow objEditRow = null;

            Portal.Core.DAL.CategoryRow objParentRow       = null;
            Portal.Core.DAL.CategoryRow objrow_find_parent = null;

            Portal.Core.DAL.CategoryRow[] objTopRows;
            int intMaxOrder = 0;

            using (Portal.Core.DAL.MainDB objDb = new Portal.Core.DAL.MainDB())
            {
                if (_catparent != 0)
                {
                    int cat_id_find_parent = GetCatParent(Convert.ToInt32(_catparent));
                    objrow_find_parent = objDb.CategoryCollection.GetByPrimaryKey(cat_id_find_parent);
                    _catedition        = objrow_find_parent.EditionType_ID;
                }

                //if (_catparent == 0)
                //    objEditRow = objDb.EditionTypeCollection.GetByPrimaryKey(_catedition);
                //else
                //{
                objParentRow = objDb.CategoryCollection.GetByPrimaryKey(_catparent);
                //    objEditRow = objDb.EditionTypeCollection.GetByPrimaryKey(objParentRow.EditionType_ID);
                //}

                objEditRow = objDb.EditionTypeCollection.GetByPrimaryKey(_catedition);

                objTopRows = objDb.CategoryCollection.GetTopAsArray(1, "Cat_ParentID=" + _catparent, "Cat_Order DESC");
                if (objTopRows.Length == 1)
                {
                    if (objTopRows[0].IsCat_OrderNull)
                    {
                        intMaxOrder = 1;
                    }
                    else
                    {
                        intMaxOrder = objTopRows[0].Cat_Order + 1;
                    }
                }
                objrow.Cat_Order      = intMaxOrder;
                objrow.EditionType_ID = _catedition;
                objDb.CategoryCollection.Insert(objrow);
            }

            //#region Cập nhập vào bảng Category ở database User
            //Portal.User.Db.CategoryRow objCateUserRow = new Portal.User.Db.CategoryRow();
            //objCateUserRow.Cat_ID = objrow.Cat_ID;
            //objCateUserRow.Cat_Name = objrow.Cat_Name;
            //objCateUserRow.Cat_ParentID = objrow.Cat_ParentID;
            //objCateUserRow.Cat_Order = objrow.Cat_Order;
            //objCateUserRow.Channel_ID = Portal.API.Config.CurrentChannel;
            //using (Portal.User.Db.MainDB objDb = new Portal.User.Db.MainDB())
            //{
            //    objDb.CategoryCollection.Insert(objCateUserRow);
            //}
            //#endregion



            //cap nhat thong tin ve tab moi khi them cat
            string strEditionRef   = "";
            string strParentTabRef = "";

            if (objEditRow != null)
            {
                //strEditionRef = objEditRow.EditionDisplayURL;
                //SonPC
                String UseEditionType = ConfigurationSettings.AppSettings["UseEditionType"];
                if (UseEditionType.ToLower().IndexOf("false") >= 0)
                {
                    strEditionRef = ConfigurationSettings.AppSettings["PrefixEditionType"];
                }
                else
                {
                    strEditionRef = objEditRow.EditionDisplayURL;
                }

                //SonPC
            }
            if (objParentRow != null)
            {
                strParentTabRef = objParentRow.Cat_DisplayURL;
            }
            //thuc hien lay doi tuong GenTabHelper
            Gentabhelper objHelp = new Gentabhelper();

            objHelp.AddCategoryTab(strEditionRef, strParentTabRef, _caturl, _catname);
        }