Ejemplo n.º 1
0
        /// <summary>
        /// get paged data
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List <UserLogEntity> GetPaged(UserLogQuery query, out int count)
        {
            IDbSession session = SessionFactory.CreateSession();

            try
            {
                var sortList = new List <DapperExtensions.ISort>();
                sortList.Add(new DapperExtensions.Sort {
                    PropertyName = "ID", Ascending = false
                });

                IPredicate predicate = null;
                count = QuickRepository.Count <UserLogEntity>(session.Connection, predicate);
                var list = QuickRepository.GetPaged <UserLogEntity>(session.Connection,
                                                                    query.PageIndex, query.PageSize, predicate, sortList, false).ToList();

                return(list);
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                session.Dispose();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 流程业务记录分页方法
        /// </summary>
        /// <param name="query"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public List <AppFlowEntity> GetPaged(AppFlowQuery query, out int count)
        {
            List <AppFlowEntity> list = null;
            var conn = SessionFactory.CreateConnection();

            try
            {
                var sortList = new List <DapperExtensions.ISort>();
                sortList.Add(new DapperExtensions.Sort {
                    PropertyName = "ID", Ascending = false
                });

                IFieldPredicate predicate = null;
                if (!string.IsNullOrEmpty(query.AppInstanceID))
                {
                    predicate = Predicates.Field <AppFlowEntity>(f => f.AppInstanceID, DapperExtensions.Operator.Eq, query.AppInstanceID);
                }

                count = QuickRepository.Count <AppFlowEntity>(conn, predicate);
                list  = QuickRepository.GetPaged <AppFlowEntity>(conn, query.PageIndex, query.PageSize,
                                                                 predicate, sortList, false).ToList();

                return(list);
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <param name="count">记录数</param>
        /// <returns></returns>
        public List <ProductOrderEntity> GetPaged(ProductOrderQuery query, out int count)
        {
            List <ProductOrderEntity> list = null;
            var conn = SessionFactory.CreateConnection();

            try
            {
                var sortList = new List <DapperExtensions.ISort>();
                sortList.Add(new DapperExtensions.Sort {
                    PropertyName = "ID", Ascending = false
                });

                IFieldPredicate predicate = null;
                if (query.Status > 0)
                {
                    predicate = Predicates.Field <ProductOrderEntity>(f => f.Status, DapperExtensions.Operator.Eq, query.Status);
                }
                else if (!string.IsNullOrEmpty(query.RoleCode))
                {
                    var status = GetStatusByRoleCode(query.RoleCode);
                    if (status < 6)
                    {
                        predicate = Predicates.Field <ProductOrderEntity>(f => f.Status, DapperExtensions.Operator.Eq, status);
                    }
                    else
                    {
                        predicate = Predicates.Field <ProductOrderEntity>(f => f.Status, DapperExtensions.Operator.Ge, status);
                    }
                }

                count = QuickRepository.Count <ProductOrderEntity>(conn, predicate);
                list  = QuickRepository.GetPaged <ProductOrderEntity>(conn, query.PageIndex, query.PageSize,
                                                                      predicate, sortList, false).ToList();

                return(list);
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// user account paged query
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List <UserAccountEntity> GetPaged(UserAccountQuery query, out int count)
        {
            IDbSession session = SessionFactory.CreateSession();

            try
            {
                var sortList = new List <DapperExtensions.ISort>();
                sortList.Add(new DapperExtensions.Sort {
                    PropertyName = "ID", Ascending = false
                });

                //administator not listed(AccountType=-1)
                if (string.IsNullOrEmpty(query.UserName))
                {
                    var predicate = Predicates.Field <UserAccountEntity>(a => a.AccountType, Operator.Eq, -1, true);
                    count = QuickRepository.Count <UserAccountEntity>(session.Connection, predicate);
                    var list = QuickRepository.GetPaged <UserAccountEntity>(session.Connection,
                                                                            query.PageIndex, query.PageSize, predicate, sortList, false).ToList();
                    return(list);
                }
                else
                {
                    //query by user name
                    var pg = new PredicateGroup {
                        Operator = GroupOperator.And, Predicates = new List <IPredicate>()
                    };
                    pg.Predicates.Add(Predicates.Field <UserAccountEntity>(f => f.AccountType, Operator.Eq, -1, true));
                    pg.Predicates.Add(Predicates.Field <UserAccountEntity>(f => f.UserName,
                                                                           Operator.Like, "%" + query.UserName + "%", false));

                    count = QuickRepository.Count <UserAccountEntity>(session.Connection, pg);
                    var list = QuickRepository.GetPaged <UserAccountEntity>(session.Connection,
                                                                            query.PageIndex, query.PageSize, pg, sortList, true).ToList();

                    return(list);
                }
            }
            catch (System.Exception)
            {
                throw;
            }
        }