private VisitorDatagridEntity ProcessData(IQueryable <VisitInfoEntity> query, int?[] num, string type, int value)
        {
            string pvPrecent = "0.00%";
            string vcPrecent = "0.00%";

            int?   start = num[0];
            int?   end   = num[1];
            var    pvSum = query.Count();
            var    vcSum = query.Count(x => x.VisitingSite != x.RefererSite);
            string name;
            Expression <Func <VisitInfoEntity, bool> > countLambda;

            if (num[1] != null)
            {
                name        = num[0] / value + "-" + num[1] / value + type;
                countLambda = x => x.VisitPeriodTime > start && x.VisitPeriodTime <= end;
            }
            else
            {
                name        = num[0] / value + type + "以上";
                countLambda = x => x.VisitPeriodTime > start;
            }

            var vc = query.Where(x => x.RefererSite != x.VisitingSite).Count(countLambda);
            var pv = query.Count(countLambda);

            if (pvSum != 0)
            {
                pvPrecent = (pv / (decimal)pvSum * 100).ToString("F") + "%";
            }
            if (vcSum != 0)
            {
                vcPrecent = (vc / (decimal)vcSum * 100).ToString("F") + "%";
            }

            var data = new VisitorDatagridEntity {
                PV = pv, PVPRE = pvPrecent, VC = vc, VCPRE = vcPrecent, NAME = name
            };

            return(data);
        }
Exemple #2
0
        private VisitorDatagridEntity ProcessData(IQueryable <VisitorDatagridEntity> data, IQueryable <VisitInfoEntity> query, int pvSum, int uvSum, int num)
        {
            string pvPrecent = "0%";
            string uvPrecent = "0%";

            string name = num.ToString(CultureInfo.InvariantCulture) + "次";
            var    uv   = data.Count(x => x.Count == num);
            var    ids  = data.Where(x => x.Count == num).Select(x => x.NAME);

            if (num == 1)
            {
                name = "只访问了一次";
            }
            else if (num >= 6)
            {
                name = "访问了六次以上";
                uv   = data.Count(x => x.Count > num);
                ids  = data.Where(x => x.Count > num).Select(x => x.NAME);
            }
            var pv = (from x in query
                      where ids.Contains(x.VisitId)
                      select x).Count();

            if (pv != 0)
            {
                pvPrecent = (pv / (decimal)pvSum * 100).ToString("F") + "%";
            }
            if (uv != 0)
            {
                uvPrecent = (uv / (decimal)uvSum * 100).ToString("F") + "%";
            }

            var datas = new VisitorDatagridEntity {
                NAME = name, PV = pv, UV = uv, PVPRE = pvPrecent, UVPRE = uvPrecent
            };

            return(datas);
        }