protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         IncludeCss("PortalSettings", "/Modules/Admin/PortalSettings/css/popup.css");
         if (!IsPostBack)
         {
             AddImageUrls();
             BinDDls();
             BindData();
             SageFrameConfig sfConf = new SageFrameConfig();
             ViewState["SelectedLanguageCulture"] = sfConf.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultLanguage);
             GetLanguageList();
             GetFlagImage();
         }
         RoleController _role = new RoleController();
         string[] roles = _role.GetRoleNames(GetUsername, GetPortalID).ToLower().Split(',');
         if (!roles.Contains(SystemSetting.SUPER_ROLE[0].ToLower()))
         {
             TabContainer.Tabs[2].Visible = false;
             TabContainer.Tabs[1].Visible = false;
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
 protected void IsSuperUser()
 {
     RoleController _role = new RoleController();
     string[] roles = _role.GetRoleNames(GetUsername, GetPortalID).ToLower().Split(',');
     if(roles.Contains(SystemSetting.SUPER_ROLE[0]))
     {
         Mode=1;
     }            
     
 }
 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)
 {
     IncludeJs("UserManagement", false, "/js/jquery.pstrength-min.1.2.js");
     IncludeJsTop("UserManagement", "/js/jquery.validate.js", "/js/jquery.alerts.js");
     IncludeCss("UserManagement", "/css/jquery.alerts.css");
     imgProfileEdit.Visible = false;
     lblDuplicateUser.Visible = false;
     try
     {
         if (!IsPostBack)
         {
             Session["csv"] = null;
             aceSearchText.CompletionSetCount = GetPortalID;
             BindRolesInListBox(lstAvailableRoles);
             BindUsers(string.Empty);
             PanelVisibility(false, true, false, false, false);
             pnlSettings.Visible = false;
             BindRolesInDropDown(ddlSearchRole);
             AddImageUrls();
             LoadSuspendedIp();
             hideSubmit();
         }
         int index = rbFilterMode.SelectedIndex;
         rbFilterMode.Items[index].Attributes.Add("class", "active");
         RoleController _role = new RoleController();
         string[] roles = _role.GetRoleNames(GetUsername, GetPortalID).ToLower().Split(',');
         if (!roles.Contains(SystemSetting.SUPER_ROLE[0].ToLower()))
         {
             imgBtnExportUser.Visible = false;
             imgBtnImportUser.Visible = false;
             imgBtnSuspendedIP.Visible = false;
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IsUseFriendlyUrls=pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls);
            UserName.Focus();
            if (!IsPostBack)
            {
                HideSignUp();
                Password.Attributes.Add("onkeypress", "return clickButton(event,'" + LoginButton.ClientID + "')");               
                hypForgetPassword.Text = "Forgot Password?";        
                if (IsUseFriendlyUrls)
                {
                    if (GetPortalID > 1)
                    {
                        signup.Attributes.Add("href", ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + ".aspx"));
                        signup1.Attributes.Add("href", ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + ".aspx"));
                        hypForgetPassword.NavigateUrl = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalForgotPassword) + ".aspx");
                    }
                    else
                    {
                        signup.Attributes.Add("href", ResolveUrl("~/User-Registration.aspx"));
                        signup1.Attributes.Add("href",  ResolveUrl("~/User-Registration.aspx"));
                        hypForgetPassword.NavigateUrl = ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalForgotPassword) + ".aspx");
                    }
                   
                }
                else
                {
                        hypForgetPassword.NavigateUrl = ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalForgotPassword));
                        signup.Attributes.Add("href", ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm="+pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage)));
                        signup1.Attributes.Add("href", ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm="+pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage)));            
                }
                if (pagebase.GetSettingBollByKey(SageFrameSettingKeys.RememberCheckbox))
                {
                    RememberMe.Visible = true;
                    lblrmnt.Visible = true;
                }
                else
                {
                    RememberMe.Visible = false;
                    lblrmnt.Visible = false;
                }

             

                }
            if (HttpContext.Current.User != null)
            {
                MembershipUser user = Membership.GetUser();
                FormsIdentity identity = HttpContext.Current.User.Identity as FormsIdentity;

                if (identity != null)
                {
                    FormsAuthenticationTicket ticket = identity.Ticket;
                    int LoggedInPortalID = int.Parse(ticket.UserData.ToString());

                    if (user != null && user.UserName != "")
                    {
                        string[] sysRoles = SystemSetting.SUPER_ROLE;
                        if (GetPortalID == LoggedInPortalID || Roles.IsUserInRole(user.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;
                    }
                }
                else
                {
                    MultiView1.ActiveViewIndex = 0;
                }
            }
          
        }
示例#6
0
        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(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["Tracker"];
                            sessionTracker.PortalID = GetPortalID.ToString();
                            sessionTracker.Username = UserName.Text;
                            Session["Tracker"] = sessionTracker;
                            SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog();
                            SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString());

                            if (Request.QueryString["ReturnUrl"] != null)
                            {

                                FormsAuthentication.SetAuthCookie(UserName.Text, RememberMe.Checked);
                                
                                string PageNotFoundPage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalPageNotFound) + ".aspx").Replace("\\", "/"); ;
                                string UserRegistrationPage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + ".aspx").Replace("\\", "/"); ;
                                string PasswordRecoveryPage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalPasswordRecovery) + ".aspx").Replace("\\", "/"); ;
                                string ForgotPasswordPage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalForgotPassword) + ".aspx").Replace("\\", "/"); ;
                                string PageNotAccessiblePage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalPageNotAccessible) + ".aspx").Replace("\\", "/"); ;

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

                                if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage)
                                {
                                    Response.Redirect("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false);
                                }
                                else
                                {
                                    Response.Redirect(ResolveUrl(Request.QueryString["ReturnUrl"].ToString()), false);
                                }
                            }
                            else
                            {
                                FormsAuthentication.SetAuthCookie(UserName.Text, RememberMe.Checked);

                                if (IsUseFriendlyUrls)
                                {
                                    if (GetPortalID > 1)
                                    {
                                        Response.Redirect("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false);
                                    }
                                    else
                                    {
                                        Response.Redirect("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false);
                                    }
                                }
                                else
                                {
                                    Response.Redirect(ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false);
                                }
                            }
                        }
                        else
                        {
                            FailureText.Text = GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal");//"You are not authenticated to this portal!";
                        }
                    }
                    else
                    {
                        FailureText.Text = GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched");//"Username and Password combination doesn't matched!";
                    }
                }
            }
            else
            {
                FailureText.Text = GetSageMessage("UserLogin", "UserDoesnotExist");
            }
        }
 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();
                }
            }
        }
        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!";
            }
        }
示例#10
0
 private void LoginUser()
 {
     MembershipController member = new MembershipController();
     RoleController role = new RoleController();
     SuspendedIPController objSuspendedIP = new SuspendedIPController();
     UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text);
     HttpContext.Current.Session[SessionKeys.IsLoginClick] = false;
     if (user.UserExists && user.IsApproved)
     {
         if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text)))
         {
             if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt))
             {
                 SucessFullLogin(user);
             }
             else
             {
                 if (Session[SessionKeys.LoginHitCount] == null)
                 {
                     Session[SessionKeys.LoginHitCount] = 1;
                 }
                 else
                 {
                     loginhit = Convert.ToInt32(Session[SessionKeys.LoginHitCount]);
                     loginhit++;
                     Session[SessionKeys.LoginHitCount] = loginhit;
                 }
                 FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched"));//"Username and Password combination doesn't matched!";
                 CaptchaValue.Text = string.Empty;
                 if (loginhit == 3)
                 {
                     Page.Response.Redirect(Page.Request.Url.ToString(), true);
                 }
                 if (loginhit > 3 && loginhit < 6)
                 {
                     InitializeCaptcha();
                     CaptchaValue.Text = string.Empty;
                 }
                 else if (loginhit >= 6)
                 {
                     objSuspendedIP.SaveSuspendedIP(ipAddress);
                     SuspendedIPAddressException();
                     Session[SessionKeys.LoginHitCount] = 0;
                     MultiView1.Visible = false;
                 }
             }
         }
     }
     else
     {
         if (Session[SessionKeys.LoginHitCount] == null)
         {
             Session[SessionKeys.LoginHitCount] = 1;
         }
         else
         {
             loginhit = Convert.ToInt32(Session[SessionKeys.LoginHitCount]);
             loginhit++;
             Session[SessionKeys.LoginHitCount] = loginhit;
         }
         FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UserDoesnotExist"));
         CaptchaValue.Text = string.Empty;
         if (loginhit == 3)
         {
             Page.Response.Redirect(Page.Request.Url.ToString(), true);
         }
         if (loginhit > 3 && loginhit < 6)
         {
             InitializeCaptcha();
             CaptchaValue.Text = string.Empty;
         }
         else if (loginhit >= 6)
         {
             objSuspendedIP.SaveSuspendedIP(ipAddress);
             SuspendedIPAddressException();
             Session[SessionKeys.LoginHitCount] = 0;
             MultiView1.Visible = false;
         }
     }
 }
        protected void imgBtnExportUser_Click(object sender, EventArgs e)
        {
            RoleController _role = new RoleController();
            string[] roles = _role.GetRoleNames(GetUsername, GetPortalID).ToLower().Split(',');
            if (roles.Contains(SystemSetting.SUPER_ROLE[0].ToLower()))
            {
                UserExportToExcel();
                ShowMessage(SageMessageTitle.Exception.ToString(), "No any data to export", "", SageMessageType.Alert);
            }

        }
        private void SavePortalSettings()
        {
            try
            {
                SettingProvider sageSP = new SettingProvider();
                //Add Single Key Values that may contain Comma values so need to be add sepratly
                #region "Single Key Value Add/Updatge"

                //SageFrameSettingKeys.PageTitle
                sageSP.SaveSageSetting(SettingType.SiteAdmin.ToString(), SageFrameSettingKeys.PageTitle,
                    txtPortalTitle.Text.Trim(), GetUsername, GetPortalID.ToString());

                //SageFrameSettingKeys.MetaDescription
                sageSP.SaveSageSetting(SettingType.SiteAdmin.ToString(), SageFrameSettingKeys.MetaDescription,
                    txtDescription.Text, GetUsername, GetPortalID.ToString());

                //SageFrameSettingKeys.MetaKeywords
                sageSP.SaveSageSetting(SettingType.SiteAdmin.ToString(), SageFrameSettingKeys.MetaKeywords,
                    txtKeyWords.Text, GetUsername, GetPortalID.ToString());

                //SageFrameSettingKeys.PortalLogoTemplate
                sageSP.SaveSageSetting(SettingType.SiteAdmin.ToString(), SageFrameSettingKeys.PortalLogoTemplate,
                    txtLogoTemplate.Text.Trim(), GetUsername, GetPortalID.ToString());

                //SageFrameSettingKeys.PortalCopyright
                sageSP.SaveSageSetting(SettingType.SiteAdmin.ToString(), SageFrameSettingKeys.PortalCopyright,
                    txtCopyright.Text.Trim(), GetUsername, GetPortalID.ToString());

                //SageFrameSettingKeys.PortalTimeZone
                sageSP.SaveSageSetting(SettingType.SiteAdmin.ToString(), SageFrameSettingKeys.PortalTimeZone,
                    ddlPortalTimeZone.SelectedItem.Value, GetUsername, GetPortalID.ToString());

                //SageFrameSettingKeys.Message Setting       
                string mt = rdbDefault.Checked == true ? rdbDefault.Value : rdbCustom.Value;
                sageSP.SaveSageSetting(SettingType.SiteAdmin.ToString(), SageFrameSettingKeys.MessageTemplate,
                    mt, GetUsername, GetPortalID.ToString());

                #endregion

                //For Multiple Keys and Values
                #region "Multiple Key Value Add/Update"

                StringBuilder sbSettingKey = new StringBuilder();
                StringBuilder sbSettingValue = new StringBuilder();
                StringBuilder sbSettingType = new StringBuilder();

                //Collecting Setting Values
                ///Super user settings
                StringBuilder sbSettingKey_super = new StringBuilder();
                StringBuilder sbSettingValue_super = new StringBuilder();
                StringBuilder sbSettingType_super = new StringBuilder();


                //SageFrameSettingKeys.SiteAdminEmailAddress
                sbSettingKey.Append(SageFrameSettingKeys.SiteAdminEmailAddress + ",");
                sbSettingValue.Append(txtSiteAdminEmailAddress.Text.Trim() + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.PortalGoogleAdSenseID
                sbSettingKey.Append(SageFrameSettingKeys.PortalGoogleAdSenseID + ",");
                sbSettingValue.Append(txtPortalGoogleAdSenseID.Text.Trim() + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");


                //SageFrameSettingKeys.PortalShowProfileLink
                sbSettingKey.Append(SageFrameSettingKeys.PortalShowProfileLink + ",");
                sbSettingValue.Append(rblPortalShowProfileLink.SelectedItem.Value + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.RememberCheckbox
                sbSettingKey.Append(SageFrameSettingKeys.RememberCheckbox + ",");
                sbSettingValue.Append(chkEnableRememberme.Checked + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //CssJs Optimization
                sbSettingKey.Append(SageFrameSettingKeys.OptimizeCss + ",");
                sbSettingValue.Append(chkOptCss.Checked + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                sbSettingKey.Append(SageFrameSettingKeys.OptimizeJs + ",");
                sbSettingValue.Append(chkOptJs.Checked + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                sbSettingKey.Append(SageFrameSettingKeys.EnableLiveFeeds + ",");
                sbSettingValue.Append(chkLiveFeeds.Checked + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.ShowSideBar
                sbSettingKey.Append(SageFrameSettingKeys.ShowSideBar + ",");
                sbSettingValue.Append(chkShowSidebar.Checked + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SSL
                sbSettingKey.Append(SageFrameSettingKeys.UseSSL + ",");
                sbSettingValue.Append(cbUseSSL.Checked + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.PortalUserRegistration
                sbSettingKey.Append(SageFrameSettingKeys.PortalUserRegistration + ",");
                sbSettingValue.Append(rblUserRegistration.SelectedItem.Value + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");


                //SageFrameSettingKeys.PortalLoginpage
                sbSettingKey.Append(SageFrameSettingKeys.PortalLoginpage + ",");
                sbSettingValue.Append(ddlLoginPage.SelectedItem.Value.StartsWith("sf") ? string.Format("sf/{0},", ddlLoginPage.SelectedItem.Value) : string.Format("{0},", ddlLoginPage.SelectedItem.Value));
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.PortalUserActivation
                sbSettingKey.Append(SageFrameSettingKeys.PortalUserActivation + ",");
                sbSettingValue.Append(ddlPortalUserActivation.SelectedItem.Value.StartsWith("sf") ? string.Format("sf/{0},", ddlPortalUserActivation.SelectedItem.Value) : string.Format("{0},", ddlPortalUserActivation.SelectedItem.Value));
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.PortalRegistrationPage
                sbSettingKey.Append(SageFrameSettingKeys.PortalRegistrationPage + ",");
                sbSettingValue.Append(ddlUserRegistrationPage.SelectedItem.Value.StartsWith("sf") ? string.Format("sf/{0},", ddlUserRegistrationPage.SelectedItem.Value) : string.Format("{0},", ddlUserRegistrationPage.SelectedItem.Value));
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.PortalForgotPassword
                sbSettingKey.Append(SageFrameSettingKeys.PortalForgotPassword + ",");
                sbSettingValue.Append(ddlPortalForgotPassword.SelectedItem.Value.StartsWith("sf") ? string.Format("sf/{0},", ddlPortalForgotPassword.SelectedItem.Value) : string.Format("{0},", ddlPortalForgotPassword.SelectedItem.Value));
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.PortalPageNotAccessible
                sbSettingKey.Append(SageFrameSettingKeys.PortalPageNotAccessible + ",");
                sbSettingValue.Append(ddlPortalPageNotAccessible.SelectedItem.Value.StartsWith("sf") ? string.Format("sf/{0},", ddlPortalPageNotAccessible.SelectedItem.Value) : string.Format("{0},", ddlPortalPageNotAccessible.SelectedItem.Value));
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.PortalPageNotFound
                sbSettingKey.Append(SageFrameSettingKeys.PortalPageNotFound + ",");
                sbSettingValue.Append(ddlPortalPageNotFound.SelectedItem.Value.StartsWith("sf") ? string.Format("sf/{0},", ddlPortalPageNotFound.SelectedItem.Value) : string.Format("{0},", ddlPortalPageNotFound.SelectedItem.Value));
                sbSettingType.Append(SettingType.SiteAdmin + ",");


                //SageFrameSettingKeys.PortalPasswordRecovery
                sbSettingKey.Append(SageFrameSettingKeys.PortalPasswordRecovery + ",");
                sbSettingValue.Append(ddlPortalPasswordRecovery.SelectedItem.Value.StartsWith("sf") ? string.Format("sf/{0},", ddlPortalPasswordRecovery.SelectedItem.Value) : string.Format("{0},", ddlPortalPasswordRecovery.SelectedItem.Value));
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //PortalUserProfilePage
                sbSettingKey.Append(SageFrameSettingKeys.PortalUserProfilePage + ",");
                sbSettingValue.Append(ddlPortalUserProfilePage.SelectedItem.Value.StartsWith("sf") ? string.Format("sf/{0},", ddlPortalUserProfilePage.SelectedItem.Value) : string.Format("{0},", ddlPortalUserProfilePage.SelectedItem.Value));
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //PortalDefaultPage
                sbSettingKey.Append(SageFrameSettingKeys.PortalDefaultPage + ",");
                sbSettingValue.Append(ddlPortalDefaultPage.SelectedItem.Value + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");


                //SageFrameSettingKeys.PortalDefaultLanguage
                sbSettingKey.Append(SageFrameSettingKeys.PortalDefaultLanguage + ",");
                sbSettingValue.Append(ddlDefaultLanguage.SelectedItem.Value + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //Added by Bj for OpenID conumer key and Secret key

                //SageFrameSettingKeys.FaceBookConsumerKey
                sbSettingKey.Append(SageFrameSettingKeys.ShowOpenID + ",");
                sbSettingValue.Append(chkOpenID.Checked + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.FaceBookConsumerKey
                sbSettingKey.Append(SageFrameSettingKeys.FaceBookConsumerKey + ",");
                sbSettingValue.Append(txtFacebookConsumerKey.Text + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.FaceBokkSecretkey
                sbSettingKey.Append(SageFrameSettingKeys.FaceBookSecretkey + ",");
                sbSettingValue.Append(txtFaceBookSecretKey.Text + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.LinkedInConsumerKey
                sbSettingKey.Append(SageFrameSettingKeys.LinkedInConsumerKey + ",");
                sbSettingValue.Append(txtLinkedInConsumerKey.Text + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.LinkedInSecretKey
                sbSettingKey.Append(SageFrameSettingKeys.LinkedInSecretKey + ",");
                sbSettingValue.Append(txtLinkedInSecretKey.Text + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");


                //SageFrameSettingKeys.EnableCDN
                bool enableCDN = chkEnableCDN.Checked == true ? true : false;
                sbSettingKey.Append(SageFrameSettingKeys.EnableCDN + ",");
                sbSettingValue.Append(enableCDN + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");

                //SageFrameSettingKeys.EnableSessionTracker
                bool enableSessionTracker = chkSessionTracker.Checked == true ? true : false;
                sbSettingKey.Append(SageFrameSettingKeys.EnableSessionTracker + ",");
                sbSettingValue.Append(enableSessionTracker + ",");
                sbSettingType.Append(SettingType.SiteAdmin + ",");


                //SageFrameSettingKeys.EnableDasboardHelp                    
                sbSettingKey_super.Append(SageFrameSettingKeys.EnableDasboardHelp + ",");
                sbSettingValue_super.Append(chkDashboardHelp.Checked + ",");
                sbSettingType_super.Append(SettingType.SiteAdmin + ",");

                RoleController _role = new RoleController();
                string[] roles = _role.GetRoleNames(GetUsername, GetPortalID).ToLower().Split(',');
                if (roles.Contains(SystemSetting.SUPER_ROLE[0].ToLower()))
                {
                    ///Superuser Settings 
                    //Collecting Setting Values
                    sbSettingKey_super.Append(SageFrameSettingKeys.SuperUserPortalId + ",");
                    sbSettingValue_super.Append(ddlHostPortal.SelectedItem.Value + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.SuperUserTitle                
                    sbSettingKey_super.Append(SageFrameSettingKeys.SuperUserTitle + ",");
                    sbSettingValue_super.Append(txtHostTitle.Text.Trim() + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.SuperUserURL
                    sbSettingKey_super.Append(SageFrameSettingKeys.SuperUserURL + ",");
                    sbSettingValue_super.Append(txtHostUrl.Text.Trim() + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.SuperUserEmail
                    sbSettingKey_super.Append(SageFrameSettingKeys.SuperUserEmail + ",");
                    sbSettingValue_super.Append(txtHostEmail.Text.Trim() + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.SuperUserCopyright
                    sbSettingKey_super.Append(SageFrameSettingKeys.SuperUserCopyright + ",");
                    sbSettingValue_super.Append(chkCopyright.Checked + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.UseCustomErrorMessages
                    sbSettingKey_super.Append(SageFrameSettingKeys.UseCustomErrorMessages + ",");
                    sbSettingValue_super.Append(chkUseCustomErrorMessages.Checked + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");


                    //SageFrameSettingKeys.UseFriendlyUrls
                    sbSettingKey_super.Append(SageFrameSettingKeys.UseFriendlyUrls + ",");
                    sbSettingValue_super.Append(true + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");



                    //SageFrameSettingKeys.SMTPServer
                    sbSettingKey_super.Append(SageFrameSettingKeys.SMTPServer + ",");
                    sbSettingValue_super.Append(txtSMTPServerAndPort.Text.Trim() + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.SMTPAuthentication
                    sbSettingKey_super.Append(SageFrameSettingKeys.SMTPAuthentication + ",");
                    sbSettingValue_super.Append(rblSMTPAuthentication.SelectedItem.Value + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.SMTPEnableSSL
                    sbSettingKey_super.Append(SageFrameSettingKeys.SMTPEnableSSL + ",");
                    sbSettingValue_super.Append(chkSMTPEnableSSL.Checked + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.SMTPUsername
                    sbSettingKey_super.Append(SageFrameSettingKeys.SMTPUsername + ",");
                    sbSettingValue_super.Append(txtSMTPUserName.Text.Trim() + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.SMTPPassword
                    sbSettingKey_super.Append(SageFrameSettingKeys.SMTPPassword + ",");
                    sbSettingValue_super.Append(txtSMTPPassword.Text.Trim() + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");


                    //SageFrameSettingKeys.FileExtensions
                    sbSettingKey_super.Append(SageFrameSettingKeys.FileExtensions + ",");
                    sbSettingValue_super.Append(txtFileExtensions.Text.Trim() + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.HelpURL
                    sbSettingKey_super.Append(SageFrameSettingKeys.HelpURL + ",");
                    sbSettingValue_super.Append(txtHelpUrl.Text.Trim() + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.SettingPageExtension
                    sbSettingKey_super.Append(SageFrameSettingKeys.SettingPageExtension + ",");
                    sbSettingValue_super.Append(txtPageExtension.Text.Trim() + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.Scheduler
                    sbSettingKey_super.Append(SageFrameSettingKeys.Scheduler + ",");
                    sbSettingValue_super.Append(txtScheduler.Checked + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                    //SageFrameSettingKeys.UserAgentMode
                    int userAgent = rdBtnPC.Checked == true ? 1 : (rdBtnMobile.Checked == true ? 2 : 3);
                    sbSettingKey_super.Append(SageFrameSettingKeys.UserAgentMode + ",");
                    sbSettingValue_super.Append(userAgent + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");




                    //SageFrameSettingKeys.ServerCookieExpiration
                    sbSettingKey_super.Append(SageFrameSettingKeys.ServerCookieExpiration + ",");
                    sbSettingValue_super.Append(txtServerCookieExpiration.Text + ",");
                    sbSettingType_super.Append(SettingType.SuperUser + ",");

                }
                string SettingTypes = sbSettingType.ToString();
                if (SettingTypes.Contains(","))
                {
                    SettingTypes = SettingTypes.Remove(SettingTypes.LastIndexOf(","));
                }
                string SettingKeys = sbSettingKey.ToString();
                if (SettingKeys.Contains(","))
                {
                    SettingKeys = SettingKeys.Remove(SettingKeys.LastIndexOf(","));
                }
                string SettingValues = sbSettingValue.ToString();
                if (SettingValues.Contains(","))
                {
                    SettingValues = SettingValues.Remove(SettingValues.LastIndexOf(","));
                }
                string SettingTypes_super = sbSettingType_super.ToString();
                if (SettingTypes_super.Contains(","))
                {
                    SettingTypes_super = SettingTypes_super.Remove(SettingTypes_super.LastIndexOf(","));
                }
                string SettingKeys_super = sbSettingKey_super.ToString();
                if (SettingKeys_super.Contains(","))
                {
                    SettingKeys_super = SettingKeys_super.Remove(SettingKeys_super.LastIndexOf(","));
                }
                string SettingValues_super = sbSettingValue_super.ToString();
                if (SettingValues_super.Contains(","))
                {
                    SettingValues_super = SettingValues_super.Remove(SettingValues_super.LastIndexOf(","));
                }

                sageSP.SaveSageSettings(SettingTypes, SettingKeys, SettingValues, GetUsername, GetPortalID.ToString());
                if (roles.Contains(SystemSetting.SUPER_ROLE[0].ToLower()))
                {
                    sageSP.SaveSageSettings(SettingTypes_super, SettingKeys_super, SettingValues_super, GetUsername, "1");
                }
                HttpRuntime.Cache.Remove(CacheKeys.SageSetting);
                BindData();
                #endregion
                ShowMessage("", GetSageMessage("PortalSettings", "PortalSettingIsSavedSuccessfully"), "", SageMessageType.Success);
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
        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);
        }
示例#14
0
 private void DeleteRole(string role,string roleid)
 {
     try
     {
         if (SystemSetting.SYSTEM_ROLES.Contains(role, StringComparer.OrdinalIgnoreCase))
         {
            ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "ThisIsSystemRoleAndCannotBeDeleted"), "", SageMessageType.Alert);
         }
         else
         {
             Guid RoleID = new Guid(roleid);                  
             RoleController roleObj = new RoleController();
             roleObj.DeleteRole(RoleID, GetPortalID);
             
             BindRoles();
             ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("UserManagement", "RoleIsDeletedSuccessfully"), "", SageMessageType.Success);
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
         ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "RoleCannnotBeDeleted"), "", SageMessageType.Error);
     }
 }
        private void SagePageLoadPart()
        {
            if (!IsPostBack)
            {
                string sageNavigateUrl = string.Empty;
                SageFrameConfig sfConfig = new SageFrameConfig();
                if (IsUseFriendlyUrls)
                {
                    if (GetPortalID > 1)
                    {
                        sageNavigateUrl = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension);
                    }
                    else
                    {
                        sageNavigateUrl = ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension);
                    }
                }
                else
                {
                    sageNavigateUrl = ResolveUrl("~/Default" + Extension + "?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-"));
                }
                hypHome.NavigateUrl = sageNavigateUrl;
                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;
                FormsAuthenticationTicket ticket = SecurityPolicy.GetUserTicket(GetPortalID);
                if (ticket != null)
                {
                    int LoggedInPortalID = int.Parse(ticket.UserData.ToString());
                    if (ticket.Name != ApplicationKeys.anonymousUser)
                    {
                        string[] sysRoles = SystemSetting.SUPER_ROLE;
                        this.hypUpgrade.Visible = Roles.IsUserInRole(ticket.Name, sysRoles[0]) ? true : false;
                        if (GetPortalID == LoggedInPortalID || Roles.IsUserInRole(ticket.Name, sysRoles[0]))
                        {
                            RoleController _role = new RoleController();
                            string userinroles = _role.GetRoleNames(GetUsername, LoggedInPortalID);
                            if (userinroles != "" || userinroles != null)
                            {
                                divAdminControlPanel.Attributes.Add("style", "display:block");
                                ////foreach (string role in sysRoles)
                                ////{
                                ////    if (Roles.IsUserInRole(user.UserName, role))
                                ////    {
                                ////        IsAdmin = true;
                                ////        break;
                                ////    }
                                ////}
                            }
                            else
                            {
                                divAdminControlPanel.Attributes.Add("style", "display:none");
                            }
                        }
                        else
                        {
                            divAdminControlPanel.Attributes.Add("style", "display:none");
                        }
                    }
                    else
                    {
                        divAdminControlPanel.Attributes.Add("style", "display:none");
                    }

                }
                if (IsHandheld())
                {
                    divAdminControlPanel.Attributes.Add("style", "display:none");
                }
            }
            SessionTrackerController sTracController = new SessionTrackerController();
            sTracController.SetSessionTrackerValues(GetPortalID.ToString(), GetUsername);
        }
 protected void imgBtnSuspendedIP_Click(object sender, EventArgs e)
 {
     RoleController _role = new RoleController();
     string[] roles = _role.GetRoleNames(GetUsername, GetPortalID).ToLower().Split(',');
     if (roles.Contains(SystemSetting.SUPER_ROLE[0].ToLower()))
     {
         PanelVisibility(false, false, false, false, true);
     }
 }
        protected void btnUserImport_Click(object sender, EventArgs e)
        {
            try
            {
                bool Flag = false;
                DataSet userImportDataSet = ImportUserFile();
                List<string> lstColumnHeader = new List<string>();
                List<string> ObjMappingList = MappingList();

                if (userImportDataSet.Tables.Count > 0)
                {
                    int columnLength = userImportDataSet.Tables[0].Columns.Count;
                    for (int i = 0; i < columnLength; i++)
                    {
                        lstColumnHeader.Add(userImportDataSet.Tables[0].Columns[i].ColumnName);
                    }

                    Flag = !ObjMappingList.Except(lstColumnHeader).Any();
                    if (Flag)
                    {
                        for (int i = 0; i < columnLength; i++)
                        {
                            if (txtImportUserName.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "UserName";
                            }
                            if (txtImportFirstName.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "FirstName";
                            }
                            if (txtImportLastName.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "LastName";
                            }
                            if (txtImportEmail.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "Email";
                            }
                            if (txtImportPassword.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "Password";
                            }
                            if (txtImportPasswordSalt.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "PasswordSalt";
                            }
                            if (txtImportPasswordFormat.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "PasswordFormat";
                            }
                            if (txtImportRoleName.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "RoleName";
                            }
                            if (txtImportPortalID.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "PortalID";
                            }
                            if (txtImportIsApproved.Text == userImportDataSet.Tables[0].Columns[i].ColumnName)
                            {
                                userImportDataSet.Tables[0].Columns[i].ColumnName = "IsActive";
                            }
                        }
                    }
                    else
                    {
                        ShowMessage("", GetSageMessage("UserManagement", "ColumnMappingError"), "", SageMessageType.Alert);
                        clearField();
                        return;
                    }

                    //Listing Excel Users
                    foreach (DataRow dr in userImportDataSet.Tables[0].Rows)
                    {
                        ExportUserInfo userImportInfo = new ExportUserInfo();
                        userImportInfo.UserName = dr["UserName"].ToString();
                        userImportInfo.FirstName = dr["FirstName"].ToString();
                        userImportInfo.LastName = dr["LastName"].ToString();
                        userImportInfo.Email = dr["Email"].ToString();
                        userImportInfo.Password = dr["Password"].ToString();
                        userImportInfo.PasswordSalt = dr["PasswordSalt"].ToString();
                        userImportInfo.PasswordFormat = dr["PasswordFormat"].ToString();
                        userImportInfo.RoleName = dr["RoleName"].ToString();
                        userImportInfo.PortalID = Convert.ToInt32(dr["PortalID"]);
                        userImportInfo.IsApproved = Convert.ToBoolean(dr["IsActive"]);
                        lstUserImportUsers.Add(userImportInfo);
                    }

                    //Extracting Excel Roles

                    List<RoleInfo> lstExcelRolesSplit = new List<RoleInfo>();
                    foreach (ExportUserInfo objExport in lstUserImportUsers)
                    {
                        string[] excelRolesArr = objExport.RoleName.Split(',');
                        foreach (string role in excelRolesArr)
                        {
                            RoleInfo objRoles = new RoleInfo();
                            objRoles.PortalID = objExport.PortalID;
                            objRoles.RoleName = role.Trim();
                            lstExcelRolesSplit.Add(objRoles);
                        }
                    }

                    List<RoleInfo> lstExcelRolesIdentical = new List<RoleInfo>();
                    var ExcelRolesIdentical = lstExcelRolesSplit.Select(i => new { i.RoleName, i.PortalID }).Distinct();
                    foreach (var objRole in ExcelRolesIdentical)
                    {
                        RoleInfo objRoleInfo = new RoleInfo();
                        objRoleInfo.RoleName = objRole.RoleName;
                        objRoleInfo.PortalID = objRole.PortalID;
                        lstExcelRolesIdentical.Add(objRoleInfo);
                    }

                    //Extracting Sage Roles
                    List<RolesManagementInfo> lstSageRoles = new List<RolesManagementInfo>();
                    RolesManagementController objController = new RolesManagementController();
                    lstSageRoles = objController.GetSageFramePortalList();
                    List<RoleInfo> lstSageRolesSplit = new List<RoleInfo>();
                    foreach (RolesManagementInfo objRoleMgntInfo in lstSageRoles)
                    {
                        RoleInfo objSageRoles = new RoleInfo();
                        objSageRoles.RoleName = objRoleMgntInfo.RoleName;
                        objSageRoles.PortalID = objRoleMgntInfo.PortalID;
                        lstSageRolesSplit.Add(objSageRoles);
                    }

                    //Retrieve Identical Roles in Sage Roles and Excel Roles
                    List<RoleInfo> lstIdenticalRoles = lstExcelRolesIdentical.Except(lstSageRolesSplit).ToList();

                    //Adding Identical Roles in SageRoles
                    for (int i = 0; i < lstIdenticalRoles.Count; i++)
                    {
                        RoleInfo objRole = new RoleInfo();
                        string rolePrefix = GetPortalSEOName + "_";
                        objRole.ApplicationName = Membership.ApplicationName;
                        objRole.RoleName = lstIdenticalRoles[i].RoleName;
                        objRole.PortalID = lstIdenticalRoles[i].PortalID;
                        objRole.IsActive = 1;
                        objRole.AddedOn = DateTime.Now;
                        objRole.AddedBy = GetUsername;
                        RoleController objRoleCon = new RoleController();
                        RoleCreationStatus status = new RoleCreationStatus();
                        objRoleCon.CreateRole(objRole, out status);
                    }

                    //Listing SageFrame Users
                    UserProfileController objUserProfile = new UserProfileController();
                    List<ExportUserInfo> lstSageUsers = objUserProfile.GetSageFrameUserList();

                    //Extracting Excel Username
                    List<string> lstExcelUserName = new List<string>();
                    lstExcelUserName = lstUserImportUsers.Select(x => x.UserName).ToList();

                    //Extracting Excel Email
                    List<string> lstExcelEmail = new List<string>();
                    lstExcelEmail = lstUserImportUsers.Select(x => x.Email).ToList();

                    //Extracting SageFrame Username
                    List<string> lstSageUserName = new List<string>();
                    lstSageUserName = lstSageUsers.Select(x => x.UserName).ToList();

                    //Extracting SageFrame Email
                    List<string> lstSageEmail = new List<string>();
                    lstSageEmail = lstSageUsers.Select(x => x.Email).ToList();

                    //Check duplicacy of Self Excel Users and Email
                    List<string> lstUserNameDuplicacyinExcel = new List<string>();
                    lstUserNameDuplicacyinExcel = lstExcelUserName.GroupBy(x => x).Where(g => g.Count() > 1).Select(y => y.Key).ToList();

                    List<string> lstEmailDuplicacyinExcel = new List<string>();
                    lstEmailDuplicacyinExcel = lstExcelEmail.GroupBy(x => x).Where(g => g.Count() > 1).Select(y => y.Key).ToList();

                    if (lstUserNameDuplicacyinExcel.Count > 0 || lstEmailDuplicacyinExcel.Count > 0)
                    {
                        ShowMessage("", GetSageMessage("UserManagement", "DuplicateUsers"), "", SageMessageType.Alert);
                        clearField();
                        DeleteTempFolder();
                        return;
                    }

                    //check UserName duplicacy SageUsers And Excel Users               
                    List<string> lstUserNameDuplicacy = new List<string>();
                    lstUserNameDuplicacy = lstExcelUserName.Intersect(lstSageUserName).ToList();

                    //Removing duplicate List by UserName
                    ExportUserInfo dupUserListByUName = null;
                    List<ExportUserInfo> lstdubUserListByName = new List<ExportUserInfo>();
                    foreach (string DupUserName in lstUserNameDuplicacy)
                    {
                        List<ExportUserInfo> obj = lstUserImportUsers;
                        dupUserListByUName = lstUserImportUsers.Single(x => x.UserName == DupUserName);
                        lstUserImportUsers.Remove(dupUserListByUName);
                        //list users in excel
                        lstdubUserListByName.Add(dupUserListByUName);
                    }

                    //Extracting Email duplicacy in SageEmail and listUserImportUsers
                    List<string> lstExcelEmailInImportUsers = new List<string>();
                    lstExcelEmailInImportUsers = lstUserImportUsers.Select(x => x.Email).ToList();

                    //check Email duplicacy SageEmail And Excel Email 
                    List<string> lstEmailDuplicacy = new List<string>();
                    if (!m.RequireUniqueEmail)
                    {
                        lstEmailDuplicacy = lstExcelEmailInImportUsers.Intersect(lstSageEmail).ToList();
                    }
                    //Removing duplicate List by Email
                    ExportUserInfo dupUserListByEmail = null;
                    List<ExportUserInfo> lstdubUserListByEmail = new List<ExportUserInfo>();
                    if (lstUserImportUsers.Count != 0)
                    {
                        foreach (string DupEmail in lstEmailDuplicacy)
                        {
                            List<ExportUserInfo> obj = lstUserImportUsers;
                            dupUserListByEmail = lstUserImportUsers.Single(x => x.Email == DupEmail);
                            lstUserImportUsers.Remove(dupUserListByEmail);
                            //list users in excel
                            lstdubUserListByEmail.Add(dupUserListByEmail);
                        }
                    }

                    //Retrieve Duplicate UserList in SageUsers and Excel Users
                    lstDuplicateUserList = lstdubUserListByName.Concat(lstdubUserListByEmail).ToList();

                    //Retrieve Identical UserList in SageUsers and Excel Users
                    List<ExportUserInfo> lstIdenticalUserList = lstUserImportUsers;

                    //Adding Identical User List in SageUserList
                    if (lstIdenticalUserList.Count > 0)
                    {
                        for (int i = 0; i < lstIdenticalUserList.Count; i++)
                        {
                            UserInfo objUser = new UserInfo();
                            objUser.ApplicationName = Membership.ApplicationName;
                            objUser.FirstName = lstIdenticalUserList[i].FirstName;
                            objUser.UserName = lstIdenticalUserList[i].UserName;
                            objUser.LastName = lstIdenticalUserList[i].LastName;
                            objUser.Password = lstIdenticalUserList[i].Password;
                            objUser.PasswordSalt = lstIdenticalUserList[i].PasswordSalt;
                            objUser.Email = lstIdenticalUserList[i].Email;
                            objUser.SecurityQuestion = "";
                            objUser.SecurityAnswer = "";
                            objUser.IsApproved = lstIdenticalUserList[i].IsApproved;
                            objUser.CurrentTimeUtc = DateTime.Now;
                            objUser.CreatedDate = DateTime.Now;
                            objUser.UniqueEmail = 0;
                            objUser.PasswordFormat = Int32.Parse(lstIdenticalUserList[i].PasswordFormat);
                            objUser.PortalID = lstIdenticalUserList[i].PortalID;
                            objUser.AddedOn = DateTime.Now;
                            objUser.AddedBy = GetUsername;
                            objUser.UserID = Guid.NewGuid();
                            objUser.RoleNames = lstIdenticalUserList[i].RoleName;
                            objUser.StoreID = GetStoreID;
                            objUser.CustomerID = GetCustomerID;
                            UserCreationStatus status = new UserCreationStatus();
                            MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.CREATE);
                        }
                    }
                    else
                    {
                        lblDuplicateUser.Visible = true;
                        ShowMessage("", GetSageMessage("UserManagement", "UsersNotAdded"), "", SageMessageType.Error);
                        ExportDuplicateUserList();
                    }
                    if (lstDuplicateUserList.Count > 0 && lstIdenticalUserList.Count > 0)
                    {
                        lblDuplicateUser.Visible = true;
                        ShowMessage("", GetSageMessage("UserManagement", "UsersAddedSuccessfullyWithDuplicateUserReport"), "", SageMessageType.Success);
                        ExportDuplicateUserList();
                    }
                    if (lstDuplicateUserList.Count == 0 && lstIdenticalUserList.Count > 0)
                    {
                        ShowMessage("", GetSageMessage("UserManagement", "UsersAddedSuccessfully"), "", SageMessageType.Success);
                    }
                    clearField();
                    DeleteTempFolder();

                }
            }
            catch (Exception ex)
            {

                throw ex;
            }

        }
        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);
                            }
                        }
                    }
                }
            }
        }
 private void LogInPublicModeRegistration(UserInfo user)
 {
     string strRoles = string.Empty;
     RoleController role = new RoleController();
     SageFrameConfig sfConfig = new SageFrameConfig();
     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 = user.UserName;
         //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(user.UserName, GetPortalID.ToString());
         }
         {
             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);
             // Create the cookie.
             SecurityPolicy objSecurity = new SecurityPolicy();
             Response.Cookies.Add(new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket));
             if (!IsParent)
             {
                 Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false);
             }
             else
             {
                 Response.Redirect(ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false);
             }
         }
     }
 }
示例#20
0
        protected void imgAdd_Click(object sender, EventArgs e)
        {
            try
            {
                    string rolePrefix = GetPortalSEOName + "_";   
                    RoleInfo objRole = new RoleInfo();
                    objRole.ApplicationName =Membership.ApplicationName;
                    objRole.RoleName = txtRole.Text;
                    objRole.PortalID = GetPortalID;
                    objRole.IsActive = 1;
                    objRole.AddedOn = DateTime.Now;
                    objRole.AddedBy = GetUsername;

                    RoleController r = new RoleController();
                    RoleCreationStatus status = new RoleCreationStatus();
                    r.CreateRole(objRole, out status);                   
                    if (status == RoleCreationStatus.DUPLICATE_ROLE)
                    {
                        ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "ThisRoleAlreadyExists"), "", SageMessageType.Error);
                        
                    }
                    else if (status == RoleCreationStatus.SUCCESS)
                    {
                        BindRoles();
                        pnlRole.Visible = false;
                        pnlRoles.Visible = true;                       
                        ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("UserManagement", "RoleSavedSuccessfully"), "", SageMessageType.Success);
                    }
                   
               
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
        private void LogInPublicModeRegistration(UserInfo user)
        {
            string strRoles = string.Empty;           
            RoleController role = new RoleController();
            SageFrameConfig sfConfig = new SageFrameConfig();
                
                    string userRoles = role.GetRoleNames(user.UserName, GetPortalID);
                    strRoles += userRoles;
                    if (strRoles.Length > 0)
                    {
                        SetUserRoles(strRoles);
                        SessionTracker sessionTracker = (SessionTracker)Session["Tracker"];
                        sessionTracker.PortalID = GetPortalID.ToString();
                        sessionTracker.Username = user.UserName;
                        Session["Tracker"] = sessionTracker;
                        SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog();
                        SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString());
                        {
                            FormsAuthentication.SetAuthCookie(user.UserName, true);
                            bool IsUseFriendlyUrls = sfConfig.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls);
                            if (IsUseFriendlyUrls)
                            {
                                if (GetPortalID > 1)
                                {
                                    Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"), false);
                                }
                                else
                                {
                                    Response.Redirect(ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"), false);
                                }
                            }
                            else
                            {
                                Response.Redirect(ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false);
                            }

                        }
                    }               

            
        }
        private void LogInPublicModeRegistration()
        {
            string strRoles = string.Empty;
            MembershipController member = new MembershipController();
            RoleController role = new RoleController();
            UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text);

            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["Tracker"];
                        sessionTracker.PortalID = GetPortalID.ToString();
                        sessionTracker.Username = UserName.Text;
                        Session["Tracker"] = sessionTracker;
                        SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog();
                        string ReturnUrl = string.Empty;
                        SageFrameConfig sfConfig = new SageFrameConfig();
                        SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username,
                                                          GetPortalID.ToString());
                        FormsAuthentication.SetAuthCookie(UserName.Text, true);
                        
                        if (Request.QueryString["ReturnUrl"] != null)
                        {
                            Response.Redirect(ResolveUrl(Request.QueryString["ReturnUrl"].ToString()), false);
                        }
                        else
                        {
                            bool IsUseFriendlyUrls = pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls);
                            if (IsUseFriendlyUrls)
                            {
                                if (GetPortalID > 1)
                                {
                                    Response.Redirect("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false);
                                }
                                else
                                {
                                    Response.Redirect("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false);
                                }
                            }
                            else
                            {
                                Response.Redirect(ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false);
                            }
                        }
                    }
                }
            }
        }
        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(sessionTracker, sessionTracker.Username, GetPortalID.ToString());
                StringBuilder redirectURL = new StringBuilder();
                if (Request.QueryString["ReturnUrl"] != null)
                {
                    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);
                    // Create the cookie.
                    Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName + "_" + GetApplicationName + "_" + GetPortalID, encTicket));
                    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("~/");
                        redirectURL.Append(PortalAPI.DefaultPageWithExtension);
                    }
                    else
                    {
                        redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString()));
                    }
                }
                else
                {
                    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);

                    // Create the cookie.
                    Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName + "_" + GetApplicationName + "_" + GetPortalID, encTicket));
                    if (GetPortalID > 1)
                    {
                        redirectURL.Append("~/portal/");
                        redirectURL.Append(GetPortalSEOName);
                        redirectURL.Append("/");
                        redirectURL.Append(PortalAPI.DefaultPageWithExtension);
                    }
                    else
                    {
                        redirectURL.Append("~/");
                        redirectURL.Append(PortalAPI.DefaultPageWithExtension);
                    }
                }
                HttpContext.Current.Session["IsLoginClick" + user.UserName] = true;
                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 LogInPublicModeRegistration(UserInfo user)
 {
     string strRoles = string.Empty;
     RoleController role = new RoleController();
     SageFrameConfig sfConfig = new SageFrameConfig();
     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 = user.UserName;
         Session[SessionKeys.Tracker] = sessionTracker;
         SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog();
         SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString());
         {
             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);
             // Create the cookie.
             Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName + "_" + GetApplicationName + "_" + GetPortalID, encTicket));
             bool IsUseFriendlyUrls = sfConfig.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls);
             if (IsUseFriendlyUrls)
             {
                 if (GetPortalID > 1)
                 {
                     Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false);
                 }
                 else
                 {
                     Response.Redirect(ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false);
                 }
             }
             else
             {
                 Response.Redirect(ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false);
             }
         }
     }
 }
        private void LogInPublicModeRegistration()
        {
            string strRoles = string.Empty;
            MembershipController member = new MembershipController();
            RoleController role = new RoleController();
            UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text);

            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();
                        SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString());
                        {
                            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);

                            // Create the cookie.
                            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName + "_" + GetApplicationName + "_" + GetPortalID, encTicket));
                            bool IsUseFriendlyUrls = pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls);
                            if (IsUseFriendlyUrls)
                            {
                                if (GetPortalID > 1)
                                {
                                    Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false);
                                }
                                else
                                {
                                    Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false);
                                }
                            }
                            else
                            {
                                Response.Redirect(ResolveUrl("~/Default" + Extension + "?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false);
                            }
                        }
                    }
                }
            }
        }