Esempio n. 1
0
    protected void g_ItemCommand(object source, DataGridCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            this.Response.Redirect("FloatNotifiesEdit.aspx?ID=" + e.Item.Cells[6].Text, true);
        }

        if (e.CommandName == "Deletes")
        {
            DAL.Tables.T_FloatNotify fn = new DAL.Tables.T_FloatNotify();

            fn.Delete("ID=" + e.Item.Cells[6].Text);

            Shove._Web.Cache.ClearCache("FloatNotifyContent");
            BindData();
        }
    }
Esempio n. 2
0
    private void BindData()
    {
        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);
            }
        }

        g.DataSource = dt;
        g.DataBind();
    }
    private void BindData()
    {
        HidID.Value = Shove._Web.Utility.GetRequest("ID");

        int id = Shove._Convert.StrToInt(HidID.Value, 0);

        if (id < 0)
        {
            PF.GoError(ErrorNumber.Unknow, "参数错误或数据被删除", this.Page.GetType().BaseType.FullName);

            return;
        }

        DataTable dt = new DAL.Tables.T_FloatNotify().Open("", "ID=" + id.ToString() + "", "");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

            return;
        }

        if (dt.Rows.Count == 0)
        {
            PF.GoError(ErrorNumber.Unknow, "参数错误或数据被删除", this.Page.GetType().BaseType.FullName);

            return;
        }

        DataRow dr = dt.Rows[0];

        tbName.Text      = dr["Title"].ToString();
        tbUrl.Text       = dr["Url"].ToString();
        tbOrder.Text     = dr["Order"].ToString();
        cbisShow.Checked = Shove._Convert.StrToBool(dr["isShow"].ToString(), true);
        HidColor.Value   = dr["Color"].ToString();
    }
Esempio n. 4
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string Title = tbName.Text.Trim();

        if (Title == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入广告标题!");

            return;
        }

        string Url = tbUrl.Text.Trim();

        Regex regex = new Regex(@"([\w-]+\.)+[\w-]+.([^a-z])(/[\w- ./?%&=]*)?|[a-zA-Z0-9\-\.][\w-]+.([^a-z])(/[\w- ./?%&=]*)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
        Match m     = regex.Match(Url);

        if (!m.Success)
        {
            Shove._Web.JavaScript.Alert(this, "输入的URL地址格式错误,请仔细检查。");

            return;
        }

        int order = Shove._Convert.StrToInt(tbOrder.Text.Trim(), -1);

        if (order < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "顺序输入非法!");

            return;
        }

        DAL.Tables.T_FloatNotify fn = new DAL.Tables.T_FloatNotify();

        string color = Shove._Web.Utility.GetRequest("highlight_color");

        if (color == "")
        {
            color = "#000000";
        }

        fn.Order.Value = order;
        fn.Url.Value   = Url;
        fn.Title.Value = Title;
        fn.Color.Value = color;

        long Result = fn.Insert();

        if (Result > 0)
        {
            //清除缓存
            string CacheKey = "FloatNotifyContent";
            Shove._Web.Cache.ClearCache(CacheKey);

            Shove._Web.JavaScript.Alert(this, "添加成功", "FloatNotifies.aspx");
        }
        else
        {
            Shove._Web.JavaScript.Alert(this, "添加失败");
        }
    }
Esempio n. 5
0
    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);
    }