Beispiel #1
0
        private IQueryable <Petition> getByCondition(PetitionCondition condition)
        {
            IQueryable <Petition> q = defaultOrderQuery();

            if (condition == null)
            {
                return(q);
            }
            if (condition.StartTime != null)
            {
                q = q.Where(t => t.PetitionDate >= condition.StartTime.Value);
            }
            if (condition.EndTime != null)
            {
                q = q.Where(t => t.PetitionDate <= condition.EndTime.Value);
            }
            if (!string.IsNullOrEmpty(condition.ProblemAddress))
            {
                q = q.Where(t => t.ProblemAddress == condition.ProblemAddress);
            }
            if (condition.CategoryId != 0)
            {
                q = q.Where(t => t.CategoryId == condition.CategoryId);
            }
            if (condition.Daily != null)
            {
                q = q.Where(t => t.PetitionDate == condition.Daily.Value);
            }
            return(q);
        }
Beispiel #2
0
        /// <summary>
        /// 案件人数
        /// </summary>
        /// <param name="visit"></param>
        /// <param name="countyId"></param>
        /// <returns></returns>
        private int getPeopleCount(int visit, PetitionCondition condition)
        {
            IQueryable <Petition> q = getByCondition(condition);

            q = q.Where(t => t.VisitType == visit);
            return(q.Count() == 0 ? 0 : q.Sum(t => t.Count));
            //var q = database.Petition.Where(t => t.VisitType == visit && t.ProblemAddress == countyId && t.PetitionDate == today);
            //return q.Count() == 0 ? 0 : q.Sum(t => t.Count);
        }
Beispiel #3
0
        /// <summary>
        /// 案件起数
        /// </summary>
        /// <param name="visit"></param>
        /// <param name="countyId"></param>
        /// <returns></returns>
        private int getPetitionNumber(int visit, PetitionCondition condition)
        {
            IQueryable <Petition> q = getByCondition(condition);

            q = q.Where(t => t.VisitType == visit);
            return(q.Count());
            //var today = DateTime.Now.Date;
            //return database.Petition.Count(t => t.VisitType == visit && t.ProblemAddress == countyId && t.PetitionDate == today);
        }
Beispiel #4
0
        public List <Petition> getList(PetitionCondition condition, int pagenum, int pagesize, out int count)
        {
            IQueryable <Petition> q = getByCondition(condition);

            count = q.Count();
            var list = q.Skip((pagenum - 1) * pagesize).Take(pagesize).ToList();

            if (list.Count == 0)
            {
                return(list);
            }
            foreach (var item in list)
            {
                loadForeignKey(item);
            }
            return(list);
        }
Beispiel #5
0
        public List <PetitionStatistics> getStatistics(out int total_Qi, out int total_Ren, PetitionCondition condition)
        {
            List <PetitionStatistics> result = new List <PetitionStatistics>();
            var list = database.County.Where(t => t.Level == (int)Level.County).ToList();

            if (list.Count == 0)
            {
                throw new ApplicationException("县区为空");
            }
            foreach (var item in list)
            {
                PetitionStatistics model = new PetitionStatistics();
                condition.ProblemAddress = item.Id;
                model.City_Qi            = getPetitionNumber((int)Visit.City, condition);
                model.City_Ren           = getPeopleCount((int)Visit.City, condition);
                model.Province_Qi        = getPetitionNumber((int)Visit.Province, condition);
                model.Province_Ren       = getPeopleCount((int)Visit.Province, condition);
                model.Capital_Qi         = getPetitionNumber((int)Visit.Capital, condition);
                model.Capital_Ren        = getPeopleCount((int)Visit.Capital, condition);
                model.NoVisit_Qi         = getPetitionNumber((int)Visit.NoVisit, condition);
                model.NoVisit_Ren        = getPeopleCount((int)Visit.NoVisit, condition);
                model.CountyId           = item.Id;
                model.CountyName         = item.Name;
                result.Add(model);
            }
            result.Add(getSum(result, out total_Qi, out total_Ren));
            return(result);
        }