예제 #1
0
        public async Task <PageDataRes <ResSchedule> > GetPageAsync([FromBody] NavigateOrderPageDataReq pageReq)
        {
            var page = new PageDataRes <ResSchedule>();

            if (pageReq != null)
            {
                var query = pageReq.query;
                Filter <ResSchedule> filter = null;
                if (query.Count > 0)
                {
                    var fuc = FilterHelper <ResSchedule> .GetExpression(query, "schedulegetpage");

                    filter = new Repository.Filter <ResSchedule>(fuc);
                }
                OrderBy <ResSchedule> orderBy = null;
                if (pageReq.order != null && !string.IsNullOrWhiteSpace(pageReq.order.columnName))
                {
                    orderBy = new Repository.OrderBy <ResSchedule>(pageReq.order.columnName, pageReq.order.reverse);
                }
                try
                {
                    var result = await _dataPager.QueryAsync(
                        pageReq.pageNum, pageReq.pageSize, filter, orderBy, navigationPropertyPaths : null);

                    page = PageMapper <ResSchedule> .ToPageDateRes(result);

                    return(page);
                }
                catch (Exception ex)
                {
                    page.code = ResCode.Error;
                    page.msg  = ex.Message;
                    return(page);
                }
            }
            else
            {
                page.code = ResCode.Error;
                page.msg  = "参数不正确";
                return(page);
            }
        }
예제 #2
0
        public virtual async Task <ActionResult <PageDataRes <TEntity> > > GetPage([FromBody] NavigateOrderPageDataReq req)
        {
            var result = new PageDataRes <TEntity>()
            {
                code = ResCode.Success
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                try
                {
                    var               query        = req.query;
                    string            parameterstr = typeof(TEntity).Name + "Page";
                    OrderBy <TEntity> order        = null;
                    if (req.order != null)
                    {
                        order = new OrderBy <TEntity>(req.order.columnName, req.order.reverse);
                    }
                    var repository = uow.GetRepository <TEntity>();
                    var fuc        = FilterHelper <TEntity> .GetExpression(query, parameterstr);

                    var filter = new Repository.Filter <TEntity>(fuc);
                    var models = await _dataPager.QueryAsync(req.pageNum, req.pageSize, filter, order, req.navPropertyPaths);

                    result = PageMapper <TEntity> .ToPageDateRes(models);

                    return(result);
                }
                catch (Exception ex)
                {
                    result.code = ResCode.ServerError;
                    result.msg  = ex.Message;
                    return(result);
                }
            }
        }
예제 #3
0
        public virtual async Task <ActionResult <PageDataRes <TEntity> > > GetPageAsync([FromBody] NavigateOrderPageDataReq pageReq)
        {
            bool cp = false;

            using (var uow = _uowProvider.CreateUnitOfWork())
                cp = await CheckPermission("Edit", uow);
            if (cp)
            {
                var page = new PageDataRes <TEntity>();
                try
                {
                    string parameterstr = _typeName + "Page";
                    if (pageReq != null)
                    {
                        var query = pageReq.query;
                        query.Add(new FilterNode
                        {
                            andorop  = "and",
                            key      = "StopFlag",
                            binaryop = "eq",
                            value    = false
                        });
                        var fuc = FilterHelper <TEntity> .GetExpression(query, parameterstr);

                        var filter = new Repository.Filter <TEntity>(fuc);
                        if (pageReq.order == null || pageReq.order.columnName == null)
                        {
                            pageReq.order            = new Order();
                            pageReq.order.columnName = "Id";
                            pageReq.order.reverse    = false;
                        }
                        var orderBy = new Repository.OrderBy <TEntity>(pageReq.order.columnName, pageReq.order.reverse);
                        try
                        {
                            var result = await _dataPager.QueryAsync(pageReq.pageNum, pageReq.pageSize, filter,
                                                                     orderBy, pageReq.navPropertyPaths);

                            page = PageMapper <TEntity> .ToPageDateRes(result);

                            return(page);
                        }
                        catch (Exception ex)
                        {
                            page.code = ResCode.Error;
                            page.msg  = ex.Message;
                            return(page);
                        }
                    }
                    else
                    {
                        page.code = ResCode.Error;
                        page.msg  = "参数不正确";
                        return(page);
                    }
                }
                catch (Exception ex)
                {
                    page.code = ResCode.ServerError;
                    page.msg  = ex.Message;
                    return(page);
                }
            }
            else
            {
                return(Unauthorized());
            }
        }
예제 #4
0
        public virtual async Task <ActionResult <PageDataRes <TEntity> > > GetPageAsync([FromBody] NavigateOrderPageDataReq pageReq)
        {
            bool cp = false;

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                cp = await CheckPermission("Read", uow);
            }
            string nvastr       = "";
            string parameterstr = typeof(TEntity).Name + "Page";

            if (cp)
            {
                var page = new PageDataRes <TEntity>();
                try
                {
                    if (pageReq != null)
                    {
                        var query = pageReq.query;
                        var fuc   = FilterHelper <TEntity> .GetExpression(query, parameterstr);

                        var filter = new Repository.Filter <TEntity>(fuc);
                        if (pageReq.order == null || string.IsNullOrEmpty(pageReq.order.columnName))
                        {
                            pageReq.order.columnName = "Id";
                            pageReq.order.reverse    = false;
                        }
                        var orderBy  = new Repository.OrderBy <TEntity>(pageReq.order.columnName, pageReq.order.reverse);
                        var includes = _uowProvider.CreateUnitOfWork().GetRepository <TEntity>();

                        try
                        {
                            var result = await _dataPager.QueryAsync(pageReq.pageNum, pageReq.pageSize, filter,
                                                                     orderBy, pageReq.navPropertyPaths);

                            page = PageMapper <TEntity> .ToPageDateRes(result);

                            return(page);
                        }
                        catch (Exception ex)
                        {
                            page.code = ResCode.Error;
                            page.msg  = ex.Message;
                            return(page);
                        }
                    }
                    else
                    {
                        page.code = ResCode.Error;
                        page.msg  = "参数不能为空";
                        return(page);
                    }
                }
                catch (Exception ex)
                {
                    page.code = ResCode.ServerError;
                    page.msg  = ex.Message;
                    return(page);
                }
            }
            else
            {
                return(Unauthorized());
            }
        }