예제 #1
0
        public List <ModelloDelega> searchModelliDelegaPaging(DocsPaVO.utente.InfoUtente utente, List <Ruolo> ruoli, SearchModelloDelegaInfo searchInfo, SearchPagingContext pagingContext)
        {
            string idPeople   = utente.idPeople;
            string conditions = buildConditions(searchInfo);
            Dictionary <string, string> paramList = new Dictionary <string, string>();

            paramList.Add("idUtente", idPeople);
            paramList.Add("param1", conditions);
            PagingQuery pagingQuery = new PagingQuery("S_COUNT_MODELLI_DELEGA", "S_GET_MODELLI_DELEGA_PAGING", pagingContext, paramList);
            string      commandText = pagingQuery.Query.getSQL();

            logger.Debug("QUERY : " + commandText);
            DataSet ds = new DataSet();

            ExecuteQuery(ds, commandText);
            List <ModelloDelega> res = new List <ModelloDelega>();

            if (ds.Tables[0].Rows.Count != 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ModelloDelega temp = buildModelloDelega(ds.Tables[0].Rows[i], ruoli);
                    res.Add(temp);
                }
            }
            return(res);
        }
 public void Loaded(object o)
 {
     _pagingQuery = new PagingQuery {
         PageSize = 2, PageIndex = 1
     };
     Init(o);
 }
예제 #3
0
        public async Task <List <TEntity> > GetAsync <TEntity>(PagingQuery paging, bool reversal = true, EntityStatus status = EntityStatus.Normal) where TEntity : ClientBaseEntity
        {
            long start, end;

            if (reversal)
            {
                var len = paging.RecordCount == 0 ? await GetLengthAsync <TEntity>() : paging.RecordCount;

                paging.RecordCount = (int)len;
                start = len - paging.PageIndex * paging.PageSize;
            }
            else
            {
                start = (paging.PageIndex - 1) * paging.PageSize;
            }
            end = start + paging.PageSize - 1;
            var objectIds = await Database.ListRangeAsync(AddKeyPrefix <TEntity>("List"), start, end);

            if (objectIds == null || objectIds.Count() == 0)
            {
                return(null);
            }
            var entitys = (await GetAsync <TEntity>(objectIds.Select(a => a.ToString()).ToArray()))
                          .Where(a => (a.Status & status) > 0)
                          .ToList();

            return(entitys);
        }
예제 #4
0
        public async Task <List <TEntity> > GetListAsync <TEntity>(PagingQuery paging = null, Func <TEntity, bool> where = null, Func <TEntity, object> orderAsc = null, Func <TEntity, object> orderDesc = null) where TEntity : BaseEntity, new()
        {
            IQueryable <TEntity> query = Context.Set <TEntity>();

            if (where != null)
            {
                query = (IQueryable <TEntity>)query.Where(where);
            }
            if (orderAsc != null)
            {
                query = (IQueryable <TEntity>)query.OrderBy(orderAsc);
            }
            if (orderDesc != null)
            {
                query = (IQueryable <TEntity>)query.OrderByDescending(orderDesc);
            }
            if (paging == null)
            {
                return(await query.ToListAsync());
            }
            if (paging.RecordCount == 0)
            {
                paging.RecordCount = await query.CountAsync();
            }
            return(await query.AsNoTracking().Skip(paging.Skip).Take(paging.PageSize).ToListAsync());
        }
예제 #5
0
        public IActionResult GetComments([FromQuery] PagingQuery paging, [FromQuery] CommentLevel deliveryLevel, [FromQuery] CommentLevel orderLevel, [FromQuery] DateTime?startDate, [FromQuery] DateTime?endDate, int businessId, [FromServices] IBusinessRepository businessRepository)
        {
            var start = startDate ?? new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            var end   = endDate ?? new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            int[] businessIds;
            if (businessId == 0)
            {
                if (Business.Category == BusinessCategory.Chain)
                {
                    businessIds = businessRepository.GetStoresOnlyId(Business.ID).Select(a => a.Item1).ToArray();
                }
                else
                {
                    businessIds = new[] { Business.ID };
                }
            }
            else
            {
                businessIds = new[] { businessId };
            }
            var list = Service.GetComments(deliveryLevel, orderLevel, start, end, paging, businessIds);

            return(Json(new
            {
                rows = list,
                count = paging.RecordCount
            }));
        }
예제 #6
0
        public PagingResult UpConnectorAuthList(PagingQuery pagingQuery, int connectorId)
        {
            PagingResult productList = new PagingResult()
            {
                PageIndex = pagingQuery.PageIndex,
                PageSize  = pagingQuery.PageSize
            };
            string    str      = string.Format("select * from {0} where DownConnectorId={1} and Status=1 limit 1", RelationBusiness._TableName, connectorId);
            DataTable relation = DbAccess.GetDataTable(str);

            if (relation == null || relation.Rows.Count == 0)
            {
                return(productList);
            }
            int             upConnectorId = Utils.ToInt(relation.Rows[0]["UpConnectorId"]);
            ConnectorEntity upConnector   = (ConnectorEntity) new ConnectorBusiness().GetEntity("Id=" + upConnectorId);
            GroupEntity     upGroup       = (GroupEntity) new GroupBusiness().GetEntity("Id=" + upConnector.GroupId);

            productList = GetAuthProductList(pagingQuery, upConnectorId, true);
            if (productList.Data != null)
            {
                string    sql = string.Format("select * from {0} where UpConnectorId={1} and DownConnectorId={2} and Status=1", ProductRelationBusiness._TableName, upConnectorId, connectorId);
                DataTable dt  = DbAccess.GetDataTable(sql);
                string    selectIds;
                if (dt == null || dt.Rows.Count <= 0)
                {
                    selectIds = "";
                }
                else
                {
                    selectIds = string.Join(",", dt.AsEnumerable().Select(dr => Utils.ToString(dr["UpProductId"])));
                    selectIds = "," + selectIds + ",";
                }

                foreach (Dictionary <string, object> item in (ArrayList)productList.Data)
                {
                    item.Add("ConnectorId", upConnectorId);
                    string preview = upGroup.Domain + "/Supplier/Product/Product.aspx?p=" + upConnector.VirtualDir + "&pid=" + Utils.ToString(item["ProductId"]) + "&sid=" + upConnector.SellerId;
                    item.Add("Preview", preview);
                    if (!string.IsNullOrEmpty(selectIds))
                    {
                        if (selectIds.Contains("," + Utils.ToString(item["ProductId"]) + ","))
                        {
                            item.Add("Imported", true);
                        }
                        else
                        {
                            item.Add("Imported", false);
                        }
                    }
                    else
                    {
                        item.Add("Imported", false);
                    }
                }
            }
            return(productList);
        }
예제 #7
0
        public async Task <IActionResult> GetOrders([FromQuery] PagingQuery paging, [FromQuery] DateTime?startDate, [FromQuery] DateTime?endDate, [FromQuery] string code)
        {
            var list = await Service.GetOrdersAsync(Business.ID, paging, startDate ?? DateTime.Now, endDate ?? DateTime.Now, code);

            return(Json(new {
                rows = list,
                count = paging.RecordCount
            }));
        }
예제 #8
0
        private async Task <IEnumerable <BlogViewModel> > LoadAll()
        {
            var result = new List <BlogViewModel>();

            var filterRules = new FilterCondition();

            if (SelectedCategories.IsNotNullOrEmpty())
            {
                var filterCategories = new FilterGroup();
                foreach (var category in SelectedCategories)
                {
                    filterCategories.Add(new FilterRule
                    {
                        Field          = "CategoryId",
                        FilterOperator = FilterOperator.Equal,
                        PropertyValues = new List <object> {
                            Guid.Parse(category)
                        },
                        LogicalOperator = LogicalOperator.Or
                    });
                }

                filterRules.Add(filterCategories);
            }

            if (SearchText.IsNotNullOrEmpty())
            {
                var filterGroup = new FilterGroup()
                {
                    LogicalOperator = LogicalOperator.And
                };
                filterGroup.Add(new FilterRule("Title", FilterOperator.Contains, LogicalOperator.Or, SearchText));
                filterGroup.Add(new FilterRule("Summary", FilterOperator.Contains, LogicalOperator.Or, SearchText));
                filterGroup.Add(new FilterRule("MarkdownContent", FilterOperator.Contains, LogicalOperator.Or, SearchText));
                filterRules.Add(filterGroup);
            }

            var pageQuery = new PagingQuery
            {
                Pagination = new Pagination
                {
                    PageNumber = PageNumber,
                    PageSize   = PageSize,
                },
                FilterCondition = filterRules
            };
            var entities = await _dataAdminService.GetPagedArticles(pageQuery);

            Total = entities.TotalRecords;
            if (entities.Count > 0)
            {
                var viewModels = AppRuntimeContext.Current.Adapt <List <BlogViewModel> >(entities);
                result.AddRange(viewModels);
            }
            //  await Task.Delay(1000 * 3);
            return(result);
        }
예제 #9
0
        /// <summary>
        /// 通过条件获取合作商信息
        /// </summary>
        /// <param name="id">授权ID</param>
        /// <returns>大于0成功,否则失败</returns>
        /// <remarks>
        /// <list type="bullet">
        /// <item></item>
        /// </list>
        /// </remarks>
        public PagingResult GetMyConnectorList(PagingQuery pagingQuery, int connectorId, int status = 0)
        {
            PagingResult result = new PagingResult();

            result.PageIndex = pagingQuery.PageIndex;
            result.PageSize  = pagingQuery.PageSize;
            string condition = "1=1 and a.Status=1";
            string field     = string.Empty;

            if (status == 0)
            {
                //我的下游合作商
                condition += string.Format(" and a.UpConnectorId={0}", connectorId);
                field      = "a.DownConnectorId=b.Id";
            }
            else
            {
                //我的上游合作商
                condition += string.Format(" and a.DownConnectorId={0}", connectorId);
                field      = "a.UpConnectorId=b.Id";
            }

            //遍历所有子节点
            foreach (Condition c in pagingQuery.Condition)
            {
                if (!string.IsNullOrEmpty(c.Value))
                {
                    switch (c.Name.ToLower())
                    {
                    case "keyword":
                        condition += string.Format(" and (b.Name like '%{0}%' or b.Mobile like '%{0}%')", c.Value);
                        break;

                    case "status":
                        condition += c.ToWhereString("a.Status");
                        break;
                    }
                }
            }

            string sql0 = string.Format("select count(0) from {0} a inner join {1} b on {2} where {4};",
                                        RelationBusiness._TableName, TableName, field, GroupBusiness._TableName, condition);
            string sql1 = string.Format("select b.Name,b.SellerId,b.Logo,b.Mobile,b.GroupId,a.Id,a.UpConnectorId,a.UpBuyerId,a.DownConnectorId,a.AddTime,a.Status,a.IsOpen,a.InvitedFrom,c.ImageDomain from {0} a inner join {1} b on {2} inner join {3} c on b.GroupId=c.Id  where {4} order by b.AddTime desc limit {5},{6};",
                                        RelationBusiness._TableName, TableName, field, GroupBusiness._TableName, condition, pagingQuery.PageSize * (pagingQuery.PageIndex - 1), pagingQuery.PageSize);

            Tuple <int, DataTable> ds = DbAccess.GetPageTable(new Tuple <string, string>(sql0, sql1),
                                                              new System.Data.Common.DbParameter[] {  });

            if (ds == null)
            {
                return(result);
            }
            result.TotalCount = Utils.ToInt(ds.Item1);
            result.Data       = ds.Item2;
            return(result);
        }
예제 #10
0
        public IActionResult GetUserList([FromQuery] PagingQuery query)
        {
            var report = Service.GetUserListByChain(Business.ID, query);

            return(Json(new
            {
                rows = query.RecordCount,
                list = report
            }));
        }
예제 #11
0
        public IActionResult GetComments(int id, [FromQuery] PagingQuery paging)
        {
            var list = Service.GetComments(id, paging);

            return(Json(new
            {
                list,
                more = list.Count > 0
            }));
        }
예제 #12
0
        public PagingResult GetOrderList(PagingQuery pagingQuery, int connectorId, int status = 0)
        {
            PagingResult result = new PagingResult();

            result.PageIndex = pagingQuery.PageIndex;
            result.PageSize  = pagingQuery.PageSize;
            string condition = "1=1";
            string field     = string.Empty;

            if (status == 0)
            {
                //我的下游合作商订单
                condition += string.Format(" and a.UpConnectorId={0}", connectorId);
                field      = "a.DownConnectorId=b.Id";
            }
            else
            {
                //我的上游合作商订单
                condition += string.Format(" and a.DownConnectorId={0}", connectorId);
                field      = "a.UpConnectorId=b.Id";
            }

            //遍历所有子节点
            foreach (Condition c in pagingQuery.Condition)
            {
                if (!string.IsNullOrEmpty(c.Value))
                {
                    switch (c.Name.ToLower())
                    {
                    case "keyword":
                        condition += string.Format(" and (a.UpOddNumber like '%{0}%' or a.DownOddNumber like '%{0}%')", c.Value);
                        break;
                        //case "upoddnumber":
                        //    condition += c.ToWhereString("a.UpOddNumber");
                        //    break;
                        //case "downoddnumber":
                        //    condition += c.ToWhereString("a.DownOddNumber");
                        //    break;
                    }
                }
            }

            string sql = string.Format("select count(0) from {0} a inner join {1} b on {2} where {3} ;select b.Name,a.Id,a.UpConnectorId,a.DownConnectorId,a.UpOddNumber,a.UpPayables,a.DownOddNumber,a.DownPayables,a.AddTime from {0} a inner join {1} b on {2}  where {3} order by b.AddTime desc limit {4},{5};",
                                       TableName, ConnectorBusiness._TableName, field, condition, pagingQuery.PageSize * (pagingQuery.PageIndex - 1), pagingQuery.PageSize);
            DataSet ds = DbAccess.ExecuteDataset(sql);

            if (ds == null || ds.Tables.Count != 2)
            {
                return(result);
            }
            result.TotalCount = Utils.ToInt(ds.Tables[0].Rows[0][0]);
            result.Data       = ds.Tables[1];
            return(result);
        }
예제 #13
0
 public Order()
 {
     InitializeComponent();
     Paging = new PagingQuery {
         PageIndex = 1, PageSize = 20
     };
     this.Loaded += (a, b) =>
     {
         LoadData();
     };
 }
예제 #14
0
        public void ShouldReturnQuestionsPageWithProvidedSize(PagingQuery pagingQuery)
        {
            var maximumPageSize = pagingQuery.PageSize;

            var actualQuestions = _testController.GetQuestions(new QuestionQuery(), pagingQuery);

            actualQuestions.Should().BeAssignableTo <IEnumerable <QuestionDto> >()
            .And.HaveCountLessOrEqualTo(maximumPageSize, "Controller should not return more questions than client requested")
            .And.Subject.Select(q => q.Id).Should()
            .BeEquivalentTo(_testQuestions.Select(q => q.Id).Skip(pagingQuery.StartPage * pagingQuery.PageSize).Take(pagingQuery.PageSize));
        }
예제 #15
0
        public async Task <List <TangOrder> > GetOrdersAsync(int businessId, PagingQuery paging, DateTime startTime, DateTime endTime, string code = null)
        {
            var end   = endTime.AddDays(1);
            var query = Context.TangOrders.Where(a => a.BusinessId == businessId && a.CreateTime >= startTime && a.CreateTime < end);

            if (!string.IsNullOrEmpty(code))
            {
                query = query.Where(a => a.Code.Contains(code));
            }
            paging.RecordCount = query.Count();
            return(await query.OrderByDescending(a => a.CreateTime).Skip(paging.Skip).Take(paging.PageSize).ToListAsync());
        }
예제 #16
0
        /// <summary>
        /// 通过条件获取合作商信息
        /// </summary>
        /// <param name="id">授权ID</param>
        /// <returns>大于0成功,否则失败</returns>
        /// <remarks>
        /// <list type="bullet">
        /// <item></item>
        /// </list>
        /// </remarks>
        public PagingResult GetMyConnectorList(PagingQuery pagingQuery, int connectorId, int status = 0)
        {
            PagingResult result = new PagingResult();

            result.PageIndex = pagingQuery.PageIndex;
            result.PageSize  = pagingQuery.PageSize;
            string condition = "1=1 and a.Status=1";
            string field     = string.Empty;

            if (status == 0)
            {
                //我的下游合作商
                condition += string.Format(" and a.UpConnectorId={0}", connectorId);
                field      = "a.DownConnectorId=b.Id";
            }
            else
            {
                //我的上游合作商
                condition += string.Format(" and a.DownConnectorId={0}", connectorId);
                field      = "a.UpConnectorId=b.Id";
            }

            //遍历所有子节点
            foreach (Condition c in pagingQuery.Condition)
            {
                if (!string.IsNullOrEmpty(c.Value))
                {
                    switch (c.Name.ToLower())
                    {
                    case "keyword":
                        condition += string.Format(" and (b.Name like '%{0}%' or b.Mobile like '%{0}%')", c.Value);
                        break;

                    case "status":
                        condition += c.ToWhereString("a.Status");
                        break;
                    }
                }
            }

            string sql = string.Format("select count(0) from {0} a inner join {1} b on {2} where {3} ;select b.Name,b.SellerId,b.Logo,b.Mobile,b.GroupId,a.Id,a.UpConnectorId,a.UpBuyerId,a.DownConnectorId,a.AddTime,a.Status,a.IsOpen,a.InvitedFrom from {0} a inner join {1} b on {2}  where {3} order by b.AddTime desc limit {4},{5};",
                                       RelationBusiness._TableName, TableName, field, condition, pagingQuery.PageSize * (pagingQuery.PageIndex - 1), pagingQuery.PageSize);
            DataSet ds = DbService.ExecuteDataset(sql);

            if (ds == null || ds.Tables.Count != 2)
            {
                return(result);
            }
            result.TotalCount = Utils.ToInt(ds.Tables[0].Rows[0][0]);
            result.Data       = ds.Tables[1];
            return(result);
        }
예제 #17
0
파일: Account.cs 프로젝트: tynr426/ict
 public static IResultResponse Get(SysParameter para)
 {
     try
     {
         PagingQuery  query  = para.ToPagingQuery();
         PagingResult result = new AccountBusiness(para.dapperFactory).GetList(query);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
예제 #18
0
        public List <TEntity> GetRange <TEntity>(PagingQuery paging, EntityStatus status = EntityStatus.Normal) where TEntity : ClientBaseEntity
        {
            var key       = AddKeyPrefix <TEntity>("List");
            var objectIds = Database.ListRange(key, paging.Skip, paging.Skip + paging.PageSize);

            if (objectIds == null || objectIds.Count() == 0)
            {
                return(null);
            }
            return(Get <TEntity>(objectIds.Select(a => a.ToString()).ToArray())
                   .Where(a => (a.Status & status) > 0)
                   .ToList());
        }
예제 #19
0
        /// <summary>
        /// 客户端获取订单列表,按天查询有效的订单
        /// </summary>
        /// <param name="id"></param>
        /// <param name="query"></param>
        /// <param name="createTime"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        public IActionResult GetOrders(int id, [FromQuery] PagingQuery query, [FromQuery] DateTime?createTime, [FromServices] IOrderRepository service)
        {
            var result = new JsonData();
            var orders = service.GetOrder(id, createTime ?? DateTime.Now, query);

            result.Data = new
            {
                list = orders,                          // 订单列表
                rows = query.RecordCount                // 总记录数
            };
            result.Success = true;
            return(Json(result));
        }
예제 #20
0
        /// <summary>
        /// 通过条件获取机组信息
        /// </summary>
        /// <remarks>
        /// <list type="bullet">
        /// <item></item>
        /// </list>
        /// </remarks>
        public PagingResult GetGroupList(PagingQuery pagingQuery)
        {
            PagingResult result = new PagingResult();

            result.PageIndex = pagingQuery.PageIndex;
            result.PageSize  = pagingQuery.PageSize;
            string condition = "1=1";

            //遍历所有子节点
            foreach (Condition c in pagingQuery.Condition)
            {
                if (!string.IsNullOrEmpty(c.Value))
                {
                    switch (c.Name.ToLower())
                    {
                    case "keyword":
                        condition += string.Format(" and Name like '%{0}%'", c.Value);
                        break;

                    case "name":
                        condition += c.ToWhereString("Name");
                        break;

                    case "domain":
                        condition += c.ToWhereString("Domain");
                        break;

                    case "dbid":
                        condition += c.ToWhereString("DBId");
                        break;

                    case "status":
                        condition += c.ToWhereString("Status");
                        break;
                    }
                }
            }

            string sql = string.Format("select count(0) from {0} where {1} ;select * from {0}  where {1} order by AddTime desc limit {2},{3};", TableName,
                                       condition, pagingQuery.PageSize * (pagingQuery.PageIndex - 1), pagingQuery.PageSize);
            DataSet ds = DbService.ExecuteDataset(sql);

            if (ds == null || ds.Tables.Count != 2)
            {
                return(result);
            }

            result.TotalCount = Utils.ToInt(ds.Tables[0].Rows[0][0]);
            result.Data       = ds.Tables[1];
            return(result);
        }
예제 #21
0
 public static IResultResponse GetUpProductList(SysParameter para)
 {
     try
     {
         PagingQuery  query       = para.ToPagingQuery();
         int          connectorId = para.ToInt("ConnectorId", 0);
         PagingResult result      = new AuthProductBusiness(para.dapperFactory).UpConnectorAuthList(query, connectorId);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
예제 #22
0
파일: Connector.cs 프로젝트: tynr426/ict
 public static IResultResponse DownConnectorStock(SysParameter para)
 {
     try
     {
         PagingQuery  query       = para.ToPagingQuery();
         int          connectorId = para.ToInt("ConnectorId", 0);
         PagingResult result      = new ConnectorBusiness(para.dapperFactory).DownConnectorStock(connectorId, query);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
예제 #23
0
        public void PagingQueryWithoutPage()
        {
            var    query = new PagingQuery();
            string sql   = QueryUtil.ResolveSql(query.Sql, query);

            Assert.IsTrue(sql.Equals(@"SELECT
				[dr].*,
				ROW_NUMBER() OVER (ORDER BY [Date]) AS [RowNumber]
			FROM
				dbo.FnDateRange('4/1/19', '5/1/19') [dr]
			ORDER BY
				[Date]
			"            ));
        }
예제 #24
0
파일: Order.cs 프로젝트: tynr426/ict
 public static IResultResponse OrderList(SysParameter para)
 {
     try
     {
         PagingQuery  query       = para.ToPagingQuery();
         int          connectorId = para.ToInt("ConnectorId");
         int          status      = para.ToInt("Status", 0);
         PagingResult result      = new OrderRelationBusiness(para.dapperFactory).GetOrderList(query, connectorId, status);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
예제 #25
0
        public async Task <ActionResult <object> > GetMyMatchs(int id, [FromQuery] PagingQuery paging, [FromServices] IUserInfoService service)
        {
            var players = await service.GetPlayersAsync(id, paging);

            if (players == null)
            {
                return(new List <object>());
            }
            var ids    = players.Select(a => a.MatchId).ToList();
            var matchs = await service.GetAsync <Match>(ids);

            players.ForEach(a => a.Match = matchs.FirstOrDefault(b => b.ID == a.MatchId));

            return(players.Select(a => new { Host = a.Match.HostName, Visitor = a.Match.VisitorName, a.Match.HostScore, a.Match.VisitorScore, a.Score, a.Match.StartTime, Id = a.ID }).ToList());
        }
예제 #26
0
        public async Task <Page <T> > Query(PagingQuery <T> pagingQuery)
        {
            await using (Context)
            {
                var query = Entities.Where(pagingQuery.Condition);
                var order = pagingQuery.Order;

                order ??= entity => entity.Id;

                query = pagingQuery.IsAscendingOrder ? query.OrderBy(order).ThenBy(entity => entity.Id) : query.OrderByDescending(order).ThenBy(entity => entity.Id);
                query = query.Skip(pagingQuery.PageNumber * pagingQuery.PageSize).Take(pagingQuery.PageSize);

                return(Page <T> .From(pagingQuery, await query.ToListAsync()));
            }
        }
예제 #27
0
        public void PagingQueryWithAnyPage()
        {
            var query = new PagingQuery()
            {
                Page = 3
            };
            string sql = QueryUtil.ResolveSql(query.Sql, query);

            Assert.IsTrue(sql.Equals(@"SELECT
				[dr].*,
				ROW_NUMBER() OVER (ORDER BY [Date]) AS [RowNumber]
			FROM
				dbo.FnDateRange('4/1/19', '5/1/19') [dr]
			ORDER BY
				[Date]
			OFFSET 30 ROWS FETCH NEXT 10 ROWS ONLY"            ));
        }
예제 #28
0
        /// <summary>
        /// 通过条件获取连接器客户信息
        /// </summary>
        /// <remarks>
        /// <list type="bullet">
        /// <item></item>
        /// </list>
        /// </remarks>
        public PagingResult GetConnectorList(PagingQuery pagingQuery)
        {
            PagingResult result = new PagingResult();

            result.PageIndex = pagingQuery.PageIndex;
            result.PageSize  = pagingQuery.PageSize;
            string condition = "1=1";

            //遍历所有子节点
            foreach (Condition c in pagingQuery.Condition)
            {
                if (!string.IsNullOrEmpty(c.Value))
                {
                    switch (c.Name.ToLower())
                    {
                    case "mobile":
                        condition += c.ToWhereString("Mobile");
                        break;

                    case "keyword":
                        condition += string.Format(" and (Name like '%{0}%' or Mobile  like '%{0}%')", c.Value);
                        break;

                    case "status":
                        condition += c.ToWhereString("Status");
                        break;
                    }
                }
            }

            string sql0 = string.Format("select count(0) from {0} where {1} ;", TableName,
                                        condition);
            string sql1 = string.Format("select * from {0}  where {1} order by AddTime desc limit {2},{3};", TableName,
                                        condition, pagingQuery.PageSize * (pagingQuery.PageIndex - 1), pagingQuery.PageSize);
            Tuple <int, DataTable> ds = DbAccess.GetPageTable(new Tuple <string, string>(sql0, sql1), new System.Data.Common.DbParameter[] { });

            if (ds == null)
            {
                return(result);
            }
            result.TotalCount = Utils.ToInt(ds.Item1);
            result.Data       = ds.Item2;
            return(result);
        }
예제 #29
0
        public IActionResult GetOrders([FromQuery] PagingQuery query, OrderStatus status, DateTime?startDate, DateTime?endDate, int businessId, int delivery)
        {
            if (!startDate.HasValue)
            {
                startDate = DateTime.Now;
            }
            if (!endDate.HasValue)
            {
                endDate = DateTime.Now;
            }
            var list = Service.GetOrders(Business.ID, businessId, status, query, startDate.Value, endDate.Value, delivery).Select(a => new { a.Identifier, a.BusinessId, a.OrderCode, a.CreateTime, a.Status, a.Price, a.ReceiverName, a.Phone, a.ReceiverAddress });

            return(Json(new
            {
                list,
                rows = query.RecordCount,
                pages = query.PageCount
            }));
        }
예제 #30
0
        protected override PagedResult <TAggregateRoot> DoGetPagedResult(PagingQuery pagingQuery,
                                                                         Expression <Func <TAggregateRoot, dynamic> >[] eagerLoadingProperties = null)
        {
            //ParameterChecker.ArgumentNotNull(pagingQuery.SortGroup, "sortGroup");
            IQueryable <TAggregateRoot> query = EFContext.Context.Set <TAggregateRoot>();

            if (eagerLoadingProperties != null)
            {
                for (var i = 0; i < eagerLoadingProperties.Length; i++)
                {
                    var eagerLoadingProperty = eagerLoadingProperties[i];
                    var eagerLoadingPath     = GetEagerLoadingPath(eagerLoadingProperty);
                    query = query.Include(eagerLoadingPath);
                }
            }
            if (pagingQuery.FilterCondition != null)
            {
                query = query.Filter(pagingQuery.FilterCondition);
            }
            if (pagingQuery.SortGroup != null)
            {
                query = query.Sort(pagingQuery.SortGroup);
            }
            if (pagingQuery.Pagination.Total.HasValue == false)
            {
                pagingQuery.Pagination.Total = query.Count();
            }
            var skip = pagingQuery.Pagination.Start;
            var take = pagingQuery.Pagination.PageSize;

            query = query.Skip(skip).Take(take);
            var result = new PagedResult <TAggregateRoot>
                         (
                pagingQuery.Pagination.Total.Value,
                pagingQuery.Pagination.PageSize,
                pagingQuery.Pagination.PageNumber,
                query.ToList()
                         );

            return(result);
        }