Esempio n. 1
0
        public void AddChildFolderNode(FolderNode child)
        {
            FolderNode node = FindFolderNode(child);

            if (node != null)
            {
                foreach (string key in child.IDS.Keys)
                {
                    node._ids.Add(key, key);
                    break;
                }
            }
            else
            {
                this._childFolderNodes.Add(child);
            }
        }
Esempio n. 2
0
        public void AddChildFolderNode(FolderNode child)
        {
            FolderNode node = FindFolderNode(child);

            if (node != null)
            {
                foreach (string key in child.IDS.Keys)
                {
                    node._ids.Add(key, key);
                    break;
                }
            }
            else
            {
                this._childFolderNodes.Add(child);
            }
        }
Esempio n. 3
0
        public FolderNode FindFolderNode(FolderNode child)
        {
            if (_folderNameInPath == child.FolderName)
            {
                return(this);
            }

            foreach (FolderNode node in _childFolderNodes)
            {
                FolderNode found = node.FindFolderNode(child);

                if (found != null)
                {
                    return(found);
                }
            }

            return(null);
        }
Esempio n. 4
0
        // Find node given a path
        public FolderNode FindFolderNode(string path)
        {
            string[]   separator = { @"\" };
            string[]   folders   = path.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            FolderNode node      = null;

            if (folders.Length > 0)
            {
                int index = 0;
                node = FindFolderNode(new FolderNode(folders[index]));

                for (; index < folders.Length && node != null; index++)
                {
                    node = node.FindFolderNode(new FolderNode(folders[index]));
                }
            }

            return(node);
        }
Esempio n. 5
0
        public FolderNode FindFolderNode(FolderNode child)
        {
            if (_folderNameInPath == child.FolderName)
                return this;

            foreach (FolderNode node in _childFolderNodes)
            {
               FolderNode found = node.FindFolderNode(child);

               if (found != null) return found;
            }

            return null;
        }
Esempio n. 6
0
        public void ProcessFolderInformation(string parentDirectoryId)
        {
            View directoryView = _targetDb.OpenView(String.Format("Select Directory, Directory_Parent, DefaultDir from Directory where Directory_Parent = '{0}'", parentDirectoryId));

            directoryView.Execute();

            Record directoryRecord = directoryView.Fetch();

            while (directoryRecord != null)
            {
                string directoryId     = directoryRecord["Directory"].ToString();
                string directoryParent = directoryRecord["Directory_Parent"].ToString();
                string directoryName   = directoryRecord["DefaultDir"].ToString();

                // Check if it is a special folder
                bool isSpecialFolder = false;

                foreach (string specialFolder in SpecialFolders)
                {
                    if ((directoryId == specialFolder) || (directoryId.IndexOf(specialFolder) == 0 && directoryId.IndexOf(".") == specialFolder.Length))
                    {
                        if (!_directories.ContainsKey(directoryId))
                        {
                            isSpecialFolder = true;
                            _directories.Add(directoryId, String.Format("[{0}]", specialFolder));
                            _rootNode.AddChildFolderNode(new FolderNode(String.Format("[{0}]", specialFolder), directoryId));
                            break;
                        }
                    }
                }

                if (!isSpecialFolder)
                {
                    string parentPath = "";

                    _directories.TryGetValue(parentDirectoryId, out parentPath);

                    string path = ExtractFolderName(directoryName);

                    if (!String.IsNullOrEmpty(parentPath))
                    {
                        if (path == ".")
                        {
                            path = parentPath;
                        }
                        else
                        {
                            path = parentPath + "\\" + path;
                        }
                    }

                    // Add to the id, path view
                    if (!_directories.ContainsKey(directoryId))
                    {
                        // Console.WriteLine("Adding: {0} \t {1}", directoryId, folderName);
                        _directories.Add(directoryId, path);
                    }

                    //Add to tree view
                    FolderNode parentOrPeerNode = null;
                    if (!String.IsNullOrEmpty(path))
                    {
                        string nodePath = System.IO.Path.GetDirectoryName(path);

                        if (!String.IsNullOrEmpty(nodePath))
                        {
                            parentOrPeerNode = _rootNode.FindFolderNode(nodePath);
                        }
                        else
                        {
                            parentOrPeerNode = _rootNode.FindFolderNode(path);
                        }

                        //Get the last entry in the path string (not necessarily a file name)
                        path = System.IO.Path.GetFileName(path);
                        if (parentOrPeerNode != null)
                        {
                            parentOrPeerNode.AddChildFolderNode(new FolderNode(path, directoryId));
                        }
                        else
                        {
                            _rootNode.AddChildFolderNode(new FolderNode(path, directoryId));
                        }
                    }
                }

                _iterationcount++;
                //Console.WriteLine("-----------------------------------");
                //Console.WriteLine("ITERATION" + _iterationcount);
                //_rootNode.PrintChildNodes(0);
                //_rootNode.PrintDirectoryIds(0);
                //Console.WriteLine("-----------------------------------\n");

                ProcessFolderInformation(directoryId);

                directoryRecord.Close();
                directoryRecord = directoryView.Fetch();
            }

            directoryView.Close();
        }