예제 #1
0
        void CreateNodeImpl(CreateNodeCommand command)
        {
            var node = GetNodeFromCommand(command);
            if (node == null)
                return;

            node.X = command.X;
            node.Y = command.Y;

            AddNodeToCurrentWorkspace(node, centered: command.DefaultPosition);
            CurrentWorkspace.RecordCreatedModel(node);
        }
예제 #2
0
        private void CreateNodeImpl(CreateNodeCommand command)
        {
            NodeModel nodeModel = Model.CreateNode(
                command.NodeId,
                command.NodeName,
                command.X,
                command.Y,
                command.DefaultPosition,
                command.TransformCoordinates);

            CurrentSpace.RecordCreatedModel(nodeModel);
        }
예제 #3
0
        void CreateNodeImpl(CreateNodeCommand command)
        {
            var node = GetNodeFromCommand(command);
            if (node == null)
            {
                throw new Exception("Could not create node: " + command.Name);
            }

            node.X = command.X;
            node.Y = command.Y;

            AddNodeToCurrentWorkspace(node, centered: command.DefaultPosition);
            CurrentWorkspace.RecordCreatedModel(node);
        }
예제 #4
0
        void CreateNodeImpl(CreateNodeCommand command)
        {
            var node = GetNodeFromCommand(command);

            if (node == null)
            {
                return;
            }

            node.X = command.X;
            node.Y = command.Y;

            AddNodeToCurrentWorkspace(node, centered: command.DefaultPosition);
            CurrentWorkspace.RecordCreatedModel(node);
        }
예제 #5
0
        void CreateNodeImpl(CreateNodeCommand command)
        {
            var node = GetNodeFromCommand(command);

            if (node == null)
            {
                throw new Exception("Could not create node: " + command.Name);
            }

            node.X = command.X;
            node.Y = command.Y;

            AddNodeToCurrentWorkspace(node, centered: command.DefaultPosition);
            CurrentWorkspace.RecordCreatedModel(node);
        }
예제 #6
0
        private void CreateNodeImpl(CreateNodeCommand command)
        {
            NodeModel nodeModel = Model.CreateNode(
                command.NodeId,
                command.NodeName,
                command.X,
                command.Y,
                command.DefaultPosition,
                command.TransformCoordinates);

            CurrentSpace.RecordCreatedModel(nodeModel);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
예제 #7
0
        public async Task <IActionResult> Create([FromBody] CreateNodeCommand node)
        {
            if (ModelState.IsValid)
            {
                var nodeToCreate = new Node();
                nodeToCreate.Name     = node.Name;
                nodeToCreate.ParentId = node.ParentId;
                _context.Add(nodeToCreate);
                await _context.SaveChangesAsync();

                return(Ok(nodeToCreate));
            }

            return(BadRequest());
        }
예제 #8
0
        internal async Task CreateNode(params string[] nodes)
        {
            using (ConfigurationServiceClient _configService = new ConfigurationServiceClient("ConfigurationServiceEndpoint"))
            {
                string currentcontext = "~/";

                for (int index = 0; index < nodes.Length; index++)
                {
                    //CreateNodeCommand is used for creating a node. Other available commands are as follows:
                    //DeleteNodeCommand, MoveNodesCommand, CopyNodesCommand, SetAttributeCommand, DeleteAttributeCommand, RecalculateCommand,
                    //RestartRealtimeCommand, CreateNodeCommand, UpdateNodeCommand, CreateCalculationCommand, UpdateNameCommand,
                    //ReloadExternalMappingsCommand, FlushJobQueueCommand
                    CreateNodeCommand command = new CreateNodeCommand();

                    string nodeName = nodes[index];
                    command.Tag        = nodeName;
                    command.Attributes = new Dictionary <string, string>
                    {
                        ["displayName"] = nodeName
                    };

                    string nodeType;
                    if (index == nodes.Length - 1)
                    {
                        //Creating timeseries node type as concerned for this sample application.
                        nodeType = NodeType.TimeSeries.ToString();                            //Creating Timeseries node type at the below most level(leaf node) where the timeseries data will be pushed.
                        command.Attributes.Add("VectorElementData", GetDescriptor(nodeName)); //Special attributes needed only for Timeseries node.
                        command.Attributes.Add("DataRate", "0");                              //Special attributes needed only for Timeseries node.
                    }
                    else
                    {
                        nodeType = NodeType.Unspecified.ToString(); //Creating unspecified node type for rest of the levels as those are not of concern for this sample application.
                    }

                    command.Attributes.Add("nodeType", nodeType);
                    command.ContextSelector = currentcontext;
                    command.User            = "******";

                    await _configService.ExecuteAsync(new List <Command>() { command }); //This call will create an asset node in Galore.

                    //Preparing context for next level node
                    currentcontext += $"{nodeName}/";
                }
            }
        }
예제 #9
0
        private void SelectedItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (SelectedItems.Count == 1)
            {
                SelectedItem = SelectedItems.First();
            }
            else
            {
                SelectedItem = null;
            }

            CopyCommand.RaiseCanExecuteChanged();
            CutCommand.RaiseCanExecuteChanged();
            PasteCommand.RaiseCanExecuteChanged();
            CreateGroupCommand.RaiseCanExecuteChanged();
            MoveToGroupCommand.RaiseCanExecuteChanged();
            CreateNodeCommand.RaiseCanExecuteChanged();
        }
예제 #10
0
        /// <summary>
        /// Создание нового узла с заданным системным идентификаторомю
        /// </summary>
        /// <param name="nodeType">тип узла</param>
        /// <param name="sysIdentifier">системный идентификатор</param>
        /// <returns>SC-адрес</returns>
        public ScAddress CreateNode(ElementType nodeType, Identifier sysIdentifier)
        {
            ScAddress nodeAddress = GetNodeAddress(sysIdentifier);

            if (knowledgeBase.IsAvaible)
            {
                if (nodeAddress == ScAddress.Invalid)
                {
                    var command  = new CreateNodeCommand(nodeType);
                    var response = (CreateNodeResponse)knowledgeBase.ExecuteCommand(command);
                    if (response.Header.ReturnCode == ReturnCode.Successfull)
                    {
                        if (SetSysIdentifier(response.CreatedNodeAddress, sysIdentifier))
                        {
                            nodeAddress = response.CreatedNodeAddress;
                        }
                    }
                }
            }
            return(nodeAddress);
        }
예제 #11
0
            /// <summary>
            /// Call this static method to reconstruct a RecordableCommand-derived
            /// object given an XmlElement that was previously saved with Serialize
            /// method. This method simply redirects the XmlElement to respective
            /// RecordableCommand-derived classes based on its type.
            /// </summary>
            /// <param name="element">The XmlElement from which the RecordableCommand
            /// can be reconstructed.</param>
            /// <returns>Returns the reconstructed RecordableCommand object. If a
            /// RecordableCommand cannot be reconstructed, this method throws a
            /// relevant exception.</returns>
            ///
            internal static RecordableCommand Deserialize(XmlElement element)
            {
                if (string.IsNullOrEmpty(element.Name))
                {
                    throw new ArgumentException("XmlElement without name");
                }

                switch (element.Name)
                {
                case "CreateNodeCommand":
                    return(CreateNodeCommand.DeserializeCore(element));

                case "SelectModelCommand":
                    return(SelectModelCommand.DeserializeCore(element));

                case "CreateNoteCommand":
                    return(CreateNoteCommand.DeserializeCore(element));

                case "SelectInRegionCommand":
                    return(SelectInRegionCommand.DeserializeCore(element));

                case "DragSelectionCommand":
                    return(DragSelectionCommand.DeserializeCore(element));

                case "MakeConnectionCommand":
                    return(MakeConnectionCommand.DeserializeCore(element));

                case "DeleteModelCommand":
                    return(DeleteModelCommand.DeserializeCore(element));

                case "UndoRedoCommand":
                    return(UndoRedoCommand.DeserializeCore(element));
                }

                string message = string.Format("Unknown command: {0}", element.Name);

                throw new ArgumentException(message);
            }
예제 #12
0
        private void CreateNodeImpl(CreateNodeCommand command)
        {
            NodeModel nodeModel = CurrentSpace.AddNode(
                command.NodeId,
                command.NodeName,
                command.X,
                command.Y,
                command.DefaultPosition,
                command.TransformCoordinates);

            CurrentSpace.RecordCreatedModel(nodeModel);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
예제 #13
0
        NodeModel GetNodeFromCommand(CreateNodeCommand command)
        {
            if (command.Node != null)
            {
                return command.Node;
            }

            if (command.NodeXml != null)
            {
                // command was deserialized, we must create the node directly
                return NodeFactory.CreateNodeFromXml(command.NodeXml, SaveContext.File);
            }

            // legacy command, hold on to your butts
            var name = command.Name;
            var nodeId = command.ModelGuid;

            // find nodes with of the same type with the same GUID
            var query = CurrentWorkspace.Nodes.Where(n => n.GUID.Equals(nodeId) && n.Name.Equals(name));

            // safely ignore a node of the same type with the same GUID
            if (query.Any())
            {
                return query.First();
            }

            // To be used in the event it's a custom node we're making.
            Guid customNodeId;

            if (command is CreateProxyNodeCommand)
            {
                var proxyCommand = command as CreateProxyNodeCommand;

                return NodeFactory.CreateProxyNodeInstance(nodeId, name,
                    proxyCommand.NickName, proxyCommand.Inputs, proxyCommand.Outputs);
            }

            // Then, we have to figure out what kind of node to make, based on the name.

            NodeModel node;

            // First, we check for a DSFunction by looking for a FunctionDescriptor
            var functionItem = LibraryServices.GetFunctionDescriptor(name);
            if (functionItem != null)
            {
                node = (functionItem.IsVarArg)
                    ? new DSVarArgFunction(functionItem) as NodeModel
                    : new DSFunction(functionItem);
                node.GUID = nodeId;
                return node;
            }

            // If that didn't work, let's try using the NodeFactory
            if (NodeFactory.CreateNodeFromTypeName(name, out node))
            {
                node.GUID = nodeId;
                return node;
            }

            // And if that didn't work, then it must be a custom node.
            if (Guid.TryParse(name, out customNodeId))
            {
                node = CustomNodeManager.CreateCustomNodeInstance(customNodeId);
                node.GUID = nodeId;
                return node;
            }

            // We're out of ideas, log an error.
            Logger.LogError("Could not create instance of node with name: " + name);
            return null;
        }
예제 #14
0
 public GenericCommandResult Create([FromBody] CreateNodeCommand command, [FromServices] NodeHandler handler)
 {
     return((GenericCommandResult)handler.Handle(command));
 }
예제 #15
0
        private void CreateNewNode(Repo.IElement element)
        {
            var command = new CreateNodeCommand(this.model, element);

            this.controller.Execute(command);
        }
예제 #16
0
            /// <summary>
            /// Call this static method to reconstruct a RecordableCommand-derived
            /// object given an XmlElement that was previously saved with Serialize
            /// method. This method simply redirects the XmlElement to respective
            /// RecordableCommand-derived classes based on its type.
            /// </summary>
            /// <param name="element">The XmlElement from which the RecordableCommand
            /// can be reconstructed.</param>
            /// <returns>Returns the reconstructed RecordableCommand object. If a
            /// RecordableCommand cannot be reconstructed, this method throws a
            /// relevant exception.</returns>
            ///
            internal static RecordableCommand Deserialize(XmlElement element)
            {
                if (string.IsNullOrEmpty(element.Name))
                {
                    throw new ArgumentException("XmlElement without name");
                }

                RecordableCommand command = null;

                switch (element.Name)
                {
                case "OpenFileCommand":
                    command = OpenFileCommand.DeserializeCore(element);
                    break;

                case "PausePlaybackCommand":
                    command = PausePlaybackCommand.DeserializeCore(element);
                    break;

                case "RunCancelCommand":
                    command = RunCancelCommand.DeserializeCore(element);
                    break;

                case "CreateNodeCommand":
                    command = CreateNodeCommand.DeserializeCore(element);
                    break;

                case "SelectModelCommand":
                    command = SelectModelCommand.DeserializeCore(element);
                    break;

                case "CreateNoteCommand":
                    command = CreateNoteCommand.DeserializeCore(element);
                    break;

                case "SelectInRegionCommand":
                    command = SelectInRegionCommand.DeserializeCore(element);
                    break;

                case "DragSelectionCommand":
                    command = DragSelectionCommand.DeserializeCore(element);
                    break;

                case "MakeConnectionCommand":
                    command = MakeConnectionCommand.DeserializeCore(element);
                    break;

                case "DeleteModelCommand":
                    command = DeleteModelCommand.DeserializeCore(element);
                    break;

                case "UndoRedoCommand":
                    command = UndoRedoCommand.DeserializeCore(element);
                    break;

                case "ModelEventCommand":
                    command = ModelEventCommand.DeserializeCore(element);
                    break;

                case "UpdateModelValueCommand":
                    command = UpdateModelValueCommand.DeserializeCore(element);
                    break;

                case "ConvertNodesToCodeCommand":
                    command = ConvertNodesToCodeCommand.DeserializeCore(element);
                    break;

                case "CreateCustomNodeCommand":
                    command = CreateCustomNodeCommand.DeserializeCore(element);
                    break;

                case "SwitchTabCommand":
                    command = SwitchTabCommand.DeserializeCore(element);
                    break;
                }

                if (null != command)
                {
                    command.IsInPlaybackMode = true;
                    command.Tag = element.GetAttribute("Tag");
                    return(command);
                }

                string message = string.Format("Unknown command: {0}", element.Name);

                throw new ArgumentException(message);
            }
예제 #17
0
        NodeModel GetNodeFromCommand(CreateNodeCommand command)
        {
            if (command.Node != null)
            {
                return(command.Node);
            }

            if (command.NodeXml != null)
            {
                // command was deserialized, we must create the node directly
                return(NodeFactory.CreateNodeFromXml(command.NodeXml, SaveContext.File));
            }

            // legacy command, hold on to your butts
            var name   = command.Name;
            var nodeId = command.NodeId;

            // find nodes with of the same type with the same GUID
            var query = CurrentWorkspace.Nodes.Where(n => n.GUID.Equals(nodeId) && n.Name.Equals(name));

            // safely ignore a node of the same type with the same GUID
            if (query.Any())
            {
                return(query.First());
            }

            // To be used in the event it's a custom node we're making.
            Guid customNodeId;

            if (command is CreateProxyNodeCommand)
            {
                var proxyCommand = command as CreateProxyNodeCommand;

                return(NodeFactory.CreateProxyNodeInstance(nodeId, name,
                                                           proxyCommand.NickName, proxyCommand.Inputs, proxyCommand.Outputs));
            }

            // Then, we have to figure out what kind of node to make, based on the name.

            NodeModel node;

            // First, we check for a DSFunction by looking for a FunctionDescriptor
            var functionItem = LibraryServices.GetFunctionDescriptor(name);

            if (functionItem != null)
            {
                node = (functionItem.IsVarArg)
                    ? new DSVarArgFunction(functionItem) as NodeModel
                    : new DSFunction(functionItem);
                node.GUID = nodeId;
                return(node);
            }

            // If that didn't work, let's try using the NodeFactory
            if (NodeFactory.CreateNodeFromTypeName(name, out node))
            {
                node.GUID = nodeId;
                return(node);
            }

            // And if that didn't work, then it must be a custom node.
            if (Guid.TryParse(name, out customNodeId))
            {
                node      = CustomNodeManager.CreateCustomNodeInstance(customNodeId);
                node.GUID = nodeId;
                return(node);
            }

            // We're out of ideas, log an error.
            Logger.LogError("Could not create instance of node with name: " + name);
            return(null);
        }
예제 #18
0
        NodeModel GetNodeFromCommand(CreateNodeCommand command)
        {
            if (command.Node != null)
            {
                return command.Node;
            }

            if (command.NodeXml != null)
            {
                // command was deserialized, we must create the node directly
                return NodeFactory.CreateNodeFromXml(command.NodeXml, SaveContext.File, currentWorkspace.ElementResolver);
            }

            // legacy command, hold on to your butts
            var name = command.Name;
            var nodeId = command.ModelGuid;

            // find nodes with of the same type with the same GUID
            var query = CurrentWorkspace.Nodes.Where(n => n.GUID.Equals(nodeId) && n.Name.Equals(name));

            // safely ignore a node of the same type with the same GUID
            if (query.Any())
            {
                return query.First();
            }

            // To be used in the event it's a custom node we're making.
            Guid customNodeId;

            if (command is CreateProxyNodeCommand)
            {
                var proxyCommand = command as CreateProxyNodeCommand;

                return NodeFactory.CreateProxyNodeInstance(nodeId, name,
                    proxyCommand.NickName, proxyCommand.Inputs, proxyCommand.Outputs);
            }

            // Then, we have to figure out what kind of node to make, based on the name.

            NodeModel node = CreateNodeFromNameOrType(nodeId, name);
            if (node != null) return node;

            // And if that didn't work, then it must be a custom node.
            if (Guid.TryParse(name, out customNodeId))
            {
                node = CustomNodeManager.CreateCustomNodeInstance(customNodeId);
                node.GUID = nodeId;
                return node;
            }

            // We're out of ideas, log an error.
            Logger.LogError("Could not create instance of node with name: " + name);
            return null;
        }