Beispiel #1
0
        public ActionResult GetPlistNodeActions(GetPlistNodeActions requestModel)
        {
            NodeDescriptor node;

            if (!AcDomain.NodeHost.Nodes.TryGetNodeById(requestModel.NodeId.ToString(), out node))
            {
                throw new ValidationException("意外的节点标识" + requestModel.NodeId);
            }
            OntologyDescriptor ontology;

            if (!AcDomain.NodeHost.Ontologies.TryGetOntology(requestModel.OntologyId, out ontology))
            {
                throw new ValidationException("意外的本体标识" + requestModel.OntologyId);
            }
            var list = new List <NodeAssignActionTr>();

            foreach (var action in ontology.Actions.Values)
            {
                Guid   id;
                string isAllowed;
                string isAudit;
                var    nodeActions = node.Node.NodeActions;
                if (nodeActions.ContainsKey(ontology) && nodeActions[ontology].ContainsKey(action.ActionVerb))
                {
                    var nodeAction = nodeActions[ontology][action.ActionVerb];
                    id        = nodeAction.Id;
                    isAllowed = nodeAction.IsAllowed;
                    isAudit   = nodeAction.IsAudit;
                }
                else
                {
                    id        = Guid.NewGuid();
                    isAllowed = AllowType.ImplicitAllow.ToName();
                    isAudit   = AuditType.ImplicitAudit.ToName();
                }
                var item = new NodeAssignActionTr
                {
                    ActionId        = action.Id,
                    ActionIsAllow   = action.AllowType.ToName(),
                    ActionIsAudit   = action.AuditType.ToName(),
                    ActionIsPersist = action.IsPersist,
                    Id           = id,
                    Name         = action.Name,
                    NodeCode     = node.Node.Code,
                    NodeId       = node.Node.Id,
                    NodeName     = node.Node.Name,
                    OntologyId   = action.OntologyId,
                    OntologyName = ontology.Ontology.Name,
                    Verb         = action.Verb,
                    IsAllowed    = isAllowed,
                    IsAudit      = isAudit
                };
                list.Add(item);
            }
            var data = new MiniGrid <NodeAssignActionTr> {
                total = list.Count, data = list
            };

            return(this.JsonResult(data));
        }
Beispiel #2
0
        public ActionResult GetPlistNodeActions(GetPlistNodeActions requestModel)
        {
            NodeDescriptor node;
            if (!AcDomain.NodeHost.Nodes.TryGetNodeById(requestModel.NodeId.ToString(), out node))
            {
                throw new ValidationException("意外的节点标识" + requestModel.NodeId);
            }
            OntologyDescriptor ontology;
            if (!AcDomain.NodeHost.Ontologies.TryGetOntology(requestModel.OntologyId, out ontology))
            {
                throw new ValidationException("意外的本体标识" + requestModel.OntologyId);
            }
            var list = new List<NodeAssignActionTr>();
            foreach (var action in ontology.Actions.Values)
            {
                Guid id;
                string isAllowed;
                string isAudit;
                var nodeActions = node.Node.NodeActions;
                if (nodeActions.ContainsKey(ontology) && nodeActions[ontology].ContainsKey(action.ActionVerb))
                {
                    var nodeAction = nodeActions[ontology][action.ActionVerb];
                    id = nodeAction.Id;
                    isAllowed = nodeAction.IsAllowed;
                    isAudit = nodeAction.IsAudit;
                }
                else
                {
                    id = Guid.NewGuid();
                    isAllowed = AllowType.ImplicitAllow.ToName();
                    isAudit = AuditType.ImplicitAudit.ToName();
                }
                var item = new NodeAssignActionTr
                {
                    ActionId = action.Id,
                    ActionIsAllow = action.AllowType.ToName(),
                    ActionIsAudit = action.AuditType.ToName(),
                    ActionIsPersist = action.IsPersist,
                    Id = id,
                    Name = action.Name,
                    NodeCode = node.Node.Code,
                    NodeId = node.Node.Id,
                    NodeName = node.Node.Name,
                    OntologyId = action.OntologyId,
                    OntologyName = ontology.Ontology.Name,
                    Verb = action.Verb,
                    IsAllowed = isAllowed,
                    IsAudit = isAudit
                };
                list.Add(item);
            }
            var data = new MiniGrid<NodeAssignActionTr> { total = list.Count, data = list };

            return this.JsonResult(data);
        }