Пример #1
0
        //////////////////////////////////////////////////////////////
        //////////////////// PRIVATE METHODS /////////////////////////
        //////////////////////////////////////////////////////////////
        /// <summary>
        /// Open storage
        /// </summary>
        /// <param name="mode"></param>
        private void OpenRoot(string path = "")
        {
            if (mgr_state == STATE_OPENED)
            {
                mgr.Close();
            }
            mgr_state = STATE_UNDEFINED;
            if (path != "")
            {
                ROOT = path;
            }
            else
            {
                ROOT = VSUILib.VSUICommonFunctions.SelectPath(DEFS.KEY_STORAGE_ROOT, "Select the storage root directory");
            }

            if (ROOT != "")
            {
                mgr_state = STATE_SELECTED;
                mgr       = new VSEngine(ROOT);
                OpenStorage();
                if (mgr_state == STATE_OPENED)
                {
                    CloseStorage();
                    statusStrip.Items.Clear();
                    statusStrip.Items.Add("Storage root: " + ROOT);
                    DUMP = ROOT;
                    DisplaySpaceList();
                }
            }
            ShowButtons();
        }
Пример #2
0
        /// <summary>
        /// Initialize all objects and indexes (re-open, storage is on)
        /// </summary>
        private void initialize_storage()
        {
            // Initialize Catalog
            node_space    = Storage.GetSpace(DEFX.XML_SPACE_NAME);
            content_space = Storage.GetSpace(DEFX.XML_CONTENT_SPACE_NAME);
            if (content_space == null)
            {
                content_space = node_space;
            }

            // Check for space ownership, set if undefined
            if (NodeSpace.Owner != DEFX.SYSTEM_OWNER_VSXML)
            {
                if (NodeSpace.Owner == DEFS.SYSTEM_OWNER_UNDEFINED)
                {
                    if (NodeSpace.GetRootID(DEFX.NODE_TYPE_CATALOG) > 0)
                    {
                        Storage.Close();
                        throw new VXmlException(VXmlException.E0023_NOT_EMPTY_UNDEFINED_SPACE_CODE, ": '" + NodeSpace.Name + "'");
                    }
                    else
                    {
                        NodeSpace.Owner = DEFX.SYSTEM_OWNER_VSXML;
                    }
                }
                else
                {
                    Storage.Close();
                    throw new VXmlException(VXmlException.E0022_NOT_VSXML_NODE_SPACE_CODE, ": '" + NodeSpace.Owner + "'");
                }
            }
            if (content_space.Name != DEFX.SYSTEM_OWNER_VSXML)
            {
                if (content_space.Owner != DEFX.SYSTEM_OWNER_VSXML)
                {
                    if (content_space.Owner == DEFS.SYSTEM_OWNER_UNDEFINED)
                    {
                        if (content_space.GetRootID(DEFX.NODE_TYPE_CONTENT) > 0)
                        {
                            Storage.Close();
                            throw new VXmlException(VXmlException.E0023_NOT_EMPTY_UNDEFINED_SPACE_CODE, ": '" + content_space.Name + "'");
                        }
                        else
                        {
                            content_space.Owner = DEFX.SYSTEM_OWNER_VSXML;
                        }
                    }
                    else
                    {
                        Storage.Close();
                        throw new VXmlException(VXmlException.E0022_NOT_VSXML_NODE_SPACE_CODE, ": '" + content_space.Owner + "'");
                    }
                }
            }

            // 1.Lookup root catalog node
            this.OBJ = NodeSpace.GetRootObject(DEFX.NODE_TYPE_CATALOG);

            if (this.OBJ == null)
            {   // Create root catalog object
                long sz = DEFX.ROOT_CATALOG_NODE_NAME.Length + 64 + NODE_FIXED_LENGTH;

                this.OBJ      = NodeSpace.Allocate(sz, DEFX.NODE_TYPE_CATALOG, 0, NODE_FIXED_LENGTH);                   // Create default chunk
                this.type     = DEFX.NODE_TYPE_CATALOG;
                this.OWNER_ID = this.OBJ.Id;
                this.FGEN     = 0;
                OBJ.Set(DEFX.F_NAME, DEFX.ROOT_CATALOG_NODE_NAME);
            }

            this.type = DEFX.NODE_TYPE_CATALOG;

            this.root_catalog = this;

            // INDEXES

            // Create/Open Checkout index
            if (node_space.IndexExists(DEFX.INDEX_NAME_CHARGEOUT))
            {
                index_check_out = node_space.GetIndex(DEFX.INDEX_NAME_CHARGEOUT);
            }
            else
            {
                index_check_out = node_space.CreateIndex(DEFX.INDEX_NAME_CHARGEOUT, true);
            }

            // Create/Open Reference index
            if (node_space.IndexExists(DEFX.INDEX_NAME_REFERENCE))
            {
                index_reference = node_space.GetIndex(DEFX.INDEX_NAME_REFERENCE);
            }
            else
            {
                index_reference = node_space.CreateIndex(DEFX.INDEX_NAME_REFERENCE, false);
            }



            // Create/Open CATALOG index
            if (node_space.IndexExists(DEFX.INDEX_NAME_CATALOG))
            {
                index_catalog = node_space.GetIndex(DEFX.INDEX_NAME_CATALOG);
            }
            else
            {
                index_catalog = node_space.CreateIndex(DEFX.INDEX_NAME_CATALOG, false);
            }

            // Create/Open DOCUMENT index
            if (node_space.IndexExists(DEFX.INDEX_NAME_DOCUMENT))
            {
                index_document = node_space.GetIndex(DEFX.INDEX_NAME_DOCUMENT);
            }
            else
            {
                index_document = node_space.CreateIndex(DEFX.INDEX_NAME_DOCUMENT, false);
            }

            state = DEFS.STATE_OPENED;
        }