private void PopNews() { if (base._User != null) { string key = "Get_Win_Info_" + base._User.ID.ToString(); DataTable cacheAsDataTable = Shove._Web.Cache.GetCacheAsDataTable("Get_Win_Info_" + base._User.ID.ToString()); if (cacheAsDataTable == null) { cacheAsDataTable = new Views.V_BuyDetails().Open("top 1 LotteryName,IsuseName,WinLotteryNumber,LotteryNumber,WinMoneyNoWithTax", "IsOpened = 1 and UserID = " + base._User.ID, "ID DESC"); if (cacheAsDataTable == null) { PF.GoError(4, "数据库繁忙,请重试(537)", base.GetType().FullName); return; } Shove._Web.Cache.SetCache(key, cacheAsDataTable, 300); } StringBuilder builder = new StringBuilder(); builder.Append(base._User.Name).Append(","); if (cacheAsDataTable.Rows.Count != 0) { Shove._Web.Utility.GetUrl(); for (int i = 0; i < cacheAsDataTable.Rows.Count; i++) { builder.Append(cacheAsDataTable.Rows[i]["LotteryName"].ToString()).Append("第").Append(cacheAsDataTable.Rows[i]["IsuseName"].ToString()).Append("期中奖号码是 ").Append(cacheAsDataTable.Rows[i]["WinLotteryNumber"].ToString()).Append(" 您投注的号码是").Append(_String.Cut(cacheAsDataTable.Rows[i]["LotteryNumber"].ToString(), 15)).Append(" ,").Append((_Convert.StrToDouble(cacheAsDataTable.Rows[i]["WinMoneyNoWithTax"].ToString(), 0.0) > 0.0) ? "<font style='color:red;'>中奖了</font>,希望您再接再厉,夺得更多奖金。" : "没有中奖,希望您继续努力,祝您早日中大奖。"); } this.label1.Text = HmtlManage.GetHtml(AppDomain.CurrentDomain.BaseDirectory + "Home/Room/Template/FloatNotify.html").Replace("$FloatNotifyContent$", builder.ToString()); } } }
private void PopNews() { if (_User == null) { return; } string CacheKeyName = "Get_Win_Info_" + _User.ID.ToString(); DataTable dt = Shove._Web.Cache.GetCacheAsDataTable("Get_Win_Info_" + _User.ID.ToString()); if (dt == null) { dt = new DAL.Views.V_BuyDetails().Open("top 1 LotteryName,IsuseName,WinLotteryNumber,LotteryNumber,WinMoneyNoWithTax", "IsOpened = 1 and UserID = " + _User.ID, "ID DESC"); if (dt == null) { PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试(537)", this.GetType().FullName); return; } Shove._Web.Cache.SetCache(CacheKeyName, dt, 300); } StringBuilder sb = new StringBuilder(); sb.Append(_User.Name).Append(","); if (dt.Rows.Count != 0) { string SiteUrl = Shove._Web.Utility.GetUrl(); for (int i = 0; i < dt.Rows.Count; i++) { sb.Append(dt.Rows[i]["LotteryName"].ToString()).Append("第") .Append(dt.Rows[i]["IsuseName"].ToString()).Append("期中奖号码是 ") .Append(dt.Rows[i]["WinLotteryNumber"].ToString()) .Append(" 您投注的号码是") .Append(Shove._String.Cut(dt.Rows[i]["LotteryNumber"].ToString(), 15)).Append(" ,") .Append(Shove._Convert.StrToDouble(dt.Rows[i]["WinMoneyNoWithTax"].ToString(), 0) > 0 ? "<font style='color:red;'>中奖了</font>,希望您再接再厉,夺得更多奖金。" : "没有中奖,希望您继续努力,祝您早日中大奖。"); } string FloatNotify = HmtlManage.GetHtml(AppDomain.CurrentDomain.BaseDirectory + "Home/Room/Template/FloatNotify.html"); label1.Text = FloatNotify.Replace("$FloatNotifyContent$", sb.ToString()); } }
protected override void OnLoad(EventArgs e) { if (!base.IsPostBack) { new FirstUrl().Save(); } this.PageUrl = base.Request.Url.AbsoluteUri; this._Site = new Sites()[1L]; if (this._Site == null) { PF.GoError(1, "域名无效,限制访问", base.GetType().FullName); } else { this._User = Users.GetCurrentUser(this._Site.ID); if (this.isRequestLogin && (this._User == null)) { PF.GoLogin(this.RequestLoginPage); } else { try { PlaceHolder holder = this.Page.FindControl("phHead") as PlaceHolder; if (holder != null) { UserControl child = this.Page.LoadControl("~/Home/Room/UserControls/WebHead.ascx") as UserControl; holder.Controls.Add(child); } PlaceHolder holder2 = this.Page.FindControl("phFoot") as PlaceHolder; if (holder2 != null) { UserControl control2 = this.Page.LoadControl("~/Home/Room/UserControls/WebFoot.ascx") as UserControl; holder2.Controls.Add(control2); } } catch { } string str = ((base.Request.Url.Query == "") ? base.Request.Url.AbsoluteUri : base.Request.Url.AbsoluteUri.Replace(base.Request.Url.Query, "")).Replace(Utility.GetUrl(), "").Replace("/", "_").Replace(".aspx", ""); if (str.StartsWith("_")) { str = str.Remove(0, 1); } if (FloatNotifyPageList.IndexOf("," + str + ",") > -1) { StringBuilder builder = new StringBuilder(); string key = "FloatNotifyContent"; DataTable cacheAsDataTable = Shove._Web.Cache.GetCacheAsDataTable(key); if (cacheAsDataTable == null) { cacheAsDataTable = new Tables.T_FloatNotify().Open("", "", "[Order] asc,[DateTime] desc"); if ((cacheAsDataTable != null) && (cacheAsDataTable.Rows.Count > 0)) { Shove._Web.Cache.SetCache(key, cacheAsDataTable, 0xea60); } } bool flag = false; int num = this._Site.SiteOptions["Opt_FloatNotifiesTime"].ToInt(3); string name = "LastLoginShowFloatNotifyUserID"; switch (num) { case 1: { HttpCookie cookie = base.Request.Cookies[name]; if ((cookie != null) && !string.IsNullOrEmpty(cookie.Value)) { flag = true; } break; } case 2: flag = DateTime.Now.Minute == 0; break; case 3: flag = true; break; } if (((cacheAsDataTable != null) && (cacheAsDataTable.Rows.Count > 0)) && flag) { DataRow[] rowArray = cacheAsDataTable.Select("isShow=1"); for (int i = 0; i < rowArray.Length; i++) { if (i == 2) { break; } int num4 = i + 1; builder.Append("<font color='" + rowArray[i]["Color"].ToString() + "'>").Append(num4.ToString()).Append(".</font>").Append("<a href='").Append(rowArray[i]["Url"].ToString()).Append("' target='_blank' style='text-decoration: none;color:").Append(rowArray[i]["Color"].ToString()).Append(";' onmouseover=\"this.style.color='#ff6600';\" onmouseout=\"this.style.color='").Append(rowArray[i]["Color"].ToString()).Append("';\">").Append(rowArray[i]["Title"].ToString()).Append("</a><br />"); } string html = HmtlManage.GetHtml(AppDomain.CurrentDomain.BaseDirectory + "Home/Web/Template/FloatNotify.html"); Label label = new Label(); int num5 = FloatNotifyTimeOut * 100; label.Text = html.Replace("$FloatNotifyTimeOut$", num5.ToString()).Replace("$FloatNotifyContent$", builder.ToString()); try { base.Form.Controls.AddAt(0, label); } catch (Exception exception) { new Log("Page").Write(str + exception.Message); } HttpCookie cookie2 = new HttpCookie(name) { Value = "", Expires = DateTime.Now.AddYears(-20) }; try { HttpContext.Current.Response.Cookies.Add(cookie2); } catch { } } } string fullName = base.GetType().FullName; try { fullName = fullName.Substring(4, fullName.Length - 9); } catch { } int appSettingsInt = WebConfig.GetAppSettingsInt(fullName, -1); if (appSettingsInt > 0) { base.Response.Cache.SetExpires(DateTime.Now.AddSeconds((double)appSettingsInt)); base.Response.Cache.SetCacheability(HttpCacheability.Server); base.Response.Cache.VaryByParams["*"] = true; base.Response.Cache.SetValidUntilExpires(true); base.Response.Cache.SetVaryByCustom("SitePage"); } base.OnLoad(e); } } }
protected override void OnLoad(EventArgs e) { if (!this.IsPostBack) { //为 CPS 商家保存第一次访问的二级域名 new FirstUrl().Save(); } PageUrl = this.Request.Url.AbsoluteUri; #region 获取站点 _Site = new Sites()[1]; if (_Site == null) { PF.GoError(ErrorNumber.Unknow, "域名无效,限制访问", this.GetType().FullName); return; } #endregion #region 获取用户 _User = Users.GetCurrentUser(_Site.ID); if (isRequestLogin && (_User == null)) { PF.GoLogin(RequestLoginPage); return; } #endregion #region 加载头部和底部 try { PlaceHolder phHead = Page.FindControl("phHead") as PlaceHolder; if (phHead != null) { UserControl Head = Page.LoadControl("~/Home/Room/UserControls/WebHead.ascx") as UserControl; Head.ID = "WebHead1"; phHead.Controls.Add(Head); } PlaceHolder phFoot = Page.FindControl("phFoot") as PlaceHolder; if (phFoot != null) { UserControl Foot = Page.LoadControl("~/Home/Room/UserControls/WebFoot.ascx") as UserControl; phFoot.Controls.Add(Foot); } } catch { } #endregion #region 弹出广告 string ClassName = (this.Request.Url.Query == "" ? this.Request.Url.AbsoluteUri : this.Request.Url.AbsoluteUri.Replace(this.Request.Url.Query, "")).Replace(Shove._Web.Utility.GetUrl(), "").Replace("/", "_").Replace(".aspx", ""); if (ClassName.StartsWith("_")) { ClassName = ClassName.Remove(0, 1); } if (FloatNotifyPageList.IndexOf("," + ClassName + ",") > -1) { StringBuilder sb = new StringBuilder(); string CacheKey = "FloatNotifyContent"; DataTable dt = Shove._Web.Cache.GetCacheAsDataTable(CacheKey); if (dt == null) { dt = new DAL.Tables.T_FloatNotify().Open("", "", "[Order] asc,[DateTime] desc"); if (dt != null && dt.Rows.Count > 0) { Shove._Web.Cache.SetCache(CacheKey, dt, 60000); } } bool IsShow = false; int FloatNotifiesType = _Site.SiteOptions["Opt_FloatNotifiesTime"].ToInt(3); string LastLoginFloatNotifyKey = "LastLoginShowFloatNotifyUserID"; switch (FloatNotifiesType) { case 1: { HttpCookie cookieLastLoginFloatNotify = Request.Cookies[LastLoginFloatNotifyKey]; if (cookieLastLoginFloatNotify != null && !String.IsNullOrEmpty(cookieLastLoginFloatNotify.Value)) { IsShow = true; } } break; case 2: { IsShow = (DateTime.Now.Minute == 0); } break; case 3: { IsShow = true; } break; } if (dt != null && dt.Rows.Count > 0 && IsShow) { DataRow[] drs = dt.Select("isShow=1"); for (int i = 0; i < drs.Length; i++) { if (i == 2) { break; } sb.Append("<font color='" + drs[i]["Color"].ToString() + "'>").Append((i + 1).ToString()).Append(".</font>").Append("<a href='").Append(drs[i]["Url"].ToString()).Append("' target='_blank' style='text-decoration: none;color:").Append(drs[i]["Color"].ToString()).Append(";' onmouseover=\"this.style.color='#ff6600';\" onmouseout=\"this.style.color='").Append(drs[i]["Color"].ToString()).Append("';\">").Append(drs[i]["Title"].ToString()).Append("</a><br />"); } string FloatNotify = HmtlManage.GetHtml(AppDomain.CurrentDomain.BaseDirectory + "Home/Web/Template/FloatNotify.html"); Label label = new Label(); label.Text = FloatNotify.Replace("$FloatNotifyTimeOut$", (FloatNotifyTimeOut * 100).ToString()).Replace("$FloatNotifyContent$", sb.ToString()); try { this.Form.Controls.AddAt(0, label); } catch (Exception ex) { new Log("Page").Write(ClassName + ex.Message); } // 从 Cookie 中移除 浮出广告的UserID HttpCookie cookieLastLoginFloatNotify = new HttpCookie(LastLoginFloatNotifyKey); cookieLastLoginFloatNotify.Value = ""; cookieLastLoginFloatNotify.Expires = DateTime.Now.AddYears(-20); try { HttpContext.Current.Response.Cookies.Add(cookieLastLoginFloatNotify); } catch { } } } #endregion #region 缓存 string PageName = this.GetType().FullName; try { PageName = PageName.Substring(4, PageName.Length - 9); } catch { } int SitePageCacheSeconds = Shove._Web.WebConfig.GetAppSettingsInt(PageName, -1); if (SitePageCacheSeconds > 0) { this.Response.Cache.SetExpires(DateTime.Now.AddSeconds(SitePageCacheSeconds)); this.Response.Cache.SetCacheability(HttpCacheability.Server); this.Response.Cache.VaryByParams["*"] = true; this.Response.Cache.SetValidUntilExpires(true); this.Response.Cache.SetVaryByCustom("SitePage"); } #endregion //HtmlMeta hm = new HtmlMeta(); //hm.HttpEquiv = "X-UA-Compatible"; //hm.Content = "IE=EmulateIE7"; //Page.Header.Controls.Add(hm); base.OnLoad(e); }