예제 #1
0
        /// <summary>
        /// 获取未绑定设备信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <DeviceListDto> > GetPagedUnBindDevices(GetDevicesInput input)
        {
            var query = _deviceRepository.GetAllIncluding(c => c.Point);

            query = query.WhereIf(!input.Name.IsNullOrWhiteSpace(), c => c.DeviceName.Contains(input.Name))
                    .WhereIf(!input.Num.IsNullOrWhiteSpace(), c => c.DeviceNum.Contains(input.Num));
            var bindDevice = await _operatorDeviceRepository.GetAllListAsync();

            var result = from c in query
                         join d in bindDevice on c.Id equals d.DeviceId into temp
                         from tt in temp.DefaultIfEmpty()
                         where tt == null
                         select c;
            var deviceCount = await result.CountAsync();

            var devices = await result
                          .OrderBy(input.Sorting)
                          .PageBy(input)
                          .ToListAsync();

            //var deviceListDtos = ObjectMapper.Map<List <DeviceListDto>>(devices);
            var deviceListDtos = devices.MapTo <List <DeviceListDto> >();

            return(new PagedResultDto <DeviceListDto>(
                       deviceCount,
                       deviceListDtos
                       ));
        }
예제 #2
0
        /// <summary>
        /// 获取Device的分页列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <DeviceListDto> > GetPagedDevices(GetDevicesInput input)
        {
            var query = _deviceRepository.GetAllIncluding(c => c.Point);

            query = query.WhereIf(!input.Name.IsNullOrWhiteSpace(), c => c.DeviceName.Contains(input.Name))
                    .WhereIf(!input.Num.IsNullOrWhiteSpace(), c => c.DeviceNum.Contains(input.Num))
                    .WhereIf(!input.Cate.IsNullOrWhiteSpace(), c => c.DeviceType.Contains(input.Cate));
            var deviceCount = await query.CountAsync();

            var devices = await query
                          .OrderBy(input.Sorting)
                          .PageBy(input)
                          .ToListAsync();

            //var deviceListDtos = ObjectMapper.Map<List <DeviceListDto>>(devices);
            var deviceListDtos = devices.MapTo <List <DeviceListDto> >();

            return(new PagedResultDto <DeviceListDto>(
                       deviceCount,
                       deviceListDtos
                       ));
        }