Example #1
0
        private void BindData(int pageIndex)
        {
            int    pressID   = ConvertHelper.ToInt32(hidPressID.Value);
            string bookGuID  = txtBookGuidLink.Value;
            string timestart = textTimeStart.Text;
            string timeend   = textTimeEnd.Text;
            int    serialId  = ConvertHelper.ToInt32(bookType.SelectedValue);

            if (string.IsNullOrEmpty(timestart))
            {
                timestart          = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
                textTimeStart.Text = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
            }
            if (string.IsNullOrEmpty(timeend))
            {
                timeend          = DateTime.Now.ToString("yyyy-MM-dd");
                textTimeEnd.Text = DateTime.Now.ToString("yyyy-MM-dd");
            }
            if (pageIndex <= 0)
            {
                pageIndex = 1;
            }
            int             recordCount      = 0;
            int             totalPersonCount = 0;
            long            totalTimeLength  = 0;
            int             totalReadCount   = 0;
            BookCountAccess data             = new BookCountAccess();

            DataTable dt = data.GetBookReadCountData(pageIndex, 10, serialId, pressID, bookGuID, timestart, timeend, userId, ref recordCount, ref totalPersonCount, ref totalTimeLength, ref totalReadCount);

            num.Value = recordCount.ToString();
            AspNetPager1.CurrentPageIndex = pageIndex;
            AspNetPager1.RecordCount      = recordCount;
            AspNetPager1.DataBind();
        }
Example #2
0
        /// <summary>
        /// 获取图书阅读分析统计
        /// </summary>
        /// <returns></returns>
        public void GetBookReadCountData(HttpContext context)
        {
            int    pageIndex = ConvertHelper.ToInt32(context.Request["pageIndex"]);
            int    pageSize  = ConvertHelper.ToInt32(context.Request["pageSize"]);
            int    pressId   = ConvertHelper.ToInt32(context.Request["pressId"]);
            int    type      = ConvertHelper.ToInt32(context.Request["type"]);
            string bookGuid  = context.Request["bookGuid"];
            string startDate = context.Request["startDate"];
            string endDate   = context.Request["endDate"];

            if (string.IsNullOrEmpty(startDate))
            {
                startDate = DateTime.Now.AddDays(-7).ToShortDateString();
            }
            if (string.IsNullOrEmpty(endDate))
            {
                endDate = DateTime.Now.ToShortDateString();
            }

            int             recordCount      = 0;
            int             totalPersonCount = 0;
            long            totalTimeLength  = 0;
            int             totalReadCount   = 0;
            BookCountAccess data             = new BookCountAccess();

            DataTable dt = data.GetBookReadCountData(pageIndex, pageSize, type, pressId, bookGuid, startDate, endDate, new BasePage.BasePage().userId, ref recordCount, ref totalPersonCount, ref totalTimeLength, ref totalReadCount);

            ResponseBookReadCountModel result = new ResponseBookReadCountModel();

            result.list             = dt;
            result.recordCount      = recordCount;
            result.avgTimeLength    = totalReadCount == 0 ? 0 : (int)(totalTimeLength / totalReadCount);
            result.totalPersonCount = totalPersonCount;
            result.totalReadCount   = totalReadCount;
            string strResult = JsonConvert.SerializeObject(result);

            context.Response.Write(strResult);
        }