Example #1
0
        /// <summary>
        /// This method, first introduced in this sample application, looks up a specified node and returns an array of all of it's child nodes.
        /// </summary>
        /// <param name="parentId">The database GUID of the node to look up and return the child nodes from.</param>
        /// <param name="cinegyClient">A valid instance of a CAS proxy client</param>
        /// <param name="clientContext">The context to be returned and invalidated</param>
        /// <returns>An array of child nodes, belonging to the parent node specifed.</returns>
        private static Node[] GetChildren(Guid parentId, CinegyDataAccessServiceClient cinegyClient, ConnectContext clientContext)
        {
            string errorMsg;
            int    retCode;

            //While CinegyAS node id's are often exchanged as simple .NET Guids, they need to be cast into this
            //special NODEID object when actually used with the proxy client methods. This object contains the
            //actual GUID as a field.
            NODEID id = new NODEID();

            id._nodeid_id = parentId;

            //When calling the method to GetChildrenNodes, a real instance of the parent node does not need to be
            //created - a local copy of NodeBase (from which Node inherits) can be used instead, with the crucial
            //ID value allocated. Doing this save a call just to get a real copy of the 'Node' first.
            NodeBase parentNode = new NodeBase()
            {
                _id = id
            };

            //The first interesting new method of this sample - the call to GetChildrenNode.
            //This method requires a reference to the NodeBase (which can be a previously returned instance of a Node, or a local variable of NodeBase),
            //which will be used as the parent to query.
            //The GET_NODE_REQUEST_TYPE is interesting, since it allows you to filter the results to show all, deleted or not deleted nodes. Not Deleted will
            //be the most useful in many cases.
            Node[] children = cinegyClient.GetChildrenNodes(clientContext, parentNode, GET_NODE_REQUEST_TYPE.NotDeleted, out retCode, out errorMsg);

            if (retCode != 0)
            {
                Console.WriteLine("Error " + retCode + " while trying to retrieve Children: " + errorMsg);

                return(null);
            }

            return(children);
        }
Example #2
0
        private static Node GetNode(Guid nodeId, CinegyDataAccessServiceClient cinegyClient, ConnectContext clientContext)
        {
            string errorMsg;
            int    retCode;
            NODEID id = new NODEID();

            id._nodeid_id = nodeId;

            NodeBase nodeBase = new NodeBase()
            {
                _id = id
            };

            Node node = cinegyClient.GetNode(clientContext, nodeBase, GET_NODE_REQUEST_TYPE.NotDeleted, out retCode, out errorMsg);

            if (node == null)
            {
                Console.WriteLine("Error " + retCode + " while trying to retrieve Node: " + errorMsg);

                return(null);
            }

            return(node);
        }