Ejemplo n.º 1
0
        public HttpResponseMessage GetPointDetailByUserId(string userId = null, int page = 1, int pageSize = 10)
        {
            var pointdetailCon = new PointDetailSearchCondition
            {
                Brokers = _brokerService.GetBrokerById(Convert.ToInt32(userId)),
                Page = Convert.ToInt32(page),
                PageCount = pageSize
            };

            var PointDetailList = _pointdetailService.GetPointDetailsByCondition(pointdetailCon).Select(p => new
            {
                Id = p.Id,
                p.Addpoints,
                p.Pointsds,
                p.Addtime

            }).ToList().Select(p => new
            {
                Id = p.Id,
                p.Addpoints,
                p.Pointsds,
                Addtime = p.Addtime.ToString("yyyy-MM-dd")

            });
            var PointDetailListCount = _pointdetailService.GetPointDetailCount(pointdetailCon);
            return PageHelper.toJson(new { List = PointDetailList, Condition = pointdetailCon, totalCount = PointDetailListCount });

        }
Ejemplo n.º 2
0
		public IQueryable<PointDetailEntity> GetPointDetailsByCondition(PointDetailSearchCondition condition)
		{
			var query = _pointdetailRepository.Table;
			try
			{
				if (condition.AddtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Addtime>= condition.AddtimeBegin.Value);
                }
                if (condition.AddtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Addtime < condition.AddtimeEnd.Value);
                }
				if (condition.UptimeBegin.HasValue)
                {
                    query = query.Where(q => q.Uptime>= condition.UptimeBegin.Value);
                }
                if (condition.UptimeEnd.HasValue)
                {
                    query = query.Where(q => q.Uptime < condition.UptimeEnd.Value);
                }
				if (!string.IsNullOrEmpty(condition.Pointsds))
                {
                    query = query.Where(q => q.Pointsds.Contains(condition.Pointsds));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (condition.Brokers != null )
                {
                    query = query.Where(q =>q.Broker.Id==condition.Brokers.Id);
                }
				if (condition.Addpointss != null && condition.Addpointss.Any())
                {
                    query = query.Where(q => condition.Addpointss.Contains(q.Addpoints));
                }
				if (condition.Totalpointss != null && condition.Totalpointss.Any())
                {
                    query = query.Where(q => condition.Totalpointss.Contains(q.Totalpoints));
                }
				if (condition.Addusers != null && condition.Addusers.Any())
                {
                    query = query.Where(q => condition.Addusers.Contains(q.Adduser));
                }
				if (condition.Upusers != null && condition.Upusers.Any())
                {
                    query = query.Where(q => condition.Upusers.Contains(q.Upuser));
                }
				if(condition.OrderBy.HasValue)
				{
					switch (condition.OrderBy.Value)
                    {
						case EnumPointDetailSearchOrderBy.OrderById:
							query = condition.isDescending?query.OrderByDescending(q=>q.Id):query.OrderBy(q=>q.Id);
							break;
                    }
					
				}
				else
				{
					query = query.OrderBy(q=>q.Id);
				}

				if (condition.Page.HasValue && condition.PageCount.HasValue)
                {
                    query = query.Skip((condition.Page.Value - 1)*condition.PageCount.Value).Take(condition.PageCount.Value);
                }
				return query;
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return null;
			}
		}
Ejemplo n.º 3
0
		public int GetPointDetailCount (PointDetailSearchCondition condition)
		{
			var query = _pointdetailRepository.Table;
			try
			{
				if (condition.AddtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Addtime>= condition.AddtimeBegin.Value);
                }
                if (condition.AddtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Addtime < condition.AddtimeEnd.Value);
                }
				if (condition.UptimeBegin.HasValue)
                {
                    query = query.Where(q => q.Uptime>= condition.UptimeBegin.Value);
                }
                if (condition.UptimeEnd.HasValue)
                {
                    query = query.Where(q => q.Uptime < condition.UptimeEnd.Value);
                }
				if (!string.IsNullOrEmpty(condition.Pointsds))
                {
                    query = query.Where(q => q.Pointsds.Contains(condition.Pointsds));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (condition.Brokers != null )
                {
                    query = query.Where(q => condition.Brokers.Id ==(q.Broker.Id));
                }
				if (condition.Addpointss != null && condition.Addpointss.Any())
                {
                    query = query.Where(q => condition.Addpointss.Contains(q.Addpoints));
                }
				if (condition.Totalpointss != null && condition.Totalpointss.Any())
                {
                    query = query.Where(q => condition.Totalpointss.Contains(q.Totalpoints));
                }
				if (condition.Addusers != null && condition.Addusers.Any())
                {
                    query = query.Where(q => condition.Addusers.Contains(q.Adduser));
                }
				if (condition.Upusers != null && condition.Upusers.Any())
                {
                    query = query.Where(q => condition.Upusers.Contains(q.Upuser));
                }
				return query.Count();
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return -1;
			}
		}