Exemplo n.º 1
0
        private void BindModuleControls()
        {
            string preFix = string.Empty;
            string paneName = string.Empty;
            string ControlSrc = string.Empty;
            string phdContainer = string.Empty;
            string PageSEOName = string.Empty;
            SageUserControl suc = new SageUserControl();

            SageFrameConfig sfConfig = new SageFrameConfig();
            string portalDefaultPage = sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage);
            if (PagePath != null)
            {
                suc.PagePath = PagePath;
            }
            else
            {
                suc.PagePath = portalDefaultPage;
            }
            if (PagePath != null)
            {
                PageSEOName = GetPageSEOName(PagePath);
            }
            else
            {
                PageSEOName = GetPageSEOName(portalDefaultPage);
            }
            PageSEOName = PageSEOName.Replace("-and-", "&").Replace(" ", "-");

            //:TODO: Need to get controlType and pageID from the selected page from routing path
            //string controlType = "0";
            //string pageID = "2";
            StringBuilder redirecPath = new StringBuilder();
            if (PageSEOName != string.Empty)
            {

                string SEOName = portalDefaultPage.Replace(" ", "-");
                List<UserModuleInfo> lstUserModules = new List<UserModuleInfo>();
                bool SuperRole = false;
                string previewCode = "none";
                bool isPreview = false;
                if (Request.QueryString["preview"] != null)
                {
                    previewCode = Request.QueryString["preview"].ToString();
                    isPreview = true;
                }

                if (Session[SessionKeys.SageRoles] != null && Session[SessionKeys.SageRoles].ToString() != string.Empty)
                {
                    string[] objRole = Session[SessionKeys.SageRoles].ToString().Split(',');
                    foreach (string role in objRole)
                    {
                        if (role.Replace(" ", string.Empty).ToLower().Equals(ApplicationKeys.Super_User.ToLower().Replace("-", string.Empty)))
                        {
                            SuperRole = true;
                        }
                    }
                }
                if (GetUsername.Equals(ApplicationKeys.anonymousUser))
                {
                    lstUserModules = sfConfig.GetPageModules_Anonymous("1", PageSEOName, GetUsername, GetCurrentCulture());
                }
                else if (SuperRole)
                {
                    lstUserModules = sfConfig.GetPageModules_Superuser("1", PageSEOName, GetUsername, GetCurrentCulture(), isPreview, previewCode);
                }
                else
                {
                    lstUserModules = sfConfig.GetPageModules("1", PageSEOName, GetUsername, GetCurrentCulture(), isPreview, previewCode);
                }
                Uri url = HttpContext.Current.Request.Url;
                if (lstUserModules[0].IsPageAvailable)
                {

                    if (lstUserModules[0].IsPageAccessible)
                    {
                        #region "Load Controls"

                        if (lstUserModules.Count > 0)
                        {
                            OverridePageInfo(lstUserModules[0]);
                            bool isUserLoggedIn = IsUserLoggedIn();
                            if (isUserLoggedIn)
                            {
                                SecurityPolicy objSecurity = new SecurityPolicy();
                                objSecurity.UpdateExpireTime(GetUsername, GetPortalID);
                            }
                            bool isHandheld = IsHandheld();
                            List<string> moduleDefIDList = new List<string>();
                            foreach (UserModuleInfo usermodule in lstUserModules)
                            {
                                bool handheld_status = bool.Parse(usermodule.IsHandHeld.ToString());
                                if (isHandheld == handheld_status)
                                {
                                    paneName = usermodule.PaneName;
                                    paneName = "pch_" + paneName;
                                    if (string.IsNullOrEmpty(paneName))
                                        paneName = "ContentPane";
                                    string UserModuleTitle = usermodule.UserModuleTitle != string.Empty ? usermodule.UserModuleTitle.ToString() : string.Empty;
                                    ControlSrc = usermodule.ControlSrc;
                                    string SupportsPartialRendering = usermodule.SupportsPartialRendering.ToString();
                                    string SuffixClass = usermodule.SuffixClass.ToString();
                                    string HeaderText = usermodule.ShowHeaderText ? usermodule.HeaderText : "";
                                    bool ContainsEdit = usermodule.IsEdit;
                                    int ControlCount = usermodule.ControlsCount;
                                    UserControl uc = pchWhole.FindControl("lytA") as UserControl;
                                    PlaceHolder phdPlaceHolder = uc.FindControl(paneName) as PlaceHolder;
                                    SuffixClass = isUserLoggedIn && ContainsEdit ? string.Format("sfLogged sfModule{0}", SuffixClass) : string.Format("sfModule{0}", SuffixClass);
                                    if (phdPlaceHolder != null)
                                    {
                                        string TemplateControls = Server.MapPath(string.Format("~/Templates/{0}/modules/{1}", activeTemplate, ControlSrc.Substring(ControlSrc.IndexOf('/'), ControlSrc.Length - ControlSrc.IndexOf('/'))));
                                        ControlSrc = File.Exists(TemplateControls) ? string.Format("/Templates/{0}/modules/{1}", activeTemplate, ControlSrc.Substring(ControlSrc.IndexOf('/'), ControlSrc.Length - ControlSrc.IndexOf('/'))) : string.Format("/{0}", ControlSrc);
                                        LoadControl(phdPlaceHolder, ControlSrc, paneName, usermodule.UserModuleID.ToString(), SuffixClass, HeaderText, isUserLoggedIn, GetModuleControls(usermodule.UserModuleID, ContainsEdit, ControlCount, usermodule.ModuleDefID), GetPaneNameContainer(UserModuleTitle), ContainsEdit);
                                        //changecss 1 take module list here take usermodulename
                                        moduleDefIDList.Add(usermodule.ModuleDefID.ToString());
                                    }
                                }
                            }
                            SetModuleDefList(moduleDefIDList);
                        }

                        #endregion
                        else
                        {
                            if (!IsParent)
                            {
                                redirecPath.Append(url.Scheme);
                                redirecPath.Append("://");
                                redirecPath.Append(url.Authority);
                                redirecPath.Append(PortalAPI.GetApplicationName);
                                redirecPath.Append("/portal/");
                                redirecPath.Append(GetPortalSEOName);
                                redirecPath.Append("/");
                                redirecPath.Append(PortalAPI.PageNotFoundPageWithExtension);
                            }
                            else
                            {
                                redirecPath.Append(url.Scheme);
                                redirecPath.Append("://");
                                redirecPath.Append(url.Authority);
                                redirecPath.Append(PortalAPI.PageNotFoundURL);
                            }

                            Response.Redirect(redirecPath.ToString());
                        }
                    }
                    else
                    {
                        if (!IsParent)
                        {
                            redirecPath.Append(url.Scheme);
                            redirecPath.Append("://");
                            redirecPath.Append(url.Authority);
                            redirecPath.Append(PortalAPI.GetApplicationName);
                            redirecPath.Append("/portal/");
                            redirecPath.Append(GetPortalSEOName);
                            redirecPath.Append("/");
                            redirecPath.Append(PortalAPI.PageNotAccessiblePageWithExtension);
                        }
                        else
                        {
                            redirecPath.Append(url.Scheme);
                            redirecPath.Append("://");
                            redirecPath.Append(url.Authority);
                            redirecPath.Append(PortalAPI.PageNotAccessibleURL);
                        }
                        Response.Redirect(redirecPath.ToString());
                    }
                }
                else
                {
                    //page is not found
                    if (!IsParent)
                    {
                        redirecPath.Append(url.Scheme);
                        redirecPath.Append("://");
                        redirecPath.Append(url.Authority);
                        redirecPath.Append(PortalAPI.GetApplicationName);
                        redirecPath.Append("/portal/");
                        redirecPath.Append(GetPortalSEOName);
                        redirecPath.Append("/");
                        redirecPath.Append(PortalAPI.PageNotFoundPageWithExtension);
                    }
                    else
                    {
                        redirecPath.Append(url.Scheme);
                        redirecPath.Append("://");
                        redirecPath.Append(url.Authority);
                        redirecPath.Append(PortalAPI.PageNotFoundURL);
                    }
                    Response.Redirect(redirecPath.ToString());
                }
            }
            SetScreenWidth(GetUsername);
        }
Exemplo n.º 2
0
        private void SetPageInitPart()
        {
            ltrJQueryLibrary.Text = GetAdminJqueryLibraryPath();
            CheckUserLogin();
            string PageName = Path.GetFileNameWithoutExtension(PagePath);
            //adminImage.ImageUrl = GetUserImage;
            if (PageName != null)
            {
                SecurityPolicy objSecurity = new SecurityPolicy();

                userName = objSecurity.GetUser(GetPortalID);
                templateFavicon = SetFavIcon(GetActiveTemplate);
                Extension = SageFrameSettingKeys.PageExtension;
                ApplicationController objAppController = new ApplicationController();
                objSecurity.UpdateExpireTime(userName, GetPortalID);
                if (!objAppController.CheckRequestExtension(Request))
                {
                    SageInitPart();
                }
                SetGlobalVariable();
                bool IsAdmin = true;
                IncludeStartup(GetPortalID, pchHolder, IsAdmin);
            }
            else
            {
                Response.Redirect(PortalAPI.PageNotAccessibleURL);
            }
        }