コード例 #1
0
ファイル: AppFlowService.cs プロジェクト: besley/Slickflow
        /// <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();
            }
        }
コード例 #2
0
ファイル: AppFlowService.cs プロジェクト: zitjubiz/Slickflow
 /// <summary>
 /// 流程业务记录分页方法
 /// </summary>
 /// <param name="query">查询实体</param>
 /// <param name="count">数目</param>
 /// <returns></returns>
 public List <AppFlowEntity> GetPaged(AppFlowQuery query, out int count)
 {
     using (var session = DbFactory.CreateSession())
     {
         var appFlowDbSet = session.GetRepository <AppFlowEntity>().GetDbSet();
         var sqlQuery     = (from vw in appFlowDbSet
                             select vw);
         if (!string.IsNullOrEmpty(query.AppInstanceID))
         {
             sqlQuery = sqlQuery.Where(e => e.AppInstanceID == query.AppInstanceID);
         }
         count = sqlQuery.Count();
         var list = sqlQuery.OrderByDescending(e => e.ID)
                    .Skip(query.PageIndex * query.PageSize)
                    .Take(query.PageSize)
                    .ToList();
         return(list);
     }
 }
コード例 #3
0
        public ResponseResult <List <AppFlowEntity> > QueryPaged([FromBody] AppFlowQuery query)
        {
            var result = ResponseResult <List <AppFlowEntity> > .Default();

            try
            {
                var count = 0;
                var list  = AppFlowService.GetPaged(query, out count);
                result = ResponseResult <List <AppFlowEntity> > .Success(list);

                result.TotalRowsCount = count;
                result.TotalPages     = (count + query.PageSize - 1) / query.PageSize;
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <List <AppFlowEntity> > .Error(
                    string.Format("获取{0}分页数据失败,错误{1}", "AppFlow", ex.Message)
                    );
            }
            return(result);
        }