protected void Page_Load(object sender, EventArgs e)
 {
    
     SecurityPolicy objSecurity = new SecurityPolicy();
     FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
     if (ticket.Name != ApplicationKeys.anonymousUser)
     {
         int LoggedInPortalID = int.Parse(ticket.UserData.ToString());
     }
     else
     {
         RedirectToInvalid();
     }
    // IncludeCss("UserProfile", "/js/jquery-ui-1.8.14.custom/css/redmond/jquery-ui-1.8.16.custom.css");
     IncludeJs("UserManagementValidation", "/js/jquery.validate.js");
     tblEditProfile.Visible = false;
     tblViewProfile.Visible = true;
     divSaveProfile.Visible = false;
     sfUserProfile.Visible = false;
     divUserInfo.Visible = true;
     if (!IsPostBack)
     {
         LoadUserDetails();
         
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            IncludeCss("OutOfStockNotification", "/Templates/" + TemplateName + "/css/GridView/tablesort.css",
                       "/Templates/" + TemplateName + "/css/MessageBox/style.css", "/Modules/AspxCommerce/AspxOutOfStockNotification/css/module.css");
            IncludeJs("OutOfStockNotification", "/js/GridView/jquery.grid.js", "/js/GridView/SagePaging.js",
                      "/js/GridView/jquery.global.js", "/js/GridView/jquery.dateFormat.js",
                      "/js/MessageBox/jquery.easing.1.3.js", "/js/MessageBox/alertbox.js", "/Modules/AspxCommerce/AspxOutOfStockNotification/js/stockNotification.js");


            StoreID = GetStoreID;
            PortalID = GetPortalID;
            UserName = GetUsername;
            UserModuleID = SageUserModuleID;
            CultureName = GetCurrentCultureName;
            SecurityPolicy objSecurity = new SecurityPolicy();
            FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
            if (ticket != null && ticket.Name != ApplicationKeys.anonymousUser)
            {
                MembershipController member = new MembershipController();
                UserInfo userDetail = member.GetUserDetails(GetPortalID, GetUsername);
                userEmail = userDetail.Email;
            }
        }
        IncludeLanguageJS();
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalServicePath",
                                                " var aspxservicePath='" + ResolveUrl("~/") +
                                                "Modules/AspxCommerce/AspxCommerceServices/" + "';", true);
        
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         GetPortalCommonInfo(out StoreID, out PortalID, out CustomerID, out UserName, out CultureName, out SessionCode);
         AspxCommonInfo aspxCommonObj = new AspxCommonInfo(StoreID, PortalID, UserName, CultureName);
         ServicePath = ResolveUrl(this.AppRelativeTemplateSourceDirectory);
         SecurityPolicy objSecurity = new SecurityPolicy();
         FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
         templateName = TemplateName;
         IncludeCss("WishItemListCSS", "/Templates/" + templateName + "/css/MessageBox/style.css", "/Templates/" + templateName + "/css/PopUp/style.css", "/Templates/" + templateName + "/css/ToolTip/tooltip.css", "/Modules/AspxCommerce/AspxWishList/css/WishItems.css");
         IncludeJs("WishItemListJS", "/Modules/AspxCommerce/AspxWishList/js/WishItemList.js", "/js/Paging/jquery.pagination.js", "/js/DateTime/date.js", "/js/MessageBox/jquery.easing.1.3.js", "/js/MessageBox/alertbox.js", "/js/PopUp/custom.js", "/js/jquery.tipsy.js", "/js/encoder.js");
         if (ticket != null && ticket.Name != ApplicationKeys.anonymousUser)
         {
             MembershipController member = new MembershipController();
             UserInfo userDetail = member.GetUserDetails(GetPortalID, GetUsername);
             UserFullName = userDetail.FirstName + " " + userDetail.LastName;
             UserEmailWishList = userDetail.Email;
             if (UserEmailWishList.Contains(","))
             {
                 string[] commaSeparator = { "," };
                 string[] value = UserEmailWishList.Split(commaSeparator, StringSplitOptions.RemoveEmptyEntries);
                 UserEmailWishList = value[0];
             }
             if (!string.IsNullOrEmpty(SageUserModuleID))
             {
                 UserModuleIDWishList = int.Parse(SageUserModuleID);
             }
             if (!IsPostBack)
             {
                 resolveUrl = ResolveUrl("~/"); 
             }
             StoreSettingConfig ssc = new StoreSettingConfig();
             ssc.GetStoreSettingParamFour(StoreSetting.ShowAddToCartButton, StoreSetting.DefaultProductImageURL, StoreSetting.AllowOutStockPurchase, StoreSetting.SortByOptions, out AllowAddToCart, out NoImageWishList, out AllowOutStockPurchase, out sortByOptions, StoreID, PortalID, CultureName);
         }
         else
         {
             SageFrameConfig pagebase = new SageFrameConfig();
             pageExtension = SageFrameSettingKeys.PageExtension;
             if (GetPortalID > 1)
             {
                 Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage)) + pageExtension + "?ReturnUrl=" + Request.Url.ToString(), false);
             }
             else
             {
                 Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage)) + pageExtension + "?ReturnUrl=" + Request.Url.ToString(), false);
             }
         }
         IncludeLanguageJS();
         BindWishList(aspxCommonObj);
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            IncludeLanguageJS();
            Extension = SageFrameSettingKeys.PageExtension;
            SecurityPolicy objSecurity = new SecurityPolicy();
            FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
            if (ticket != null)
            {
                int LoggedInPortalID = int.Parse(ticket.UserData.ToString());
                if (ticket.Name != ApplicationKeys.anonymousUser)
                {
                    string[] sysRoles = SystemSetting.SUPER_ROLE;
                    if (GetPortalID == LoggedInPortalID || Roles.IsUserInRole(ticket.Name, sysRoles[0]))
                    {
                        RoleController _role = new RoleController();
                        string userinroles = _role.GetRoleNames(GetUsername, LoggedInPortalID);
                        if (userinroles != string.Empty || userinroles != null)
                        {

                        }
                        else
                        {
                            lnkloginStatus.Text = SageLogInText;
                            lnkloginStatus.CommandName = "LOGIN";
                        }
                    }
                    else
                    {
                        lnkloginStatus.Text = SageLogInText;
                        lnkloginStatus.CommandName = "LOGIN";
                    }
                    lnkloginStatus.Text = SageLogOutText;
                    lnkloginStatus.CommandName = "LOGOUT";
                }
                else
                {
                    lnkloginStatus.Text = SageLogInText;
                    lnkloginStatus.CommandName = "LOGIN";
                }
            }
            else
            {
                lnkloginStatus.Text = SageLogInText;
                lnkloginStatus.CommandName = "LOGIN";
            }
        }
        catch
        {
        }
    }
 public static string IssueToken(int portalID)
 {
     string token = "";
     string uniqueId = Guid.NewGuid().ToString();
     RoleController role = new RoleController();
     string roles = role.GetRoleNames(GetUser(portalID), portalID).ToLower(); //.Split(',');
     SecurityPolicy objSecurity = new SecurityPolicy();
     string authcookie = objSecurity.FormsCookieName(portalID);
     string auth = IsUserLoggedIn(portalID) ? authcookie : "anonymoususer";
     string timestamp = DateTime.Now.ToString("yyyyMMddHHmmssffff");
     token = uniqueId + ":" + auth + ":" + timestamp;
     HttpContext.Current.Session["Auth_Token"] = token;
     return token;
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        IncludeLanguageJS();
        appPath = GetApplicationName;
        SecurityPolicy objSecurity = new SecurityPolicy();
        userName = objSecurity.GetUser(GetPortalID);
        Extension = SageFrameSettingKeys.PageExtension;


        if (!IsPostBack)
        {
            // BindThemes();
            //BindLayouts();
            //BindValues();
            hlnkDashboard.Visible = false;
            SageFrameConfig conf = new SageFrameConfig();
            string ExistingPortalShowProfileLink = conf.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalShowProfileLink);
            lnkAccount.NavigateUrl = GetProfileLink();
            if (ExistingPortalShowProfileLink == "1")
            {
                lnkAccount.Visible = true;
            }
            else
            {
                lnkAccount.Visible = false;
            }
            SageFrame.Application.Application app = new SageFrame.Application.Application();
            lblVersion.Text = string.Format("V {0}", app.FormatShortVersion(app.Version, true));
        }
        hypLogo.NavigateUrl = GetPortalAdminPage();
        hypLogo.ImageUrl = appPath + "/Administrator/Templates/Default/images/sagecomers-logoicon.png";
        RoleController _role = new RoleController();
        string[] roles = _role.GetRoleNames(GetUsername, GetPortalID).ToLower().Split(',');
        if (roles.Contains(SystemSetting.SUPER_ROLE[0].ToLower()) || roles.Contains(SystemSetting.SITEADMIN.ToLower()))
        {
            hlnkDashboard.Visible = true;
            hlnkDashboard.NavigateUrl = GetPortalAdminPage();
            cpanel.Visible = true;
            AspxAdminNotificationView1.Visible = true;
            IsAdmin = true;
        }
        else
        {
            cpanel.Visible = false;
        }
        
    }
 private static bool IsUserLoggedIn(int portalID)
 {
     bool IsLoggedIn = false;
     SecurityPolicy objSecurity = new SecurityPolicy();
     FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(portalID);
     if (ticket != null)
     {
         int LoggedInPortalID = ticket.UserData != "" && ticket.UserData != null ? int.Parse(ticket.UserData.ToString()) : 0;
         if (ticket.Name != ApplicationKeys.anonymousUser)
         {
             string[] sysRoles = SystemSetting.SUPER_ROLE;
             if (portalID == LoggedInPortalID || Roles.IsUserInRole(ticket.Name, sysRoles[0]))
             {
                 IsLoggedIn = true;
             }
         }
     }
     return IsLoggedIn;
 }
 public bool CheckSessionActive(AspxCommonInfo aspxCommonObj)
 {
     if (HttpContext.Current.User != null)
     {
         SecurityPolicy objSecurity = new SecurityPolicy();
         FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(aspxCommonObj.PortalID);
         if (ticket != null && ticket.Name != ApplicationKeys.anonymousUser)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     else
     {
         return false;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            Extension = SageFrameSettingKeys.PageExtension;
            SageFrameConfig sfConfig = new SageFrameConfig();
            SecurityPolicy objSecurity = new SecurityPolicy();
            userName = objSecurity.GetUser(GetPortalID);
            if (!IsPostBack)
            {
                profileText = GetSageMessage("LoginStatus", "MyProfile");
                Literal lnkProfileUrl = (Literal)LoginView1.TemplateControl.FindControl("lnkProfileUrl");
                RegisterURL = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalRegistrationPage) + SageFrameSettingKeys.PageExtension;
                if (sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalShowProfileLink) == "1")
                {
                    if (!IsParent)
                    {
                        profileURL = "<a  href='" + GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalUserProfilePage) + SageFrameSettingKeys.PageExtension + "'>" + profileText + "</a>";
                    }
                    else
                    {
                        profileURL = "<a  href='" + GetParentURL + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalUserProfilePage) + SageFrameSettingKeys.PageExtension + "'>" + profileText + "</a>";
                    }

                }
                else
                {
                    profileURL = "";
                }
                if (!IsParent)
                {
                    RegisterURL = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalRegistrationPage) + SageFrameSettingKeys.PageExtension;
                }
                else
                {
                    RegisterURL = GetParentURL + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalRegistrationPage) + SageFrameSettingKeys.PageExtension;
                }

            }
        }
 private void SetPortalCofig()
 {
     Hashtable hstPortals = GetPortals();
     SageUserControl suc = new SageUserControl();
     suc.PagePath = PagePath;
     int portalID = 1;
     #region "Get Portal SEO Name and PortalID"
     if (string.IsNullOrEmpty(Request.QueryString["ptSEO"]))
     {
         if (string.IsNullOrEmpty(PortalSEOName))
         {
             PortalSEOName = GetDefaultPortalName(hstPortals, 1);// 1 is default parent PortalID 
         }
         else if (!hstPortals.ContainsKey(PortalSEOName.ToLower().Trim()))
         {
             PortalSEOName = GetDefaultPortalName(hstPortals, 1);
         }
         else
         {
             portalID = int.Parse(hstPortals[PortalSEOName.ToLower().Trim()].ToString());
         }
     }
     else
     {
         PortalSEOName = Request.QueryString["ptSEO"].ToString().ToLower().Trim();
         portalID = Int32.Parse(Request.QueryString["ptlid"].ToString());
     }
     #endregion
     suc.SetPortalSEOName(PortalSEOName.ToLower().Trim());
     Session[SessionKeys.SageFrame_PortalSEOName] = PortalSEOName.ToLower().Trim();
     Session[SessionKeys.SageFrame_PortalID] = portalID;
     Session[SessionKeys.SageFrame_AdminTheme] = ThemeHelper.GetAdminTheme(GetPortalID, GetUsername);
     Globals.sysHst[ApplicationKeys.ActiveTemplate + "_" + portalID] = TemplateController.GetActiveTemplate(GetPortalID).TemplateSeoName;
     Globals.sysHst[ApplicationKeys.ActivePagePreset + "_" + portalID] = PresetHelper.LoadActivePagePreset(GetActiveTemplate, GetPageSEOName(Request.Url.ToString()));
     suc.SetPortalID(portalID);
     SetPortalID(portalID);
     #region "Set user credentials for modules"
     SecurityPolicy objSecurity = new SecurityPolicy();
     if (objSecurity.GetUser(GetPortalID) != string.Empty)
     {
         SettingProvider objSP = new SettingProvider();
         SageFrameConfig sfConfig = new SageFrameConfig();
         string strRoles = string.Empty;
         List<SageUserRole> sageUserRolles = objSP.RoleListGetByUsername(objSecurity.GetUser(GetPortalID), GetPortalID);
         if (sageUserRolles != null)
         {
             foreach (SageUserRole userRole in sageUserRolles)
             {
                 strRoles += userRole.RoleId + ",";
             }
         }
         if (strRoles.Length > 1)
         {
             strRoles = strRoles.Substring(0, strRoles.Length - 1);
         }
         if (strRoles.Length > 0)
         {
             SetUserRoles(strRoles);
         }
     }
     #endregion
 }
        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);
        }
 private void SetAdminParts()
 {
     SecurityPolicy objSecurity = new SecurityPolicy();
     HttpCookie authCookie = Request.Cookies[objSecurity.FormsCookieName(GetPortalID)];
     if (authCookie != null)
     {
         RoleController _role = new RoleController();
         bool isDashboardAccessible = _role.IsDashboardAccesible(GetUsername, GetPortalID);
         if (isDashboardAccessible)
         {
             divAdminControlPanel.Visible = true;
             ApplicationController objAppController = new ApplicationController();
             // objAppController.ChangeCss(Page, "pchWhole", "lytA", "sfOuterWrapper", "style", "margin-top:30px");
         }
     }
     else
     {
         divAdminControlPanel.Visible = false;
     }
     if (IsHandheld())
     {
         divAdminControlPanel.Visible = false;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            IncludeLanguageJS();
            Extension = SageFrameSettingKeys.PageExtension;
            if (!IsPostBack)
            {
                int logHit = Convert.ToInt32(Session[SessionKeys.LoginHitCount]);
                if (logHit >= 3)
                {
                    dvCaptchaField.Visible = true;
                    InitializeCaptcha();
                    GenerateCaptchaImage();
                }
                else
                {
                    dvCaptchaField.Visible = false;
                }

                Refresh.ImageUrl = GetTemplateImageUrl("imgrefresh.png", true);
                Password.Attributes.Add("onkeypress", "return clickButton(event,'" + LoginButton.ClientID + "')");
                if (!IsParent)
                {
                    hypForgotPassword.NavigateUrl =
                       GetParentURL + "/portal/" + GetPortalSEOName + "/" +
                                   pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalForgotPassword) + Extension;
                }
                else
                {
                    hypForgotPassword.NavigateUrl =
                        GetParentURL + "/" + pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalForgotPassword) +
                                   Extension;
                }
                string registerUrl =
                    GetParentURL + "/" + pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalUserRegistration) +
                               Extension;

                if (pagebase.GetSettingBoolValueByIndividualKey(SageFrameSettingKeys.RememberCheckbox))
                {
                    chkRememberMe.Visible = true;
                    lblrmnt.Visible = true;
                }
                else
                {
                    chkRememberMe.Visible = false;
                    lblrmnt.Visible = false;
                }
            }
            SecurityPolicy objSecurity = new SecurityPolicy();
            FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
            if (ticket != null && ticket.Name != ApplicationKeys.anonymousUser)
            {
                int LoggedInPortalID = int.Parse(ticket.UserData.ToString());
                string[] sysRoles = SystemSetting.SUPER_ROLE;
                if (GetPortalID == LoggedInPortalID || Roles.IsUserInRole(ticket.Name, sysRoles[0]))
                {
                    RoleController _role = new RoleController();
                    string userinroles = _role.GetRoleNames(GetUsername, LoggedInPortalID);
                    if (userinroles != "" || userinroles != null)
                    {
                        MultiView1.ActiveViewIndex = 1;
                    }
                    else
                    {
                        MultiView1.ActiveViewIndex = 0;
                    }
                }
                else
                {
                    MultiView1.ActiveViewIndex = 0;
                }

            }
            else
            {
                MultiView1.ActiveViewIndex = 0;
            }
            // Added For openID services
            divOpenIDProvider.Visible = false;
            if (AllowRegistration())
            {
                if (pagebase.GetSettingBoolValueByIndividualKey(SageFrameSettingKeys.ShowOpenID) == true)
                {
                    divOpenIDProvider.Visible = true;
                    CheckOpenID();
                }
            }
        }
        private void SagePageLoadPart()
        {
            if (!IsPostBack)
            {
                string sageNavigateUrl = string.Empty;
                SageFrameConfig sfConfig = new SageFrameConfig();

                if (!IsParent)
                {
                    sageNavigateUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension;
                }
                else
                {
                    sageNavigateUrl = GetParentURL + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension;
                }
                hypHome.NavigateUrl = sageNavigateUrl;//GetHostURL + "/Admin/Admin" + Extension;
                // hypHome.Text = sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage);
                //hypHome.ImageUrl = GetAdminImageUrl("home.png", true);
                hypPreview.NavigateUrl = sageNavigateUrl;
                lnkAccount.NavigateUrl = GetProfileLink(sfConfig);
                Image imgProgress = (Image)UpdateProgress1.FindControl("imgPrgress");
                if (imgProgress != null)
                {
                    imgProgress.ImageUrl = GetAdminImageUrl("ajax-loader.gif", true);
                }
                // bool IsAdmin = false;
                SecurityPolicy objSecurity = new SecurityPolicy();
                FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
                if (ticket != null)
                {
                    int LoggedInPortalID = int.Parse(ticket.UserData.ToString());
                    if (ticket.Name != ApplicationKeys.anonymousUser)
                    {
                        string[] sysRoles = SystemSetting.SYSTEM_SUPER_ROLES;
                        this.hypUpgrade.Visible = IsParent ? (Roles.IsUserInRole(ticket.Name, sysRoles[1]) ? true : false) : false;

                        if (GetPortalID == LoggedInPortalID || Roles.IsUserInRole(ticket.Name, sysRoles[0]))
                        {
                            RoleController _role = new RoleController();
                            string userinroles = _role.GetRoleNames(GetUsername, LoggedInPortalID);
                            if (userinroles != "" || userinroles != null)
                            {
                                bool isDashboardAccessible = _role.IsDashboardAccesible(GetUsername, GetPortalID);
                                foreach (string role in sysRoles)
                                {
                                    if (userinroles.ToLower() == role)
                                    {
                                        isDashboardAccessible = true;
                                    }
                                }
                                if (!isDashboardAccessible)
                                {
                                    divAdminControlPanel.Visible = false;
                                }
                            }
                            else
                            {
                                divAdminControlPanel.Visible = false;
                            }
                        }
                        else
                        {
                            divAdminControlPanel.Visible = false;
                        }
                    }
                    else
                    {
                        divAdminControlPanel.Visible = false;
                    }

                }
                if (IsHandheld())
                {
                    divAdminControlPanel.Visible = false;
                }
            }
            //SessionTrackerController sTracController = new SessionTrackerController();
            //sTracController.SetSessionTrackerValues(GetPortalID.ToString(), GetUsername);
        }
        private string GetUserName()
        {

            try
            {
                SecurityPolicy sp = new SecurityPolicy();
                string userName = sp.GetUser(GetPortalID);
                if (userName != ApplicationKeys.anonymousUser)
                {
                    return userName;
                }
                else
                {
                    return ApplicationKeys.anonymousUser;
                }
            }
            catch
            {
                return ApplicationKeys.anonymousUser;
            }

        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            SageFrameConfig pagebase = new SageFrameConfig();
            string PortalLoginpage = pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage);//Ask santosh to get portal login page
            SecurityPolicy objSecurity = new SecurityPolicy();
            FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);

            AspxCommonInfo aspxCommonObj = new AspxCommonInfo();
            base.GetPortalCommonInfo(out storeID, out portalID, out customerID, out userName, out cultureName, out sessionCode);
            aspxCommonObj = new AspxCommonInfo(storeID, portalID, userName, cultureName, customerID, sessionCode);

            RewardPointsGeneralSettingsIsActive = RewardPointsController.RewardPointsGeneralSettingsIsActive(aspxCommonObj).ToString();

            StoreSettingConfig ssc = new StoreSettingConfig();
            ssc.GetStoreSettingParamThree(StoreSetting.AllowUsersToCreateMultipleAddress,
                                        StoreSetting.MainCurrency,
                                        StoreSetting.ShowAddToCartButton,
                                        out allowMultipleAddress,
                                        out CurrencyCodeSlected,
                                        out AllowAddToCart,
                                        storeID,
                                        portalID,
                                        cultureName
                                        );

            IsRewardInstl = AspxCommonController.GetModuleInstallationInfo("AspxRewardPoints", aspxCommonObj).ToString();

            if (ticket != null && ticket.Name != ApplicationKeys.anonymousUser)
            {
                if (!IsPostBack)
                {
                    string templateName = TemplateName;

                    IncludeCss("UserDashBoardCSS", "/Templates/" + templateName + "/css/GridView/tablesort.css", "/Templates/" + templateName + "/css/StarRating/jquery.rating.css", "/Templates/" + templateName + "/css/MessageBox/style.css",
                                "/Templates/" + templateName + "/css/PopUp/style.css", "/Templates/" + templateName + "/css/JQueryUIFront/jquery.ui.all.css", "/Templates/" + templateName + "/css/PasswordValidation/jquery.validate.password.css", "/Templates/" + templateName + "/css/ToolTip/tooltip.css");
                    IncludeJs("UserDashBoardJS", "/Modules/AspxCommerce/AspxWishList/js/WishItemList.js", "/js/jDownload/jquery.jdownload.js", "/js/DateTime/date.js", "/js/MessageBox/jquery.easing.1.3.js",
                        "/js/MessageBox/alertbox.js", "/js/StarRating/jquery.MetaData.js", "/js/FormValidation/jquery.validate.js", "/js/PasswordValidation/jquery.validate.password.js",
                        "/js/GridView/jquery.grid.js", "/js/GridView/SagePaging.js", "/js/GridView/jquery.global.js", "/js/GridView/jquery.dateFormat.js", "/js/GridView/jquery.tablesorter.min.js", "/js/StarRating/jquery.rating.pack.js", "/js/encoder.js",
                        "/js/StarRating/jquery.rating.js", "/js/PopUp/custom.js", "/js/jquery.tipsy.js", "/Modules/AspxCommerce/AspxUserDashBoard/js/userdashboard.js", "/js/Paging/jquery.pagination.js", "/js/FormValidation/jquery.form-validation-and-hints.js");
                
                    userModuleIDUD = int.Parse(SageUserModuleID);
                    ModulePath = ResolveUrl(this.AppRelativeTemplateSourceDirectory);

                    MembershipController m = new MembershipController();
                    UserInfo sageUser = m.GetUserDetails(GetPortalID, GetUsername);

                    AspxCommonController objUser = new AspxCommonController();
                    UsersInfo userDetails = objUser.GetUserDetails(aspxCommonObj);

                    if (userDetails.UserName != null)
                    {
                        userEmail = userDetails.Email;
                        userFirstName = userDetails.FirstName;
                        userLastName = userDetails.LastName;
                        userPicture = userDetails.ProfilePicture;
                        userEmailWishList = userEmail;//userDetail.Email;//added later for wishlist
                        userIP = HttpContext.Current.Request.UserHostAddress;
                        IPAddressToCountryResolver ipToCountry = new IPAddressToCountryResolver();
                        ipToCountry.GetCountry(userIP, out countryName);
                    }


                    BindUserDetails();
                }
                IncludeAllLanguageJS();
            }
            else
            {
                if (!IsParent)
                {
                    Response.Redirect(ResolveUrl(GetParentURL + "/portal/" + GetPortalSEOName + "/" + PortalLoginpage) + ".aspx?ReturnUrl=" + Request.Url.ToString(), false);
                }
                else
                {
                    Response.Redirect(ResolveUrl("~/" + PortalLoginpage) + ".aspx?ReturnUrl=" + Request.Url.ToString(), false);
                }
            }
            IncludeAllLanguageJS();

            GetUserRecentActivity(aspxCommonObj);
            GetAddressBookDetails(aspxCommonObj);
            GetAllCountry();

            GetMyOrders(aspxCommonObj);

        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }
    }
    protected void Page_Load(object sender, EventArgs e)    
    {
        try
        {
            if (!IsPostBack)
            {
                IncludeCss("ItemsManage", "/Templates/" + TemplateName + "/css/GridView/tablesort.css", "/Templates/" + TemplateName + "/css/MessageBox/style.css", "/Templates/" + TemplateName + "/css/AjaxUploader/fileuploader.css",
                   "/Templates/" + TemplateName + "/css/Tabs/slidingtabs-vertical.css","/Modules/AspxCommerce/AspxItemsManagement/css/module.css");
              
                IncludeJs("ItemsManage",  "/js/GridView/jquery.grid.js","/js/FormValidation/jquery.validate.js",
                          "/js/GridView/SagePaging.js", "/js/GridView/jquery.global.js",
                          "/js/GridView/jquery.dateFormat.js", "/js/DateTime/date.js",
                          "/js/ImageGallery/jquery.mousewheel.js",
                          "/js/MessageBox/jquery.easing.1.3.js", "/js/MessageBox/alertbox.js",                        
                          "/js/Tabs/jquery.slidingtabs.js",
                          "/js/AjaxFileUploader/ajaxupload.js", "/js/PopUp/custom.js",
                          "/Modules/AspxCommerce/AspxItemsManagement/js/ItemManagement.js", "/js/PopUp/popbox.js",
                          "/js/CurrencyFormat/jquery.formatCurrency-1.4.0.js",
                          "/js/CurrencyFormat/jquery.formatCurrency.all.js", "/js/AjaxFileUploader/fileuploader.js");

                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ckEditorUserModuleID", " var ckEditorUserModuleID='" + SageUserModuleID + "';", true);
                IncludeJs("ItemsManageCk", "/Editors/ckeditor/ckeditor.js", "/Editors/ckeditor/adapters/jquery.js");
                //Page.ClientScript.RegisterClientScriptInclude("JQueryFormValidated", ResolveUrl("~/js/FormValidation/jquery.validate.js"));
                StoreID = GetStoreID;
                PortalID = GetPortalID;
                UserName = GetUsername;
                UserModuleId = SageUserModuleID;
                CultureName = GetCurrentCultureName;
                SecurityPolicy objSecurity = new SecurityPolicy();
                FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
                if (ticket != null && ticket.Name != ApplicationKeys.anonymousUser)
                {
                    MembershipController member = new MembershipController();
                    UserInfo userDetail = member.GetUserDetails(GetPortalID, GetUsername);
                    userEmail = userDetail.Email;
                }
                StoreSettingConfig ssc = new StoreSettingConfig();
                MaximumFileSize = int.Parse(ssc.GetStoreSettingsByKey(StoreSetting.MaximumImageSize, StoreID, PortalID, CultureName));
                MaxDownloadFileSize = int.Parse(ssc.GetStoreSettingsByKey(StoreSetting.MaxDownloadFileSize, StoreID, PortalID, CultureName));
                PriceUnit = ssc.GetStoreSettingsByKey(StoreSetting.MainCurrency, StoreID, PortalID, CultureName);
                WeightUnit =ssc.GetStoreSettingsByKey(StoreSetting.WeightUnit, StoreID, PortalID, CultureName);
                DimensionUnit = ssc.GetStoreSettingsByKey(StoreSetting.DimensionUnit, StoreID, PortalID, CultureName);
                LowStockItemRss = ssc.GetStoreSettingsByKey(StoreSetting.LowStockItemRss, StoreID, PortalID, CultureName);
                CurrencyCodeSlected = ssc.GetStoreSettingsByKey(StoreSetting.MainCurrency, StoreID, PortalID,CultureName);
                AllowOutStockPurchase = ssc.GetStoreSettingsByKey(StoreSetting.AllowOutStockPurchase, StoreID, PortalID, CultureName);
                AllowRealTimeNotifications = ssc.GetStoreSettingsByKey(StoreSetting.AllowRealTimeNotifications, StoreID, PortalID, CultureName);
                if (AllowRealTimeNotifications.ToLower() == "true")
                {
                    IncludeJs("SignalR", false, "/js/SignalR/jquery.signalR-2.2.0.min.js", "/signalr/hubs", "/Modules/AspxCommerce/AspxStartUpEvents/js/RealTimeAspxMgmt.js");
                }
                if(LowStockItemRss.ToLower()=="true")
                {
                   RssFeedUrl = ssc.GetStoreSettingsByKey(StoreSetting.RssFeedURL, StoreID, PortalID, CultureName);
                }
                GetItemTabSetting();
            }
            
            AddLanguage();
            IncludeLanguageJS();
           
        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            IncludeLanguageJS();

            GetPortalCommonInfo(out storeID, out portalID, out customerID, out userName, out cultureName, out sessionCode);
            AspxCommonInfo aspxCommonObj = new AspxCommonInfo(storeID, portalID, userName, cultureName, customerID, sessionCode);

            List<CouponSession> cs = new List<CouponSession>();
            cs = CheckOutSessions.Get<List<CouponSession>>("CouponSession");
            Coupon = json_serializer.Serialize(cs);

            List<GiftCardUsage> gc = CheckOutSessions.Get<List<GiftCardUsage>>("UsedGiftCard");
            GiftCard = json_serializer.Serialize(gc);

            Discount = CheckOutSessions.Get<Decimal>("DiscountAmount", 0);

            string templateName = TemplateName;
            IncludeCss("CheckOutInformationContent", "/Templates/" + templateName + "/css/MessageBox/style.css", "/Templates/" + templateName + "/css/JQueryUIFront/jquery.ui.all.css",
                "/Templates/" + templateName + "/css/ToolTip/tooltip.css", "/Modules/AspxCommerce/AspxCheckoutWithSingleAddress/css/module.css");
            IncludeJs("CheckOutInformationContent", "/js/encoder.js", "/js/FormValidation/jquery.validate.js", "/js/jquery.cookie.js", "/js/MessageBox/jquery.easing.1.3.js", "/js/MessageBox/alertbox.js", "/js/jquery.tipsy.js", "/Modules/AspxCommerce/AspxCheckoutWithSingleAddress/js/SingleCheckOut.js");

            ssc.GetStoreSettingParamEleven(StoreSetting.DefaultProductImageURL, StoreSetting.ShoppingCartURL, StoreSetting.MyAccountURL,
                StoreSetting.AllowedShippingCountry, StoreSetting.AllowedBillingCountry, StoreSetting.SingleCheckOutURL,
                StoreSetting.DimensionUnit, StoreSetting.WeightUnit, StoreSetting.AskCustomerToSubscribe, StoreSetting.ShipDetailPageURL,
                StoreSetting.AllowUsersToCreateMultipleAddress, out noImageCheckOutInfoPath, out ShoppingCartURL, out myAccountURL,
                out AllowededShippingCountry, out AllowededBillingCountry, out SingleAddressCheckOutURL, out DimentionalUnit,
                out WeightUnit, out ShowSubscription, out ShippingDetailPage, out allowMultipleAddress, storeID, portalID, cultureName);

            if (!IsPostBack)
            {

                HideSignUp();
                PasswordAspx.Attributes.Add("onkeypress", "return clickButton(event,'" + LoginButton.ClientID + "')");

                if (!IsParent)
                {
                    hypForgotPassword.NavigateUrl =
                        ResolveUrl(GetParentURL + "/portal/" + GetPortalSEOName + "/sf/" +
                                   pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalForgotPassword) + SageFrameSettingKeys.PageExtension);
                }
                else
                {
                    hypForgotPassword.NavigateUrl =
                        ResolveUrl("~/sf/" + pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalForgotPassword) +
                                  SageFrameSettingKeys.PageExtension);
                }
                string registerUrl =
                    ResolveUrl("~/sf/" + pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalUserRegistration) +
                               SageFrameSettingKeys.PageExtension);
                signup.Attributes.Add("href", ResolveUrl("~/sf/sfUser-Registration" + SageFrameSettingKeys.PageExtension));
                signup1.Attributes.Add("href", ResolveUrl("~/sf/sfUser-Registration" + SageFrameSettingKeys.PageExtension));

                if (Boolean.Parse(pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.RememberCheckbox)))
                {
                    RememberMe.Visible = true;
                    lblrmnt.Visible = true;
                }
                else
                {
                    RememberMe.Visible = false;
                    lblrmnt.Visible = false;
                }

                object serverVars = new
                {
                    noImageCheckOutInfoPath = noImageCheckOutInfoPath,
                    ShoppingCartURL = ShoppingCartURL,
                    myAccountURL = myAccountURL,
                    singleAddressCheckOutURL = SingleAddressCheckOutURL,
                    CartUrl = ShoppingCartURL,
                    AllowedShippingCountry = AllowededShippingCountry,
                    AllowedBillingCountry = AllowededBillingCountry,
                    dimentionalUnit = DimentionalUnit,
                    weightunit = WeightUnit,
                    showSubscription = ShowSubscription,
                    allowMultipleAddress = allowMultipleAddress,
                    shippingDetailPage = ShippingDetailPage,
                    Discount = Discount

                };

                ServerVars = json_serializer.Serialize(serverVars);
                LoadCartDetails(aspxCommonObj);
                LoadCountry();
                LoadAddress(aspxCommonObj);
                LoadPaymentGateway(aspxCommonObj);
                LoadRewardPoints(aspxCommonObj);
            }


            if (HttpContext.Current.User != null)
            {
                SecurityPolicy objSecurity = new SecurityPolicy();
                FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
                if (ticket != null && ticket.Name != ApplicationKeys.anonymousUser)
                {
                    int LoggedInPortalID = int.Parse(ticket.UserData.ToString());
                    string[] sysRoles = SystemSetting.SUPER_ROLE;
                    MembershipController member = new MembershipController();
                    UserInfo userDetail = member.GetUserDetails(GetPortalID, GetUsername);
                    if (GetPortalID == LoggedInPortalID || Roles.IsUserInRole(userDetail.UserName, sysRoles[0]))
                    {
                        RoleController _role = new RoleController();
                        string userinroles = _role.GetRoleNames(GetUsername, LoggedInPortalID);
                        if (userinroles != "" || userinroles != null)
                        {
                            MultiView1.ActiveViewIndex = 1;
                        }
                        else
                        {
                            MultiView1.ActiveViewIndex = 0;
                        }
                    }
                    else
                    {
                        MultiView1.ActiveViewIndex = 0;
                    }
                }
                else
                {
                    MultiView1.ActiveViewIndex = 0;
                }
            }

        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }

    }
 private void SetCustomerID()
 {
     int customerID = 0;
     SecurityPolicy objSecurity = new SecurityPolicy();
     FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
     if (ticket != null)
     {
         CustomerGeneralInfo sageUserCust = CustomerGeneralInfoController.CustomerIDGetByUsername(ticket.Name, GetStoreID, GetPortalID);
         if (sageUserCust != null)
         {
             customerID = sageUserCust.CustomerID;
         }
         Session[SessionKeys.SageFrame_CustomerID] = customerID;
     }
 }
        private void LogInPublicModeRegistration()
        {
            string strRoles = string.Empty;
            MembershipController member = new MembershipController();
            RoleController role = new RoleController();
            UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text.Trim());

            if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text)))
            {
                if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt))
                {
                    string userRoles = role.GetRoleNames(user.UserName, GetPortalID);
                    strRoles += userRoles;
                    if (strRoles.Length > 0)
                    {
                        SetUserRoles(strRoles);
                        //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker];
                        //sessionTracker.PortalID = GetPortalID.ToString();
                        //sessionTracker.Username = UserName.Text;
                        //Session[SessionKeys.Tracker] = sessionTracker;
                        SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog();
                        SageFrameConfig SageConfig = new SageFrameConfig();
                        SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension);
                        bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.EnableSessionTracker));
                        if (EnableSessionTracker)
                        {
                            SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString());
                        }
                        {
                            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                  user.UserName,
                                  DateTime.Now,
                                  DateTime.Now.AddMinutes(30),
                                  true,
                                  GetPortalID.ToString(),
                                  FormsAuthentication.FormsCookiePath);

                            StoreSettingConfig ssc = new StoreSettingConfig();


                            if (ssc.GetStoreSettingsByKey(StoreSetting.AllowRealTimeNotifications, GetStoreID, GetPortalID, GetCurrentCultureName).ToLower() == "true")
                            {
                                RealTimeHelper.UpdateAdminNotifications(GetStoreID, GetPortalID);    
                            }
                            

                            // Encrypt the ticket.
                            string encTicket = FormsAuthentication.Encrypt(ticket);

                            // Create the cookie.
                            string randomCookieValue = GenerateRandomCookieValue();
                            Session[SessionKeys.RandomCookieValue] = randomCookieValue;
                            SecurityPolicy objSecurity = new SecurityPolicy();
                            HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket);
                            SageFrameConfig objConfig = new SageFrameConfig();
                            string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration);
                            int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration));
                            expiryTime = expiryTime < 5 ? 5 : expiryTime;
                            cookie.Expires = DateTime.Now.AddMinutes(expiryTime);
                            Response.Cookies.Add(cookie);
                            string sessionCode = string.Empty;
                            ServiceSecurity.IssueToken(GetPortalID);
                            if (HttpContext.Current.Session.SessionID != null)
                            {
                                sessionCode = HttpContext.Current.Session.SessionID.ToString();
                            }
                            int CustomerID = GetUserDetailsByUserName(UserName.Text,GetPortalID).CustomerID;
                            UpdateCartAnonymoususertoRegistered(GetStoreID, GetPortalID, CustomerID, sessionCode);
                            if (!IsParent)
                            {
                                Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false);
                            }
                            else
                            {
                                Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false);
                            }
                        }
                    }
                }
            }
        }
        public void GetPortalCommonInfo(out int StoreID, out int PortalID, out string UserName, out string CultureName)
        {
            StoreID = 0;
            if (HttpContext.Current.Session[SessionKeys.SageFrame_StoreID] != null &&
                   HttpContext.Current.Session[SessionKeys.SageFrame_StoreID].ToString() != string.Empty)
            {
                StoreID = Int32.Parse(HttpContext.Current.Session[SessionKeys.SageFrame_StoreID].ToString());
            }
            PortalID = 0;
            if (HttpContext.Current.Session[SessionKeys.SageFrame_PortalID] != null &&
                   HttpContext.Current.Session[SessionKeys.SageFrame_PortalID].ToString() != string.Empty)
            {
                PortalID = Int32.Parse(HttpContext.Current.Session[SessionKeys.SageFrame_PortalID].ToString());
            }
            try
            {
                SecurityPolicy objSecurity = new SecurityPolicy();
                UserName = objSecurity.GetUser(GetPortalID);

            }
            catch
            {
                UserName = ApplicationKeys.anonymousUser;
            }
            CultureName = CultureInfo.CurrentCulture.Name;
        }
    public void CheckAccess()
    {
        string preFix = string.Empty;
        string paneName = string.Empty;
        string ControlSrc = string.Empty;
        string phdContainer = string.Empty;
        string PageSEOName = string.Empty;
        string redirecPath = string.Empty;
        SageFrameConfig sfConfig = new SageFrameConfig();
        IsUseFriendlyUrls = sfConfig.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls);
        StoreAccessDetailsInfo storeAccessTracker = new StoreAccessDetailsInfo();
        storeAccessTracker.PortalID = GetPortalID;
        storeAccessTracker.StoreID = GetStoreID;
        storeAccessTracker.Username = GetUsername;
        SecurityPolicy objSecurity = new SecurityPolicy();
        FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
        StoreAccessResultInfo saResults = (StoreAccessResultInfo) GetStoreAccessByCurrentData(storeAccessTracker);
        bool storeClosed = (bool) saResults.StoreClosed;
        bool storeAccessible = (bool) saResults.IsAccess;

        if (storeAccessible)
        {

                       string returnURL = HttpContext.Current.Session["StoreClosed"].ToString();
            HttpContext.Current.Session.Remove("StoreClosed");
            Response.Redirect(returnURL);

        }
        else
        {
        }

    }
 /// <summary>
 /// Returns username
 /// </summary>
 /// <param name="portalID">portalID</param>
 /// <param name="authToken"> authentication token</param>
 /// <returns>Returns userName</returns>
 private string GetUsername(int portalID, string authToken)
 {
     try
     {
         SecurityPolicy objSecurity = new SecurityPolicy();
         string userName = objSecurity.GetUser(portalID, authToken);
         if (userName != ApplicationKeys.anonymousUser)
         {
             return userName;
         }
         else
         {
             return ApplicationKeys.anonymousUser;
         }
     }
     catch
     {
         return ApplicationKeys.anonymousUser;
     }
 }
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        MembershipController member = new MembershipController();
        RoleController role = new RoleController();
        UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text);
        if (user.UserExists && user.IsApproved)
        {
            if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(PasswordAspx.Text)))
            {
                if (PasswordHelper.ValidateUser(user.PasswordFormat, PasswordAspx.Text, user.Password, user.PasswordSalt))
                {
                    string userRoles = role.GetRoleNames(user.UserName, GetPortalID);
                    strRoles += userRoles;
                    if (strRoles.Length > 0)
                    {
                        SetUserRoles(strRoles);
                        //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker];
                        //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker];
                        //sessionTracker.PortalID = GetPortalID.ToString();
                        //sessionTracker.Username = UserName.Text;
                        //Session[SessionKeys.Tracker] = sessionTracker;
                        SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog();
                        SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString());

                        StringBuilder redirectURL = new StringBuilder();
                        SecurityPolicy objSecurity = new SecurityPolicy();
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                          user.UserName,
                          DateTime.Now,
                          DateTime.Now.AddMinutes(30),
                          true,
                          GetPortalID.ToString(),
                          FormsAuthentication.FormsCookiePath);

                        string encTicket = FormsAuthentication.Encrypt(ticket);

                        string randomCookieValue = GenerateRandomCookieValue();
                        Session[SessionKeys.RandomCookieValue] = randomCookieValue;
                        HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket);
                        SageFrameConfig objConfig = new SageFrameConfig();
                        string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration);
                        int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration));
                        expiryTime = expiryTime < 5 ? 5 : expiryTime;
                        cookie.Expires = DateTime.Now.AddMinutes(expiryTime);
                        Response.Cookies.Add(cookie);
                        ServiceSecurity.IssueToken(GetPortalID);
                        if (Request.QueryString["ReturnUrl"] != null)
                        {
                            string PageNotFoundPage = PortalAPI.PageNotFoundURLWithRoot;
                            string UserRegistrationPage = PortalAPI.RegistrationURLWithRoot;
                            string PasswordRecoveryPage = PortalAPI.PasswordRecoveryURLWithRoot;
                            string ForgotPasswordPage = PortalAPI.ForgotPasswordURL;
                            string PageNotAccessiblePage = PortalAPI.PageNotAccessibleURLWithRoot;

                            string ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString();

                            if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage)
                            {
                                redirectURL.Append(GetParentURL);
                                redirectURL.Append(PortalAPI.DefaultPageWithExtension);
                            }
                            else
                            {
                                redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString()));
                            }
                        }
                        else
                        {




                            if (!IsParent)
                            {
                                redirectURL.Append(GetParentURL);
                                redirectURL.Append("/portal/");
                                redirectURL.Append(GetPortalSEOName);
                                redirectURL.Append("/");
                                redirectURL.Append(ssc.GetStoreSettingsByKey(StoreSetting.SingleCheckOutURL, GetStoreID, GetPortalID, GetCurrentCultureName));
                                redirectURL.Append(SageFrameSettingKeys.PageExtension);
                            }
                            else
                            {
                                redirectURL.Append(GetParentURL);
                                redirectURL.Append("/");
                                redirectURL.Append(ssc.GetStoreSettingsByKey(StoreSetting.SingleCheckOutURL, GetStoreID, GetPortalID, GetCurrentCultureName));
                                redirectURL.Append(SageFrameSettingKeys.PageExtension);
                            }

                        }

                        int customerID = GetCustomerID;
                        if (customerID == 0)
                        {
                            CustomerGeneralInfo sageUserCust = CustomerGeneralInfoController.CustomerIDGetByUsername(user.UserName, storeID, portalID);
                            if (sageUserCust != null)
                            {
                                customerID = sageUserCust.CustomerID;
                            }
                        }
                        AspxCommonController objCommonCont = new AspxCommonController();
                        objCommonCont.UpdateCartAnonymoususertoRegistered(storeID, portalID, customerID, sessionCode);
                        Response.Redirect(redirectURL.ToString(), false);
                    }
                    else
                    {
                        FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal"));
                    }
                }
                else
                {
                    FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched"));//"Username and Password combination doesn't matched!";
                }
            }
        }
        else
        {
            FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UserDoesnotExist"));
        }
    }
        private static bool CheckAuth(int portalId, int userModuleId, string uName, string authToken, string permType)
        {
            string spName = "";
            spName = permType == "v" ? "usp_CheckModulePermissionView" : "usp_CheckModulePermissionEdit";
            SecurityPolicy objSecurity = new SecurityPolicy();
            string userName = objSecurity.GetUser(portalId, authToken);

            if (userName == "superuser")
            {
                return true;
            }
            else if (permType == "e" && uName != "anonymoususer" && uName == userName)
            {
                List<KeyValuePair<string, object>> para = new List<KeyValuePair<string, object>>();
                para.Add(new KeyValuePair<string, object>("@UserModuleID", userModuleId));
                para.Add(new KeyValuePair<string, object>("@PortalID", portalId));
                para.Add(new KeyValuePair<string, object>("@userName", uName));
                SQLHandler handler = new SQLHandler();
                int flag = handler.ExecuteAsScalar<int>(spName, para);
                if (flag == 1)
                    return true;
                else
                    return false;
            }
            else if (permType == "v" && uName == userName)
            {
                List<KeyValuePair<string, object>> para = new List<KeyValuePair<string, object>>();
                para.Add(new KeyValuePair<string, object>("@UserModuleID", userModuleId));
                para.Add(new KeyValuePair<string, object>("@PortalID", portalId));
                para.Add(new KeyValuePair<string, object>("@userName", uName));
                SQLHandler handler = new SQLHandler();
                int flag = handler.ExecuteAsScalar<int>(spName, para);
                if (flag == 1)
                    return true;
                else
                    return false;

            }
            return false;
        }
    protected void lnkloginStatus_Click(object sender, EventArgs e)
    {
        try
        {
   
            SageFrameConfig SageConfig = new SageFrameConfig();
            SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension);
            bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingsByKey(SageFrameSettingKeys.EnableSessionTracker));

            SessionTracker sessionTrackerNew = new SessionTracker();
            if (EnableSessionTracker)
            {
                string sessionID = HttpContext.Current.Session.SessionID;
                SageFrame.Web.SessionLog sLogNew = new SageFrame.Web.SessionLog();
                sLogNew.SessionLogStart(sessionTrackerNew, sessionID);
            }           
            string ReturnUrl = string.Empty;
            string RedUrl = string.Empty;
            SageFrameConfig sfConfig = new SageFrameConfig();
            if (lnkloginStatus.CommandName == "LOGIN")
            {

                if (Request.QueryString["ReturnUrl"] == null)
                {
                    ReturnUrl = Request.RawUrl.ToString();
                    if (!(ReturnUrl.ToLower().Contains(SageFrameSettingKeys.PageExtension)))
                    {
                        //ReturnUrl = ReturnUrl.Remove(strURL.LastIndexOf('/'));
                        if (ReturnUrl.EndsWith("/"))
                        {
                            ReturnUrl += sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension;
                        }
                        else
                        {
                            ReturnUrl += '/' + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension;
                        }
                    }
                }
                else
                {
                    ReturnUrl = Request.QueryString["ReturnUrl"].ToString();
                }
                if (!IsParent)
                {
                    RedUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension;

                }
                else
                {
                    RedUrl = GetParentURL + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension;
                }

            }
            else
            {

                if (EnableSessionTracker)
                {
                    SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog();
                    sLog.SessionLogEnd(GetPortalID);
                }

                SecurityPolicy objSecurity = new SecurityPolicy();
                HttpCookie authenticateCookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID));
                authenticateCookie.Expires = DateTime.Now.AddYears(-1);
                string randomCookieValue = GenerateRandomCookieValue();
                HttpContext.Current.Session[SessionKeys.RandomCookieValue] = randomCookieValue;
                Response.Cookies.Add(authenticateCookie);
                lnkloginStatus.Text = "Login";
                SetUserRoles(string.Empty);
                //create new sessionID
                SessionIDManager manager = new SessionIDManager();
                manager.RemoveSessionID(System.Web.HttpContext.Current);
                var newId = manager.CreateSessionID(System.Web.HttpContext.Current);
                var isRedirected = true;
                var isAdded = true;
                manager.SaveSessionID(System.Web.HttpContext.Current, newId, out isRedirected, out isAdded);

                if (!IsParent)
                {
                    RedUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension;
                }
                else
                {
                    RedUrl = GetParentURL + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension;
                }
            }
            CheckOutHelper cHelper = new CheckOutHelper();
            cHelper.ClearSessions();            

            FormsAuthentication.SignOut();
            Response.Redirect(RedUrl, false);
        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }
    }
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            SecurityPolicy objSecurity = new SecurityPolicy();
            FormsAuthenticationTicket ticket = objSecurity.GetUserTicket(GetPortalID);
            if (ticket != null && ticket.Name == ApplicationKeys.anonymousUser)
            {
                int logHit = Convert.ToInt32(Session[SessionKeys.LoginHitCount]);
                if (logHit >= 3)
                {
                    this.Session[SessionKeys.CaptchaImageText] = null;

                    if (ValidateCaptcha())
                    {
                        LoginUser();
                    }
                }
                else
                {
                    LoginUser();
                }
            }
        }
        protected void SucessFullLogin(UserInfo user)
        {
            RoleController role = new RoleController();
            Session[SessionKeys.LoginHitCount] = null;
            string userRoles = role.GetRoleNames(user.UserName, GetPortalID);
            strRoles += userRoles;
            if (strRoles.Length > 0)
            {
                SetUserRoles(strRoles);
                //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker];
                //sessionTracker.PortalID = GetPortalID.ToString();
                //sessionTracker.Username = UserName.Text;
                //Session[SessionKeys.Tracker] = sessionTracker;
                SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog();
                SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString());
                StringBuilder redirectURL = new StringBuilder();
                SecurityPolicy objSecurity = new SecurityPolicy();
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                        user.UserName,
                        DateTime.Now,
                        DateTime.Now.AddMinutes(30),
                        true,
                        GetPortalID.ToString(),
                        FormsAuthentication.FormsCookiePath);

                // Encrypt the ticket.
                string encTicket = FormsAuthentication.Encrypt(ticket);
                //generate random cookieValue
                string randomCookieValue = GenerateRandomCookieValue();
                Session[SessionKeys.RandomCookieValue] = randomCookieValue;
                //create new cookie with random cookie name and encrypted ticket
                HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket);
                //get default time from  setting
                SageFrameConfig objConfig = new SageFrameConfig();
                string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration);
                int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration));
                expiryTime = expiryTime < 5 ? 5 : expiryTime;
                //set cookie expiry time
                cookie.Expires = DateTime.Now.AddMinutes(expiryTime);
                //add cookie to the browser
                Response.Cookies.Add(cookie);
                ServiceSecurity.IssueToken(GetPortalID);

                if (Request.QueryString["ReturnUrl"] != null)
                {
                    string PageNotFoundPage = PortalAPI.PageNotFoundURLWithRoot;
                    string UserRegistrationPage = PortalAPI.RegistrationURLWithRoot;
                    string PasswordRecoveryPage = PortalAPI.PasswordRecoveryURLWithRoot;
                    string ForgotPasswordPage = PortalAPI.ForgotPasswordURL;
                    string PageNotAccessiblePage = PortalAPI.PageNotAccessibleURLWithRoot;
                    string ReturnUrlPage = string.Empty;
                    if (Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString().Contains(GetHostURL()))
                    {
                         ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString();
                    }
                    else
                    {
                         ReturnUrlPage = GetHostURL() + Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString();
                    }
                      string RequestURL = Request.Url.ToString();
                    Uri RequestURLPageUri = new Uri(RequestURL);
                    string portalHostURL = RequestURLPageUri.AbsolutePath.TrimStart('/');
                    if (GetApplicationName==string.Empty)
                    {
                    bool IsWellFormedReturnUrlPage = Uri.IsWellFormedUriString(ReturnUrlPage, UriKind.Absolute);

                    
                        if (IsWellFormedReturnUrlPage)
                        {
                            Uri ReturnUrlPageUri = new Uri(ReturnUrlPage);
                            string ReturnURl = ReturnUrlPageUri.Scheme + Uri.SchemeDelimiter + ReturnUrlPageUri.Host + ":" + ReturnUrlPageUri.Port;
                            string HostUrl = GetHostURL();
                            Uri uriHostURL = new Uri(HostUrl);
                            Uri uriReturnURL = new Uri(ReturnURl);
                            var resultCompareURL = Uri.Compare(uriHostURL, uriReturnURL,
                                UriComponents.Host | UriComponents.PathAndQuery,
                                UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase);
                            int resultComparePortalURL = 0;
                            if (portalHostURL.ToLower().Contains("portal") && resultCompareURL == 0)
                            {
                                Uri ReturnUrlPageHostUri = new Uri(ReturnUrlPage);
                                string portalReturnURL = ReturnUrlPageHostUri.AbsolutePath.TrimStart('/');
                                string[] portalReturnURLSplit = portalReturnURL.Split('/');
                                string ReturnURLSplitPortal = portalReturnURLSplit[0];
                                string ReturnURLSplitPortalName = portalReturnURLSplit[1];
                                string ReturnURLWithPortal = ReturnURLSplitPortal + "/" + ReturnURLSplitPortalName;

                                string[] portalHostURLSplit = portalHostURL.Split('/');
                                string HostURLSplitPortal = portalHostURLSplit[0];
                                string HostURLSplitPortalName = portalHostURLSplit[1];
                                string HostURLWithPortal = HostURLSplitPortal + "/" + HostURLSplitPortalName;
                                resultComparePortalURL = string.Compare(ReturnURLWithPortal, HostURLWithPortal);
                            }
                            if (resultCompareURL != 0 || resultComparePortalURL != 0)
                            {
                                PageNotFoundURL();
                            }
                        }
                        else
                        {
                            PageNotFoundURL();
                        }
                    }

                    if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage)
                    {
                        redirectURL.Append(GetParentURL);
                        redirectURL.Append(PortalAPI.DefaultPageWithExtension);
                    }
                    else
                    {
                        redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString()));
                    }
                }
                else
                {
                    if (!IsParent)
                    {
                        redirectURL.Append(GetParentURL);
                        redirectURL.Append("/portal/");
                        redirectURL.Append(GetPortalSEOName);
                        redirectURL.Append("/");
                        redirectURL.Append(PortalAPI.DefaultPageWithExtension);
                    }
                    else
                    {
                        redirectURL.Append(GetParentURL);
                        redirectURL.Append("/");
                        redirectURL.Append(PortalAPI.DefaultPageWithExtension);
                    }
                }
                HttpContext.Current.Session[SessionKeys.IsLoginClick] = true;
                if (Session[SessionKeys.LoginHitCount] != null)
                {
                    HttpContext.Current.Session.Remove(SessionKeys.LoginHitCount);
                }
                Response.Redirect(redirectURL.ToString(), false);
            }
            else
            {
                FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal"));//"You are not authenticated to this portal!";
            }
        }
 private void RestartApplication()
 {
     SageFrame.Application.Application app = new SageFrame.Application.Application();
     File.SetLastWriteTime((app.ApplicationMapPath + "\\web.config"), System.DateTime.Now);
     SecurityPolicy objSecurity = new SecurityPolicy();
     HttpCookie authenticateCookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID));
     authenticateCookie.Expires = DateTime.Now.AddYears(-1);
     Response.Cookies.Add(authenticateCookie);
     System.Web.Security.FormsAuthentication.SignOut();
     SetUserRoles(string.Empty);
     string redUrl = string.Empty;
     SageFrameConfig sfConfig = new SageFrameConfig();
     if (!IsParent)
     {
         redUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension;
     }
     else
     {
         redUrl = GetParentURL + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension;
     }
     Response.Redirect(redUrl);
 }
        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);
            }
        }