Beispiel #1
0
        public ActionResult GetPlistArchives(GetPlistArchives input)
        {
            if (!ModelState.IsValid)
            {
                return(ModelState.ToJsonResult());
            }
            OntologyDescriptor ontology;

            if (!AcDomain.NodeHost.Ontologies.TryGetOntology(input.OntologyCode, out ontology))
            {
                throw new ValidationException("意外的本体码" + input.OntologyCode);
            }
            EntityTypeState entityType;

            if (!AcDomain.EntityTypeSet.TryGetEntityType(new Coder("Edi", "Archive"), out entityType))
            {
                throw new AnycmdException("意外的实体类型Edi.Archive");
            }
            foreach (var filter in input.Filters)
            {
                PropertyState property;
                if (!AcDomain.EntityTypeSet.TryGetProperty(entityType, filter.field, out property))
                {
                    throw new ValidationException("意外的Archive实体类型属性" + filter.field);
                }
            }
            int pageIndex = input.PageIndex;
            int pageSize  = input.PageSize;
            var queryable = ontology.Archives.Select(ArchiveTr.Create).AsQueryable();

            foreach (var filter in input.Filters)
            {
                queryable = queryable.Where(filter.ToPredicate(), filter.value);
            }

            var list = queryable.OrderBy(input.SortField + " " + input.SortOrder).Skip(pageIndex * pageSize).Take(pageSize);

            return(this.JsonResult(new MiniGrid <ArchiveTr> {
                total = queryable.Count(), data = list
            }));
        }
        public ActionResult GetPlistArchives(GetPlistArchives input)
        {
            if (!ModelState.IsValid)
            {
                return ModelState.ToJsonResult();
            }
            OntologyDescriptor ontology;
            if (!AcDomain.NodeHost.Ontologies.TryGetOntology(input.OntologyCode, out ontology))
            {
                throw new ValidationException("意外的本体码" + input.OntologyCode);
            }
            EntityTypeState entityType;
            if (!AcDomain.EntityTypeSet.TryGetEntityType(new Coder("Edi", "Archive"), out entityType))
            {
                throw new AnycmdException("意外的实体类型Edi.Archive");
            }
            foreach (var filter in input.Filters)
            {
                PropertyState property;
                if (!AcDomain.EntityTypeSet.TryGetProperty(entityType, filter.field, out property))
                {
                    throw new ValidationException("意外的Archive实体类型属性" + filter.field);
                }
            }
            int pageIndex = input.PageIndex;
            int pageSize = input.PageSize;
            var queryable = ontology.Archives.Select(ArchiveTr.Create).AsQueryable();
            foreach (var filter in input.Filters)
            {
                queryable = queryable.Where(filter.ToPredicate(), filter.value);
            }

            var list = queryable.OrderBy(input.SortField + " " + input.SortOrder).Skip(pageIndex * pageSize).Take(pageSize);

            return this.JsonResult(new MiniGrid<ArchiveTr> { total = queryable.Count(), data = list });
        }