⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gethits.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite
{
    using PowerEasy.Common;
    using PowerEasy.Contents;
    using PowerEasy.Model.Contents;
    using PowerEasy.Web.UI;
    using System;
    using System.Web.UI;

    public class GetHits : DynamicPage
    {
        private int dayHits;
        private int hits;
        private int monthHits;
        private int weekHits;

        protected override void Render(HtmlTextWriter writer)
        {
            if (!this.Page.IsPostBack)
            {
                int id = BasePage.RequestInt32("id");
                string str = BasePage.RequestStringToLower("HitsType");
                if (string.IsNullOrEmpty(str))
                {
                    this.UpdateHits(id);
                }
                this.ShowHits(id, str);
            }
        }

        private void ShowHits(int id, string hitsType)
        {
            CommonModelInfo commonModelInfoById = ContentManage.GetCommonModelInfoById(id);
            int hits = 0;
            string str = hitsType;
            if (str != null)
            {
                if (!(str == "dayhits"))
                {
                    if (str == "weekhits")
                    {
                        hits = commonModelInfoById.WeekHits;
                        goto Label_0059;
                    }
                    if (str == "monthhits")
                    {
                        hits = commonModelInfoById.MonthHits;
                        goto Label_0059;
                    }
                }
                else
                {
                    hits = commonModelInfoById.DayHits;
                    goto Label_0059;
                }
            }
            hits = commonModelInfoById.Hits;
        Label_0059:
            base.Response.Write("document.write('" + hits + "');");
        }

        private void UpdateHits(int id)
        {
            DateTime time;
            CommonModelInfo commonModelInfoById = ContentManage.GetCommonModelInfoById(id);
            if (!commonModelInfoById.LastHitTime.HasValue)
            {
                time = DateTime.Now;
            }
            else
            {
                time = commonModelInfoById.LastHitTime.Value;
            }
            this.hits = commonModelInfoById.Hits + 1;
            this.dayHits = commonModelInfoById.DayHits;
            this.weekHits = commonModelInfoById.WeekHits;
            this.monthHits = commonModelInfoById.MonthHits;
            DateTime now = DateTime.Now;
            if (string.Compare(time.ToShortDateString(), DateTime.Now.ToShortDateString(), true) == 0)
            {
                this.dayHits++;
            }
            else
            {
                this.dayHits = 1;
            }
            DateTime time3 = now.AddDays((double) -DataConverter.CLng(now.DayOfWeek));
            DateTime time4 = time3.AddDays(7.0);
            if ((DateTime.Compare(time, time3) >= 0) && (DateTime.Compare(time, time4) <= 0))
            {
                this.weekHits++;
            }
            else
            {
                this.weekHits = 1;
            }
            if ((string.Compare(time.Year.ToString(), now.Year.ToString()) == 0) && (string.Compare(time.Month.ToString(), now.Month.ToString()) == 0))
            {
                this.monthHits++;
            }
            else
            {
                this.monthHits = 1;
            }
            ContentManage.UpdateHits(id, this.hits, this.dayHits, this.weekHits, this.monthHits, time);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -