Esempio n. 1
0
        public static string CreateNewUser(string firstName, string lastName, string jobTitle, string email, string company, string title, string frimAum, string firmType)
        {
            string rtnVal = string.Empty;

            var proxy = new BusinessProxy();

            try
            {
                //GenerateJqueryErrorForTesting();

                string emailExistenceRtnVal = proxy.CheckEmailExistence(email);

                if (emailExistenceRtnVal != "1")
                {
                    rtnVal = proxy.CreateUser(firstName, lastName, jobTitle, email, company, GetIPAddress(), title, frimAum, firmType);
                }
                else
                {
                    // user already exists. login straight away! - no need to add the record
                    rtnVal = "1";
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            return(rtnVal);
        }
Esempio n. 2
0
        void context_AcquireRequestState(object sender, EventArgs e)
        {
            try
            {
                HttpApplication application = (HttpApplication)sender;
                HttpContext     context     = application.Context;

                string emailExists = string.Empty;

                string     cookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
                HttpCookie myCookie   = new HttpCookie(cookieName);
                myCookie = HttpContext.Current.Request.Cookies[cookieName];

                if (myCookie != null && myCookie.Value != "undefined")
                {
                    // string email = Server.UrlDecode();
                    string email = Uri.UnescapeDataString(myCookie.Value);

                    var proxy = new BusinessProxy();

                    emailExists = proxy.CheckEmailExistence(email);

                    if (emailExists == "1")
                    {
                        string jsonEntUser = proxy.GetUserDetailsByEmail(email);

                        JArray userObjects = JArray.Parse(jsonEntUser);

                        foreach (var userObject in userObjects)
                        {
                            if (HttpContext.Current.Session != null)
                            {
                                HttpContext.Current.Session["UserId"] = userObject["Id"].ToString();
                                HttpContext.Current.Session["Email"]  = userObject["Email"].ToString();
                                HttpContext.Current.Session["Name"]   = userObject["FirstName"].ToString();

                                break;
                            }
                        }

                        // exception: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
                        // to overcome add, make add response 'false'
                        //HttpContext.Current.Response.Redirect("client-welcome.aspx", false);
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect("login.aspx", false);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Esempio n. 3
0
        public static string CheckEmailExistence(string email)
        {
            string rtnVal = string.Empty;

            var proxy = new BusinessProxy();

            //ClientBasePage.GenerateJqueryErrorForTesting();

            try
            {
                rtnVal = proxy.CheckEmailExistence(email);

                if (rtnVal == "1")
                {
                    string jsonEntUser = proxy.GetUserDetailsByEmail(email);

                    JArray userObjects = JArray.Parse(jsonEntUser);

                    // add session
                    foreach (var userObject in userObjects)
                    {
                        HttpContext.Current.Session["UserId"] = userObject["Id"].ToString();
                        HttpContext.Current.Session["Email"]  = userObject["Email"].ToString();
                        HttpContext.Current.Session["Name"]   = userObject["FirstName"].ToString();

                        break;
                    }

                    // get cookie name
                    string cookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];

                    // add cookie
                    HttpCookie myCookie = new HttpCookie(cookieName);
                    myCookie.Value   = email;
                    myCookie.Expires = DateTime.Now.AddDays(365d);
                    HttpContext.Current.Response.Cookies.Add(myCookie);

                    // check cookie
                    HttpCookie newCookie = new HttpCookie(cookieName);
                    newCookie = HttpContext.Current.Request.Cookies[cookieName];
                    string cookieValue = newCookie.Value;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            return(rtnVal);
        }
        public void GetCookieTransfer()
        {
            string emailExists = string.Empty;

            string cookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];

            HttpCookie myCookie = new HttpCookie(cookieName);

            myCookie = HttpContext.Current.Request.Cookies[cookieName];

            // if cookie exists, redirect to client-welcome.aspx
            if (myCookie != null && myCookie.Value != "undefined")
            {
                string email = Server.UrlDecode(myCookie.Value);

                var proxy = new BusinessProxy();

                try
                {
                    emailExists = proxy.CheckEmailExistence(email);

                    if (emailExists == "1")
                    {
                        string jsonEntUser = proxy.GetUserDetailsByEmail(email);

                        JArray userObjects = JArray.Parse(jsonEntUser);

                        foreach (var userObject in userObjects)
                        {
                            HttpContext.Current.Session["UserId"] = userObject["Id"].ToString();
                            HttpContext.Current.Session["Email"]  = userObject["Email"].ToString();
                            HttpContext.Current.Session["Name"]   = userObject["FirstName"].ToString();

                            break;
                        }

                        // exception: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
                        // to overcome add, make add response 'false'
                        Response.Redirect("client-welcome.aspx", false);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }
            }
        }
        public void CreateUserLocally(string firstName, string lastName, string jobTitle, string email, string firmName, string title, string firmAum, string firmType)
        {
            var proxy = new BusinessProxy();

            string emailExistenceRtnVal = proxy.CheckEmailExistence(email);

            if (emailExistenceRtnVal != "1")
            {
                string prospectId = proxy.CreateUser(firstName, lastName, jobTitle, email, firmName, GetIPAddress(), title, firmAum, firmType);

                if (prospectId != "-1")
                {
                    HttpCookie cookie = Request.Cookies["cookieastpub"];
                    string     userId = Server.HtmlEncode(cookie.Value);

                    proxy.LinkUserCookie(Guid.Parse(userId), Guid.Parse(prospectId));
                }
            }
        }
Esempio n. 6
0
        public static string CreateNewUser(string firstName, string lastName, string jobTitle, string email, string firmName, string title, string frimAum, string firmType)
        {
            string rtnVal = string.Empty;

            var proxy = new BusinessProxy();

            try
            {
                string emailExistenceRtnVal = proxy.CheckEmailExistence(email);

                if (emailExistenceRtnVal != "1")
                {
                    rtnVal = proxy.CreateUser(firstName, lastName, jobTitle, email, firmName, GetIPAddress(), title, frimAum, firmType);

                    // hubspot registration
                    CreateNewContactInHubSpot(firstName, lastName, jobTitle, email, firmName, title, frimAum, firmType);

                    // send email on client registration
                    SendEmailOnClientRegistration(email);
                }
                else
                {
                    // user already exists. login straight away! - no need to add the record
                    rtnVal = "1";
                }

                // if user is exists, add user to session
                if (rtnVal == "1")
                {
                    string jsonEntUser = proxy.GetUserDetailsByEmail(email);

                    JArray userObjects = JArray.Parse(jsonEntUser);

                    // add session
                    foreach (var userObject in userObjects)
                    {
                        HttpContext.Current.Session["UserId"] = userObject["Id"].ToString();
                        HttpContext.Current.Session["Email"]  = userObject["Email"].ToString();
                        HttpContext.Current.Session["Name"]   = userObject["FirstName"].ToString();

                        break;
                    }

                    // add cookie
                    string cookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];

                    HttpCookie myCookie = new HttpCookie(cookieName);
                    myCookie.Value   = email;
                    myCookie.Expires = DateTime.Now.AddDays(365d);
                    HttpContext.Current.Response.Cookies.Add(myCookie);

                    HttpCookie newCookie = new HttpCookie(cookieName);
                    newCookie = HttpContext.Current.Request.Cookies[cookieName];
                    string cookieValue = newCookie.Value;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            return(rtnVal);
        }