Beispiel #1
0
        private void recordData()
        {
            // check for cookie and 
            
            BrowsingData o;
            if (Session["BrowsingData"]!=null)
            {
                o = (BrowsingData)Session["BrowsingData"];
                if (HttpContext.Current.Request.UrlReferrer !=null)
                    o.addLink(HttpContext.Current.Request.UrlReferrer.ToString(),HttpContext.Current.Request.RawUrl);
                else
                    o.addLink("New", HttpContext.Current.Request.RawUrl);
            }

            else
            {
                Object checkcookie = Request.Cookies["BrowsingData"];
                if (checkcookie != null) // already visited once
                {
                    String user = Request.Cookies["BrowsingData"].Value;
                    //user = new ProjectUtilities().DecryptText(user);
                    o = new BrowsingData(user, HttpContext.Current);
                    Session["BrowsingData"] = o;
                    String cd = o.id + ":" + o.visitcount;
                    // encrypt cookie
                    //cd = new ProjectUtilities().EncryptText(cd);
                    // create the cookie here  And 
                    // set the cookie
                    Response.Cookies["BrowsingData"].Value = cd;
                    Response.Cookies["BrowsingData"].Expires = DateTime.MaxValue;
                }
                else // completely fresh visit
                {
                    o = new BrowsingData(HttpContext.Current);                   
                    Session["BrowsingData"] = o;
                    String cd = o.id + ":" + o.visitcount;
                    Response.Cookies["BrowsingData"].Value = cd;
                    Response.Cookies["BrowsingData"].Expires = DateTime.MaxValue;
                }      
            }      
        }
Beispiel #2
0
 public void commit(BrowsingData x)
 {
     String q = "Insert into BrowserData (SessionId,VisitCount,DeviceType,Mobile,CurrentLink,Referrer,IPAddress,Resolution,Browser) Values (@a,@b,@c,@d,@e,@f,@g,@h,@i)";
     SqlConnection c = new SqlConnection(new ProjectUtilities().cons());
     SqlCommand com = new SqlCommand(q,c);
     com.Parameters.AddWithValue("@a", this.id);
     com.Parameters.AddWithValue("@b", this.visitcount);
     com.Parameters.AddWithValue("@c", this.device);
     com.Parameters.AddWithValue("@d", this.mobile);
     com.Parameters.AddWithValue("@g", this.ip);
     com.Parameters.AddWithValue("@h", this.resolution);
     com.Parameters.AddWithValue("@i", this.browser);
     try {
         c.Open();
         com.Parameters.AddWithValue("@e", this.links);
         com.Parameters.AddWithValue("@f", this.currentPage);
         com.ExecuteNonQuery();
     }
     catch (Exception e) { }
     finally { c.Close(); }
  }