private void Bind(string nick, string session, DateTime start, DateTime end, int totalCount, int recordCount)
    {
        int TotalPage = totalCount % recordCount != 0 ? (totalCount / recordCount) + 1 : totalCount / recordCount; //总页数

        int page = 1;

        try
        {
            page = int.Parse(Request.QueryString["Page"]);
            if (ViewState["page"] != null)
            {
                page = int.Parse(ViewState["page"].ToString());
                ViewState["page"] = null;
            }
        }
        catch { }

        IList <GoodsInfo> list = taoGoodsService.GetTopBuyGoods(HttpUtility.UrlDecode(Request.Cookies["nick"].Value), start, end, page, recordCount);

        if (list.Count > 0)
        {
            string           pids       = "";
            List <GoodsInfo> cachegoods = new List <GoodsInfo>();
            if (Cache["taobaogoodslist"] != null)
            {
                cachegoods = (List <GoodsInfo>)Cache["taobaogoodslist"];
            }
            foreach (GoodsInfo info in list)
            {
                if (!cachegoods.Contains(info))
                {
                    pids += info.num_iid + ",";
                }
            }

            if (pids != "")
            {
                List <GoodsInfo> goodsinfoList = TaoBaoAPI.GetGoodsInfoList(nick, session, pids.Substring(0, pids.Length - 1));

                if (Cache["taobaogoodslist"] == null)
                {
                    Cache.Insert("taobaogoodslist", goodsinfoList, null, DateTime.Now.AddHours(12), System.Web.Caching.Cache.NoSlidingExpiration);
                }
                else
                {
                    cachegoods.AddRange(goodsinfoList);
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                IList <GoodsInfo> thislist = ((List <GoodsInfo>)Cache["taobaogoodslist"]).Where(o => o.num_iid == list[i].num_iid).ToList();
                if (thislist.Count > 0)
                {
                    list[i].title   = thislist[0].title;
                    list[i].price   = thislist[0].price;
                    list[i].pic_url = thislist[0].pic_url;
                }
            }
        }

        //for (int i = 0; i < list.Count; i++)
        //{
        //    GoodsInfo rinfo = TaoBaoAPI.GetGoodsInfo(list[i].num_iid);
        //    list[i].title = rinfo.title;
        //    list[i].price = rinfo.price;
        //}

        lblCurrentPage.Text = "共" + totalCount.ToString() + "条记录 当前页:" + page + "/" + (TotalPage == 0 ? 1 : TotalPage);

        lnkFrist.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1&" + "start=" + start.ToShortDateString() + "&end=" + end.ToShortDateString();
        if (page > 1)
        {
            lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(page - 1) + "&" + "start=" + start.ToShortDateString() + "&end=" + end.ToShortDateString();
        }

        if (page != TotalPage && TotalPage != 0)
        {
            lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(page + 1) + "&" + "start=" + start.ToShortDateString() + "&end=" + end.ToShortDateString();
        }
        lnkEnd.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + (TotalPage == 0 ? 1 : TotalPage) + "&" + "start=" + start.ToShortDateString() + "&end=" + end.ToShortDateString();

        Rpt_PageVisit.DataSource = list;
        Rpt_PageVisit.DataBind();
        TB_Start.Text = start.ToString("yyyy-MM-dd");
        TB_End.Text   = end.ToString("yyyy-MM-dd");
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Cookies["nick"] == null)
            {
                System.Threading.Thread.Sleep(1000 * 6);
            }
            string       nickNo    = DataHelper.Encrypt(HttpUtility.UrlDecode(Request.Cookies["nick"].Value));
            VisitService vistitDal = new VisitService();
            DateTime[]   darray    = DataHelper.GetDateTime(DateTime.Now, 1);
            Rpt_IpPV.DataSource = vistitDal.GetIndexTotalInfoList(nickNo, darray[0], darray[1]).OrderByDescending(o => o.Value).ToList();
            Rpt_IpPV.DataBind();

            Rpt_OnlineCustomer.DataSource = vistitDal.GetIndexOnlineCustomer(nickNo, 3, darray[0], darray[1]);
            Rpt_OnlineCustomer.DataBind();

            TaoBaoGoodsServive taoGoodsService = new TaoBaoGoodsServive();

            IList <GoodsInfo> list = taoGoodsService.GetTopBuyGoods(HttpUtility.UrlDecode(Request.Cookies["nick"].Value), darray[0], darray[1], 1, 3);

            if (list.Count > 0)
            {
                string           pids       = "";
                List <GoodsInfo> cachegoods = new List <GoodsInfo>();
                if (Cache["taobaogoodslist"] != null)
                {
                    cachegoods = (List <GoodsInfo>)Cache["taobaogoodslist"];
                }
                foreach (GoodsInfo info in list)
                {
                    if (!cachegoods.Contains(info))
                    {
                        pids += info.num_iid + ",";
                    }
                }

                if (pids != "")
                {
                    List <GoodsInfo> goodsinfoList = TaoBaoAPI.GetGoodsInfoList(HttpUtility.UrlDecode(Request.Cookies["nick"].Value), Request.Cookies["nicksession"].Value, pids.Substring(0, pids.Length - 1));

                    if (Cache["taobaogoodslist"] == null)
                    {
                        Cache.Insert("taobaogoodslist", goodsinfoList, null, DateTime.Now.AddHours(12), System.Web.Caching.Cache.NoSlidingExpiration);
                    }
                    else
                    {
                        cachegoods.AddRange(goodsinfoList);
                    }
                }
                for (int i = 0; i < list.Count; i++)
                {
                    IList <GoodsInfo> thislist = ((List <GoodsInfo>)Cache["taobaogoodslist"]).Where(o => o.num_iid == list[i].num_iid).ToList();
                    if (thislist.Count > 0)
                    {
                        list[i].title   = thislist[0].title;
                        list[i].price   = thislist[0].price;
                        list[i].pic_url = thislist[0].pic_url;
                    }
                }
            }

            Rpt_GoodsSellTop.DataSource = list;
            Rpt_GoodsSellTop.DataBind();

            SiteTotalService siteTotalDal = new SiteTotalService();
            BindRpt_OrderTotal(siteTotalDal);
            TopSiteTotalInfo lastweek  = siteTotalDal.GetOrderTotalInfo(DateTime.Now.AddDays(-7), DateTime.Now, HttpUtility.UrlDecode(Request.Cookies["nick"].Value));
            TopSiteTotalInfo llastweek = siteTotalDal.GetOrderTotalInfo(DateTime.Now.AddDays(-14), DateTime.Now.AddDays(-8), HttpUtility.UrlDecode(Request.Cookies["nick"].Value));
            ViewState["lastweek"]  = lastweek;
            ViewState["llastweek"] = llastweek;
        }
    }