Пример #1
0
 public bool Delete()
 {
     if (IsReferenced() != null)
     {
         return(false);                        // some other doc refers to this doc
     }
     _DocNodeRef.Kill();
     _ParentDocSet.MarkDocAsDeleted(this);
     return(true);
 }
Пример #2
0
        // graph constructor is marked INTERNAL because we want the client to use the
        // static class factory method CreateGraph(), which redirects here after doing checks.
        // For opening existing graphs,
        // we provide another method called OpenGraph() which redirects here also.
        internal GlGraph(string graph_name)
        {
            bool creating_new = !GlobalsGraphAdmin.AllGraphs().Contains(graph_name);

            _GlNodeRef = GlobalsGraphAdmin.ActiveConnection().CreateNodeReference(graph_name);

            if (creating_new)
                _GlNodeRef.Set(GlobalsGraphAdmin.GL_GRAPH_FLAG); // format identifier, causes persistence
            else
            {
                // opening an existing graph. Start by initializing the existing nodes
                string loop_node_guid = _GlNodeRef.NextSubscript(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, "");
                while (loop_node_guid != "")
                {
                    Guid new_guid = Guid.Empty;

                    if (Guid.TryParse(loop_node_guid, out new_guid))
                        AllNodesByGuid.Add(new_guid, new GlGraphNode(this, new_guid));
                    else
                        _GlNodeRef.Kill(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, loop_node_guid); // clean up bad data

                    loop_node_guid = _GlNodeRef.NextSubscript(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, loop_node_guid);
                }

                // now loop again and load the edges
                foreach (GlGraphNode loop_node in AllNodes)
                {
                    loop_node.InitializeEdges();
                }
            }
        }
        internal static void DeleteEntity <TEntity>(TEntity entity, NodeReference node, Connection connection)
        {
            try
            {
                connection.StartTransaction();

                node.AcquireLock(NodeReference.EXCLUSIVE_LOCK,
                                 NodeReference.LOCK_INCREMENTALLY,
                                 NodeReference.RELEASE_AT_TRANSACTION_END);

                var key = PrimaryKeyCalculator.GetPrimaryKey(entity);

                if (!IsKeyExists(key, node))
                {
                    throw new GlobalsDbException("Unable to delete entity. Entity with this primary key does not exist");
                }

                node.SetSubscriptCount(0);

                node.AppendSubscript(key);

                node.Kill();

                connection.Commit();
            }
            catch
            {
                connection.Rollback();
                throw;
            }
        }
Пример #4
0
        // constructor is marked INTERNAL because we want the client to use the
        // static class factory method CreateDocSet(), which redirects here after doing checks.
        // For opening existing doc sets,
        // we provide another method called OpenDocSet() which redirects here also.

        internal GlDocSet(string docset_name)
        {
            bool creating_new = !GlobalsDocDB.AllDocSetNames().Contains(docset_name);

            _GlNodeRef = GlobalsDocDB.ActiveConnection().CreateNodeReference(docset_name);

            if (creating_new)
            {
                _GlNodeRef.Set(GlobalsDocDB.GL_DOCS_FLAG); // format identifier, causes persistence
            }
            else
            {
                // opening an existing doc set. Start by initializing the existing nodes
                string loop_node_guid = _GlNodeRef.NextSubscript("");
                while (loop_node_guid != "")
                {
                    Guid new_guid = Guid.Empty;

                    if (Guid.TryParse(loop_node_guid, out new_guid))
                    {
                        AllDocsByGuid.Add(new_guid, new GlDoc(this, new_guid));
                    }
                    else
                    {
                        _GlNodeRef.Kill(loop_node_guid); // clean up bad data
                    }
                    loop_node_guid = _GlNodeRef.NextSubscript(loop_node_guid);
                }
            }
        }
Пример #5
0
    public static void Main(String[] args)
    {
        Connection myConn = ConnectionContext.GetConnection();

        try {
            myConn.Connect("User", "_SYSTEM", "SYS");
            NodeReference nodeRef = myConn.CreateNodeReference("myGlobal");
            // Read both existing nodes
            Console.WriteLine("Value of ^myGlobal is " + nodeRef.GetString());
            Console.WriteLine("Value of ^myGlobal(\"sub1\") is " + nodeRef.GetString("sub1"));
            nodeRef.Kill(); // delete entire array
            nodeRef.Close();
            myConn.Close();
        }
        catch (GlobalsException e) { Console.WriteLine(e.Message); }
    } // end Main()
        private static void WriteEnumerable(NodeReference node, IEnumerable items)
        {
            var index = 0;

            node.Kill();

            foreach (var item in items)
            {
                node.AppendSubscript(ToSubscriptString(index));

                WriteItem(item, node);

                node.SetSubscriptCount(node.GetSubscriptCount() - 1);
                index++;
            }

            node.AppendSubscript(EnumerableLengthsSubscriptName);
            node.Set(ToSubscriptString(index));
            node.SetSubscriptCount(node.GetSubscriptCount() - 1);
        }
        private static void WriteArray(NodeReference node, Array array)
        {
            node.Kill();

            if (array == null)
            {
                return;
            }

            node.AppendSubscript(EnumerableLengthsSubscriptName);
            node.Set(ToSubscriptString(GetArrayLengths(array)));
            node.SetSubscriptCount(node.GetSubscriptCount() - 1);

            var indexedElements = GetIndexedElements(array, new List <int>());

            foreach (var indexedElement in indexedElements)
            {
                node.AppendSubscript(ToSubscriptString(indexedElement.Item2));
                WriteItem(indexedElement.Item1, node);
                node.SetSubscriptCount(node.GetSubscriptCount() - 1);
            }
        }
Пример #8
0
        // graph constructor is marked INTERNAL because we want the client to use the
        // static class factory method CreateGraph(), which redirects here after doing checks.
        // For opening existing graphs,
        // we provide another method called OpenGraph() which redirects here also.
        internal GlGraph(string graph_name)
        {
            bool creating_new = !GlobalsGraphAdmin.AllGraphs().Contains(graph_name);

            _GlNodeRef = GlobalsGraphAdmin.ActiveConnection().CreateNodeReference(graph_name);

            if (creating_new)
            {
                _GlNodeRef.Set(GlobalsGraphAdmin.GL_GRAPH_FLAG); // format identifier, causes persistence
            }
            else
            {
                // opening an existing graph. Start by initializing the existing nodes
                string loop_node_guid = _GlNodeRef.NextSubscript(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, "");
                while (loop_node_guid != "")
                {
                    Guid new_guid = Guid.Empty;

                    if (Guid.TryParse(loop_node_guid, out new_guid))
                    {
                        AllNodesByGuid.Add(new_guid, new GlGraphNode(this, new_guid));
                    }
                    else
                    {
                        _GlNodeRef.Kill(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, loop_node_guid); // clean up bad data
                    }
                    loop_node_guid = _GlNodeRef.NextSubscript(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, loop_node_guid);
                }

                // now loop again and load the edges
                foreach (GlGraphNode loop_node in AllNodes)
                {
                    loop_node.InitializeEdges();
                }
            }
        }
Пример #9
0
 public void Delete()
 {
     _GlNodeRef.Kill();
 }
Пример #10
0
 public void Delete()
 {
     _GlNodeRef.Kill();
     AllDocsByGuid.Clear();
     _GlNodeRef = null;
 }