protected void Timer1_Tick(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["BrowserDate"]; try { Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"))); int currentAdIndex = 0; DataView dvAds = new DataView(); if (Request.Url.AbsolutePath.ToLower() == "/group.aspx") { string commandStr = ""; int lastSeen = 0; dvAds = dat.GetGroupAds(Request.QueryString["ID"].ToString(), ref commandStr, ref lastSeen); DataView dv = dat.GetDataDV("SELECT * FROM BigAdStatistics_Anonymous WHERE isGroup='True' AND SessionNum = '" + Session["BigAnonymousGroupSession"].ToString() + "'"); if (int.Parse(dv[0]["LastSeenIndex"].ToString()) == dat.NUMB_TOTAL_BIG_ADS - 1) currentAdIndex = 0; else currentAdIndex = int.Parse(dv[0]["LastSeenIndex"].ToString()) + 1; } else { if (Session["ADBigDV"] == null || Session["ADBigCount"] == null) dat.GetAdSet(1, true); dvAds = (DataView)Session["ADBigDV"]; currentAdIndex = int.Parse(Session["ADBigCount"].ToString()); if (currentAdIndex < dvAds.Count - 1) { currentAdIndex++; } else { currentAdIndex = 0; } } //Draw the next ad DrawAd(currentAdIndex, dvAds); Session["ADBigCount"] = currentAdIndex; } catch (Exception ex) { Errorlabel.Text = ex.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { //Response.Cache.SetCacheability(HttpCacheability.NoCache); try { if (!IsPostBack) { HttpCookie cookie = Request.Cookies["BrowserDate"]; Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"))); DateTime timeNow = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")); DataView dvUserAds; int lastSeen = 0; if (Request.Url.AbsolutePath.ToLower() == "/group.aspx") { //If we are in the group, all we need to do is get //ads that are in this location and in the groups categories //plus ads that are only in the location and have displayToAll = 'True' string commandStr = ""; dvUserAds = dat.GetGroupAds(Request.QueryString["ID"].ToString(), ref commandStr, ref lastSeen); } else { dvUserAds = dat.GetAdSet(1, true); } DataBind2(dvUserAds, lastSeen); } } catch (Exception ex) { Errorlabel.Text = ex.ToString() + "<br/><br/>" + Request.Url.AbsolutePath.ToLower(); } }