示例#1
0
        public ActionResult GetPlistBatches(GetPlistBatchs input)
        {
            if (!ModelState.IsValid)
            {
                return(ModelState.ToJsonResult());
            }
            Guid?ontologyId = null;

            if (string.IsNullOrEmpty(input.OntologyCode))
            {
                ontologyId = null;
            }
            else
            {
                OntologyDescriptor ontology;
                if (!AcDomain.NodeHost.Ontologies.TryGetOntology(input.OntologyCode, out ontology))
                {
                    throw new ValidationException("意外的本体码" + input.OntologyCode);
                }
                ontologyId = ontology.Ontology.Id;
            }
            var pagingData = new PagingInput(input.PageIndex
                                             , input.PageSize, input.SortField, input.SortOrder);

            if (ontologyId != null)
            {
                input.Filters.Insert(0, FilterData.EQ("OntologyId", ontologyId.Value));
            }
            var data = GetRequiredService <IBatchQuery>().GetPlist(base.EntityType, () =>
            {
                RdbDescriptor rdb;
                if (!AcDomain.Rdbs.TryDb(base.EntityType.DatabaseId, out rdb))
                {
                    throw new AnycmdException("意外配置的Batch实体类型对象数据库标识" + base.EntityType.DatabaseId);
                }
                List <DbParameter> ps;
                var filterString = new SqlFilterStringBuilder().FilterString(rdb, input.Filters, "a", out ps);
                if (!string.IsNullOrEmpty(filterString))
                {
                    filterString = " where " + filterString;
                }
                return(new SqlFilter(filterString, ps.ToArray()));
            }, pagingData);

            Debug.Assert(pagingData.Total != null, "pagingData.Total != null");
            return(this.JsonResult(new MiniGrid <BatchTr> {
                total = pagingData.Total.Value, data = data.Select(a => new BatchTr(a))
            }));
        }
示例#2
0
        public ActionResult GetPlistBatches(GetPlistBatchs input)
        {
            if (!ModelState.IsValid)
            {
                return ModelState.ToJsonResult();
            }
            Guid? ontologyId = null;
            if (string.IsNullOrEmpty(input.OntologyCode))
            {
                ontologyId = null;
            }
            else
            {
                OntologyDescriptor ontology;
                if (!AcDomain.NodeHost.Ontologies.TryGetOntology(input.OntologyCode, out ontology))
                {
                    throw new ValidationException("意外的本体码" + input.OntologyCode);
                }
                ontologyId = ontology.Ontology.Id;
            }
            var pagingData = new PagingInput(input.PageIndex
                , input.PageSize, input.SortField, input.SortOrder);
            if (ontologyId != null)
            {
                input.Filters.Insert(0, FilterData.EQ("OntologyId", ontologyId.Value));
            }
            var data = GetRequiredService<IBatchQuery>().GetPlist(base.EntityType, () =>
            {
                RdbDescriptor rdb;
                if (!AcDomain.Rdbs.TryDb(base.EntityType.DatabaseId, out rdb))
                {
                    throw new AnycmdException("意外配置的Batch实体类型对象数据库标识" + base.EntityType.DatabaseId);
                }
                List<DbParameter> ps;
                var filterString = new SqlFilterStringBuilder().FilterString(rdb, input.Filters, "a", out ps);
                if (!string.IsNullOrEmpty(filterString))
                {
                    filterString = " where " + filterString;
                }
                return new SqlFilter(filterString, ps.ToArray());
            }, pagingData);

            Debug.Assert(pagingData.Total != null, "pagingData.Total != null");
            return this.JsonResult(new MiniGrid<BatchTr> { total = pagingData.Total.Value, data = data.Select(a => new BatchTr(a)) });
        }