Example #1
0
        public void ConvertPageTest()
        {
            var page = new PageInput
            {
                Index = 1,
                Size  = 2,
                Sort  =
                    new SortInput[]
                {
                    new SortInput
                    {
                        Desc    = true,
                        OrderBy = nameof(userinfo_us.age),
                    },
                    new SortInput
                    {
                        Desc    = false,
                        OrderBy = nameof(userinfo_us.name),
                    }
                }
            };
            var pageList = _data.AsQueryable().QueryByPageInput(page).ToList();

            Assert.IsTrue(pageList.Count == 2);
            Assert.AreEqual(pageList[0], _data[5]);

            pageList = _data.AsQueryable().QueryByPageInput(page).ToList();
            Assert.IsTrue(pageList.Count == 2);
            Assert.AreEqual(pageList[0], _data[5]);
        }
        public async Task <PageResult <Base_DictionaryResultDto> > GetDataListAsync(PageInput <ConditionDTO> input)
        {
            var q = GetIQueryable().Select(a => new Base_DictionaryResultDto
            {
                Id              = a.Id,
                DicDesc         = a.DicDesc,
                DicDisplayValue = a.DicDisplayValue,
                DicKey          = a.DicKey,
                DicValue        = a.DicValue,
                STATUS          = a.STATUS,
                CreateDate      = a.CreateDate,
                CreatorId       = a.CreatorId,
                CreatorName     = a.CreatorName,
                UpdateId        = a.UpdateId,
                UpdateTime      = a.UpdateTime,
                UpdateName      = a.UpdateName
            });

            var where = LinqHelper.True <Base_DictionaryResultDto>();
            var search = input.Search;

            //筛选
            if (!search.Condition.IsNullOrEmpty() && !search.Keyword.IsNullOrEmpty())
            {
                var newWhere = DynamicExpressionParser.ParseLambda <Base_DictionaryResultDto, bool>(
                    ParsingConfig.Default, false, $@"{search.Condition}.Contains(@0)", search.Keyword);
                where = where.And(newWhere);
            }

            return(await q.Where(where).GetPageResultAsync(input));
        }
Example #3
0
        public async Task <PageResult <IF_OrderResultDTO> > GetDataListAsync(PageInput <ConditionDTO> input)
        {
            Expression <Func <F_Order, F_UserInfo, Base_DepartmentRelation, F_PublishFood, Base_Dictionary, IF_OrderResultDTO> > select = (a, b, c, d, f) => new IF_OrderResultDTO
            {
                UserName          = b.UserName,
                OldDepartmentName = c.OldDepartment,
                FoodName          = d.FoodName,
                StatusName        = f.DicDisplayValue
            };

            select = select.BuildExtendSelectExpre();
            var q = from a in GetIQueryable().AsExpandable()
                    join e in Service.GetIQueryable <F_OrderInfo>() on a.OrderCode equals e.OrderCode
                    join f in  Service.GetIQueryable <F_PublishFood>() on e.PublishFoodId equals f.Id
                    join b in Service.GetIQueryable <F_UserInfo>() on a.UserInfoId equals b.Id into ab
                    from b in ab.DefaultIfEmpty()
                    join c  in  Service.GetIQueryable <Base_DepartmentRelation>() on b.FullDepartment equals c.Department into bc
                    from c in bc.DefaultIfEmpty()
                    join g  in Service.GetIQueryable <Base_Dictionary>() on  new { Status = a.Status.ToString(), OrderStatus = "OrderStatus" } equals new { Status = g.DicValue, OrderStatus = g.DicKey } into ag
            from h in ag.DefaultIfEmpty()
            select @select.Invoke(a, b, c, f, h);

            var where = LinqHelper.True <IF_OrderResultDTO>();
            var search = input.Search;

            //筛选
            if (!search.Condition.IsNullOrEmpty() && !search.Keyword.IsNullOrEmpty())
            {
                var newWhere = DynamicExpressionParser.ParseLambda <IF_OrderResultDTO, bool>(
                    ParsingConfig.Default, false, $@"{search.Condition}.Contains(@0)", search.Keyword);
                where = where.And(newWhere);
            }

            return(await q.Where(where).OrderByDescending(a => a.CreateTime).GetPageResultAsync(input));
        }
Example #4
0
        /// <summary>
        /// Performs execution of the command
        /// </summary>
        protected override void ProcessRecord()
        {
            // Compile a filter from the provided input
            NPodFilter filter = null;

            if (ParameterPresent("Guid"))
            {
                filter                    = new NPodFilter();
                filter.NPodGuid           = new GuidFilter();
                filter.NPodGuid.MustEqual = Guid;
            }

            PageInput page = PageInput.First;
            NPodList  list = Connection.GetNebNPods(page, filter, null);

            foreach (NPod item in list.Items)
            {
                WriteObject(item);
            }

            while (list.More)
            {
                // advance the page
                page.Page = page.Page + 1;

                list = Connection.GetNebNPods(page, filter, null);
                foreach (NPod item in list.Items)
                {
                    WriteObject(item);
                }
            }
        }
        public async Task <PageResult <Base_Log> > GetLogList(PageInput <LogsInputDTO> input)
        {
            input.SortField = "CreateTime";
            input.SortType  = "desc";

            return(await _logBus.GetLogListAsync(input));
        }
Example #6
0
        [AbpAuthorize(PermissionNames.Pages_Book_See)]//特性方式权限检查

        public async Task <PagedResultDto <BookListoutput> > GetAllAsync(PageInput pageInput, SeachInput seachInput, OrderInput orderInput)
        {
            //  PermissionChecker.Authorize(PermissionNames.Pages_Book_See);权限检查

            using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete))//禁用默认过滤器
            {
                var bookList = await _bookRepository.GetAll().Include(p => p.User).ToListAsync();

                if (!string.IsNullOrEmpty(seachInput.SeachBookName))
                {
                    bookList = bookList.Where(p => p.BookName.Contains(seachInput.SeachBookName)).ToList();
                }
                if (orderInput.OrderName == "Desc")
                {
                    bookList = bookList.OrderByDescending(p => p.BookName).ToList();
                }
                else
                {
                    bookList = bookList.OrderBy(p => p.BookName).ToList();
                }



                var booksCount = bookList.Count();
                var taskList   = bookList.Skip((pageInput.pageIndex - 1) * pageInput.pageMax).Take(pageInput.pageMax).ToList();


                return(new PagedResultDto <BookListoutput>(booksCount, taskList.MapTo <List <BookListoutput> >()
                                                           ));
            }

            // var bookList = await _bookRepository.GetAll().Include(p => p.User).ToListAsync();
        }
Example #7
0
        public async Task <List <JobTraceEntity> > QueryTracesAsync(PageInput page)
        {
            var orderStr = page.OrderBy ?? "StartTime DESC";
            var param    = new DynamicParameters();

            param.Add("PageIndex", page.PageIndex);
            param.Add("PageSize", page.PageSize);

            var andStr = string.Empty;

            if (page.Extens.Any())
            {
                page.Extens.AsList().ForEach(c => param.Add(c.Key, c.Value));
                andStr = " AND " + string.Join(" AND ", page.Extens.Select(c => $"{c.Key} = @{c.Key}"));
            }
            var total = await _context.ExecuteScalarAsync <int>($"SELECT COUNT(1) FROM  JobTrace {NOLOCK} Where 1=1 {andStr}", param);

            var list = (await _context.QueryAsync <JobTraceEntity>($"SELECT * FROM  JobTrace {NOLOCK} Where 1=1 {andStr} ORDER BY {orderStr} {PAGESUFFIX}", param))?.ToList();

            if (list.Any())
            {
                list.ForEach(p => p.Total = total);
            }
            return(list);
        }
Example #8
0
        private Expression <Func <ED.Models.Query.User, bool> > BuildExpression(PageInput pageInput)
        {
            Expression <Func <ED.Models.Query.User, bool> > filterExp = user => true;

            if (string.IsNullOrWhiteSpace(pageInput.Name))
            {
                return(filterExp);
            }

            switch (pageInput.Type)
            {
            case 0:
                filterExp = user => user.Name.Contains(pageInput.Name) || user.Email.Contains(pageInput.Name);
                break;

            case 1:
                filterExp = user => user.Name.Contains(pageInput.Name);
                break;

            case 2:
                filterExp = user => user.Email.Contains(pageInput.Name);
                break;
            }

            return(filterExp);
        }
Example #9
0
        public async Task <PageResult <PB_Location> > GetDataListAsync(PageInput <PB_LocationQM> input)
        {
            var q = GetIQueryable();

            var where = LinqHelper.True <PB_Location>();
            var search = input.Search;

            q = q.Include(i => i.PB_Storage).Include(i => i.PB_Laneway).Include(i => i.PB_StorArea).Include(i => i.PB_Rack);

            if (!search.StorId.IsNullOrEmpty())
            {
                where = where.And(p => p.StorId == search.StorId);
            }

            if (!search.Keyword.IsNullOrEmpty())
            {
                where = where.And(w => w.Code.Contains(search.Keyword) || w.Name.Contains(search.Keyword) || w.PB_Rack.Name.Contains(search.Keyword) || w.PB_Rack.Code.Contains(search.Keyword) || w.PB_Laneway.Name.Contains(search.Keyword) || w.PB_Laneway.Code.Contains(search.Keyword));
            }
            //if (!search.StorName.IsNullOrEmpty())
            //    where = where.And(w => w.PB_Storage.Name.Contains(search.StorName) || w.PB_Storage.Code.Contains(search.StorName));
            if (!search.AreaName.IsNullOrEmpty())
            {
                where = where.And(w => w.PB_StorArea.Name.Contains(search.AreaName) || w.PB_StorArea.Code.Contains(search.AreaName));
            }
            return(await q.Where(where).GetPageResultAsync(input));
        }
Example #10
0
        public async Task <List <JobTasksEntity> > QueryPagerAsync(PageInput page)
        {
            var orderStr = page.OrderBy ?? "CreateTime";
            var param    = new DynamicParameters();

            param.Add("PageIndex", page.PageIndex);
            param.Add("PageSize", page.PageSize);

            var andStr = string.Empty;

            if (page.Extens.Any())
            {
                page.Extens.AsList().ForEach(c => param.Add(c.Key, (c.Key.Equals("Title") ? $"%{c.Value}%" : c.Value)
                                                            ));
                andStr = " AND " + string.Join(" AND ", page.Extens.Select(c => $"{c.Key} {(c.Key.Equals("Title") ? "LIKE" : "=")} @{c.Key}"));
            }
            var total = await _context.ExecuteScalarAsync <int>($"SELECT COUNT(1) FROM  JobTasks Where Status<>-1 {andStr}", param);

            var list = (await _context.QueryAsync <JobTasksEntity>($"SELECT * FROM  JobTasks {NOLOCK} Where Status<>-1 {andStr} ORDER BY {orderStr} {PAGESUFFIX}", param))?.ToList();

            if (list.Any())
            {
                list.ForEach(p => p.Total = total);
            }
            return(list);
        }
Example #11
0
        [Route("page"), HttpPost] // {index:int}/{page:int}
        public async Task <IHttpActionResult> page([FromBody] PageInput page)
        {
            #region /// 检查输入信息正确性
            if (!ModelState.IsValid)
            {
                return(BadRequest(this.GetModelStateError(ModelState)));
            }
            #endregion
#if DEBUG
            Console.WriteLine("User/page 用户分页列表userService={0}", userService == null);
            if (userService == null)
            {
                return(BadRequest("UserServer Map Error"));
            }
            //[FromUri]string username
#endif
            var skip = (page.page - 1) * page.limit;
            try
            {
                var DtoUsers = await userService.UserPageListAsync(skip, page.limit, "Name");

                return(Ok(DtoUsers));
            }
            catch (BusinessException ex)
            {
                Console.WriteLine("UserControll Get BusinessException Ex");
                return(BadRequest(ex.Message));
            }
        }
Example #12
0
        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public async Task <IResponseOutput> GetUserListAsync(PageInput param)
        {
            var userQurey = _userRepo.Query.Count(out int count).PageBy(param);

            var data = await(from u in userQurey
                             join r in _roleRepo.Query
                             on u.RoleId equals r.Id into ur
                             from r2 in ur.DefaultIfEmpty()
                             select new UserListOutput
            {
                Id          = u.Id,
                CreatedTime = u.CreatedTime,
                Name        = u.NickName,
                UserName    = u.UserName,
                NickName    = u.NickName,
                Remark      = u.Remark,
                RoleNames   = new string[] { r2.Name },
                Status      = u.Status
            }).ToListAsync();

            var result = new PageOutput <UserListOutput>()
            {
                List  = data,
                Total = count
            };

            return(ResponseOutput.Ok(result));
        }
Example #13
0
        public GetResults <UserDto> GetUsers(PageInput input)
        {
            var result    = GetDefault <GetResults <UserDto> >();
            var q         = _userQuery.GetAll();
            var dsadsa    = q.ToList();
            var filterExp = BuildExpression(input);
            var query     = _userQuery.FindQueryable(q, filterExp, user => user.Id, SortOrder.Descending, input.Current, input.Size);
            var dsadsadsg = query.ToList();

            result.Total = _userQuery.Find(filterExp).Count();

            result.Data = query.Select(user => new UserDto()
            {
                Id         = user.Id,
                CreateTime = user.CreationTime,
                Email      = user.Email,
                State      = user.State,
                Name       = user.Name,
                RealName   = user.RealName,
                Password   = "******",
                Roles      = user.UserRoles.Take(4).Select(z => new BaseEntityDto()
                {
                    Id   = z.Role.Id,
                    Name = z.Role.RoleName
                }).ToList(),

                TotalRole = user.UserRoles.Count()
            }).ToList();

            return(result);
        }
Example #14
0
        public async Task <PageResult <IF_UserInfoResultDto> > GetDataListAsync(PageInput <ConditionDTO> input)
        {
            Expression <Func <F_UserInfo, F_ShopInfo, IF_UserInfoResultDto> > select = (a, b) => new IF_UserInfoResultDto
            {
                ShopName = b.ShopName
            };

            select = select.BuildExtendSelectExpre();
            var q = from a in GetIQueryable().AsExpandable()
                    join b in Service.GetIQueryable <F_ShopInfo>() on a.ShopInfoId equals b.Id into ab
                    from b in ab.DefaultIfEmpty()
                    select @select.Invoke(a, b);

            var where = LinqHelper.True <IF_UserInfoResultDto>();
            var search = input.Search;

            //筛选
            if (!search.Condition.IsNullOrEmpty() && !search.Keyword.IsNullOrEmpty())
            {
                var newWhere = DynamicExpressionParser.ParseLambda <IF_UserInfoResultDto, bool>(
                    ParsingConfig.Default, false, $@"{search.Condition}.Contains(@0)", search.Keyword);
                where = where.And(newWhere);
            }

            return(await q.Where(where).GetPageResultAsync(input));
        }
Example #15
0
        /// <summary>
        /// 页面列表--查询(分页)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PageResult <Mini_PageDTO> > GetDataListAsync(PageInput <ConditionDTO> input)
        {
            var proj_id = _operator?.Property?.Last_Interview_Project;

            var q = from a in GetIQueryable()
                    join b in Db.GetIQueryable <mini_page_type>() on a.Page_Type_Id equals b.Id
                    where a.Project_Id == proj_id && a.Deleted == false && b.Deleted == false
                    select new Mini_PageDTO
            {
                Id           = a.Id,
                Page_Type_Id = a.Page_Type_Id,
                Code         = a.Code,
                Name         = a.Name,
                Sort         = a.Sort,
                PageTypeName = b.Type_Name
            };

            var where = LinqHelper.True <Mini_PageDTO>();

            var search = input.Search;

            //筛选
            if (!search.Condition.IsNullOrEmpty() && !search.Keyword.IsNullOrEmpty())
            {
                var newWhere = DynamicExpressionParser.ParseLambda <Mini_PageDTO, bool>(
                    ParsingConfig.Default, false, $@"{search.Condition}.Contains(@0)", search.Keyword);
                where = where.And(newWhere);
            }

            return(await q.Where(where).GetPageResultAsync(input));
        }
        public async Task <PageResult <Base_UserLog> > GetLogListAsync(PageInput <UserLogsInputDTO> input)
        {
            var whereExp = LinqHelper.True <Base_UserLog>();
            var search   = input.Search;

            if (!search.logContent.IsNullOrEmpty())
            {
                whereExp = whereExp.And(x => x.LogContent.Contains(search.logContent));
            }
            if (!search.logType.IsNullOrEmpty())
            {
                whereExp = whereExp.And(x => x.LogType == search.logType);
            }
            if (!search.opUserName.IsNullOrEmpty())
            {
                whereExp = whereExp.And(x => x.CreatorRealName.Contains(search.opUserName));
            }
            if (!search.startTime.IsNullOrEmpty())
            {
                whereExp = whereExp.And(x => x.CreateTime >= search.startTime);
            }
            if (!search.endTime.IsNullOrEmpty())
            {
                whereExp = whereExp.And(x => x.CreateTime <= search.endTime);
            }

            return(await GetIQueryable().Where(whereExp).GetPageResultAsync(input));
        }
Example #17
0
        /// <summary>
        /// 分页查询用户信息
        /// </summary>
        /// <param name="queryUserInput"></param>
        /// <returns></returns>
        public async Task <PageOutput <QueryUserOutput> > GetPageUsers(PageInput <QueryUserInput> queryUserInput)
        {
            long rows;
            IList <IPredicate> predlist = new List <IPredicate>();

            predlist.Add(Predicates.Field <User>(p => p.Status, Operator.Eq, (int)Status.normal));
            if (queryUserInput != null && queryUserInput.Query != null && !string.IsNullOrWhiteSpace(queryUserInput.Query.UserName))
            {
                predlist.Add(Predicates.Field <User>(p => p.UserName, Operator.Like, queryUserInput.Query.UserName + "%"));
            }
            IPredicateGroup group = Predicates.Group(GroupOperator.And, predlist.ToArray());

            IList <ISort> sorts = new List <ISort>();

            sorts.Add(new Sort {
                PropertyName = "Id", Ascending = false
            });

            var users = Mapper.Map <IEnumerable <User>, IEnumerable <QueryUserOutput> >(await _userRepository.GetPage(group, sorts, queryUserInput.PageIndex, queryUserInput.PageSize, out rows));


            return(new PageOutput <QueryUserOutput> {
                Rows = rows, Result = users, PageIndex = queryUserInput.PageIndex
            });
        }
        public async Task <PageOutput> GetPageAsync(PageInput model, string tableName, string sqlWhere, dynamic pms1, dynamic pms2)
        {
            var sqlStr   = new System.Text.StringBuilder("select * from ");
            var sqlCount = new System.Text.StringBuilder("select count(1) from ");

            sqlStr.Append(tableName);
            sqlCount.Append(tableName);
            sqlStr.Append(sqlWhere.ToString());
            sqlCount.Append(sqlWhere.ToString());

            #region 分页系列
            if (model.Offset == 0 && model.PageSize == 0)//不分页==》这时候两个条件是一样的
            {
                return(await GetPageAsync(sqlStr.ToString(), pms1, sqlCount.ToString(), pms2));
            }
            if (model.Offset < 0)
            {
                model.Offset = 0;
            }
            if (model.PageSize < 1)
            {
                model.PageSize = 10;
            }
            model.PageIndex = model.Offset / model.PageSize + 1;

            pms1.PageIndex = model.PageIndex;
            pms1.PageSize  = model.PageSize;

            sqlStr.Insert(0, string.Format("select * from(select row_number() over(order by {0}) Id,* from (", model.OrderStr));
            sqlStr.Append(") TempA) as TempInfo where Id<= @PageIndex * @PageSize and Id>(@PageIndex-1)*@PageSize");
            return(await GetPageAsync(sqlStr.ToString(), pms1, sqlCount.ToString(), pms2));

            #endregion
        }
Example #19
0
        /// <summary>
        /// 查询项目中用户列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PageResult <UserProjectDTO> > GetDataListAsync(PageInput <ConditionDTO> input)
        {
            var q = from a in Db.GetIQueryable <mini_project_user>()
                    join b in Db.GetIQueryable <mini_project>() on a.Project_Id equals b.Id
                    join c in Db.GetIQueryable <Base_User>() on a.User_Id equals c.Id
                    where a.Deleted == false &&
                    a.Deleted == false &&
                    b.Deleted == false &&
                    c.Deleted == false
                    select new UserProjectDTO
            {
                Id           = a.Id,
                Project_Id   = a.Project_Id,
                Project_Code = b.Project_Code,
                Project_Name = b.Project_Name,
                User_Id      = a.User_Id,
                User_Code    = c.UserName,
                User_Name    = c.RealName
            };

            var where = LinqHelper.True <UserProjectDTO>();
            var search = input.Search;

            //筛选
            if (!search.Condition.IsNullOrEmpty() && !search.Keyword.IsNullOrEmpty())
            {
                var newWhere = DynamicExpressionParser.ParseLambda <UserProjectDTO, bool>(
                    ParsingConfig.Default, false, $@"{search.Condition}.Contains(@0)", search.Keyword);
                where = where.And(newWhere);
            }

            return(await q.Where(where).GetPageResultAsync(input));
        }
Example #20
0
        /// <summary>
        /// Performs execution of the command
        /// </summary>
        protected override void ProcessRecord()
        {
            try
            {
                List <SpuFilter> filters = new List <SpuFilter>();

                if (ParameterPresent("SpuSerial"))
                {
                    SpuFilter f = new SpuFilter();
                    f.Serial           = new StringFilter();
                    f.Serial.MustEqual = SpuSerial;
                    filters.Add(f);
                }

                if (ParameterPresent("Unused"))
                {
                    SpuFilter f = new SpuFilter();
                    f.NotInNPod = true;
                    filters.Add(f);
                }

                // convert to filter
                SpuFilter filter = GenerateFilter(filters);

                SpuSort sort = new SpuSort();
                sort.Serial = SortDirection.Ascending;

                PageInput page = PageInput.First;
                SpuList   list = Connection.GetSpus(page, filter, sort);

                foreach (Spu item in list.Items)
                {
                    WriteObject(item);
                }

                while (list.More)
                {
                    // advance the page
                    page.Page = page.Page + 1;

                    list = Connection.GetSpus(page, filter, sort);
                    foreach (Spu item in list.Items)
                    {
                        WriteObject(item);
                    }
                }
            }
            catch (AggregateException exceptions)
            {
                foreach (Exception ex in exceptions.InnerExceptions)
                {
                    WriteError(ex);
                }
            }
            catch (Exception ex)
            {
                WriteError(ex);
            }
        }
        public async Task <PageResult <Report_MaterialSummaryVM> > GetDataListAsync(PageInput <Report_MaterialSummaryQM> input)
        {
            var search = input.Search;
            var mQuery = from lm in Db.GetIQueryable <IT_LocalMaterial>()
                         group lm by new { lm.MaterialId, lm.BatchNo } into g
                 select new { MaterialId = g.Key.MaterialId, BatchNo = g.Key.BatchNo, SumCount = g.Sum(p => p.Num) } into lms
            join m in Db.GetIQueryable <PB_Material>() on lms.MaterialId equals m.Id
            join mt in Db.GetIQueryable <PB_MaterialType>() on m.MaterialTypeId equals mt.Id
            join me in Db.GetIQueryable <PB_Measure>() on m.MeasureId equals me.Id
            select new Report_MaterialSummaryVM
            {
                Id               = m.Id,
                Name             = m.Name,
                Code             = m.Code,
                BarCode          = m.BarCode,
                SimpleName       = m.SimpleName,
                MaterialTypeId   = m.MaterialTypeId,
                MaterialId       = m.Id,
                MaterialName     = m.Name,
                MaterialTypeName = mt.Name,
                MeasureId        = me.Id,
                MeasureName      = me.Name,
                Spec             = m.Spec,
                Max              = m.Max,
                Min              = m.Min,
                Price            = m.Price,
                SumCount         = lms.SumCount,
                BatchNo          = lms.BatchNo,
            };

            if (!search.MaterialTypeId.IsNullOrEmpty())
            {
                mQuery = mQuery.Where(w => w.MaterialTypeId == search.MaterialTypeId);
            }
            if (!search.MaterialName.IsNullOrEmpty())
            {
                mQuery = mQuery.Where(w => w.Name.Contains(search.MaterialName) || w.Code.Contains(search.MaterialName) || w.SimpleName.Contains(search.MaterialName) || w.BarCode.Contains(search.MaterialName));
            }
            if (search.MinAlert)
            {
                mQuery = mQuery.Where(w => w.Min >= w.SumCount && w.Min.HasValue);
            }
            if (search.MaxAlert)
            {
                mQuery = mQuery.Where(w => w.Max <= w.SumCount && w.Max.HasValue);
            }
            if (!search.BatchNo.IsNullOrEmpty())
            {
                mQuery = mQuery.Where(w => w.BatchNo == search.BatchNo);
            }
            var pageResult = await mQuery.GetPageResultAsync(input);

            //var listbatch =
            foreach (var item in pageResult.Data)
            {
                item.Id = item.Id + "_" + item.BatchNo;
            }
            return(pageResult);
        }
Example #22
0
        public ValidationStateDictionary ValidatePageInput(PageInput pageInput)
        {
            ValidationStateDictionary validationState = new ValidationStateDictionary();

            validationState.Add(typeof(PageInput), validator.Validate(pageInput));

            return(validationState);
        }
Example #23
0
        public void FillSet()
        {
            PageInput pageIn = new PageInput(Format.FillSet, 13, 0, 0, new List <String>(new String[] { "abc", "abc", "acei", "abc", "abc", "acei", "abc", "abc", "ace", "ai" }));
            Page      page   = pageIn.Compose();
            String    actual = page.ToString();

            Assert.AreEqual("acei acei abc\nabc abc abc\nabc abc ace\nai\n", actual);
        }
Example #24
0
        public void LineMoment()
        {
            PageInput pageIn = new PageInput(Format.LineMoment, 14, 0, 7, new List <String>(new String[] { "abc", "abc", "acei", "abc", "abc", "acei", "abc", "abc", "abc", "ace", "ai" }));
            Page      page   = pageIn.Compose();
            String    actual = page.ToString();

            Assert.AreEqual("abc abc acei\nabc abc acei\nabc  abc abc\nace       ai\n", actual);
        }
Example #25
0
        public void TestMethod1()
        {
            PageInput pageIn = new PageInput(Format.Fill, 5, 0, 0, new List <String>(new String[] { "abc", "abc" }));
            Page      page   = pageIn.Compose();
            String    actual = page.ToString();

            Assert.AreEqual("abc\nabc\n", actual);
        }
Example #26
0
        public GetResults <AlbumDto> GetAlbumRankByClassifyId(long classifyId, PageInput input)
        {
            var result     = GetDefault <GetResults <AlbumDto> >();
            var classifies = _albumQuery.Page(input.Current, input.Size, out var pageCount, album => album.ClassifyId == classifyId, new { SubCount = true, PlayCount = true, BuyCount = true });

            result.Data  = _mapper.Map <List <AlbumDto> >(classifies);
            result.Total = pageCount;
            return(result);
        }
Example #27
0
        /// <summary>
        /// Performs execution of the command
        /// </summary>
        protected override void ProcessRecord()
        {
            try
            {
                List <NPodGroupFilter> filters = new List <NPodGroupFilter>();

                if (ParameterPresent("Guid"))
                {
                    NPodGroupFilter f = new NPodGroupFilter();
                    f.Guid           = new GuidFilter();
                    f.Guid.MustEqual = Guid;
                    filters.Add(f);
                }

                if (ParameterPresent("Name"))
                {
                    NPodGroupFilter f = new NPodGroupFilter();
                    f.Name           = new StringFilter();
                    f.Name.MustEqual = Name;
                    filters.Add(f);
                }

                // convert to filter
                NPodGroupFilter filter = GenerateFilter(filters);

                PageInput     page = PageInput.First;
                NPodGroupList list = Connection.GetNebNPodGroups(page, filter, null);

                foreach (NPodGroup item in list.Items)
                {
                    WriteObject(item);
                }

                while (list.More)
                {
                    // advance the page
                    page.Page = page.Page + 1;

                    list = Connection.GetNebNPodGroups(page, filter, null);
                    foreach (NPodGroup item in list.Items)
                    {
                        WriteObject(item);
                    }
                }
            }
            catch (AggregateException exceptions)
            {
                foreach (Exception ex in exceptions.InnerExceptions)
                {
                    WriteError(ex);
                }
            }
            catch (Exception ex)
            {
                WriteError(ex);
            }
        }
        public async Task <PageResult <Base_UserDTO> > GetDataListAsync(PageInput <Base_UsersInputDTO> input)
        {
            Expression <Func <Base_User, Base_Department, Base_UserDTO> > select = (a, b) => new Base_UserDTO
            {
                DepartmentName = b.Name
            };
            var search = input.Search;

            select = select.BuildExtendSelectExpre();
            var q_User = search.all ? Service.GetIQueryable <Base_User>() : GetIQueryable();
            var q      = from a in q_User.AsExpandable()
                         join b in Service.GetIQueryable <Base_Department>() on a.DepartmentId equals b.Id into ab
                         from b in ab.DefaultIfEmpty()
                         select @select.Invoke(a, b);

            var where = LinqHelper.True <Base_UserDTO>();

            if (!search.userId.IsNullOrEmpty())
            {
                where = where.And(x => x.Id == search.userId);
            }
            if (!search.keyword.IsNullOrEmpty())
            {
                var keyword = $"%{search.keyword}%";
                q = q.Where(x =>
                            EF.Functions.Like(x.UserName, keyword) ||
                            EF.Functions.Like(x.RealName, keyword));
            }

            var list = await q.Where(where).GetPageResultAsync(input);

            await SetProperty(list.Data);

            return(list);

            async Task SetProperty(List <Base_UserDTO> users)
            {
                //补充用户角色属性
                List <string> userIds   = users.Select(x => x.Id).ToList();
                var           userRoles = await(from a in Service.GetIQueryable <Base_UserRole>()
                                                join b in Service.GetIQueryable <Base_Role>() on a.RoleId equals b.Id
                                                where userIds.Contains(a.UserId)
                                                select new
                {
                    a.UserId,
                    RoleId = b.Id,
                    b.RoleName
                }).ToListAsync();

                users.ForEach(aUser =>
                {
                    var roleList       = userRoles.Where(x => x.UserId == aUser.Id);
                    aUser.RoleIdList   = roleList.Select(x => x.RoleId).ToList();
                    aUser.RoleNameList = roleList.Select(x => x.RoleName).ToList();
                });
            }
        }
Example #29
0
        public GetResults <SoundDto> GetSoundPageByAlbumId(long albumId, PageInput input)
        {
            var result = GetDefault <GetResults <SoundDto> >();
            var sounds = _soundQuery.Page(input.Current, input.Size, out var pageCount, sound => sound.AlbumId == albumId, new { Id = true });

            result.Data  = _mapper.Map <List <SoundDto> >(sounds);
            result.Total = pageCount;
            return(result);
        }
Example #30
0
        public OutputBase GetAllUsers()
        {
            PageInput input = new PageInput()
            {
                Current = 1, Size = 10
            };

            return(_userService.GetUsers(input));
        }