Exemplo n.º 1
0
        public void GetUserActivityCookieData()
        {
            var  proxy = new BusinessProxy();
            Guid userId;

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

            HttpCookie myCookie = new HttpCookie(cookieName);

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

            if (myCookie != null && myCookie.Value != "undefined")
            {
                HttpCookie cookie = Request.Cookies[cookieName];
                userId = Guid.Parse(Server.HtmlEncode(cookie.Value));
            }
            else
            {
                userId = Guid.NewGuid();

                HttpCookie cookie = new HttpCookie(cookieName);
                cookie.Value   = userId.ToString();
                cookie.Expires = DateTime.MaxValue;
                Response.Cookies.Add(cookie);
            }

            int pageId = int.Parse(proxy.GetPageUrlId(HttpContext.Current.Request.Url.AbsolutePath));

            proxy.CreateUserActivity(userId, pageId);
        }