예제 #1
0
        public async Task <MessageModel <List <TasksQzEntity> > > FindAsync(JobItemQueryDto queryDto)
        {
            MessageModel <List <TasksQzEntity> > messageModel = new MessageModel <List <TasksQzEntity> >();
            var jobItems = FreeSQL.Instance.Select <TasksQzEntity>()
                           .WhereIf(!string.IsNullOrEmpty(queryDto.AppId), b => b.AppId == queryDto.AppId)
                           .WhereIf(!string.IsNullOrEmpty(queryDto.Name), b => b.Name == queryDto.Name)
                           .WhereIf(queryDto.Deleted != (int)BoolStatus.All, b => b.IsDeleted == (queryDto.Deleted == (int)BoolStatus.True))
                           .OrderBy(b => b.CreateTime)
                           .Count(out var total) //总记录数量
                           .Page(queryDto.PageIndex, queryDto.PageSize)
                                                 //.Skip(queryDto.PageIndex)
                                                 //.Limit(queryDto.PageSize) //第100行-110行的记录
                           .ToList();

            messageModel.response = jobItems;
            messageModel.Total    = total.ObjToInt();
            messageModel.success  = true;
            return(messageModel);
        }
        public async Task <MessageModel <List <TasksQzDto> > > Find([FromBody] JobItemQueryDto queryDto)
        {
            var messageModel = new MessageModel <List <TasksQzDto> >();

            messageModel.success = true;
            messageModel.msg     = "成功";

            var ss = await _tasksQzService.FindAsync(queryDto);

            var dtos = _mapper.Map <List <TasksQzDto> >(ss.response);
            var logs = await _qzRunLogService.Find(dtos.Select(x => x.Id).ToArray());

            dtos.AsParallel().ForAll(a =>
            {
                var log = logs.FindAll(x => x.TasksQzId == a.Id);
                if (log != null && log.Any())
                {
                    a.Logs = _mapper.Map <List <QzRunLogDto> >(log.OrderByDescending(x => x.LogTime).Take(5));
                }
            });
            messageModel.response = dtos;
            messageModel.Total    = ss.Total;
            return(messageModel);
        }