public ActionResult GetNodeElementCares(GetNodeElementCares input) { if (!ModelState.IsValid) { return(ModelState.ToJsonResult()); } NodeDescriptor node; if (!AcDomain.NodeHost.Nodes.TryGetNodeById(input.NodeId.ToString(), out node)) { throw new ValidationException("意外的节点标识" + input.NodeId); } OntologyDescriptor ontology; if (!AcDomain.NodeHost.Ontologies.TryGetOntology(input.OntologyId, out ontology)) { throw new ValidationException("意外的本体标识" + input.OntologyId); } var data = new List <NodeAssignElementTr>(); var nodeElementCares = AcDomain.NodeHost.Nodes.GetNodeElementCares(node); foreach (var element in ontology.Elements.Values) { var id = Guid.NewGuid(); var isAssigned = false; var isInfoIdItem = false; var nodeElementCare = nodeElementCares.FirstOrDefault(a => a.NodeId == input.NodeId && a.ElementId == element.Element.Id); if (nodeElementCare != null) { id = nodeElementCare.Id; isAssigned = true; isInfoIdItem = nodeElementCare.IsInfoIdItem; } data.Add(new NodeAssignElementTr { Code = element.Element.Code, CreateOn = element.Element.CreateOn, ElementId = element.Element.Id, ElementIsInfoIdItem = element.Element.IsInfoIdItem, Icon = element.Element.Icon, Id = id, IsAssigned = isAssigned, IsEnabled = element.Element.IsEnabled, IsInfoIdItem = isInfoIdItem, Name = element.Element.Name, NodeId = input.NodeId, OntologyId = input.OntologyId, SortCode = element.Element.SortCode }); } int pageIndex = input.PageIndex; int pageSize = input.PageSize; var queryable = data.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 <NodeAssignElementTr> { total = queryable.Count(), data = list })); }
public ActionResult GetNodeElementCares(GetNodeElementCares input) { if (!ModelState.IsValid) { return ModelState.ToJsonResult(); } NodeDescriptor node; if (!AcDomain.NodeHost.Nodes.TryGetNodeById(input.NodeId.ToString(), out node)) { throw new ValidationException("意外的节点标识" + input.NodeId); } OntologyDescriptor ontology; if (!AcDomain.NodeHost.Ontologies.TryGetOntology(input.OntologyId, out ontology)) { throw new ValidationException("意外的本体标识" + input.OntologyId); } var data = new List<NodeAssignElementTr>(); var nodeElementCares = AcDomain.NodeHost.Nodes.GetNodeElementCares(node); foreach (var element in ontology.Elements.Values) { var id = Guid.NewGuid(); var isAssigned = false; var isInfoIdItem = false; var nodeElementCare = nodeElementCares.FirstOrDefault(a => a.NodeId == input.NodeId && a.ElementId == element.Element.Id); if (nodeElementCare != null) { id = nodeElementCare.Id; isAssigned = true; isInfoIdItem = nodeElementCare.IsInfoIdItem; } data.Add(new NodeAssignElementTr { Code = element.Element.Code, CreateOn = element.Element.CreateOn, ElementId = element.Element.Id, ElementIsInfoIdItem = element.Element.IsInfoIdItem, Icon = element.Element.Icon, Id = id, IsAssigned = isAssigned, IsEnabled = element.Element.IsEnabled, IsInfoIdItem = isInfoIdItem, Name = element.Element.Name, NodeId = input.NodeId, OntologyId = input.OntologyId, SortCode = element.Element.SortCode }); } int pageIndex = input.PageIndex; int pageSize = input.PageSize; var queryable = data.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<NodeAssignElementTr> { total = queryable.Count(), data = list }); }