/// <summary> /// Nạp chồng Thủ tục khởi tạo các điều khiển con /// </summary> override protected void CreateChildControls() { // Lấy thông tin Tab hiện thời PortalDefinition.Tab tab = PortalDefinition.GetCurrentTab(); if (tab == null) { return; } // Kiểm tra quyền của người sử dụng ChannelUsers objuser = new ChannelUsers(); // Edit by Tqdat // Xu ly viec khong de Session Timeout la BienTapvien out ra khoi fan Admin // - Neu bi Session TimeOut thi kiem tra xem Cookie co ton tai User va Pass hay ko // + Neu Co thi Login lai de lay lai session // + Neu Khong thi Redirect ra trang login.aspx //bool isHasViewRights = objuser.HasViewRights(Page.User, tab.roles); /*if (isHasViewRights == false) * { * // Kiem tra xem co Cookie hay ko * HttpCookie cookie = Request.Cookies["PortalUser"]; * if (cookie != null) * { * objuser.Login(cookie.Values["AC"].Trim(), cookie.Values["PW"].Trim()); * isHasViewRights = true; * } * }*/ if (objuser.HasViewRights(Page.User, tab.roles)) { RenderColumns(tab, tab.Columns, DisplayRegion); if (IsAdmin) { // Hiển thị vùng trắng của các cột rỗng foreach (HtmlTableCell _objEmptyColumn in _arrAllEmptyColumn) { LiteralControl _ltrSpace = new LiteralControl(); _ltrSpace.Text = " "; _objEmptyColumn.Controls.Add(_ltrSpace); } } } else { Cache cache = new Cache(HttpContext.Current.Application); string path = HttpContext.Current.Request.Url.AbsolutePath.ToLower(); string _strCacheKey = Config.GetPortalUniqueCacheKey() + path + "_" + HttpContext.Current.User.Identity.Name; string _strCacheRawKey = Config.GetPortalUniqueCacheKey() + "_Raw" + HttpContext.Current.Request.RawUrl + "_" + HttpContext.Current.User.Identity.Name; cache[_strCacheKey] = null; cache[_strCacheRawKey] = null; Session["NotPermission"] = "True"; Session["lastPath"] = HttpContext.Current.Request.RawUrl; Response.Redirect("/login.aspx"); } }
/// <summary> /// Nạp chồng Thủ tục khởi tạo các điều khiển con /// </summary> override protected void CreateChildControls() { // Lấy thông tin Tab hiện thời PortalDefinition.Tab tab = PortalDefinition.GetCurrentTab(); if (tab == null) { return; } // Kiểm tra quyền của người sử dụng ChannelUsers objuser = new ChannelUsers(); if (objuser.HasViewRights(Page.User, tab.roles)) { // Tiến hành sinh mã cho các cột của Tab // Vùng bắt đầu là DisplayRegion. RenderColumns(tab, tab.Columns, DisplayRegion); } else { // Add by tqdat Cache cache = new Cache(HttpContext.Current.Application); string path = HttpContext.Current.Request.Url.AbsolutePath.ToLower(); string _strCacheKey = Config.GetPortalUniqueCacheKey() + path + "_" + HttpContext.Current.User.Identity.Name; string _strCacheRawKey = Config.GetPortalUniqueCacheKey() + "_Raw" + HttpContext.Current.Request.RawUrl + "_" + HttpContext.Current.User.Identity.Name; cache[_strCacheKey] = null; cache[_strCacheRawKey] = null; Session["lastPath"] = HttpContext.Current.Request.RawUrl; // Neu khong duoc fep access vao hoac Mat Session thi redirect ve trang Login Response.Redirect("/login.aspx"); } }
private void HandlerServerRequest(HttpContext context, ref string url) { Cache cache = new Cache(HttpContext.Current.Application); string strRq = context.Request.Url.AbsolutePath; string currentUser = context.User.Identity.Name; string path = context.Request.Url.AbsolutePath.ToLower(); // Kiểm tra Cache xem đường dẫn này đã xử lý lần nào chưa - so voi ca duong dan that string newsRef = "", templistRef = "", newstemp = "", multiref = "";//dung trong cac truong hop:Co so, lay cpmode, template, bien k so string[] newsParams; //cắt ký tự đầu "/" string tabRef = path.Substring(path.IndexOf("/") + 1); //path.Substring(path.LastIndexOf("/") + 1); Replace(strRoot, "");// get "TabRef.ext" //cắt ký tự cuối ".aspx" tabRef = tabRef.Substring(0, tabRef.LastIndexOf(".aspx")); // get "TabRef" // Kiểm tra để tách lọc phần mã tham chiếu của tin - Them co che do tin newsRef va luu url vao cache de khoi ton tai nguyen. if (tabRef != "") { //mảng các thành phần url string[] _arrReferenceParts = tabRef.Split("/".ToCharArray()); //truong hop khi thong so cua tabref nhanh duoc co tu 2 phan tro len thi: //1. xac dinh xem thanh phan cuoi co phai ID cua tin khong? Neu phai thi day la dang tab --> News (Co the dat them dau hieu de nhan dien news //2. Neu khong phai la ID cua tin thi co 2 truong hop say ra 1- la tabref luon , 2- la mot loai query moi //nếu là tin if ((_arrReferenceParts.Length >= 2 && StringProcess.IsNumber(_arrReferenceParts[_arrReferenceParts.Length - 1])) || (_arrReferenceParts.Length >= 2 && _arrReferenceParts[_arrReferenceParts.Length - 1].IndexOf("_tm,") > 0)) { string[] str = { "_tm," }; //mảng tách bởi chỗi _tm, newsParams = _arrReferenceParts[_arrReferenceParts.Length - 1].Split(str, StringSplitOptions.None); newsRef = newsParams[0]; if (newsParams.Length > 0) { //chuoi co dang home/parent/child/newsid_tm,3_title.aspx if (_arrReferenceParts[_arrReferenceParts.Length - 1].IndexOf("_tm,") > 0) { //newstemp co dang 3_title newstemp = newsParams[newsParams.Length - 1].Substring(0, 1); } //lay phan con lai lam tabref :home/parent/child tabRef = tabRef.Replace("/" + _arrReferenceParts[_arrReferenceParts.Length - 1], ""); } _arrReferenceParts = String.Join("/", _arrReferenceParts, 0, _arrReferenceParts.Length - 1).Split("/".ToCharArray()); templistRef = _arrReferenceParts[_arrReferenceParts.Length - 1]; tabRef = String.Join("/", _arrReferenceParts, 0, _arrReferenceParts.Length - 1); } else { //truong hop khong phai newsref if (_arrReferenceParts.Length >= 2) { if (_arrReferenceParts.Length == 2) { templistRef = _arrReferenceParts[_arrReferenceParts.Length - 1]; tabRef = String.Join("/", _arrReferenceParts, 0, _arrReferenceParts.Length - 1); } else { templistRef = _arrReferenceParts[_arrReferenceParts.Length - 2]; newsRef = _arrReferenceParts[_arrReferenceParts.Length - 1]; if (newsRef.IndexOf(",") > -1) { multiref = newsRef; newsRef = ""; } tabRef = String.Join("/", _arrReferenceParts, 0, _arrReferenceParts.Length - 2); } } } } Dictionary <string, string> r = new Dictionary <string, string>(); foreach (string key in context.Request.QueryString.Keys) { r[key] = context.Request[key]; } //kiem tra xem - neu truong hop tabref co bao nhieu / thi lui ra bay nhieu lan de tro vao dung muc int intSecNum = 0; string[] strSecs = tabRef.Split("/".ToCharArray()); intSecNum = strSecs.Length; if (":chuyenmuc:users:office:adminportal:login:"******":" + tabRef.ToLower() + ":") != -1) { url = Config.GetMainPage(currentUser); } else { url = context.Request.Url.AbsolutePath.TrimStart('/'); } r["TabRef"] = tabRef.Replace("/", "."); r["NewsRef"] = newsRef; r["cpmode"] = templistRef; r["multiref"] = multiref; bool firstParam = true; foreach (KeyValuePair <string, string> e in r) { if (firstParam) { url += "?"; firstParam = false; } else { url += "&"; } url += e.Key + "=" + e.Value; } url = "~/" + url; }
/// <summary> /// Hàm trợ giúp lấy mã của Category trong Tab hiện thời khi người sử dụng chọn xem một Category /// </summary> /// <returns>Mã tham chiếu đến Category hiện thời</returns> public static string GetCurrentCategoryID() { Cache cache = new Cache(HttpContext.Current.Application); // Biến lưu trữ mã của chuyên san hiện thời int _intCurrentCategoryID = 0, _intCurrParent = 0; string _strCurrentTabRef = HttpContext.Current.Request.QueryString["TabRef"]; if (HttpContext.Current.Request.QueryString["RealRef"] != null) { _strCurrentTabRef = HttpContext.Current.Request.QueryString["RealRef"]; } string mrs = Config.GetPortalUniqueCacheKey() + "CurrentCategoryID_" + (_strCurrentTabRef == null ? "" : _strCurrentTabRef); string nrs = Config.GetPortalUniqueCacheKey() + "CurrentParentID_" + (_strCurrentTabRef == null ? "" : _strCurrentTabRef); // Tìm kiếm trong Cache if (cache[mrs] != null && cache[nrs] != null) { _intCurrentCategoryID = (int)cache[mrs]; _intCurrParent = (int)cache[nrs]; } if (_intCurrentCategoryID > 0) { return(_intCurrParent + "," + _intCurrentCategoryID); } // Lấy thông tin về Tab hiện thời PortalDefinition.Tab _objCurrentTab = PortalDefinition.getTabByRef(_strCurrentTabRef);//PortalDefinition.GetCurrentTab(); if (_objCurrentTab != null) { // Lấy mã tham chiếu của Tab string _strTabRef = _objCurrentTab.reference; string _strCategoryRef = "", _strParentRef = ""; // Tìm vị trí dấu chấm cuối int _intLastDotPos = _strTabRef.LastIndexOf('.'); if (_intLastDotPos > 0) { // Cắt lấy phần tên đại diện trên URL của Category _strCategoryRef = _objCurrentTab.reference.Substring(_intLastDotPos + 1); _strParentRef = _objCurrentTab.reference.Substring(0, _intLastDotPos); // Lấy thông tin về Category đã chọn CategoryRow _objCurrentCategory = null; using (MainDB _objDB = new MainDB()) { _objCurrentCategory = _objDB.CategoryCollection.GetRow("Cat_DisplayURL = '" + _strCategoryRef + "'"); } if (_objCurrentCategory != null) { _intCurrentCategoryID = _objCurrentCategory.Cat_ID; _intCurrParent = _objCurrentCategory.Cat_ParentID; } else { _intLastDotPos = _strParentRef.LastIndexOf('.'); _strParentRef = _strParentRef.Substring(_intLastDotPos + 1); using (MainDB _objDB = new MainDB()) { _objCurrentCategory = _objDB.CategoryCollection.GetRow("Cat_DisplayURL = '" + _strParentRef + "'"); } if (_objCurrentCategory != null) { _intCurrentCategoryID = _objCurrentCategory.Cat_ID; _intCurrParent = _objCurrentCategory.Cat_ParentID; } } } } // Lưu mã của chuyên san hiện thời vào Cache cache[mrs] = _intCurrentCategoryID; cache[nrs] = _intCurrParent; // Trả về 0 nếu không tìm thấy Category return(_intCurrParent + "," + _intCurrentCategoryID);//0 }